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: "任务取消成功"
|
||||||
});
|
});
|
||||||
|
|
|
@ -81,11 +81,11 @@
|
||||||
<fs-icon v-if="editMode" class="add-stage-btn" title="添加新阶段" icon="ion:add-circle" @click="stageAdd(index)"></fs-icon>
|
<fs-icon v-if="editMode" class="add-stage-btn" title="添加新阶段" icon="ion:add-circle" @click="stageAdd(index)"></fs-icon>
|
||||||
</div>
|
</div>
|
||||||
<div class="task">
|
<div class="task">
|
||||||
<a-button shape="round" @click="taskEdit(stage, index, task, taskIndex)">
|
<a-button shape="round" @click="taskEdit(stage, index, task, taskIndex)">
|
||||||
{{ 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>
|
||||||
|
@ -373,7 +379,7 @@ export default defineComponent({
|
||||||
|
|
||||||
const taskView = useTaskView();
|
const taskView = useTaskView();
|
||||||
|
|
||||||
const taskAdd = (stage: any, stageIndex: number, onSuccess?: any,taskDef?:any) => {
|
const taskAdd = (stage: any, stageIndex: number, onSuccess?: any, taskDef?: any) => {
|
||||||
currentStageIndex.value = stageIndex;
|
currentStageIndex.value = stageIndex;
|
||||||
currentTaskIndex.value = stage.tasks.length;
|
currentTaskIndex.value = stage.tasks.length;
|
||||||
taskFormRef.value.taskAdd((type: any, value: any) => {
|
taskFormRef.value.taskAdd((type: any, value: any) => {
|
||||||
|
@ -383,17 +389,17 @@ export default defineComponent({
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},taskDef);
|
}, taskDef);
|
||||||
};
|
};
|
||||||
|
|
||||||
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) => {
|
||||||
|
@ -423,7 +429,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return { taskAdd, taskEdit, taskCopy,taskFormRef, ...taskView };
|
return { taskAdd, taskEdit, taskCopy, taskFormRef, ...taskView };
|
||||||
}
|
}
|
||||||
|
|
||||||
function useStage(useTaskRet: any) {
|
function useStage(useTaskRet: any) {
|
||||||
|
@ -760,10 +766,10 @@ export default defineComponent({
|
||||||
height: 100%;
|
height: 100%;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
.copy{
|
.copy {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right:60px;
|
right: 60px;
|
||||||
top:18px;
|
top: 18px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #1890ff;
|
color: #1890ff;
|
||||||
|
|
|
@ -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