mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: mysql 列表读写切换
This commit is contained in:
parent
e1c2348e44
commit
44df6acb5d
@ -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 {
|
||||
|
@ -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):
|
||||
|
@ -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"`
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
@ -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<Database.VariablesUpdate>) => {
|
||||
return http.post(`/databases/variables/update`, params);
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ const hostRouter = {
|
||||
},
|
||||
{
|
||||
path: '/hosts/monitor',
|
||||
name: 'Monitor',
|
||||
name: 'Monitorx',
|
||||
component: () => import('@/views/host/monitor/index.vue'),
|
||||
meta: {
|
||||
title: 'menu.monitor',
|
||||
|
@ -75,7 +75,13 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('commons.table.description')" prop="description" />
|
||||
<el-table-column :label="$t('commons.table.description')" prop="description">
|
||||
<template #default="{ row }">
|
||||
<fu-read-write-switch :data="row.description" v-model="row.edit" @change="onChange(row)">
|
||||
<el-input v-model="row.description" @blur="row.edit = false" />
|
||||
</fu-read-write-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="createdAt"
|
||||
:label="$t('commons.table.date')"
|
||||
@ -193,6 +199,7 @@ import {
|
||||
loadRemoteAccess,
|
||||
searchMysqlDBs,
|
||||
updateMysqlAccess,
|
||||
updateMysqlDescription,
|
||||
updateMysqlPassword,
|
||||
} from '@/api/modules/database';
|
||||
import i18n from '@/lang';
|
||||
@ -343,6 +350,13 @@ const search = async () => {
|
||||
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 });
|
||||
};
|
||||
|
@ -48,8 +48,8 @@
|
||||
<el-form-item v-if="item.type === 'SFTP'" :label="$t('setting.port')">
|
||||
{{ item.varsJson['port'] }}
|
||||
</el-form-item>
|
||||
<el-form-item v-if="item.type === 'SFTP'" :label="$t('setting.username')">
|
||||
{{ item.accessKey }}
|
||||
<el-form-item v-if="item.type === 'SFTP'" :label="$t('setting.path')">
|
||||
{{ item.bucket }}
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.table.createdAt')">
|
||||
{{ dateFromat(0, 0, item.createdAt) }}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<span>{{ title }}{{ $t('setting.backupAccount') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="formRef" :model="dialogData.rowData" label-width="120px">
|
||||
<el-form ref="formRef" v-loading="loading" :model="dialogData.rowData" label-width="120px">
|
||||
<el-form-item :label="$t('commons.table.type')" prop="type" :rules="Rules.requiredSelect">
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
@ -53,13 +53,28 @@
|
||||
<el-input v-model="dialogData.rowData!.varsJson['region']" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="hasBucket(dialogData.rowData!.type)"
|
||||
v-if="hasBucket(dialogData.rowData!.type) && dialogData.rowData!.type !== 'MINIO'"
|
||||
label="Endpoint"
|
||||
prop="varsJson.endpoint"
|
||||
:rules="Rules.requiredInput"
|
||||
>
|
||||
<el-input v-model="dialogData.rowData!.varsJson['endpoint']" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="dialogData.rowData!.type === 'MINIO'"
|
||||
label="Endpoint"
|
||||
prop="varsJson.endpointItem"
|
||||
:rules="Rules.requiredInput"
|
||||
>
|
||||
<el-input v-model="dialogData.rowData!.varsJson['endpointItem']">
|
||||
<template #prepend>
|
||||
<el-select v-model="endpoints" style="width: 80px">
|
||||
<el-option label="http" value="http" />
|
||||
<el-option label="https" value="https" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="dialogData.rowData!.type !== '' && hasBucket(dialogData.rowData!.type)"
|
||||
label="Bucket"
|
||||
@ -110,6 +125,7 @@ import i18n from '@/lang';
|
||||
import { ElForm, ElMessage } from 'element-plus';
|
||||
import { Backup } from '@/api/interface/backup';
|
||||
import { addBackup, editBackup, listBucket } from '@/api/modules/backup';
|
||||
import { deepCopy } from '@/utils/util';
|
||||
|
||||
const loading = ref(false);
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
@ -117,6 +133,8 @@ const formRef = ref<FormInstance>();
|
||||
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<DialogProps>({
|
||||
});
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user