mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-05 21:14:40 +08:00
feat: add restart button for php supervisor (#10127)
Refs https://github.com/1Panel-dev/1Panel/issues/10083
This commit is contained in:
parent
00b25b39c5
commit
aad79077bf
1 changed files with 56 additions and 2 deletions
|
@ -1,12 +1,19 @@
|
|||
<template>
|
||||
<DrawerPro v-model="open" :header="$t('tool.supervisor.list')" size="60%" @close="handleClose">
|
||||
<template #content>
|
||||
<ComplexTable :data="data" v-loading="loading">
|
||||
<ComplexTable :data="data" v-loading="loading" v-model:selects="selects">
|
||||
<template #toolbar>
|
||||
<el-button type="primary" @click="openCreate">
|
||||
{{ $t('commons.button.create') + $t('tool.supervisor.list') }}
|
||||
{{ $t('commons.button.create') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
@click="batchRestart"
|
||||
:disabled="!selects.length || selects.every((item) => item.name === 'php-fpm')"
|
||||
>
|
||||
{{ $t('commons.button.restart') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-table-column type="selection" width="55" :selectable="checkSelectable" />
|
||||
<el-table-column
|
||||
:label="$t('commons.table.name')"
|
||||
fix
|
||||
|
@ -137,6 +144,11 @@ const createRef = ref();
|
|||
const dataLoading = ref(false);
|
||||
const open = ref(false);
|
||||
const runtimeID = ref(0);
|
||||
const selects = ref<any>([]);
|
||||
|
||||
function checkSelectable(row) {
|
||||
return row.name != 'php-fpm';
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
open.value = false;
|
||||
|
@ -243,6 +255,48 @@ const operate = async (operation: string, name: string) => {
|
|||
} catch (error) {}
|
||||
};
|
||||
|
||||
const batchRestart = async () => {
|
||||
if (!selects.value.length) return;
|
||||
|
||||
const filteredSelects = selects.value.filter((item) => item.name !== 'php-fpm');
|
||||
if (!filteredSelects.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const names = filteredSelects.map((item) => item.name).join(', ');
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
i18n.global.t('tool.supervisor.operatorHelper', [names, i18n.global.t('commons.operate.restart')]),
|
||||
i18n.global.t('commons.button.restart'),
|
||||
{
|
||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
|
||||
loading.value = true;
|
||||
|
||||
const promises = filteredSelects.map((item) =>
|
||||
operateSupervisorProcess({
|
||||
operate: 'restart',
|
||||
name: item.name,
|
||||
id: runtimeID.value,
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
selects.value = [];
|
||||
search();
|
||||
} catch (error) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const getFile = (name: string, file: string, runtimeID: number) => {
|
||||
fileRef.value.acceptParams(name, file, 'get', runtimeID);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue