From cd77c672bc198b26d7830d7790f3141a461b2728 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:04:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=88=E6=8A=A4=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=AD=97=E6=AE=B5=E5=A2=9E=E5=8A=A0=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=20(#1865)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/host_tool.go | 8 ++++---- .../views/host/tool/supervisor/create/index.vue | 10 +++++----- .../views/host/tool/supervisor/file/index.vue | 2 ++ .../src/views/host/tool/supervisor/index.vue | 16 ++++++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/backend/app/service/host_tool.go b/backend/app/service/host_tool.go index 9699623dd..40f164a9c 100644 --- a/backend/app/service/host_tool.go +++ b/backend/app/service/host_tool.go @@ -110,7 +110,7 @@ func (h *HostToolService) GetToolStatus(req request.HostToolReq) (*response.Host if !fileOp.Stat(configPath) { configPath = "/etc/supervisor/supervisord.conf" if !fileOp.Stat(configPath) { - return nil, errors.New("ErrConfigNotFound") + return nil, buserr.New("ErrConfigNotFound") } } } @@ -125,7 +125,7 @@ func (h *HostToolService) CreateToolConfig(req request.HostToolCreate) error { case constant.Supervisord: fileOp := files.NewFileOp() if !fileOp.Stat(req.ConfigPath) { - return errors.New("ErrConfigNotFound") + return buserr.New("ErrConfigNotFound") } cfg, err := ini.Load(req.ConfigPath) if err != nil { @@ -281,7 +281,7 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess iniPath = path.Join(includeDir, fmt.Sprintf("%s.ini", req.Name)) fileOp = files.NewFileOp() ) - if req.Operate == "edit" || req.Operate == "create" { + if req.Operate == "update" || req.Operate == "create" { if !fileOp.Stat(req.Dir) { return buserr.New("ErrConfigDirNotFound") } @@ -318,7 +318,7 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess return err } return operateSupervisorCtl("reload", "", "") - case "edit": + case "update": configFile, err := ini.Load(iniPath) if err != nil { return err diff --git a/frontend/src/views/host/tool/supervisor/create/index.vue b/frontend/src/views/host/tool/supervisor/create/index.vue index 1ab888e10..e6e3f1f42 100644 --- a/frontend/src/views/host/tool/supervisor/create/index.vue +++ b/frontend/src/views/host/tool/supervisor/create/index.vue @@ -21,7 +21,7 @@ - + @@ -54,7 +54,7 @@ const open = ref(false); const loading = ref(false); const processForm = ref(); const rules = ref({ - name: [Rules.requiredInput], + name: [Rules.requiredInput, Rules.simpleName], dir: [Rules.requiredInput], command: [Rules.requiredInput], user: [Rules.requiredInput], @@ -64,7 +64,7 @@ const initData = () => ({ operate: 'create', name: '', command: '', - user: '', + user: 'root', dir: '', numprocsNum: 1, numprocs: '1', @@ -89,9 +89,9 @@ const resetForm = () => { const acceptParams = (operate: string, config: HostTool.SupersivorProcess) => { process.value = initData(); - if (operate == 'edit') { + if (operate == 'update') { process.value = { - operate: 'edit', + operate: 'update', name: config.name, command: config.command, user: config.user, diff --git a/frontend/src/views/host/tool/supervisor/file/index.vue b/frontend/src/views/host/tool/supervisor/file/index.vue index 5e31c389b..844ce23af 100644 --- a/frontend/src/views/host/tool/supervisor/file/index.vue +++ b/frontend/src/views/host/tool/supervisor/file/index.vue @@ -52,6 +52,7 @@ import { useDeleteData } from '@/hooks/use-delete-data'; import { OperateSupervisorProcessFile } from '@/api/modules/host-tool'; import i18n from '@/lang'; import { TabsPaneContext } from 'element-plus'; +import { MsgSuccess } from '@/utils/message'; const extensions = [javascript(), oneDark]; const loading = ref(false); @@ -113,6 +114,7 @@ const submit = () => { loading.value = true; OperateSupervisorProcessFile(updateReq) .then(() => { + MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); getContent(); }) .finally(() => { diff --git a/frontend/src/views/host/tool/supervisor/index.vue b/frontend/src/views/host/tool/supervisor/index.vue index e8517e5bf..8fcf39b51 100644 --- a/frontend/src/views/host/tool/supervisor/index.vue +++ b/frontend/src/views/host/tool/supervisor/index.vue @@ -20,15 +20,19 @@