From 5272d44558714a5fbe76db5d6503abe81431aa50 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 12 Dec 2022 19:04:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=95=B0=E6=8D=AE=E5=BA=93=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8D=E6=AD=A3=E5=B8=B8=E6=97=B6=EF=BC=8C=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E9=83=A8=E5=88=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_install.go | 37 +++++++++---------- backend/app/service/database_mysql.go | 8 +++- backend/app/service/database_redis.go | 17 ++------- frontend/src/api/modules/database.ts | 2 +- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../container/container/create/index.vue | 1 + .../views/database/mysql/setting/index.vue | 14 +++++-- frontend/src/views/database/redis/index.vue | 25 ++++++++----- .../views/database/redis/setting/index.vue | 26 ++++++++----- 10 files changed, 74 insertions(+), 58 deletions(-) diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 47f98e322..3f78127e4 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -263,19 +263,7 @@ func (a AppInstallService) GetUpdateVersions(installId uint) ([]dto.AppVersion, } func (a AppInstallService) ChangeAppPort(req dto.PortUpdate) error { - ComposeFile := fmt.Sprintf("%s/%s/%s/docker-compose.yml", constant.AppInstallDir, req.Key, req.Name) - - updateInstallInfoInDB(req.Key, "port", strconv.FormatInt(req.Port, 10)) - - stdout, err := compose.Down(ComposeFile) - if err != nil { - return errors.New(stdout) - } - stdout, err = compose.Up(ComposeFile) - if err != nil { - return errors.New(stdout) - } - return nil + return updateInstallInfoInDB(req.Key, "port", true, strconv.FormatInt(req.Port, 10)) } func (a AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error) { @@ -447,18 +435,18 @@ func syncById(installId uint) error { return appInstallRepo.Save(&appInstall) } -func updateInstallInfoInDB(appKey, param string, value interface{}) { +func updateInstallInfoInDB(appKey, param string, isRestart bool, value interface{}) error { if param != "password" && param != "port" { - return + return nil } appInstall, err := appInstallRepo.LoadBaseInfoByKey(appKey) if err != nil { - return + return nil } envPath := fmt.Sprintf("%s/%s/%s/.env", constant.AppInstallDir, appKey, appInstall.Name) lineBytes, err := ioutil.ReadFile(envPath) if err != nil { - return + return err } envKey := "PANEL_DB_ROOT_PASSWORD=" if param == "port" { @@ -475,12 +463,12 @@ func updateInstallInfoInDB(appKey, param string, value interface{}) { } file, err := os.OpenFile(envPath, os.O_WRONLY|os.O_TRUNC, 0666) if err != nil { - return + return err } defer file.Close() _, err = file.WriteString(strings.Join(newFiles, "\n")) if err != nil { - return + return err } oldVal, newVal := "", "" @@ -502,4 +490,15 @@ func updateInstallInfoInDB(appKey, param string, value interface{}) { "http_port": value, }, commonRepo.WithByID(appInstall.ID)) } + + ComposeFile := fmt.Sprintf("%s/%s/%s/docker-compose.yml", constant.AppInstallDir, appKey, appInstall.Name) + stdout, err := compose.Down(ComposeFile) + if err != nil { + return errors.New(stdout) + } + stdout, err = compose.Up(ComposeFile) + if err != nil { + return errors.New(stdout) + } + return nil } diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index fcd068597..cd48f87dd 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -330,8 +330,12 @@ func (u *MysqlService) ChangePassword(info dto.ChangeDBInfo) error { } } } - updateInstallInfoInDB("mysql", "password", info.Value) - updateInstallInfoInDB("phpmyadmin", "password", info.Value) + if err := updateInstallInfoInDB("mysql", "password", false, info.Value); err != nil { + return err + } + if err := updateInstallInfoInDB("phpmyadmin", "password", true, info.Value); err != nil { + return err + } return nil } diff --git a/backend/app/service/database_redis.go b/backend/app/service/database_redis.go index c9bde952e..f3ea2d0e0 100644 --- a/backend/app/service/database_redis.go +++ b/backend/app/service/database_redis.go @@ -63,22 +63,11 @@ func (u *RedisService) UpdateConf(req dto.RedisConfUpdate) error { } func (u *RedisService) ChangePassword(req dto.ChangeDBInfo) error { - redisInfo, err := appInstallRepo.LoadBaseInfoByKey("redis") - if err != nil { + if err := updateInstallInfoInDB("redis", "password", true, req.Value); err != nil { return err } - ComposeFile := fmt.Sprintf("%s/redis/%s/docker-compose.yml", constant.AppInstallDir, redisInfo.Name) - - updateInstallInfoInDB("redis", "password", req.Value) - updateInstallInfoInDB("redis-commander", "password", req.Value) - - stdout, err := compose.Down(ComposeFile) - if err != nil { - return errors.New(stdout) - } - stdout, err = compose.Up(ComposeFile) - if err != nil { - return errors.New(stdout) + if err := updateInstallInfoInDB("redis-commander", "password", true, req.Value); err != nil { + return err } return nil diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index f248ebe22..91766da3d 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -23,7 +23,7 @@ export const updateMysqlAccess = (params: Database.ChangeInfo) => { return http.post(`/databases/change/access`, params); }; export const updateMysqlPassword = (params: Database.ChangeInfo) => { - return http.post(`/databases/change/[password]`, params); + return http.post(`/databases/change/password`, params); }; export const updateMysqlVariables = (params: Array) => { return http.post(`/databases/variables/update`, params); diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index f41f41415..4d7e27089 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -74,6 +74,7 @@ export default { updateSuccess: 'Update Success', uploadSuccess: 'Update Success', operate: 'Operate', + inputOrSelect: 'Please select or enter', }, login: { firstLogin: 'First login, please create an initial administrator user!', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 450864e48..0f3711b08 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -76,6 +76,7 @@ export default { uploadSuccess: '上传成功', operate: '操作', operateConfirm: '如果确认操作,请手动输入', + inputOrSelect: '请选择或输入', }, login: { firstLogin: '首次登录,请创建初始管理员用户!', diff --git a/frontend/src/views/container/container/create/index.vue b/frontend/src/views/container/container/create/index.vue index 2a7bbd4a4..22f0da15a 100644 --- a/frontend/src/views/container/container/create/index.vue +++ b/frontend/src/views/container/container/create/index.vue @@ -119,6 +119,7 @@ style="width: 100%" allow-create clearable + :placeholder="$t('commons.msg.inputOrSelect')" filterable v-model="row.sourceDir" > diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue index 1f7e61621..5b08bc44b 100644 --- a/frontend/src/views/database/mysql/setting/index.vue +++ b/frontend/src/views/database/mysql/setting/index.vue @@ -22,10 +22,18 @@ {{ $t('commons.button.save') }} - + - + @@ -50,7 +58,7 @@ - + diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue index ec48c34ff..cb288f6e4 100644 --- a/frontend/src/views/database/redis/index.vue +++ b/frontend/src/views/database/redis/index.vue @@ -11,14 +11,21 @@ v-model:loading="loading" > + + Redis-Commander + + -
- - Redis-Commander + + {{ $t('database.mysqlBadStatus') }} + + 【 {{ $t('database.setting') }} 】 - - + {{ $t('database.adjust') }} + +
+
{ isOnSetting.value = true; terminalRef.value.onClose(); - settingRef.value!.acceptParams({ status: redisSattus.value }); + settingRef.value!.acceptParams({ status: redisStatus.value }); }; const goRouter = async (path: string) => { @@ -90,9 +97,9 @@ const loadDashboardPort = async () => { const checkExist = (data: App.CheckInstalled) => { redisIsExist.value = data.isExist; - redisSattus.value = data.status; + redisStatus.value = data.status; loading.value = false; - if (redisIsExist.value) { + if (redisStatus.value === 'Running') { loadDashboardPort(); terminalRef.value.acceptParams(); } diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue index a8d26d623..cd805d731 100644 --- a/frontend/src/views/database/redis/setting/index.vue +++ b/frontend/src/views/database/redis/setting/index.vue @@ -74,20 +74,19 @@ v-model="redisConf" :readOnly="true" /> - + {{ $t('commons.button.save') }}
- + - + @@ -275,8 +274,15 @@ const onSubmitSave = async () => { file: redisConf.value, restartNow: true, }; - await updateRedisConfByFile(param); - ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + loading.value = true; + await updateRedisConfByFile(param) + .then(() => { + loading.value = false; + ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + }) + .catch(() => { + loading.value = true; + }); }; const loadform = async () => {