From 8b1098fc9df6c35428cee7c603b17d5eb79c34c7 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:10:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E9=87=8D=E5=BB=BA?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=93=8D=E5=BA=94=E5=BC=8F=20(#2091)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 28 ++++++++++++------- backend/constant/app.go | 1 + frontend/src/components/status/index.vue | 2 +- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../src/views/app-store/installed/index.vue | 18 ++++++++---- 7 files changed, 35 insertions(+), 17 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 3a071f6db..2bbec1972 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -694,16 +694,24 @@ func upApp(appInstall *model.AppInstall) { } func rebuildApp(appInstall model.AppInstall) error { - dockerComposePath := appInstall.GetComposePath() - out, err := compose.Down(dockerComposePath) - if err != nil { - return handleErr(appInstall, err, out) - } - out, err = compose.Up(dockerComposePath) - if err != nil { - return handleErr(appInstall, err, out) - } - return syncById(appInstall.ID) + appInstall.Status = constant.Rebuilding + _ = appInstallRepo.Save(context.Background(), &appInstall) + go func() { + dockerComposePath := appInstall.GetComposePath() + out, err := compose.Down(dockerComposePath) + if err != nil { + _ = handleErr(appInstall, err, out) + return + } + out, err = compose.Up(dockerComposePath) + if err != nil { + _ = handleErr(appInstall, err, out) + return + } + appInstall.Status = constant.Running + _ = appInstallRepo.Save(context.Background(), &appInstall) + }() + return nil } func getAppDetails(details []model.AppDetail, versions []dto.AppConfigVersion) map[string]model.AppDetail { diff --git a/backend/constant/app.go b/backend/constant/app.go index bc5b91ccc..c38368e54 100644 --- a/backend/constant/app.go +++ b/backend/constant/app.go @@ -12,6 +12,7 @@ const ( Upgrading = "Upgrading" UpgradeErr = "UpgradeErr" PullErr = "PullErr" + Rebuilding = "Rebuilding" ContainerPrefix = "1Panel-" diff --git a/frontend/src/components/status/index.vue b/frontend/src/components/status/index.vue index 384d96c4e..8d4611e94 100644 --- a/frontend/src/components/status/index.vue +++ b/frontend/src/components/status/index.vue @@ -34,7 +34,7 @@ const getType = (status: string) => { } }; -const loadingStatus = ['installing', 'building', 'restarting', 'upgrading']; +const loadingStatus = ['installing', 'building', 'restarting', 'upgrading', 'rebuilding']; const loadingIcon = (status: string): boolean => { return loadingStatus.indexOf(status) > -1; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index e16840db2..c809e9893 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -221,6 +221,7 @@ const message = { upgrading: 'Upgrading', upgradeerr: 'Upgrade Error', pullerr: 'Pull Image Error', + rebuilding: '重建中', }, units: { second: 'Second', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 062f5197b..1ba77c4db 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -219,6 +219,7 @@ const message = { upgrading: '升級中', upgradeerr: '升級失敗', pullerr: '鏡像拉取失敗', + rebuilding: '重建中', }, units: { second: '秒', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 4c53c58db..ab640affb 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -219,6 +219,7 @@ const message = { upgrading: '升级中', upgradeerr: '升级失败', pullerr: '镜像拉取失败', + rebuilding: '重建中', }, units: { second: '秒', diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index da2b045ea..f9e39a980 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -430,7 +430,7 @@ const buttons = [ openOperate(row, 'sync'); }, disabled: (row: any) => { - return row.status === 'DownloadErr' || row.status === 'Upgrading'; + return row.status === 'DownloadErr' || row.status === 'Upgrading' || row.status === 'Rebuilding'; }, }, { @@ -439,7 +439,7 @@ const buttons = [ openOperate(row, 'rebuild'); }, disabled: (row: any) => { - return row.status === 'DownloadErr' || row.status === 'Upgrading'; + return row.status === 'DownloadErr' || row.status === 'Upgrading' || row.status === 'Rebuilding'; }, }, { @@ -448,7 +448,7 @@ const buttons = [ openOperate(row, 'restart'); }, disabled: (row: any) => { - return row.status === 'DownloadErr' || row.status === 'Upgrading'; + return row.status === 'DownloadErr' || row.status === 'Upgrading' || row.status === 'Rebuilding'; }, }, { @@ -461,7 +461,8 @@ const buttons = [ row.status === 'Running' || row.status === 'Error' || row.status === 'DownloadErr' || - row.status === 'Upgrading' + row.status === 'Upgrading' || + row.status === 'Rebuilding' ); }, }, @@ -471,7 +472,12 @@ const buttons = [ openOperate(row, 'stop'); }, disabled: (row: any) => { - return row.status !== 'Running' || row.status === 'DownloadErr' || row.status === 'Upgrading'; + return ( + row.status !== 'Running' || + row.status === 'DownloadErr' || + row.status === 'Upgrading' || + row.status === 'Rebuilding' + ); }, }, { @@ -486,7 +492,7 @@ const buttons = [ openParam(row); }, disabled: (row: any) => { - return row.status === 'DownloadErr' || row.status === 'Upgrading'; + return row.status === 'DownloadErr' || row.status === 'Upgrading' || row.status === 'Rebuilding'; }, }, ];