style: 修改初始化 Supervisor 的提示文字 (#1838)

pull/1855/head
zhengkunwang 2023-08-04 18:22:01 +08:00 committed by GitHub
parent a516ba9d63
commit ac7e47bdf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 11 deletions

View File

@ -185,12 +185,10 @@ func (h *HostToolService) CreateToolConfig(req request.HostToolCreate) error {
return err
}
}
go func() {
if err = systemctl.Restart(req.ServiceName); err != nil {
global.LOG.Errorf("[init] restart %s failed err %s", req.ServiceName, err.Error())
}
}()
if err = systemctl.Restart(req.ServiceName); err != nil {
global.LOG.Errorf("[init] restart %s failed err %s", req.ServiceName, err.Error())
return err
}
}
return nil
}

View File

@ -1671,13 +1671,16 @@ const message = {
dir: 'run directory',
numprocs: 'Number of processes',
initWarn:
'Because it is not compatible with the original configuration, initializing Supervisor will modify the files parameter of the configuration file, causing all existing processes to stop, please confirm the risk in advance. The modified process configuration folder is in <1Panel installation directory>/1panel/tools/supervisord/supervisor.d',
'The initialization operation needs to modify the [include] files parameter of the configuration file, the directory where the modified service configuration file is located: 1panel installation directory/1panel/tools/supervisord/supervisor.d/',
operatorHelper: 'Operation {1} will be performed on {0}, continue? ',
uptime: 'running time',
notStartWarn: 'Supervisor is not started, please start it first',
serviceName: 'Service name',
initHelper:
'The initialization process will modify the configuration file, causing all existing processes to stop, please confirm the risk in advance',
serviceNameHelper: 'Currently only supports the Supervisor service managed by systemctl',
restartHelper:
'Initialization will restart the service, causing all the original daemon processes to close',
},
},
};

View File

@ -1586,12 +1586,14 @@ const message = {
dir: '',
numprocs: '',
initWarn:
' Supervisor files <1Panel>/1panel/tools/supervisord/supervisor.d ',
' [include] files : 1panel/1panel/tools/supervisord/supervisor.d/',
operatorHelper: ' {0} {1} ',
uptime: '',
notStartWarn: 'Supervisor ',
serviceName: '',
initHelper: ' Supervisor ',
serviceNameHelper: ' systemctl Supervisor ',
restartHelper: '',
},
},
};

View File

@ -1588,12 +1588,14 @@ const message = {
dir: '',
numprocs: '',
initWarn:
' Supervisor files <1Panel>/1panel/tools/supervisord/supervisor.d ',
' [include] files : 1panel/1panel/tools/supervisord/supervisor.d/',
operatorHelper: ' {0} {1} ',
uptime: '',
notStartWarn: ' Supervisor ',
serviceName: '',
initHelper: ' Supervisor ',
serviceNameHelper: ' systemctl Supervisor ',
restartHelper: '',
},
},
};

View File

@ -34,6 +34,7 @@
:title="$t('tool.supervisor.list')"
:divider="true"
v-if="!data.isExist || !data.ctlExist || data.init"
v-loading="loading"
>
<template #main>
<div class="app-warn">
@ -79,6 +80,7 @@ const data = ref({
ctlExist: false,
serviceName: '',
});
const loading = ref(false);
const em = defineEmits(['setting', 'getStatus', 'update:loading', 'update:maskShow']);
@ -126,6 +128,7 @@ const onOperate = async (operation: string) => {
const getStatus = async () => {
try {
loading.value = true;
em('update:loading', true);
const res = await GetSupervisorStatus();
data.value = res.data.config as HostTool.Supersivor;
@ -138,6 +141,7 @@ const getStatus = async () => {
em('getStatus', status);
} catch (error) {}
em('update:loading', false);
loading.value = false;
};
onMounted(() => {

View File

@ -11,6 +11,7 @@
</el-form-item>
<el-form-item :label="$t('tool.supervisor.serviceName')" prop="serviceName">
<el-input v-model.trim="initModel.serviceName"></el-input>
<span class="input-help">{{ $t('tool.supervisor.serviceNameHelper') }}</span>
</el-form-item>
<el-alert
:title="$t('tool.supervisor.initWarn')"
@ -18,6 +19,13 @@
:closable="false"
type="error"
/>
<el-alert
:title="$t('tool.supervisor.restartHelper')"
class="common-prompt"
:closable="false"
type="error"
effect="dark"
/>
</el-form>
</el-col>
</el-row>
@ -26,11 +34,12 @@
<el-button @click="handleClose()" :disabled="loading">
{{ $t('commons.button.cancel') }}
</el-button>
<el-button type="primary" @click="submit(initForm)" :disabled="loading">
<el-button type="primary" @click="openSubmit(initForm)" :disabled="loading">
{{ $t('commons.button.confirm') }}
</el-button>
</span>
</template>
<ConfirmDialog ref="confirmDialogRef" @confirm="submit(initForm)"></ConfirmDialog>
</el-drawer>
</template>
@ -53,7 +62,7 @@ const initModel = ref({
primaryConfig: '',
serviceName: '',
});
const confirmDialogRef = ref();
const em = defineEmits(['close']);
const acceptParams = (primaryConfig: string, serviceName: string) => {
@ -67,6 +76,19 @@ const handleClose = () => {
em('close', false);
};
const openSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
let params = {
header: i18n.global.t('commons.button.init'),
operationInfo: i18n.global.t('tool.supervisor.restartHelper'),
submitInputInfo: i18n.global.t('database.restartNow'),
};
confirmDialogRef.value!.acceptParams(params);
});
};
const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
await formEl.validate((valid) => {