github.com/manicqin/nomad@v0.9.5/ui/app/routes/clients/client.js (about) 1 import { inject as service } from '@ember/service'; 2 import Route from '@ember/routing/route'; 3 import { collect } from '@ember/object/computed'; 4 import notifyError from 'nomad-ui/utils/notify-error'; 5 import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch'; 6 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 7 8 export default Route.extend(WithWatchers, { 9 store: service(), 10 11 model() { 12 return this._super(...arguments).catch(notifyError(this)); 13 }, 14 15 breadcrumbs(model) { 16 if (!model) return []; 17 return [ 18 { 19 label: model.get('shortId'), 20 args: ['clients.client', model.get('id')], 21 }, 22 ]; 23 }, 24 25 afterModel(model) { 26 if (model && model.get('isPartial')) { 27 return model.reload().then(node => node.get('allocations')); 28 } 29 return model && model.get('allocations'); 30 }, 31 32 startWatchers(controller, model) { 33 if (model) { 34 controller.set('watchModel', this.watch.perform(model)); 35 controller.set('watchAllocations', this.watchAllocations.perform(model)); 36 } 37 }, 38 39 watch: watchRecord('node'), 40 watchAllocations: watchRelationship('allocations'), 41 42 watchers: collect('watch', 'watchAllocations'), 43 });