1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-11-10 12:35:46 +03:00

Add possibility to filter executions by status

This commit is contained in:
Jan Oberhauser 2019-12-12 17:39:56 -06:00
parent 870961b101
commit b389854046

View File

@ -16,7 +16,19 @@
</el-option>
</el-select>
</el-col>
<el-col :span="14">&nbsp;
<el-col :span="2">&nbsp;
</el-col>
<el-col :span="4">
<el-select v-model="filter.status" placeholder="Select Status" size="small" filterable @change="handleFilterChanged">
<el-option
v-for="item in statuses"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-col>
<el-col :span="8">&nbsp;
</el-col>
</el-row>
</div>
@ -169,6 +181,7 @@ export default mixins(
checkAll: false,
filter: {
status: 'ALL',
workflowId: 'ALL',
},
@ -180,6 +193,24 @@ export default mixins(
stoppingExecutions: [] as string[],
workflows: [] as IWorkflowShortResponse[],
statuses: [
{
id: 'ALL',
name: 'Any Status',
},
{
id: 'error',
name: 'Error',
},
{
id: 'running',
name: 'Running',
},
{
id: 'success',
name: 'Success',
},
],
};
},
@ -190,8 +221,12 @@ export default mixins(
combinedExecutions (): IExecutionsSummary[] {
const returnData: IExecutionsSummary[] = [];
returnData.push.apply(returnData, this.activeExecutions);
returnData.push.apply(returnData, this.finishedExecutions);
if (['ALL', 'running'].includes(this.filter.status)) {
returnData.push.apply(returnData, this.activeExecutions);
}
if (['ALL', 'error', 'success'].includes(this.filter.status)) {
returnData.push.apply(returnData, this.finishedExecutions);
}
return returnData;
},
@ -215,13 +250,23 @@ export default mixins(
}
return false;
},
workflowFilter (): IDataObject {
workflowFilterCurrent (): IDataObject {
const filter: IDataObject = {};
if (this.filter.workflowId !== 'ALL') {
filter.workflowId = this.filter.workflowId;
}
return filter;
},
workflowFilterPast (): IDataObject {
const filter: IDataObject = {};
if (this.filter.workflowId !== 'ALL') {
filter.workflowId = this.filter.workflowId;
}
if (['error', 'success'].includes(this.filter.status)) {
filter.finished = this.filter.status === 'success';
}
return filter;
},
},
watch: {
dialogVisible (newValue, oldValue) {
@ -272,7 +317,7 @@ export default mixins(
sendData.ids = Object.keys(this.selectedItems);
}
sendData.filters = this.workflowFilter;
sendData.filters = this.workflowFilterPast;
try {
await this.restApi().deleteExecutions(sendData);
@ -315,7 +360,7 @@ export default mixins(
return workflow.name;
},
async loadActiveExecutions (): Promise<void> {
const activeExecutions = await this.restApi().getCurrentExecutions(this.workflowFilter);
const activeExecutions = await this.restApi().getCurrentExecutions(this.workflowFilterCurrent);
for (const activeExecution of activeExecutions) {
if (activeExecution.workflowId !== undefined && activeExecution.workflowName === undefined) {
activeExecution.workflowName = this.getWorkflowName(activeExecution.workflowId);
@ -325,14 +370,23 @@ export default mixins(
this.$store.commit('setActiveExecutions', activeExecutions);
},
async loadFinishedExecutions (): Promise<void> {
const data = await this.restApi().getPastExecutions(this.workflowFilter, this.requestItemsPerRequest);
if (this.filter.status === 'running') {
this.finishedExecutions = [];
this.finishedExecutionsCount = 0;
return;
}
const data = await this.restApi().getPastExecutions(this.workflowFilterPast, this.requestItemsPerRequest);
this.finishedExecutions = data.results;
this.finishedExecutionsCount = data.count;
},
async loadMore () {
if (this.filter.status === 'running') {
return;
}
this.isDataLoading = true;
const filter = this.workflowFilter;
const filter = this.workflowFilterPast;
let lastId: string | number | undefined;
if (this.finishedExecutions.length !== 0) {
@ -370,7 +424,7 @@ export default mixins(
// @ts-ignore
workflows.unshift({
id: 'ALL',
name: 'All',
name: 'All Workflows',
});
Vue.set(this, 'workflows', workflows);