diff --git a/locales/en/l10n-devopsProjects-pipeline-details.js b/locales/en/l10n-devopsProjects-pipeline-details.js index 0ac0e88be7e..34986d0275b 100644 --- a/locales/en/l10n-devopsProjects-pipeline-details.js +++ b/locales/en/l10n-devopsProjects-pipeline-details.js @@ -235,6 +235,7 @@ module.exports = { // detail page // run log // task status RUN_LOGS: 'Run Logs', VIEW_FULL_LOG: 'View Full Logs', + VIEW_REAL_TIME_LOG: 'View Real-time Logs', // detail page // run log // task status // pipeline log modal PIPELINE_LOG: 'Pipeline Logs', // detail page // Create Pipeline modal // add step modal diff --git a/locales/es/l10n-devopsProjects-pipeline-details.js b/locales/es/l10n-devopsProjects-pipeline-details.js index ddca12f9939..da40df14f3e 100644 --- a/locales/es/l10n-devopsProjects-pipeline-details.js +++ b/locales/es/l10n-devopsProjects-pipeline-details.js @@ -224,6 +224,7 @@ module.exports = { // detail page // run log // task status RUN_LOGS: 'Run Logs', VIEW_FULL_LOG: 'View Full Logs', + VIEW_REAL_TIME_LOG: 'View Real-time Logs', // detail page // run log // task status // pipeline log modal PIPELINE_LOG: 'Pipeline Logs', // detail page // Create Pipeline modal // add step modal diff --git a/locales/tc/l10n-devopsProjects-pipeline-details.js b/locales/tc/l10n-devopsProjects-pipeline-details.js index 77b7a16a380..f07ec30639c 100644 --- a/locales/tc/l10n-devopsProjects-pipeline-details.js +++ b/locales/tc/l10n-devopsProjects-pipeline-details.js @@ -220,6 +220,7 @@ module.exports = { // detail page // run log // task status RUN_LOGS: 'Run Logs', VIEW_FULL_LOG: 'View Full Logs', + VIEW_REAL_TIME_LOG: 'View Real-time Logs', // detail page // run log // task status // pipeline log modal PIPELINE_LOG: 'Pipeline Logs', // detail page // Create Pipeline modal // add step modal diff --git a/locales/zh/l10n-devopsProjects-pipeline-details.js b/locales/zh/l10n-devopsProjects-pipeline-details.js index f645c60f8e2..a7c0653a65b 100644 --- a/locales/zh/l10n-devopsProjects-pipeline-details.js +++ b/locales/zh/l10n-devopsProjects-pipeline-details.js @@ -219,6 +219,7 @@ module.exports = { // detail page // run log // task status RUN_LOGS: '运行日志', VIEW_FULL_LOG: '查看完整日志', + VIEW_REAL_TIME_LOG: '查看实时日志', // detail page // run log // task status // pipeline log modal PIPELINE_LOG: '流水线日志', // detail page // Create Pipeline modal // add step modal diff --git a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.jsx b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.jsx index 73b153bd66e..19b4fdcd6c6 100644 --- a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.jsx +++ b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.jsx @@ -40,6 +40,9 @@ export default class PipelineLog extends React.Component { * @type {RunStore} */ this.store = new RunStore() + this.state = { + isDownloading: false, + } this.reaction = reaction( () => this.isEmptySteps, @@ -126,6 +129,16 @@ export default class PipelineLog extends React.Component { // this.refreshFlag = !this.refreshFlag // }, 1000) + handleDownload = async () => { + this.setState({ isDownloading: true }) + await this.store.handleDownloadLogs(this.props.params) + this.setState({ isDownloading: false }) + } + + handleJumpFullLogs = () => { + this.store.handleJumpFullLogs(this.props.params) + } + renderLeftTab(stage, index) { if (Array.isArray(stage)) { return ( @@ -200,6 +213,28 @@ export default class PipelineLog extends React.Component { )) } + get isRunning() { + return this.activeStage?.result && this.activeStage?.result === 'UNKNOWN' + } + + renderLogButton = () => { + if (this.isRunning) { + return ( + + ) + } + return ( + + + + + ) + } + render() { const { nodes } = this.props const _nodes = toJS(nodes) @@ -234,9 +269,7 @@ export default class PipelineLog extends React.Component { } /> - + {this.renderLogButton()}
{this.renderLogContent()}
diff --git a/src/stores/devops/log.js b/src/stores/devops/log.js index 753a5a3fac8..e484e3db25b 100644 --- a/src/stores/devops/log.js +++ b/src/stores/devops/log.js @@ -29,6 +29,9 @@ export default class PipelineRunStore extends BaseStore { } async getStepLog({ devops, cluster, name, branch, runId, nodeId, stepId }) { + const params = this.stepLogData.start + ? `?start=${this.stepLogData.start}` + : '' const headers = branch ? {} : { @@ -40,8 +43,7 @@ export default class PipelineRunStore extends BaseStore { devops, })}pipelines/${decodeURIComponent(name)}${ branch ? `/branches/${encodeURIComponent(branch)}` : '' - }/runs/${runId}/nodes/${nodeId}/steps/${stepId}/log/?start=${this - .stepLogData.start || 0}`, + }/runs/${runId}/nodes/${nodeId}/steps/${stepId}/log/${params}`, options: { headers }, handler: resp => { if (resp.status === 200) { diff --git a/src/stores/devops/run.js b/src/stores/devops/run.js index 25671aa08ec..7d55bd5b5ca 100644 --- a/src/stores/devops/run.js +++ b/src/stores/devops/run.js @@ -349,6 +349,7 @@ export default class PipelineRunStore extends BaseStore { ${result}` } else { const start = this.logSize + const params = start ? `?start=${start}` : '' const result = await request.get( `${this.getRunUrl({ cluster, @@ -356,11 +357,11 @@ ${result}` name, branch, runId, - })}log/?start=${this.logSize}`, + })}log/${params}`, {}, { headers: { - 'x-file-size-limit': 1024 * 1024 * 10, + // 'x-file-size-limit': 1024 * 1024 * 10, 'x-with-headers': true, }, } @@ -406,6 +407,20 @@ ${result}` // return str2.slice(index + end.length) // } + handleJumpFullLogs({ devops, name, branch, cluster }) { + name = decodeURIComponent(name) + const url = getClusterUrl( + `${window.location.protocol}//${window.location.host}/${this.getRunUrl({ + cluster, + devops, + name, + branch, + runId: this.runDetail.id, + })}log/?start=0` + ) + window.open(url) + } + async handleDownloadLogs({ devops, name, branch, cluster }) { name = decodeURIComponent(name) const url = getClusterUrl(