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-option>
</el-select> </el-select>
</el-col> </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-col>
</el-row> </el-row>
</div> </div>
@ -169,6 +181,7 @@ export default mixins(
checkAll: false, checkAll: false,
filter: { filter: {
status: 'ALL',
workflowId: 'ALL', workflowId: 'ALL',
}, },
@ -180,6 +193,24 @@ export default mixins(
stoppingExecutions: [] as string[], stoppingExecutions: [] as string[],
workflows: [] as IWorkflowShortResponse[], 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[] { combinedExecutions (): IExecutionsSummary[] {
const returnData: IExecutionsSummary[] = []; const returnData: IExecutionsSummary[] = [];
if (['ALL', 'running'].includes(this.filter.status)) {
returnData.push.apply(returnData, this.activeExecutions); returnData.push.apply(returnData, this.activeExecutions);
}
if (['ALL', 'error', 'success'].includes(this.filter.status)) {
returnData.push.apply(returnData, this.finishedExecutions); returnData.push.apply(returnData, this.finishedExecutions);
}
return returnData; return returnData;
}, },
@ -215,13 +250,23 @@ export default mixins(
} }
return false; return false;
}, },
workflowFilter (): IDataObject { workflowFilterCurrent (): IDataObject {
const filter: IDataObject = {}; const filter: IDataObject = {};
if (this.filter.workflowId !== 'ALL') { if (this.filter.workflowId !== 'ALL') {
filter.workflowId = this.filter.workflowId; filter.workflowId = this.filter.workflowId;
} }
return filter; 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: { watch: {
dialogVisible (newValue, oldValue) { dialogVisible (newValue, oldValue) {
@ -272,7 +317,7 @@ export default mixins(
sendData.ids = Object.keys(this.selectedItems); sendData.ids = Object.keys(this.selectedItems);
} }
sendData.filters = this.workflowFilter; sendData.filters = this.workflowFilterPast;
try { try {
await this.restApi().deleteExecutions(sendData); await this.restApi().deleteExecutions(sendData);
@ -315,7 +360,7 @@ export default mixins(
return workflow.name; return workflow.name;
}, },
async loadActiveExecutions (): Promise<void> { 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) { for (const activeExecution of activeExecutions) {
if (activeExecution.workflowId !== undefined && activeExecution.workflowName === undefined) { if (activeExecution.workflowId !== undefined && activeExecution.workflowName === undefined) {
activeExecution.workflowName = this.getWorkflowName(activeExecution.workflowId); activeExecution.workflowName = this.getWorkflowName(activeExecution.workflowId);
@ -325,14 +370,23 @@ export default mixins(
this.$store.commit('setActiveExecutions', activeExecutions); this.$store.commit('setActiveExecutions', activeExecutions);
}, },
async loadFinishedExecutions (): Promise<void> { 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.finishedExecutions = data.results;
this.finishedExecutionsCount = data.count; this.finishedExecutionsCount = data.count;
}, },
async loadMore () { async loadMore () {
if (this.filter.status === 'running') {
return;
}
this.isDataLoading = true; this.isDataLoading = true;
const filter = this.workflowFilter; const filter = this.workflowFilterPast;
let lastId: string | number | undefined; let lastId: string | number | undefined;
if (this.finishedExecutions.length !== 0) { if (this.finishedExecutions.length !== 0) {
@ -370,7 +424,7 @@ export default mixins(
// @ts-ignore // @ts-ignore
workflows.unshift({ workflows.unshift({
id: 'ALL', id: 'ALL',
name: 'All', name: 'All Workflows',
}); });
Vue.set(this, 'workflows', workflows); Vue.set(this, 'workflows', workflows);