github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/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 setupController(controller, model) { 33 controller.set('flagAsDraining', model && model.isDraining); 34 35 return this._super(...arguments); 36 }, 37 38 resetController(controller) { 39 controller.setProperties({ 40 eligibilityError: null, 41 stopDrainError: null, 42 drainError: null, 43 flagAsDraining: false, 44 showDrainNotification: false, 45 showDrainUpdateNotification: false, 46 showDrainStoppedNotification: false, 47 }); 48 }, 49 50 startWatchers(controller, model) { 51 if (model) { 52 controller.set('watchModel', this.watch.perform(model)); 53 controller.set('watchAllocations', this.watchAllocations.perform(model)); 54 } 55 }, 56 57 watch: watchRecord('node'), 58 watchAllocations: watchRelationship('allocations'), 59 60 watchers: collect('watch', 'watchAllocations'), 61 });