github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/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    afterModel(model) {
    16      if (model && model.get('isPartial')) {
    17        return model.reload().then(node => node.get('allocations'));
    18      }
    19      return model && model.get('allocations');
    20    },
    21  
    22    startWatchers(controller, model) {
    23      controller.set('watchModel', this.get('watch').perform(model));
    24      controller.set('watchAllocations', this.get('watchAllocations').perform(model));
    25    },
    26  
    27    watch: watchRecord('node'),
    28    watchAllocations: watchRelationship('allocations'),
    29  
    30    watchers: collect('watch', 'watchAllocations'),
    31  });