-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix devops pipeline run logs bugs (#1900)
* refactor: refactor pipeline run time Signed-off-by: yazhou <[email protected]> * fix: fix kubeconfigFile error Signed-off-by: yazhou <[email protected]> * fix: fix pipeline step log too big Signed-off-by: yazhou <[email protected]> * fix: limit pipeline run logs Signed-off-by: yazhou <[email protected]> --------- Signed-off-by: yazhou <[email protected]>
- Loading branch information
Showing
6 changed files
with
206 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/Timer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* This file is part of KubeSphere Console. | ||
* Copyright (C) 2019 The KubeSphere Console Authors. | ||
* | ||
* KubeSphere Console is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* KubeSphere Console is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { useEffect, useRef, useState } from 'react' | ||
import { formatUsedTime } from 'utils/index' | ||
|
||
const TimeCounter = ({ startTime, time }) => { | ||
const [seconds, setSeconds] = useState(0) | ||
|
||
const timerRef = useRef(null) | ||
|
||
useEffect(() => { | ||
if (startTime) { | ||
const interval = setInterval(() => { | ||
const endTime = new Date() | ||
const diff = endTime.getTime() - new Date(startTime).getTime() | ||
setSeconds(diff) | ||
}, 300) | ||
timerRef.current = interval | ||
return () => clearInterval(interval) | ||
} | ||
}, [startTime]) | ||
|
||
useEffect(() => { | ||
if (time && timerRef.current) { | ||
clearInterval(timerRef.current) | ||
} | ||
}, [time]) | ||
|
||
return t('DURATION_VALUE', { | ||
value: startTime ? formatUsedTime(time ?? seconds) : '-', | ||
}) | ||
} | ||
|
||
export default TimeCounter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters