From 44df6acb5dd8082beff748b4421b30e813f6fcb7 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Sat, 24 Dec 2022 13:31:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mysql=20=E5=88=97=E8=A1=A8=E8=AF=BB?= =?UTF-8?q?=E5=86=99=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/database_mysql.go | 18 ++ backend/app/api/v1/helper/helper.go | 7 +- backend/app/dto/database.go | 5 + backend/app/service/database_mysql.go | 5 + backend/middleware/operation.go | 17 +- backend/router/ro_database.go | 1 + cmd/server/operation/operation.json | 183 ++++++++++-------- frontend/src/api/interface/database.ts | 4 + frontend/src/api/modules/database.ts | 3 + frontend/src/routers/modules/host.ts | 2 +- frontend/src/views/database/mysql/index.vue | 16 +- .../views/setting/backup-account/index.vue | 4 +- .../setting/backup-account/operate/index.vue | 41 +++- 13 files changed, 207 insertions(+), 99 deletions(-) diff --git a/backend/app/api/v1/database_mysql.go b/backend/app/api/v1/database_mysql.go index 60d61e34c..16bff6396 100644 --- a/backend/app/api/v1/database_mysql.go +++ b/backend/app/api/v1/database_mysql.go @@ -2,6 +2,7 @@ package v1 import ( "context" + "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/constant" @@ -26,6 +27,23 @@ func (b *BaseApi) CreateMysql(c *gin.Context) { helper.SuccessWithData(c, nil) } +func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) { + var req dto.MysqlDescription + if err := c.ShouldBindJSON(&req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + if err := global.VALID.Struct(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + if err := mysqlService.UpdateDescription(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} + func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) { var req dto.ChangeDBInfo if err := c.ShouldBindJSON(&req); err != nil { diff --git a/backend/app/api/v1/helper/helper.go b/backend/app/api/v1/helper/helper.go index cd8e4acf9..f84a13b13 100644 --- a/backend/app/api/v1/helper/helper.go +++ b/backend/app/api/v1/helper/helper.go @@ -3,11 +3,12 @@ package helper import ( "context" "fmt" - "github.com/1Panel-dev/1Panel/backend/global" - "gorm.io/gorm" "net/http" "strconv" + "github.com/1Panel-dev/1Panel/backend/global" + "gorm.io/gorm" + "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/constant" @@ -46,6 +47,8 @@ func ErrorWithDetail(ctx *gin.Context, code int, msgKey string, err error) { res.Message = i18n.GetMsgWithMap("ErrRecordExist", nil) case errors.Is(constant.ErrRecordNotFound, err): res.Message = i18n.GetMsgWithMap("ErrRecordNotFound", nil) + case errors.Is(constant.ErrInvalidParams, err): + res.Message = i18n.GetMsgWithMap("ErrInvalidParams", nil) case errors.Is(constant.ErrStructTransform, err): res.Message = i18n.GetMsgWithMap("ErrStructTransform", map[string]interface{}{"detail": err}) case errors.Is(constant.ErrCaptchaCode, err): diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index e3611bac5..234d2f41e 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -2,6 +2,11 @@ package dto import "time" +type MysqlDescription struct { + ID uint `json:"id" validate:"required"` + Description string `json:"description"` +} + type MysqlDBInfo struct { ID uint `json:"id"` CreatedAt time.Time `json:"createdAt"` diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index 4a90896a0..986c25df9 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -37,6 +37,7 @@ type IMysqlService interface { ChangePassword(info dto.ChangeDBInfo) error UpdateVariables(updatas []dto.MysqlVariablesUpdate) error UpdateConfByFile(info dto.MysqlConfUpdateByFile) error + UpdateDescription(req dto.MysqlDescription) error RecoverByUpload(req dto.UploadRecover) error Backup(db dto.BackupDB) error @@ -191,6 +192,10 @@ func (u *MysqlService) Create(ctx context.Context, mysqlDto dto.MysqlDBCreate) ( return &mysql, nil } +func (u *MysqlService) UpdateDescription(req dto.MysqlDescription) error { + return mysqlRepo.Update(req.ID, map[string]interface{}{"description": req.Description}) +} + func (u *MysqlService) Backup(db dto.BackupDB) error { localDir, err := loadLocalDir() if err != nil { diff --git a/backend/middleware/operation.go b/backend/middleware/operation.go index 544378a78..a1096f8c4 100644 --- a/backend/middleware/operation.go +++ b/backend/middleware/operation.go @@ -85,16 +85,19 @@ func OperationLog() gin.HandlerFunc { } } } - var values []interface{} for key, value := range formatMap { - if strings.Contains(operationDic.FormatEN, key) { - operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, key, "%v") - operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, key, "%v") - values = append(values, value) + if strings.Contains(operationDic.FormatEN, "["+key+"]") { + if arrys, ok := value.([]string); ok { + operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(arrys, ","))) + operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", strings.Join(arrys, ","))) + } else { + operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", value)) + operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", value)) + } } } - record.DetailZH = fmt.Sprintf(operationDic.FormatZH, values...) - record.DetailEN = fmt.Sprintf(operationDic.FormatEN, values...) + record.DetailEN = operationDic.FormatEN + record.DetailZH = operationDic.FormatZH writer := responseBodyWriter{ ResponseWriter: c.Writer, diff --git a/backend/router/ro_database.go b/backend/router/ro_database.go index 5d97add06..4ef4ccb04 100644 --- a/backend/router/ro_database.go +++ b/backend/router/ro_database.go @@ -24,6 +24,7 @@ func (s *DatabaseRouter) InitDatabaseRouter(Router *gin.RouterGroup) { cmdRouter.POST("/recover", baseApi.RecoverMysql) cmdRouter.POST("/del/check", baseApi.DeleteCheckMysql) cmdRouter.POST("/del", baseApi.DeleteMysql) + cmdRouter.POST("/description/update", baseApi.UpdateMysqlDescription) cmdRouter.POST("/variables/update", baseApi.UpdateMysqlVariables) cmdRouter.POST("/conffile/update", baseApi.UpdateMysqlConfByFile) cmdRouter.POST("/search", baseApi.SearchMysql) diff --git a/cmd/server/operation/operation.json b/cmd/server/operation/operation.json index 5914dbf5d..065253fdf 100644 --- a/cmd/server/operation/operation.json +++ b/cmd/server/operation/operation.json @@ -8,8 +8,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "创建容器 name[image]", - "formatEN": "create container name[image]" + "formatZH": "创建容器 [name][image]", + "formatEN": "create container [name][image]" }, { "api": "/api/v1/containers/operate", @@ -21,8 +21,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "容器 [name] 执行 [operation] newName", - "formatEN": "container [operation] [name] newName" + "formatZH": "容器 [name] 执行 [operation] [newName]", + "formatEN": "container [operation] [name] [newName]" }, { "api": "/api/v1/containers/repo", @@ -70,8 +70,8 @@ "value": "names" } ], - "formatZH": "删除镜像仓库 names", - "formatEN": "delete image repo names" + "formatZH": "删除镜像仓库 [names]", + "formatEN": "delete image repo [names]" }, { "api": "/api/v1/containers/compose", @@ -153,8 +153,8 @@ "value": "names" } ], - "formatZH": "删除 compose 模版 names", - "formatEN": "delete compose template names" + "formatZH": "删除 compose 模版 [names]", + "formatEN": "delete compose template [names]" }, { "api": "/api/v1/containers/image/pull", @@ -173,8 +173,8 @@ "value": "reponame" } ], - "formatZH": "镜像拉取 [reponame]imageName", - "formatEN": "image pull [reponame]imageName" + "formatZH": "镜像拉取 [reponame][imageName]", + "formatEN": "image pull [reponame][imageName]" }, { "api": "/api/v1/containers/image/push", @@ -194,8 +194,8 @@ "value": "reponame" } ], - "formatZH": "[tagName] 推送到 [reponame]name", - "formatEN": "push [tagName] to [reponame]name" + "formatZH": "[tagName] 推送到 [reponame][name]", + "formatEN": "push [tagName] to [reponame][name]" }, { "api": "/api/v1/containers/image/save", @@ -207,8 +207,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "保留 [tagName] 为 [path/name]", - "formatEN": "save [tagName] as [path/name]" + "formatZH": "保留 [tagName] 为 [path]/[name]", + "formatEN": "save [tagName] as [path]/[name]" }, { "api": "/api/v1/containers/image/load", @@ -229,8 +229,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "移除镜像 names", - "formatEN": "remove image names" + "formatZH": "移除镜像 [names]", + "formatEN": "remove image [names]" }, { "api": "/api/v1/containers/image/tag", @@ -249,8 +249,8 @@ "value": "reponame" } ], - "formatZH": "tag 镜像 [reponame]targetName", - "formatEN": "tag image [reponame]targetName" + "formatZH": "tag 镜像 [reponame][targetName]", + "formatEN": "tag image [reponame][targetName]" }, { "api": "/api/v1/containers/image/build", @@ -282,8 +282,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "删除容器网络 names", - "formatEN": "delete container network names" + "formatZH": "删除容器网络 [names]", + "formatEN": "delete container network [names]" }, { "api": "/api/v1/containers/volume", @@ -304,8 +304,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "删除容器存储卷 names", - "formatEN": "delete container volume names" + "formatZH": "删除容器存储卷 [names]", + "formatEN": "delete container volume [names]" }, { "api": "/api/v1/containers/docker/operate", @@ -316,7 +316,7 @@ "paramKeys": [], "BeforeFuntions": [], "formatZH": "docker 服务 [operation]", - "formatEN": "operation docker service" + "formatEN": "[operation] docker service" }, { "api": "/api/v1/containers/daemonjson/update", @@ -352,8 +352,8 @@ "value": "names" } ], - "formatZH": "删除计划任务 names", - "formatEN": "delete cronjob names" + "formatZH": "删除计划任务 [names]", + "formatEN": "delete cronjob [names]" }, { "api": "/api/v1/cronjobs/update", @@ -433,8 +433,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "备份 mysql 数据库 mysqlName[dbName]", - "formatEN": "backup mysql database mysqlName[dbName]" + "formatZH": "备份 mysql 数据库 [mysqlName][dbName]", + "formatEN": "backup mysql database [mysqlName][dbName]" }, { "api": "/api/v1/databases/recover", @@ -446,8 +446,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "恢复 mysql 数据库 mysqlName[dbName] backupName", - "formatEN": "恢复 mysql 数据库 mysqlName[dbName] backupName" + "formatZH": "恢复 mysql 数据库 [mysqlName][dbName] [backupName]", + "formatEN": "恢复 mysql 数据库 [mysqlName][dbName] [backupName]" }, { "api": "/api/v1/databases/recover/byupload", @@ -460,8 +460,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "mysql 数据库从 [fileDir/fileName] 恢复 [mysqlName]dbName", - "formatEN": "mysql database recover [fileDir/fileName] from [mysqlName]dbName" + "formatZH": "mysql 数据库从 [fileDir]/[fileName] 恢复 [mysqlName][dbName]", + "formatEN": "mysql database recover [fileDir]/[fileName] from [mysqlName][dbName]" }, { "api": "/api/v1/databases/del", @@ -482,6 +482,23 @@ "formatZH": "删除 mysql 数据库 [name]", "formatEN": "delete mysql database [name]" }, + { + "api": "/api/v1/databases/description/update", + "method": "POST", + "bodyKeys": ["id", "description"], + "paramKeys": [], + "BeforeFuntions": [ + { + "info": "id", + "isList": false, + "db": "database_mysqls", + "key": "name", + "value": "name" + } + ], + "formatZH": "mysql 数据库 [name] 描述信息修改 [description]", + "formatEN": "The description of the mysql database [name] is modified => [description]" + }, { "api": "/api/v1/databases/variables/update", "method": "POST", @@ -527,8 +544,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "redis 数据库从 fileDir/fileName 恢复", - "formatEN": "redis database recover from fileDir/fileName" + "formatZH": "redis 数据库从 [fileDir]/[fileName] 恢复", + "formatEN": "redis database recover from [fileDir]/[fileName]" }, { "api": "/api/v1/databases/redis/conf/update", @@ -566,8 +583,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "创建快捷命令 name[command]", - "formatEN": "create quick command name[command]" + "formatZH": "创建快捷命令 [name][command]", + "formatEN": "create quick command [name][command]" }, { "api": "/api/v1/commands/del", @@ -585,8 +602,8 @@ "value": "names" } ], - "formatZH": "删除快捷命令 names", - "formatEN": "delete quick command names" + "formatZH": "删除快捷命令 [names]", + "formatEN": "delete quick command [names]" }, { "api": "/api/v1/commands/update", @@ -649,8 +666,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "下载备份记录 [source]fileName", - "formatEN": "download backup records [source]fileName" + "formatZH": "下载备份记录 [source][fileName]", + "formatEN": "download backup records [source][fileName]" }, { "api": "/api/v1/backups/record/del", @@ -699,8 +716,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "更新组 [name]type", - "formatEN": "update group [name]type" + "formatZH": "更新组 [name][type]", + "formatEN": "update group [name][type]" }, { "api": "/api/v1/groups", @@ -711,8 +728,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "创建组 [name]type", - "formatEN": "create group [name]type" + "formatZH": "创建组 [name][type]", + "formatEN": "create group [name][type]" }, { "api": "/api/v1/hosts/del", @@ -742,8 +759,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "更新主机信息 [name]addr", - "formatEN": "update host [name]addr" + "formatZH": "更新主机信息 [name][addr]", + "formatEN": "update host [name][addr]" }, { "api": "/api/v1/hosts", @@ -754,8 +771,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "创建主机 [name]addr", - "formatEN": "create host [name]addr" + "formatZH": "创建主机 [name][addr]", + "formatEN": "create host [name][addr]" }, { "api": "/api/v1/settings/expired/handle", @@ -846,8 +863,8 @@ "value": "appKey" } ], - "formatZH": "安装应用 [appKey]-name", - "formatEN": "Install app [appKey]-name" + "formatZH": "安装应用 [appKey]-[name]", + "formatEN": "Install app [appKey]-[name]" }, { "api": "/api/v1/apps/installed/op", @@ -880,8 +897,8 @@ "value": "appKey" } ], - "formatZH": "应用 [appKey]-appName operate", - "formatEN": "App [appKey]-appName operate" + "formatZH": "应用 [appKey]-[appName] [operate]", + "formatEN": "App [appKey]-[appName] [operate]" }, { "api": "/api/v1/apps/installed/sync", @@ -921,8 +938,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "应用端口修改 [key]-name => port", - "formatEN": "Application port update [key]-name => port" + "formatZH": "应用端口修改 [key]-[name] => [port]", + "formatEN": "Application port update [key]-[name] => [port]" }, { "api": "/api/v1/apps/installed/port/change", @@ -934,8 +951,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "应用端口修改 [key]-name => port", - "formatEN": "Application port update [key]-name => port" + "formatZH": "应用端口修改 [key]-[name] => [port]", + "formatEN": "Application port update [key]-[name] => [port]" }, { "api": "/api/v1/apps/files", @@ -945,8 +962,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "创建文件/文件夹 path", - "formatEN": "Create dir or file path" + "formatZH": "创建文件/文件夹 [path]", + "formatEN": "Create dir or file [path]" }, { "api": "/api/v1/apps/files/del", @@ -956,8 +973,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "删除文件/文件夹 path", - "formatEN": "Delete dir or file path" + "formatZH": "删除文件/文件夹 [path]", + "formatEN": "Delete dir or file [path]" }, { "api": "/api/v1/apps/files/batch/del", @@ -967,8 +984,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "批量删除文件/文件夹 paths", - "formatEN": "Batch delete dir or file paths" + "formatZH": "批量删除文件/文件夹 [paths]", + "formatEN": "Batch delete dir or file [paths]" }, { "api": "/api/v1/apps/files/mode", @@ -979,8 +996,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "修改权限 paths => mode", - "formatEN": "Change mode paths => mode" + "formatZH": "修改权限 [paths] => [mode]", + "formatEN": "Change mode [paths] => [mode]" }, { "api": "/api/v1/apps/files/compress", @@ -990,8 +1007,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "压缩文件 name", - "formatEN": "Compress file name" + "formatZH": "压缩文件 [name]", + "formatEN": "Compress file [name]" }, { "api": "/api/v1/apps/files/decompress", @@ -1001,8 +1018,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "解压 path", - "formatEN": "Decompress file path" + "formatZH": "解压 [path]", + "formatEN": "Decompress file [path]" }, { "api": "/api/v1/apps/files/upload", @@ -1012,8 +1029,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "上传文件 path", - "formatEN": "Upload file path" + "formatZH": "上传文件 [path]", + "formatEN": "Upload file [path]" }, { "api": "/api/v1/apps/files/rename", @@ -1024,8 +1041,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "重命名 oldName => newName", - "formatEN": "Rename oldName => newName" + "formatZH": "重命名 [oldName] => [newName]", + "formatEN": "Rename [oldName] => [newName]" }, { "api": "/api/v1/apps/files/wget", @@ -1037,8 +1054,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "下载 url => path/name", - "formatEN": "Download url => path/name" + "formatZH": "下载 url => [path]/[name]", + "formatEN": "Download url => [path]/[name]" }, { "api": "/api/v1/apps/files/move", @@ -1049,8 +1066,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "移动文件 oldPaths => newPath", - "formatEN": "Move oldPaths => newPath" + "formatZH": "移动文件 [oldPaths] => [newPath]", + "formatEN": "Move [oldPaths] => [newPath]" }, { "api": "/api/v1/apps/files/download", @@ -1060,8 +1077,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "下载文件 name", - "formatEN": "Download file name" + "formatZH": "下载文件 [name]", + "formatEN": "Download file [name]" }, { "api": "/api/v1/apps/nginx/update", @@ -1079,8 +1096,8 @@ "value": "domain" } ], - "formatZH": "更新 nginx 配置 domain", - "formatEN": "Update nginx conf domain" + "formatZH": "更新 nginx 配置 [domain]", + "formatEN": "Update nginx conf [domain]" }, { "api": "/api/v1/apps/nginx/file", @@ -1140,7 +1157,7 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "更新网站 dns name", + "formatZH": "更新网站 dns [name]", "formatEN": "Update website dns [name]" }, { @@ -1159,7 +1176,7 @@ "value": "name" } ], - "formatZH": "删除网站 dns name", + "formatZH": "删除网站 dns [name]", "formatEN": "Delete website dns [name]" }, { @@ -1266,8 +1283,8 @@ ], "paramKeys": [], "BeforeFuntions": [], - "formatZH": "[websiteName] 从上传恢复 [fileDir/fileName]", - "formatEN": "[websiteName] recover from uploads [fileDir/fileName]" + "formatZH": "[websiteName] 从上传恢复 [fileDir]/[fileName]", + "formatEN": "[websiteName] recover from uploads [fileDir]/[fileName]" }, { "api": "/api/v1/websites/domains/del", diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index 86550d58c..0bc30a4f2 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -5,6 +5,10 @@ export namespace Database { mysqlName: string; dbName: string; } + export interface DescriptionUpdate { + id: number; + description: string; + } export interface Backup { mysqlName: string; dbName: string; diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index bd88782d6..e89446924 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -25,6 +25,9 @@ export const updateMysqlAccess = (params: Database.ChangeInfo) => { export const updateMysqlPassword = (params: Database.ChangeInfo) => { return http.post(`/databases/change/password`, params); }; +export const updateMysqlDescription = (params: Database.DescriptionUpdate) => { + return http.post(`/databases/description/update`, params); +}; export const updateMysqlVariables = (params: Array) => { return http.post(`/databases/variables/update`, params); }; diff --git a/frontend/src/routers/modules/host.ts b/frontend/src/routers/modules/host.ts index e61a26f15..d1a613d74 100644 --- a/frontend/src/routers/modules/host.ts +++ b/frontend/src/routers/modules/host.ts @@ -20,7 +20,7 @@ const hostRouter = { }, { path: '/hosts/monitor', - name: 'Monitor', + name: 'Monitorx', component: () => import('@/views/host/monitor/index.vue'), meta: { title: 'menu.monitor', diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index a51bf3fc3..30fb74a64 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -75,7 +75,13 @@ - + + + { paginationConfig.total = res.data.total; }; +const onChange = async (info: any) => { + if (!info.edit) { + await updateMysqlDescription({ id: info.id, description: info.description }); + ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + } +}; + const goRouter = async (path: string) => { router.push({ path: path }); }; diff --git a/frontend/src/views/setting/backup-account/index.vue b/frontend/src/views/setting/backup-account/index.vue index e98ebccff..6b8abb8b5 100644 --- a/frontend/src/views/setting/backup-account/index.vue +++ b/frontend/src/views/setting/backup-account/index.vue @@ -48,8 +48,8 @@ {{ item.varsJson['port'] }} - - {{ item.accessKey }} + + {{ item.bucket }} {{ dateFromat(0, 0, item.createdAt) }} diff --git a/frontend/src/views/setting/backup-account/operate/index.vue b/frontend/src/views/setting/backup-account/operate/index.vue index 434841fb6..00c46d51c 100644 --- a/frontend/src/views/setting/backup-account/operate/index.vue +++ b/frontend/src/views/setting/backup-account/operate/index.vue @@ -5,7 +5,7 @@ {{ title }}{{ $t('setting.backupAccount') }} - + + + + + + ; @@ -117,6 +133,8 @@ const formRef = ref(); const typeOptions = ref(); const buckets = ref(); +const endpoints = ref('http'); + const emit = defineEmits<{ (e: 'search'): void }>(); interface DialogProps { @@ -133,6 +151,13 @@ const dialogData = ref({ }); const acceptParams = (params: DialogProps): void => { dialogData.value = params; + if (dialogData.value.title === 'edit' && dialogData.value.rowData!.type === 'MINIO') { + if (dialogData.value.rowData!.varsJson['endpoint'].indexOf('://') !== 0) { + endpoints.value = dialogData.value.rowData!.varsJson['endpoint'].split('://')[0]; + dialogData.value.rowData!.varsJson['endpointItem'] = + dialogData.value.rowData!.varsJson['endpoint'].split('://')[1]; + } + } title.value = i18n.global.t('commons.button.' + dialogData.value.title); loadOption(params.types); dialogVisiable.value = true; @@ -173,9 +198,14 @@ function hasBucket(val: string) { const getBuckets = async () => { loading.value = true; + let item = deepCopy(dialogData.value.rowData!.varsJson); + if (dialogData.value.rowData!.type === 'MINIO') { + item['endpoint'] = endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem']; + item['endpointItem'] = undefined; + } listBucket({ type: dialogData.value.rowData!.type, - vars: JSON.stringify(dialogData.value.rowData!.varsJson), + vars: JSON.stringify(item), accessKey: dialogData.value.rowData!.accessKey, credential: dialogData.value.rowData!.credential, }) @@ -194,6 +224,11 @@ const onSubmit = async (formEl: FormInstance | undefined) => { formEl.validate(async (valid) => { if (!valid) return; if (!dialogData.value.rowData) return; + if (dialogData.value.rowData!.type === 'MINIO') { + dialogData.value.rowData!.varsJson['endpoint'] = + endpoints.value + '://' + dialogData.value.rowData!.varsJson['endpointItem']; + dialogData.value.rowData!.varsJson['endpointItem'] = undefined; + } dialogData.value.rowData.vars = JSON.stringify(dialogData.value.rowData!.varsJson); if (dialogData.value.title === 'create') { await addBackup(dialogData.value.rowData);