mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-25 22:36:23 +00:00
perf: 支持终断批量快捷命令执行的任务
This commit is contained in:
@@ -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'),
|
||||||
@@ -343,9 +357,6 @@ export default {
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
case 'end':
|
case 'end':
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
clearInterval(this.executionInfo.cancel)
|
|
||||||
this.toolbar.left.run.icon = 'fa fa-play'
|
|
||||||
this.toolbar.left.run.disabled = false
|
|
||||||
this.getTaskStatus()
|
this.getTaskStatus()
|
||||||
}, 500)
|
}, 500)
|
||||||
break
|
break
|
||||||
@@ -356,6 +367,7 @@ export default {
|
|||||||
getTaskStatus() {
|
getTaskStatus() {
|
||||||
getTaskDetail(this.currentTaskId).then(data => {
|
getTaskDetail(this.currentTaskId).then(data => {
|
||||||
this.executionInfo.status = data['status']
|
this.executionInfo.status = data['status']
|
||||||
|
this.setBtn()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
wrapperError(msg) {
|
wrapperError(msg) {
|
||||||
@@ -434,7 +446,26 @@ 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.setBtn()
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
stop() {
|
||||||
|
StopJob({ task_id: this.currentTaskId }).then(() => {
|
||||||
|
this.xterm.write(this.wrapperError('Task has been canceled'))
|
||||||
|
this.getTaskStatus()
|
||||||
|
}).catch((e) => {
|
||||||
|
console.log(e)
|
||||||
|
}).finally(() => {
|
||||||
|
this.setBtn()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setBtn() {
|
||||||
|
if (this.executionInfo.status !== 'running') {
|
||||||
|
clearInterval(this.executionInfo.cancel)
|
||||||
|
this.toolbar.left.run.icon = 'fa fa-play'
|
||||||
|
}
|
||||||
|
this.toolbar.left.run.disabled = this.executionInfo.status === 'running'
|
||||||
|
this.toolbar.left.stop.disabled = this.executionInfo.status !== 'running'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user