From 31cd6691c91ba9ba482815a58ce444ee441a8f8f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:04:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E5=A2=9E=E5=8A=A0=E6=89=80=E6=9C=89=E9=80=89?= =?UTF-8?q?=E9=A1=B9=20(#2191)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #2143 --- backend/app/service/container.go | 2 +- .../src/components/container-log/index.vue | 32 ++++++++++---- frontend/src/lang/modules/en.ts | 2 + frontend/src/lang/modules/tw.ts | 2 + frontend/src/lang/modules/zh.ts | 2 + .../views/container/container/log/index.vue | 43 +++++++++++++------ 6 files changed, 61 insertions(+), 22 deletions(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index f2ff47108..7767385ec 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -567,7 +567,7 @@ func (u *ContainerService) ContainerLogs(wsConn *websocket.Conn, container, sinc } command := fmt.Sprintf("docker logs %s", container) if tail != "0" { - command += " -n " + tail + command += " --tail " + tail } if since != "all" { command += " --since " + since diff --git a/frontend/src/components/container-log/index.vue b/frontend/src/components/container-log/index.vue index 3ccd7532e..1afc4b1a9 100644 --- a/frontend/src/components/container-log/index.vue +++ b/frontend/src/components/container-log/index.vue @@ -1,15 +1,18 @@
- + - - - + + + + + + + +
{{ $t('commons.button.watch') }} @@ -134,7 +132,7 @@ watch(logVisiable, (val) => { if (screenfull.isEnabled && !val && !mobile.value) screenfull.exit(); }); const searchLogs = async () => { - if (!Number(logSearch.tail) || Number(logSearch.tail) < 0) { + if (Number(logSearch.tail) < 0) { MsgError(i18n.global.t('container.linesHelper')); return; } @@ -157,7 +155,17 @@ const searchLogs = async () => { }; const onDownload = async () => { - downloadWithContent(logInfo.value, logSearch.container + '-' + dateFormatForName(new Date()) + '.log'); + let msg = + logSearch.tail === 0 + ? i18n.global.t('container.downLogHelper1', [logSearch.container]) + : i18n.global.t('container.downLogHelper2', [logSearch.container, logSearch.tail]); + ElMessageBox.confirm(msg, i18n.global.t('file.download'), { + confirmButtonText: i18n.global.t('commons.button.confirm'), + cancelButtonText: i18n.global.t('commons.button.cancel'), + type: 'info', + }).then(async () => { + downloadWithContent(logInfo.value, logSearch.container + '-' + dateFormatForName(new Date()) + '.log'); + }); }; const onClean = async () => { @@ -209,4 +217,13 @@ defineExpose({ .fullScreen { border: none; } +.tailClass { + width: 20%; + float: left; + margin-left: 20px; +} +.fetchClass { + width: 30%; + float: left; +}