github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/routes/jobs/job.js (about) 1 import { inject as service } from '@ember/service'; 2 import Route from '@ember/routing/route'; 3 import RSVP from 'rsvp'; 4 import notifyError from 'nomad-ui/utils/notify-error'; 5 import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils'; 6 import classic from 'ember-classic-decorator'; 7 8 @classic 9 export default class JobRoute extends Route { 10 @service can; 11 @service store; 12 @service token; 13 14 breadcrumbs = jobCrumbs; 15 16 serialize(model) { 17 return { job_name: model.get('plainId') }; 18 } 19 20 model(params, transition) { 21 const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id'); 22 const name = params.job_name; 23 const fullId = JSON.stringify([name, namespace || 'default']); 24 25 return this.store 26 .findRecord('job', fullId, { reload: true }) 27 .then(job => { 28 const relatedModelsQueries = [ 29 job.get('allocations'), 30 job.get('evaluations'), 31 ]; 32 33 if (this.can.can('accept recommendation')) { 34 relatedModelsQueries.push(job.get('recommendationSummaries')); 35 } 36 37 return RSVP.all(relatedModelsQueries).then(() => job); 38 }) 39 .catch(notifyError(this)); 40 } 41 }