github.com/thomasobenaus/nomad@v0.11.1/ui/app/routes/exec.js (about) 1 import { inject as service } from '@ember/service'; 2 import Route from '@ember/routing/route'; 3 import notifyError from 'nomad-ui/utils/notify-error'; 4 import { collect } from '@ember/object/computed'; 5 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 6 import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch'; 7 8 export default Route.extend(WithWatchers, { 9 store: service(), 10 token: service(), 11 12 serialize(model) { 13 return { job_name: model.get('plainId') }; 14 }, 15 16 model(params, transition) { 17 const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id'); 18 const name = params.job_name; 19 const fullId = JSON.stringify([name, namespace || 'default']); 20 return this.store 21 .findRecord('job', fullId) 22 .then(job => { 23 return job.get('allocations').then(() => job); 24 }) 25 .catch(notifyError(this)); 26 }, 27 28 startWatchers(controller, model) { 29 if (model) { 30 controller.set('watcher', this.watch.perform(model)); 31 controller.set('watchAllocations', this.watchAllocations.perform(model)); 32 } 33 }, 34 35 watch: watchRecord('job'), 36 watchAllocations: watchRelationship('allocations'), 37 38 watchers: collect('watch', 'watchAllocations'), 39 });