github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/models/task-group.js (about) 1 import { computed } from '@ember/object'; 2 import Fragment from 'ember-data-model-fragments/fragment'; 3 import attr from 'ember-data/attr'; 4 import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes'; 5 import sumAggregation from '../utils/properties/sum-aggregation'; 6 7 const maybe = arr => arr || []; 8 9 export default Fragment.extend({ 10 job: fragmentOwner(), 11 12 name: attr('string'), 13 count: attr('number'), 14 15 tasks: fragmentArray('task'), 16 17 services: fragmentArray('service'), 18 19 volumes: fragmentArray('volume-definition'), 20 21 drivers: computed('tasks.@each.driver', function() { 22 return this.tasks.mapBy('driver').uniq(); 23 }), 24 25 allocations: computed('job.allocations.@each.taskGroup', function() { 26 return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.name); 27 }), 28 29 reservedCPU: sumAggregation('tasks', 'reservedCPU'), 30 reservedMemory: sumAggregation('tasks', 'reservedMemory'), 31 reservedDisk: sumAggregation('tasks', 'reservedDisk'), 32 33 reservedEphemeralDisk: attr('number'), 34 35 placementFailures: computed('job.latestFailureEvaluation.failedTGAllocs.[]', function() { 36 const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs'); 37 return placementFailures && placementFailures.findBy('name', this.name); 38 }), 39 40 queuedOrStartingAllocs: computed('summary.{queuedAllocs,startingAllocs}', function() { 41 return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs'); 42 }), 43 44 summary: computed('job.taskGroupSummaries.[]', function() { 45 return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.name); 46 }), 47 });