2022-12-14 01:04:10 -08:00
|
|
|
import { IExecutionsSummary } from '@/Interface';
|
|
|
|
import { useWorkflowsStore } from '@/stores/workflows';
|
|
|
|
import dateFormat from 'dateformat';
|
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import { genericHelpers } from './genericHelpers';
|
2022-10-26 01:02:56 -07:00
|
|
|
|
|
|
|
export interface IExecutionUIData {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
startTime: string;
|
|
|
|
runningTime: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const executionHelpers = mixins(genericHelpers).extend({
|
|
|
|
computed: {
|
2022-12-14 01:04:10 -08:00
|
|
|
...mapStores(useWorkflowsStore),
|
2022-10-26 01:02:56 -07:00
|
|
|
executionId(): string {
|
|
|
|
return this.$route.params.executionId;
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
workflowName(): string {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.workflowsStore.workflowName;
|
2022-10-26 01:02:56 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
currentWorkflow(): string {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.$route.params.name || this.workflowsStore.workflowId;
|
2022-10-26 01:02:56 -07:00
|
|
|
},
|
|
|
|
executions(): IExecutionsSummary[] {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.workflowsStore.currentWorkflowExecutions;
|
2022-10-26 01:02:56 -07:00
|
|
|
},
|
2022-11-04 06:04:31 -07:00
|
|
|
activeExecution(): IExecutionsSummary | null {
|
|
|
|
return this.workflowsStore.activeWorkflowExecution;
|
2022-10-26 01:02:56 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getExecutionUIDetails(execution: IExecutionsSummary): IExecutionUIData {
|
|
|
|
const status = {
|
|
|
|
name: 'unknown',
|
|
|
|
startTime: this.formatDate(new Date(execution.startedAt)),
|
|
|
|
label: 'Status unknown',
|
|
|
|
runningTime: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
if (execution.waitTill) {
|
|
|
|
status.name = 'waiting';
|
|
|
|
status.label = this.$locale.baseText('executionsList.waiting');
|
|
|
|
} else if (execution.stoppedAt === undefined) {
|
|
|
|
status.name = 'running';
|
|
|
|
status.label = this.$locale.baseText('executionsList.running');
|
2022-12-14 01:04:10 -08:00
|
|
|
status.runningTime = this.displayTimer(
|
|
|
|
new Date().getTime() - new Date(execution.startedAt).getTime(),
|
|
|
|
true,
|
|
|
|
);
|
2022-10-26 01:02:56 -07:00
|
|
|
} else if (execution.finished) {
|
|
|
|
status.name = 'success';
|
|
|
|
status.label = this.$locale.baseText('executionsList.succeeded');
|
|
|
|
if (execution.stoppedAt) {
|
2022-12-14 01:04:10 -08:00
|
|
|
status.runningTime = this.displayTimer(
|
|
|
|
new Date(execution.stoppedAt).getTime() - new Date(execution.startedAt).getTime(),
|
|
|
|
true,
|
|
|
|
);
|
2022-10-26 01:02:56 -07:00
|
|
|
}
|
|
|
|
} else if (execution.stoppedAt !== null) {
|
|
|
|
status.name = 'error';
|
|
|
|
status.label = this.$locale.baseText('executionsList.error');
|
|
|
|
if (execution.stoppedAt) {
|
2022-12-14 01:04:10 -08:00
|
|
|
status.runningTime = this.displayTimer(
|
|
|
|
new Date(execution.stoppedAt).getTime() - new Date(execution.startedAt).getTime(),
|
|
|
|
true,
|
|
|
|
);
|
2022-10-26 01:02:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
},
|
|
|
|
formatDate(date: Date) {
|
|
|
|
if (date.getFullYear() === new Date().getFullYear()) {
|
|
|
|
return dateFormat(date.getTime(), 'HH:MM:ss "on" d mmm');
|
|
|
|
}
|
|
|
|
return dateFormat(date.getTime(), 'HH:MM:ss "on" d mmm yyyy');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|