github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/routes/jobs/job/task-group.js (about) 1 import Route from '@ember/routing/route'; 2 import { collect } from '@ember/object/computed'; 3 import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch'; 4 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 5 import { qpBuilder } from 'nomad-ui/utils/classes/query-params'; 6 7 export default Route.extend(WithWatchers, { 8 breadcrumbs(model) { 9 if (!model) return []; 10 return [ 11 { 12 label: model.get('name'), 13 args: [ 14 'jobs.job.task-group', 15 model.get('name'), 16 qpBuilder({ jobNamespace: model.get('job.namespace.name') || 'default' }), 17 ], 18 }, 19 ]; 20 }, 21 22 model({ name }) { 23 // If the job is a partial (from the list request) it won't have task 24 // groups. Reload the job to ensure task groups are present. 25 return this.modelFor('jobs.job') 26 .reload() 27 .then(job => { 28 return job 29 .hasMany('allocations') 30 .reload() 31 .then(() => { 32 return job.get('taskGroups').findBy('name', name); 33 }); 34 }); 35 }, 36 37 startWatchers(controller, model) { 38 const job = model.get('job'); 39 controller.set('watchers', { 40 job: this.get('watchJob').perform(job), 41 summary: this.get('watchSummary').perform(job.get('summary')), 42 allocations: this.get('watchAllocations').perform(job), 43 }); 44 }, 45 46 watchJob: watchRecord('job'), 47 watchSummary: watchRecord('job-summary'), 48 watchAllocations: watchRelationship('allocations'), 49 50 watchers: collect('watchJob', 'watchSummary', 'watchAllocations'), 51 });