From fe9f35c587aae6f753ea51db1fe0b67dfb367cf7 Mon Sep 17 00:00:00 2001 From: Jai Bhagat Date: Tue, 11 Jan 2022 13:00:01 -0500 Subject: [PATCH] feat: add clicking functionality to alloc status legend --- ui/app/components/allocation-status-bar.js | 45 ++++++++++-- .../components/job-page/parts/summary.hbs | 69 ++++++++++++++----- 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/ui/app/components/allocation-status-bar.js b/ui/app/components/allocation-status-bar.js index 803884b6d..dc65be516 100644 --- a/ui/app/components/allocation-status-bar.js +++ b/ui/app/components/allocation-status-bar.js @@ -5,11 +5,24 @@ export default class AllocationStatusBar extends DistributionBar { layoutName = 'components/distribution-bar'; allocationContainer = null; + job = null; 'data-test-allocation-status-bar' = true; + generateLegendLink(job, status) { + if (!job || status === 'queued') return null; + + return { + queryParams: { + status: JSON.stringify([status]), + namespace: job.belongsTo('namespace').id(), + }, + }; + } + @computed( - 'allocationContainer.{queuedAllocs,completeAllocs,failedAllocs,runningAllocs,startingAllocs}' + 'allocationContainer.{queuedAllocs,completeAllocs,failedAllocs,runningAllocs,startingAllocs}', + 'job.namespace' ) get data() { if (!this.allocationContainer) { @@ -25,21 +38,43 @@ export default class AllocationStatusBar extends DistributionBar { 'lostAllocs' ); return [ - { label: 'Queued', value: allocs.queuedAllocs, className: 'queued' }, + { + label: 'Queued', + value: allocs.queuedAllocs, + className: 'queued', + legendLink: this.generateLegendLink(this.job, 'queued'), + }, { label: 'Starting', value: allocs.startingAllocs, className: 'starting', layers: 2, + legendLink: this.generateLegendLink(this.job, 'starting'), + }, + { + label: 'Running', + value: allocs.runningAllocs, + className: 'running', + legendLink: this.generateLegendLink(this.job, 'running'), }, - { label: 'Running', value: allocs.runningAllocs, className: 'running' }, { label: 'Complete', value: allocs.completeAllocs, className: 'complete', + legendLink: this.generateLegendLink(this.job, 'complete'), + }, + { + label: 'Failed', + value: allocs.failedAllocs, + className: 'failed', + legendLink: this.generateLegendLink(this.job, 'failed'), + }, + { + label: 'Lost', + value: allocs.lostAllocs, + className: 'lost', + legendLink: this.generateLegendLink(this.job, 'lost'), }, - { label: 'Failed', value: allocs.failedAllocs, className: 'failed' }, - { label: 'Lost', value: allocs.lostAllocs, className: 'lost' }, ]; } } diff --git a/ui/app/templates/components/job-page/parts/summary.hbs b/ui/app/templates/components/job-page/parts/summary.hbs index 9b4ed8509..92022e915 100644 --- a/ui/app/templates/components/job-page/parts/summary.hbs +++ b/ui/app/templates/components/job-page/parts/summary.hbs @@ -40,26 +40,57 @@ - {{#component - (if a.item.hasChildren "children-status-bar" "allocation-status-bar") - allocationContainer=a.item.summary - job=a.item.summary - onSliceClick=this.onSliceClick - class="split-view" as |chart| - }} -
    - {{#each chart.data as |datum index|}} -
  1. +
      + {{#each chart.data as |datum index|}} +
    1. - -
    2. - {{/each}} -
    - {{/component}} + {{if (eq datum.value 0) "is-empty"}}" + > + +
  2. + {{/each}} +
+ + {{else}} + +
    + {{#each chart.data as |datum index|}} +
  1. + {{#if (and (gt datum.value 0) datum.legendLink)}} + + + + {{else}} + + {{/if}} +
  2. + {{/each}} +
+
+ {{/if}}
\ No newline at end of file