github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/routes/allocations/allocation.js (about) 1 import Route from '@ember/routing/route'; 2 import { collect } from '@ember/object/computed'; 3 import { watchRecord } from 'nomad-ui/utils/properties/watch'; 4 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 5 import notifyError from 'nomad-ui/utils/notify-error'; 6 import { qpBuilder } from 'nomad-ui/utils/classes/query-params'; 7 import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils'; 8 9 export default Route.extend(WithWatchers, { 10 startWatchers(controller, model) { 11 controller.set('watcher', this.get('watch').perform(model)); 12 }, 13 14 // Allocation breadcrumbs extend from job / task group breadcrumbs 15 // even though the route structure does not. 16 breadcrumbs(model) { 17 return [ 18 { label: 'Jobs', args: ['jobs.index'] }, 19 ...jobCrumbs(model.get('job')), 20 { 21 label: model.get('taskGroupName'), 22 args: [ 23 'jobs.job.task-group', 24 model.get('job'), 25 model.get('taskGroupName'), 26 qpBuilder({ 27 jobNamespace: model.get('namespace.name') || 'default', 28 }), 29 ], 30 }, 31 { 32 label: model.get('shortId'), 33 args: ['allocations.allocation', model], 34 }, 35 ]; 36 }, 37 38 model() { 39 // Preload the job for the allocation since it's required for the breadcrumb trail 40 return this._super(...arguments) 41 .then(allocation => allocation.get('job').then(() => allocation)) 42 .catch(notifyError(this)); 43 }, 44 45 watch: watchRecord('allocation'), 46 47 watchers: collect('watch'), 48 });