From 448307564ee6501b76d16460149515ea5368fdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=9C=88?= Date: Mon, 4 Sep 2023 17:55:56 +0800 Subject: [PATCH] fix: [devops 3.5] fix devops pipeline run log (#1772) * fix: fix devops pipeline run log Signed-off-by: yazhou * fix: update pipeline run log refresh icon Signed-off-by: yazhou * fix: fix devops pipeline run log refresh action Signed-off-by: yazhou * fix: fix devops history card name Signed-off-by: yazhou --------- Signed-off-by: yazhou --- server/proxy.js | 44 +++++++ .../PipelineLogDialog/FullLogs/index.jsx | 7 +- .../Detail/PipelineLogDialog/index.scss | 12 +- .../Pipelines/Detail/TaskStatus/index.jsx | 2 +- src/pages/devops/containers/layout.jsx | 3 +- src/stores/devops/run.js | 122 ++++++++++++++---- src/utils/request.js | 7 +- 7 files changed, 162 insertions(+), 35 deletions(-) diff --git a/server/proxy.js b/server/proxy.js index fa276162dae..edd89af33cb 100644 --- a/server/proxy.js +++ b/server/proxy.js @@ -36,6 +36,50 @@ const k8sResourceProxy = { NEED_OMIT_HEADERS.forEach(key => proxyReq.removeHeader(key)) }, + proxyRes(proxyRes, req, client_res) { + let maxBufferSize = req.headers['x-file-size-limit'] + if (maxBufferSize) { + maxBufferSize = Number(maxBufferSize) + let body = Buffer.alloc(maxBufferSize) + let offset = 0 + let end = false + proxyRes.on('data', chunk => { + if (end) { + return + } + if (offset >= maxBufferSize) { + if (!client_res.getHeader('x-file-size-limit-out')) { + client_res.setHeader('x-file-size-limit-out', 'true') + } + proxyRes.emit('end') + end = true + return + } + chunk.copy(body, offset) + + offset += chunk.length + }) + proxyRes.pipe = function(res) { + proxyRes.on('end', () => { + end = true + const offset1 = Math.min(offset, maxBufferSize) + body = body.slice(0, offset1) + res.writeHead(proxyRes.statusCode, { + ...proxyRes.headers, + 'x-file-size': offset1, + }) + res.end(body) + }) + } + } + let addHeaders = req.headers['x-add-res-header'] + if (addHeaders) { + addHeaders = JSON.parse(addHeaders) + Object.keys(addHeaders).forEach(key => { + proxyRes.headers[key] = addHeaders[key] + }) + } + }, }, } diff --git a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/FullLogs/index.jsx b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/FullLogs/index.jsx index 2af9c0d8824..dbd4cc04408 100644 --- a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/FullLogs/index.jsx +++ b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/FullLogs/index.jsx @@ -36,9 +36,9 @@ export default class FullLogs extends React.Component { } @action - getPipelineIndexLog() { + getPipelineIndexLog(refresh = false) { const { params } = this.props - this.store.getRunStatusLogs(params) + this.store.getRunStatusLogs(params, refresh) } @computed @@ -84,7 +84,8 @@ export default class FullLogs extends React.Component { } handleRefreshLogs = async () => { - await this.getPipelineIndexLog() + await this.getPipelineIndexLog(true) + await this.handleRealtime() this.scrollToBottom() } diff --git a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.scss b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.scss index ea7bd9695ba..96a231b888c 100644 --- a/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.scss +++ b/src/pages/devops/containers/Pipelines/Detail/PipelineLogDialog/index.scss @@ -2,7 +2,8 @@ @import '~scss/mixins'; .container { - display: flex; + display: grid; + grid-template-columns: 215px 1fr; height: 100%; } @@ -17,13 +18,16 @@ } .left { - flex-basis: 215px; height: 500px; overflow: auto; } .right { - flex-grow: 1; + // max-height: calc(100vh - 200px); + overflow-y: auto; + display: grid; + grid-template-rows: auto 1fr; + gap: 12px; } .cutTitle { @@ -71,7 +75,6 @@ .header { height: 32px; - margin-bottom: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; @@ -93,7 +96,6 @@ .logContainer { width: 100%; - height: 100%; padding: 12px; border-radius: 4px; background-color: #242e42; diff --git a/src/pages/devops/containers/Pipelines/Detail/TaskStatus/index.jsx b/src/pages/devops/containers/Pipelines/Detail/TaskStatus/index.jsx index 290437c276f..80df6baeec1 100644 --- a/src/pages/devops/containers/Pipelines/Detail/TaskStatus/index.jsx +++ b/src/pages/devops/containers/Pipelines/Detail/TaskStatus/index.jsx @@ -256,7 +256,7 @@ export default class TaskStatus extends React.Component { /> -