From ae515b079c88a5ebee9ac0c85d011d276d1c7256 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:14:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=A2=9E=E5=8A=A0=E8=AF=A6=E6=83=85=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20(#2201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/init/migration/migrations/init.go | 8 +- frontend/src/lang/modules/en.ts | 4 +- frontend/src/lang/modules/tw.ts | 5 +- frontend/src/lang/modules/zh.ts | 5 +- frontend/src/styles/common.scss | 1 + .../views/container/compose/detail/index.vue | 36 +++------ .../container/container/handle/index.vue | 77 +++++++++++++++++++ .../src/views/container/container/index.vue | 37 ++------- .../views/container/container/prune/index.vue | 2 +- 9 files changed, 107 insertions(+), 68 deletions(-) create mode 100644 frontend/src/views/container/container/handle/index.vue diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go index 6163e15e2..b6b3e7518 100644 --- a/backend/init/migration/migrations/init.go +++ b/backend/init/migration/migrations/init.go @@ -611,7 +611,7 @@ var AddDatabases = &gormigrate.Migration{ if err := tx.Create(&model.Database{ AppInstallID: redisInfo.ID, Name: redisInfo.Name, - Type: "mariadb", + Type: "redis", Version: redisInfo.Version, From: "local", Address: redisInfo.ServiceName, @@ -627,7 +627,7 @@ var AddDatabases = &gormigrate.Migration{ if err := tx.Create(&model.Database{ AppInstallID: pgInfo.ID, Name: pgInfo.Name, - Type: "mariadb", + Type: "postgresql", Version: pgInfo.Version, From: "local", Address: pgInfo.ServiceName, @@ -643,7 +643,7 @@ var AddDatabases = &gormigrate.Migration{ if err := tx.Create(&model.Database{ AppInstallID: mongodbInfo.ID, Name: mongodbInfo.Name, - Type: "mariadb", + Type: "mongodb", Version: mongodbInfo.Version, From: "local", Address: mongodbInfo.ServiceName, @@ -659,7 +659,7 @@ var AddDatabases = &gormigrate.Migration{ if err := tx.Create(&model.Database{ AppInstallID: memcachedInfo.ID, Name: memcachedInfo.Name, - Type: "mariadb", + Type: "memcached", Version: memcachedInfo.Version, From: "local", Address: memcachedInfo.ServiceName, diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 16f277cae..3a13f6306 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -470,9 +470,9 @@ const message = { updateContaienrHelper: 'Container editing requires rebuilding the container. Any data that has not been persisted will be lost. Do you want to continue?', containerList: 'Container list', - operatorHelper: '{0} will be performed on the selected container. Do you want to continue?', + operatorHelper: '{0} will be performed on the following container, Do you want to continue?', operatorAppHelper: - 'There is a container from the App store. The {0} operation may affect the normal use of this service. Are you sure?', + 'The {0} operation will be performed on the following containers, some of which are from the App Store. This operation may affect the normal use of the service, Do you want to continue?', start: 'Start', stop: 'Stop', restart: 'Restart', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index e0b84328d..c605e0a96 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -459,8 +459,9 @@ const message = { edit: '編輯容器', updateContaienrHelper: '容器編輯需要重建容器,任何未持久化的數據將會丟失,是否繼續?', containerList: '容器列表', - operatorHelper: '將對選中容器進行 {0} 操作,是否繼續?', - operatorAppHelper: '存在來源於應用商店的容器,{0} 操作可能會影響到該服務的正常使用,是否確認?', + operatorHelper: '將對以下容器進行 {0} 操作,是否繼續?', + operatorAppHelper: + '將對以下容器進行 {0} 操作,其中部分來源於應用商店,該操作可能會影響到該服務的正常使用,是否確認?', start: '啟動', stop: '停止', restart: '重啟', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 38ed96137..79493061e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -459,8 +459,9 @@ const message = { edit: '编辑容器', updateContaienrHelper: '容器编辑需要重建容器,任何未持久化的数据将会丢失,是否继续?', containerList: '容器列表', - operatorHelper: '将对选中容器进行 {0} 操作,是否继续?', - operatorAppHelper: '存在来源于应用商店的容器,{0} 操作可能会影响到该服务的正常使用,是否确认?', + operatorHelper: '将对以下容器进行 {0} 操作,是否继续?', + operatorAppHelper: + '将对以下容器进行 {0} 操作,其中部分来源于应用商店,该操作可能会影响到该服务的正常使用,是否确认?', start: '启动', stop: '停止', restart: '重启', diff --git a/frontend/src/styles/common.scss b/frontend/src/styles/common.scss index 4a4902e85..1d59422f5 100644 --- a/frontend/src/styles/common.scss +++ b/frontend/src/styles/common.scss @@ -245,6 +245,7 @@ html { // search条圆角 .search-button { float: right; + margin-right: 10px; .el-input__wrapper { border-radius: 50px; } diff --git a/frontend/src/views/container/compose/detail/index.vue b/frontend/src/views/container/compose/detail/index.vue index 257c96549..8a8a70f4d 100644 --- a/frontend/src/views/container/compose/detail/index.vue +++ b/frontend/src/views/container/compose/detail/index.vue @@ -106,6 +106,7 @@ + @@ -117,10 +118,11 @@ import Tooltip from '@/components/tooltip/index.vue'; import MonitorDialog from '@/views/container/container/monitor/index.vue'; import ContainerLogDialog from '@/views/container/container/log/index.vue'; import TerminalDialog from '@/views/container/container/terminal/index.vue'; +import HandleDialog from '@/views/container/container/handle/index.vue'; import CodemirrorDialog from '@/components/codemirror-dialog/index.vue'; import Status from '@/components/status/index.vue'; import { dateFormat } from '@/utils/util'; -import { composeOperator, containerOperator, inspect, searchContainer } from '@/api/modules/container'; +import { composeOperator, inspect, searchContainer } from '@/api/modules/container'; import { ElMessageBox } from 'element-plus'; import i18n from '@/lang'; import { Container } from '@/api/interface/container'; @@ -131,6 +133,9 @@ const composePath = ref(); const filters = ref(); const createdBy = ref(); +const dialogContainerLogRef = ref(); +const handleRef = ref(); + const emit = defineEmits<{ (e: 'back'): void }>(); interface DialogProps { createdBy: string; @@ -228,35 +233,14 @@ const checkStatus = (operation: string) => { const onOperate = async (operation: string) => { let msg = i18n.global.t('container.operatorHelper', [i18n.global.t('container.' + operation)]); + let containers = []; for (const item of selects.value) { + containers.push(item.name); if (item.isFromApp) { msg = i18n.global.t('container.operatorAppHelper', [i18n.global.t('container.' + operation)]); - break; } } - ElMessageBox.confirm(msg, i18n.global.t('container.' + operation), { - confirmButtonText: i18n.global.t('commons.button.confirm'), - cancelButtonText: i18n.global.t('commons.button.cancel'), - type: 'info', - }).then(() => { - let ps = []; - for (const item of selects.value) { - const param = { - name: item.name, - operation: operation, - newName: '', - }; - ps.push(containerOperator(param)); - } - Promise.all(ps) - .then(() => { - search(); - MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); - }) - .catch(() => { - search(); - }); - }); + handleRef.value.acceptParams({ containers: containers, operation: operation, msg: msg }); }; const onComposeOperate = async (operation: string) => { @@ -302,8 +286,6 @@ const onTerminal = (row: any) => { dialogTerminalRef.value!.acceptParams({ containerID: row.containerID, container: row.name }); }; -const dialogContainerLogRef = ref(); - const buttons = [ { label: i18n.global.t('file.terminal'), diff --git a/frontend/src/views/container/container/handle/index.vue b/frontend/src/views/container/container/handle/index.vue new file mode 100644 index 000000000..39632e000 --- /dev/null +++ b/frontend/src/views/container/container/handle/index.vue @@ -0,0 +1,77 @@ + + + + diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue index 3f126db5b..19465bca0 100644 --- a/frontend/src/views/container/container/index.vue +++ b/frontend/src/views/container/container/index.vue @@ -179,6 +179,7 @@ + @@ -192,23 +193,22 @@ import UpgraeDialog from '@/views/container/container/upgrade/index.vue'; import MonitorDialog from '@/views/container/container/monitor/index.vue'; import ContainerLogDialog from '@/views/container/container/log/index.vue'; import TerminalDialog from '@/views/container/container/terminal/index.vue'; +import HandleDialog from '@/views/container/container/handle/index.vue'; import CodemirrorDialog from '@/components/codemirror-dialog/index.vue'; import PortJumpDialog from '@/components/port-jump/index.vue'; import Status from '@/components/status/index.vue'; import { reactive, onMounted, ref, computed } from 'vue'; import { containerListStats, - containerOperator, inspect, loadContainerInfo, loadDockerStatus, searchContainer, } from '@/api/modules/container'; import { Container } from '@/api/interface/container'; -import { ElMessageBox } from 'element-plus'; import i18n from '@/lang'; import router from '@/routers'; -import { MsgSuccess, MsgWarning } from '@/utils/message'; +import { MsgWarning } from '@/utils/message'; import { GlobalStore } from '@/store'; const globalStore = GlobalStore(); @@ -229,6 +229,7 @@ const paginationConfig = reactive({ const searchName = ref(); const dialogUpgradeRef = ref(); const dialogPortJumpRef = ref(); +const handleRef = ref(); const dockerStatus = ref('Running'); const loadStatus = async () => { @@ -415,38 +416,14 @@ const checkStatus = (operation: string, row: Container.ContainerInfo | null) => const onOperate = async (operation: string, row: Container.ContainerInfo | null) => { let opList = row ? [row] : selects.value; let msg = i18n.global.t('container.operatorHelper', [i18n.global.t('container.' + operation)]); + let containers = []; for (const item of opList) { + containers.push(item.name); if (item.isFromApp) { msg = i18n.global.t('container.operatorAppHelper', [i18n.global.t('container.' + operation)]); - break; } } - ElMessageBox.confirm(msg, i18n.global.t('container.' + operation), { - confirmButtonText: i18n.global.t('commons.button.confirm'), - cancelButtonText: i18n.global.t('commons.button.cancel'), - type: 'info', - }).then(() => { - let ps = []; - for (const item of opList) { - const param = { - name: item.name, - operation: operation, - newName: '', - }; - ps.push(containerOperator(param)); - } - loading.value = true; - Promise.all(ps) - .then(() => { - loading.value = false; - search(); - MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); - }) - .catch(() => { - loading.value = false; - search(); - }); - }); + handleRef.value.acceptParams({ containers: containers, operation: operation, msg: msg }); }; const buttons = [ diff --git a/frontend/src/views/container/container/prune/index.vue b/frontend/src/views/container/container/prune/index.vue index 588cf0013..12106d395 100644 --- a/frontend/src/views/container/container/prune/index.vue +++ b/frontend/src/views/container/container/prune/index.vue @@ -2,7 +2,7 @@
    -
  • {{ $t('container.containerPruneHelper1') }}
  • +
  • {{ $t('container.containerPruneHelper1') }}
  • {{ $t('container.containerPruneHelper2') }}
  • {{ $t('container.containerPruneHelper3') }}