From a364dbffbfc2f23dd5a49cb50dcbd11fb18a2aa1 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 11 Sep 2023 18:28:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=95=B0=E6=8D=AE=E5=BA=93=E3=80=81?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4=20(#2255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/database.go | 1 + backend/app/service/database_mysql.go | 13 +++++++++ cmd/server/docs/docs.go | 9 ++++++ cmd/server/docs/swagger.json | 9 ++++++ cmd/server/docs/swagger.yaml | 6 ++++ frontend/src/api/interface/database.ts | 1 + frontend/src/lang/modules/en.ts | 3 +- frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../container/container/operate/index.vue | 2 +- frontend/src/views/cronjob/operate/index.vue | 11 +++++-- frontend/src/views/database/mysql/index.vue | 17 ++++++++--- .../views/database/mysql/setting/index.vue | 29 +++++++++++++++++-- .../setting/snapshot/snap_status/index.vue | 7 +++-- 14 files changed, 97 insertions(+), 13 deletions(-) diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index 3e325995b..ac7c5cb97 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -27,6 +27,7 @@ type MysqlDBInfo struct { type MysqlOption struct { ID uint `json:"id"` From string `json:"from"` + Type string `json:"type"` Database string `json:"database"` Name string `json:"name"` } diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index cdd550b33..e60c8e203 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -75,6 +75,14 @@ func (u *MysqlService) SearchWithPage(search dto.MysqlDBSearch) (int64, interfac func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) { mysqls, err := mysqlRepo.List() + if err != nil { + return nil, err + } + + databases, err := databaseRepo.GetList(databaseRepo.WithTypeList("mysql,mariadb")) + if err != nil { + return nil, err + } var dbs []dto.MysqlOption for _, mysql := range mysqls { var item dto.MysqlOption @@ -82,6 +90,11 @@ func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) { return nil, errors.WithMessage(constant.ErrStructTransform, err.Error()) } item.Database = mysql.MysqlName + for _, database := range databases { + if database.Name == item.Database { + item.Type = database.Type + } + } dbs = append(dbs, item) } return dbs, err diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 74789bb0f..59ea1f35b 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -12215,6 +12215,12 @@ const docTemplate = `{ "cpuShares": { "type": "integer" }, + "entrypoint": { + "type": "array", + "items": { + "type": "string" + } + }, "env": { "type": "array", "items": { @@ -13714,6 +13720,9 @@ const docTemplate = `{ }, "name": { "type": "string" + }, + "type": { + "type": "string" } } }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index bb181144a..aba0c2b99 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -12208,6 +12208,12 @@ "cpuShares": { "type": "integer" }, + "entrypoint": { + "type": "array", + "items": { + "type": "string" + } + }, "env": { "type": "array", "items": { @@ -13707,6 +13713,9 @@ }, "name": { "type": "string" + }, + "type": { + "type": "string" } } }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 4560d7a50..5c8cbd348 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -347,6 +347,10 @@ definitions: type: string cpuShares: type: integer + entrypoint: + items: + type: string + type: array env: items: type: string @@ -1362,6 +1366,8 @@ definitions: type: integer name: type: string + type: + type: string type: object dto.MysqlStatus: properties: diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index ea7b2cd86..6b9d4d1d6 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -134,6 +134,7 @@ export namespace Database { export interface MysqlOption { id: number; from: string; + type: string; database: string; name: string; } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index c060ab31a..073cc0d16 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -318,7 +318,8 @@ const message = { deleteHelper: '" to delete this database', create: 'Create database', noMysql: 'Database service (MySQL or MariaDB)', - goInstall: 'Go to install', + goUpgrade: 'Go for upgrade', + goInstall: 'Go for install', source: 'Source', permission: 'Permission', permissionForIP: 'IP', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 2e4f98a94..18f10ca8f 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -314,6 +314,7 @@ const message = { deleteHelper: '" 刪除此數據庫', create: '創建數據庫', noMysql: '數據庫服務 (MySQL 或 MariaDB)', + goUpgrade: '去應用商店升級', goInstall: '去應用商店安裝', source: '來源', permission: '權限', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index e4633db42..21e214274 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -314,6 +314,7 @@ const message = { deleteHelper: '" 删除此数据库', create: '创建数据库', noMysql: '数据库服务 (MySQL 或 MariaDB)', + goUpgrade: '去应用列表升级', goInstall: '去应用商店安装', source: '来源', permission: '权限', diff --git a/frontend/src/views/container/container/operate/index.vue b/frontend/src/views/container/container/operate/index.vue index e0de63056..2b8fc5245 100644 --- a/frontend/src/views/container/container/operate/index.vue +++ b/frontend/src/views/container/container/operate/index.vue @@ -138,7 +138,7 @@ diff --git a/frontend/src/views/cronjob/operate/index.vue b/frontend/src/views/cronjob/operate/index.vue index 0de45df66..da82161fe 100644 --- a/frontend/src/views/cronjob/operate/index.vue +++ b/frontend/src/views/cronjob/operate/index.vue @@ -125,7 +125,7 @@
- + {{ item.name }} {{ item.key }} @@ -140,13 +140,18 @@ - + {{ item.name }} {{ item.from === 'local' ? $t('database.local') : $t('database.remote') }} - {{ item.database }} + {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }} diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index 7e08212ab..6dcfe722c 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -27,8 +27,11 @@
- - {{ item.database }} + + {{ item.database }} + + {{ item.database.substring(0, 25) }}... + {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }} @@ -40,8 +43,11 @@
- - {{ item.database }} + + {{ item.database }} + + {{ item.database.substring(0, 25) }}... + {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }} @@ -573,4 +579,7 @@ onMounted(() => { font-size: 12px; margin-top: 5px; } +.optionClass { + min-width: 350px; +} diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue index ea420f7ca..e6baeed8a 100644 --- a/frontend/src/views/database/mysql/setting/index.vue +++ b/frontend/src/views/database/mysql/setting/index.vue @@ -116,6 +116,25 @@ + + + + {{ $t('database.goUpgrade') }} + + + + +
@@ -136,7 +155,8 @@ import { loadDatabaseFile, loadMysqlBaseInfo, loadMysqlVariables, updateMysqlCon import { ChangePort, CheckAppInstalled, GetAppDefaultConfig } from '@/api/modules/app'; import { Rules } from '@/global/form-rules'; import i18n from '@/lang'; -import { MsgError, MsgSuccess } from '@/utils/message'; +import { MsgSuccess } from '@/utils/message'; +import router from '@/routers'; const loading = ref(false); @@ -152,6 +172,7 @@ const baseInfo = reactive({ }); const panelFormRef = ref(); const mysqlConf = ref(); +const upgradeVisiable = ref(); const useOld = ref(false); @@ -312,11 +333,15 @@ const loadMysqlConf = async () => { mysqlConf.value = res.data; }) .catch(() => { - MsgError(i18n.global.t('database.confNotFound')); + upgradeVisiable.value = true; loading.value = false; }); }; +const goUpgrade = () => { + router.push({ name: 'AppUpgrade' }); +}; + const onLoadInfo = async () => { await CheckAppInstalled(props.type, props.database).then((res) => { mysqlName.value = res.data.name; diff --git a/frontend/src/views/setting/snapshot/snap_status/index.vue b/frontend/src/views/setting/snapshot/snap_status/index.vue index e59238399..475a813ca 100644 --- a/frontend/src/views/setting/snapshot/snap_status/index.vue +++ b/frontend/src/views/setting/snapshot/snap_status/index.vue @@ -62,7 +62,9 @@