mirror of https://github.com/certd/certd
fix: 修复无法强制取消任务的bug
parent
9172440f79
commit
9cc01db1d5
|
@ -28,6 +28,9 @@ export default defineComponent({
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
historyId: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "icon"
|
default: "icon"
|
||||||
|
@ -59,7 +62,7 @@ export default defineComponent({
|
||||||
okText: "确认",
|
okText: "确认",
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
await api.Cancel(props.runnable.id);
|
await api.Cancel(props.historyId);
|
||||||
notification.success({
|
notification.success({
|
||||||
message: "任务取消成功"
|
message: "任务取消成功"
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
{{ task.title }}
|
{{ task.title }}
|
||||||
<pi-status-show :status="task.status?.result"></pi-status-show>
|
<pi-status-show :status="task.status?.result"></pi-status-show>
|
||||||
</a-button>
|
</a-button>
|
||||||
<fs-icon class="copy" v-if="editMode" title="复制" icon="ion:copy-outline" @click="taskCopy(stage, index, task)"></fs-icon>
|
<fs-icon v-if="editMode" class="copy" title="复制" icon="ion:copy-outline" @click="taskCopy(stage, index, task)"></fs-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="editMode" class="task-container is-add">
|
<div v-if="editMode" class="task-container is-add">
|
||||||
|
@ -99,7 +99,6 @@
|
||||||
并行任务
|
并行任务
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -188,7 +187,14 @@
|
||||||
<a-page-header title="运行历史" sub-title="点任务可查看日志" class="logs-block">
|
<a-page-header title="运行历史" sub-title="点任务可查看日志" class="logs-block">
|
||||||
<a-timeline class="mt-10">
|
<a-timeline class="mt-10">
|
||||||
<template v-for="item of histories" :key="item.id">
|
<template v-for="item of histories" :key="item.id">
|
||||||
<pi-history-timeline-item :runnable="item.pipeline" :is-current="currentHistory?.id === item.id" :edit-mode="editMode" @view="historyView(item)" @cancel="historyCancel()"></pi-history-timeline-item>
|
<pi-history-timeline-item
|
||||||
|
:runnable="item.pipeline"
|
||||||
|
:history-id="item.id"
|
||||||
|
:is-current="currentHistory?.id === item.id"
|
||||||
|
:edit-mode="editMode"
|
||||||
|
@view="historyView(item)"
|
||||||
|
@cancel="historyCancel()"
|
||||||
|
></pi-history-timeline-item>
|
||||||
</template>
|
</template>
|
||||||
<a-empty v-if="histories.length === 0"> </a-empty>
|
<a-empty v-if="histories.length === 0"> </a-empty>
|
||||||
</a-timeline>
|
</a-timeline>
|
||||||
|
@ -387,13 +393,13 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskCopy = (stage: any, stageIndex: number, task: any) => {
|
const taskCopy = (stage: any, stageIndex: number, task: any) => {
|
||||||
task = _.cloneDeep(task)
|
task = _.cloneDeep(task);
|
||||||
task.id = nanoid()
|
task.id = nanoid();
|
||||||
task.title= task.title+"_copy"
|
task.title = task.title + "_copy";
|
||||||
for (const step of task.steps) {
|
for (const step of task.steps) {
|
||||||
step.id = nanoid()
|
step.id = nanoid();
|
||||||
}
|
}
|
||||||
taskAdd(stage,stageIndex,null,task)
|
taskAdd(stage, stageIndex, null, task);
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskEdit = (stage: any, stageIndex: number, task: any, taskIndex: number, onSuccess?: any) => {
|
const taskEdit = (stage: any, stageIndex: number, task: any, taskIndex: number, onSuccess?: any) => {
|
||||||
|
|
|
@ -36,6 +36,13 @@ const StatusEnum: StatusEnumType = {
|
||||||
spin: true,
|
spin: true,
|
||||||
icon: "ant-design:sync-outlined"
|
icon: "ant-design:sync-outlined"
|
||||||
},
|
},
|
||||||
|
canceled: {
|
||||||
|
value: "canceled",
|
||||||
|
label: "已取消",
|
||||||
|
color: "yellow",
|
||||||
|
spin: true,
|
||||||
|
icon: "ant-design:minus-circle-twotone"
|
||||||
|
},
|
||||||
none: {
|
none: {
|
||||||
value: "none",
|
value: "none",
|
||||||
label: "未运行",
|
label: "未运行",
|
||||||
|
|
|
@ -236,14 +236,18 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancel(historyId: number) {
|
async cancel(historyId) {
|
||||||
const executor = runningTasks.get(historyId);
|
const executor = runningTasks.get(historyId);
|
||||||
if (executor) {
|
if (executor) {
|
||||||
await executor.cancel();
|
await executor.cancel();
|
||||||
} else {
|
} else {
|
||||||
const entity = await this.historyService.info(historyId);
|
const entity = await this.historyService.info(historyId);
|
||||||
|
if(entity == null){
|
||||||
|
return
|
||||||
|
}
|
||||||
const pipeline: Pipeline = JSON.parse(entity.pipeline);
|
const pipeline: Pipeline = JSON.parse(entity.pipeline);
|
||||||
pipeline.status.status = ResultType.canceled;
|
pipeline.status.status = ResultType.canceled;
|
||||||
|
pipeline.status.result = ResultType.canceled;
|
||||||
const runtime = new RunHistory(historyId, null, pipeline);
|
const runtime = new RunHistory(historyId, null, pipeline);
|
||||||
await this.saveHistory(runtime);
|
await this.saveHistory(runtime);
|
||||||
}
|
}
|
||||||
|
@ -291,6 +295,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||||
const entity: HistoryEntity = new HistoryEntity();
|
const entity: HistoryEntity = new HistoryEntity();
|
||||||
entity.id = parseInt(history.id);
|
entity.id = parseInt(history.id);
|
||||||
entity.userId = history.pipeline.userId;
|
entity.userId = history.pipeline.userId;
|
||||||
|
entity.status = pipelineEntity.status
|
||||||
entity.pipeline = JSON.stringify(history.pipeline);
|
entity.pipeline = JSON.stringify(history.pipeline);
|
||||||
entity.pipelineId = parseInt(history.pipeline.id);
|
entity.pipelineId = parseInt(history.pipeline.id);
|
||||||
await this.historyService.save(entity);
|
await this.historyService.save(entity);
|
||||||
|
|
Loading…
Reference in New Issue