diff --git a/web/src/views/task/CronView.vue b/web/src/views/task/CronView.vue index 1aef8f02..8f904c6b 100644 --- a/web/src/views/task/CronView.vue +++ b/web/src/views/task/CronView.vue @@ -5,12 +5,16 @@ import { useGettext } from 'vue3-gettext' import cron from '@/api/panel/cron' import file from '@/api/panel/file' import CronPreview from '@/components/common/CronPreview.vue' +import PtyTerminalModal from '@/components/common/PtyTerminalModal.vue' import { decodeBase64, formatDateTime } from '@/utils' const { $gettext } = useGettext() const logPath = ref('') const logModal = ref(false) const editModal = ref(false) +const runModal = ref(false) +const runCommand = ref('') +const runTaskName = ref('') const editTask = ref({ id: 0, @@ -97,16 +101,29 @@ const columns: any = [ { title: $gettext('Actions'), key: 'actions', - width: 280, + width: 350, hideInExcel: true, render(row: any) { return [ + h( + NButton, + { + size: 'small', + type: 'success', + secondary: true, + onClick: () => handleRun(row) + }, + { + default: () => $gettext('Run') + } + ), h( NButton, { size: 'small', type: 'warning', secondary: true, + style: 'margin-left: 15px;', onClick: () => { logPath.value = row.log logModal.value = true @@ -174,6 +191,14 @@ const handleStatusChange = (row: any) => { }) } +const handleRun = (row: any) => { + useRequest(cron.get(row.id)).onSuccess(({ data }) => { + runTaskName.value = row.name + runCommand.value = `bash '${data.shell}'` + runModal.value = true + }) +} + const handleEdit = (row: any) => { useRequest(cron.get(row.id)).onSuccess(({ data }) => { useRequest(file.content(encodeURIComponent(data.shell))).onSuccess(({ data }) => { @@ -219,7 +244,7 @@ onUnmounted(() => { { {{ $gettext('Save') }} +