github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/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 class AllocationRoute extends Route.extend(WithWatchers) { 10 startWatchers(controller, model) { 11 if (model) { 12 controller.set('watcher', this.watch.perform(model)); 13 } 14 } 15 16 // Allocation breadcrumbs extend from job / task group breadcrumbs 17 // even though the route structure does not. 18 breadcrumbs(model) { 19 const jobQueryParams = qpBuilder({ 20 jobNamespace: model.get('job.namespace.name') || 'default', 21 }); 22 23 return [ 24 { label: 'Jobs', args: ['jobs.index', jobQueryParams] }, 25 ...jobCrumbs(model.get('job')), 26 { 27 label: model.get('taskGroupName'), 28 args: [ 29 'jobs.job.task-group', 30 model.get('job.plainId'), 31 model.get('taskGroupName'), 32 jobQueryParams, 33 ], 34 }, 35 { 36 label: model.get('shortId'), 37 args: ['allocations.allocation', model], 38 }, 39 ]; 40 } 41 42 model() { 43 // Preload the job for the allocation since it's required for the breadcrumb trail 44 return super 45 .model(...arguments) 46 .then(allocation => allocation.get('job').then(() => allocation)) 47 .catch(notifyError(this)); 48 } 49 50 @watchRecord('allocation') watch; 51 52 @collect('watch') watchers; 53 }