perf: 终断批量快捷命令执行的任务

This commit is contained in:
wangruidong
2024-02-19 14:47:37 +08:00
committed by Bryan
parent dced020a20
commit ed4f8dea90
5 changed files with 48 additions and 8 deletions

View File

@@ -53,6 +53,14 @@ export function createJob(form) {
}) })
} }
export function StopJob(form) {
return request({
url: '/api/v1/ops/job-executions/stop/',
method: 'post',
data: form
})
}
export function JobUploadFile(form) { export function JobUploadFile(form) {
return request({ return request({
url: '/api/v1/ops/jobs/upload/', url: '/api/v1/ops/jobs/upload/',
@@ -62,3 +70,4 @@ export function JobUploadFile(form) {
data: form data: form
}) })
} }

View File

@@ -1198,7 +1198,8 @@
"FileSizeExceedsLimit": "File size exceeds limit", "FileSizeExceedsLimit": "File size exceeds limit",
"runSucceed": "Task executed successfully", "runSucceed": "Task executed successfully",
"EnterUploadPath": "Enter the upload path", "EnterUploadPath": "Enter the upload path",
"FileNameTooLong": "File name too long" "FileNameTooLong": "File name too long",
"StopJob": "Stop job"
}, },
"perms": { "perms": {
"": "", "": "",

View File

@@ -1196,7 +1196,8 @@
"FileSizeExceedsLimit": "ファイルサイズが制限を超えています", "FileSizeExceedsLimit": "ファイルサイズが制限を超えています",
"runSucceed": "タスクが成功しました", "runSucceed": "タスクが成功しました",
"EnterUploadPath": "アップロードパスを入力してください", "EnterUploadPath": "アップロードパスを入力してください",
"FileNameTooLong": "ファイル名が長すぎます" "FileNameTooLong": "ファイル名が長すぎます",
"StopJob": "ジョブを停止"
}, },
"perms": { "perms": {
"": "", "": "",

View File

@@ -1187,7 +1187,8 @@
"FileSizeExceedsLimit": "文件大小超出限制", "FileSizeExceedsLimit": "文件大小超出限制",
"runSucceed": "任务执行成功", "runSucceed": "任务执行成功",
"EnterUploadPath": "输入上传路径", "EnterUploadPath": "输入上传路径",
"FileNameTooLong": "文件名太长" "FileNameTooLong": "文件名太长",
"StopJob": "停止作业"
}, },
"perms": { "perms": {
"": "", "": "",

View File

@@ -57,7 +57,7 @@ import Page from '@/layout/components/Page'
import AdhocOpenDialog from '@/views/ops/Job/AdhocOpenDialog' import AdhocOpenDialog from '@/views/ops/Job/AdhocOpenDialog'
import AdhocSaveDialog from '@/views/ops/Job/AdhocSaveDialog' import AdhocSaveDialog from '@/views/ops/Job/AdhocSaveDialog'
import VariableHelpDialog from '@/views/ops/Job/VariableHelpDialog' import VariableHelpDialog from '@/views/ops/Job/VariableHelpDialog'
import { createJob, getJob, getTaskDetail } from '@/api/ops' import { createJob, StopJob, getJob, getTaskDetail } from '@/api/ops'
export default { export default {
name: 'CommandExecution', name: 'CommandExecution',
@@ -110,6 +110,20 @@ export default {
this.execute() this.execute()
} }
}, },
stop: {
type: 'button',
name: this.$t('common.Stop'),
align: 'left',
icon: 'fa fa-stop',
tip: this.$t('ops.StopJob'),
disabled: true,
el: {
type: 'danger'
},
callback: () => {
this.stop()
}
},
runas: { runas: {
type: 'input', type: 'input',
name: this.$t('ops.runAs'), name: this.$t('ops.runAs'),
@@ -305,9 +319,8 @@ export default {
this.toolbar.left.runasPolicy.callback(res.runas_policy.value) this.toolbar.left.runasPolicy.callback(res.runas_policy.value)
this.toolbar.left.language.value = res.module.value this.toolbar.left.language.value = res.module.value
this.toolbar.left.language.callback(res.module.value) this.toolbar.left.language.callback(res.module.value)
this.toolbar.left.timeout.value = res.timeout this.toolbar.fold.timeout.value = res.timeout
this.toolbar.left.timeout.callback(res.timeout) this.toolbar.fold.timeout.callback(res.timeout)
this.command = res.args this.command = res.args
this.executionInfo.status = data['status'] this.executionInfo.status = data['status']
this.executionInfo.timeCost = data['time_cost'] this.executionInfo.timeCost = data['time_cost']
@@ -348,6 +361,7 @@ export default {
this.toolbar.left.run.icon = 'fa fa-play' this.toolbar.left.run.icon = 'fa fa-play'
this.toolbar.left.run.disabled = false this.toolbar.left.run.disabled = false
this.getTaskStatus() this.getTaskStatus()
this.setStopBtn()
}, 500) }, 500)
break break
} }
@@ -435,7 +449,18 @@ export default {
this.$router.replace({ query: { taskId: this.currentTaskId }}) this.$router.replace({ query: { taskId: this.currentTaskId }})
this.setCostTimeInterval() this.setCostTimeInterval()
this.writeExecutionOutput() this.writeExecutionOutput()
this.setStopBtn()
}) })
},
stop() {
StopJob({ task_id: this.currentTaskId }).then(() => {
this.xterm.write(this.wrapperError('Task has been canceled'))
this.getTaskStatus()
this.setStopBtn()
})
},
setStopBtn() {
this.toolbar.left.stop.disabled = this.executionInfo.status !== 'running'
} }
} }
} }
@@ -447,14 +472,17 @@ export default {
background-color: rgb(247, 247, 247); background-color: rgb(247, 247, 247);
height: calc(100vh - 549px); height: calc(100vh - 549px);
overflow: hidden; overflow: hidden;
& > div { & > div {
height: 100%; height: 100%;
&>>> .xterm {
& > > > .xterm {
height: calc(100% - 8px); height: calc(100% - 8px);
overflow-y: auto; overflow-y: auto;
} }
} }
} }
.mini-button { .mini-button {
width: 12px; width: 12px;
float: right; float: right;