From c351e68bed679f3ca205b642ccc694fff8962c3c Mon Sep 17 00:00:00 2001 From: Jai Bhagat Date: Sat, 20 Nov 2021 10:30:48 -0500 Subject: [PATCH] feat: add taskgroup filter to alloc --- ui/app/controllers/jobs/job/allocations.js | 25 ++++++++++++++++++++-- ui/app/templates/jobs/job/allocations.hbs | 7 ++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ui/app/controllers/jobs/job/allocations.js b/ui/app/controllers/jobs/job/allocations.js index 8aa14e1e7..15ba86319 100644 --- a/ui/app/controllers/jobs/job/allocations.js +++ b/ui/app/controllers/jobs/job/allocations.js @@ -35,10 +35,14 @@ export default class AllocationsController extends Controller.extend( { qpClient: 'client', }, + { + qpTaskGroup: 'taskGroup', + }, ]; qpStatus = ''; qpClient = ''; + qpTaskGroup = ''; currentPage = 1; pageSize = 25; @@ -52,10 +56,10 @@ export default class AllocationsController extends Controller.extend( return ['shortId', 'name', 'taskGroupName']; } - @computed('model.allocations.[]', 'selectionStatus', 'selectionClient') + @computed('model.allocations.[]', 'selectionStatus', 'selectionClient', 'selectionTaskGroup') get allocations() { const allocations = this.get('model.allocations') || []; - const { selectionStatus, selectionClient } = this; + const { selectionStatus, selectionClient, selectionTaskGroup } = this; if (!allocations.length) return allocations; @@ -66,6 +70,9 @@ export default class AllocationsController extends Controller.extend( if (selectionClient.length && !selectionClient.includes(alloc.get('node.shortId'))) { return false; } + if (selectionTaskGroup.length && !selectionTaskGroup.includes(alloc.taskGroupName)) { + return false; + } return true; }); @@ -73,6 +80,7 @@ export default class AllocationsController extends Controller.extend( @selection('qpStatus') selectionStatus; @selection('qpClient') selectionClient; + @selection('qpTaskGroup') selectionTaskGroup; @alias('allocations') listToSort; @alias('listSorted') listToSearch; @@ -107,6 +115,19 @@ export default class AllocationsController extends Controller.extend( return clients.sort().map(dc => ({ key: dc, label: dc })); } + @computed('model.allocations.[]', 'selectionTaskGroup') + get optionsTaskGroups() { + const taskGroups = Array.from(new Set(this.model.allocations.mapBy('taskGroupName'))).compact(); + + // Update query param when the list of clients changes. + scheduleOnce('actions', () => { + // eslint-disable-next-line ember/no-side-effects + this.set('qpTaskGroup', serialize(intersection(taskGroups, this.selectionTaskGroup))); + }); + + return taskGroups.sort().map(dc => ({ key: dc, label: dc })); + } + setFacetQueryParam(queryParam, selection) { this.set(queryParam, serialize(selection)); } diff --git a/ui/app/templates/jobs/job/allocations.hbs b/ui/app/templates/jobs/job/allocations.hbs index 320575a51..2e164ad89 100644 --- a/ui/app/templates/jobs/job/allocations.hbs +++ b/ui/app/templates/jobs/job/allocations.hbs @@ -27,6 +27,13 @@ @selection={{this.selectionClient}} @onSelect={{action this.setFacetQueryParam "qpClient"}} /> +