github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/allocation-status-bar.js (about) 1 import { computed } from '@ember/object'; 2 import DistributionBar from './distribution-bar'; 3 import { attributeBindings } from '@ember-decorators/component'; 4 import classic from 'ember-classic-decorator'; 5 6 @classic 7 @attributeBindings('data-test-allocation-status-bar') 8 export default class AllocationStatusBar extends DistributionBar { 9 layoutName = 'components/distribution-bar'; 10 11 allocationContainer = null; 12 job = null; 13 14 'data-test-allocation-status-bar' = true; 15 16 generateLegendLink(job, status) { 17 if (!job || status === 'queued') return null; 18 19 return { 20 queryParams: { 21 status: JSON.stringify([status]), 22 namespace: job.belongsTo('namespace').id(), 23 }, 24 }; 25 } 26 27 @computed( 28 'allocationContainer.{queuedAllocs,completeAllocs,failedAllocs,runningAllocs,startingAllocs,lostAllocs,unknownAllocs}', 29 'job.namespace' 30 ) 31 get data() { 32 if (!this.allocationContainer) { 33 return []; 34 } 35 36 const allocs = this.allocationContainer.getProperties( 37 'queuedAllocs', 38 'completeAllocs', 39 'failedAllocs', 40 'runningAllocs', 41 'startingAllocs', 42 'lostAllocs', 43 'unknownAllocs' 44 ); 45 return [ 46 { 47 label: 'Queued', 48 value: allocs.queuedAllocs, 49 className: 'queued', 50 legendLink: this.generateLegendLink(this.job, 'queued'), 51 }, 52 { 53 label: 'Starting', 54 value: allocs.startingAllocs, 55 className: 'starting', 56 layers: 2, 57 legendLink: this.generateLegendLink(this.job, 'starting'), 58 }, 59 { 60 label: 'Running', 61 value: allocs.runningAllocs, 62 className: 'running', 63 legendLink: this.generateLegendLink(this.job, 'running'), 64 }, 65 { 66 label: 'Complete', 67 value: allocs.completeAllocs, 68 className: 'complete', 69 legendLink: this.generateLegendLink(this.job, 'complete'), 70 }, 71 { 72 label: 'Unknown', 73 value: allocs.unknownAllocs, 74 className: 'unknown', 75 legendLink: this.generateLegendLink(this.job, 'unknown'), 76 help: 'Allocation is unknown since its node is disconnected.', 77 }, 78 { 79 label: 'Failed', 80 value: allocs.failedAllocs, 81 className: 'failed', 82 legendLink: this.generateLegendLink(this.job, 'failed'), 83 }, 84 { 85 label: 'Lost', 86 value: allocs.lostAllocs, 87 className: 'lost', 88 legendLink: this.generateLegendLink(this.job, 'lost'), 89 }, 90 ]; 91 } 92 }