github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/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      controller.set('watchModel', this.get('watch').perform(model));
    34      controller.set('watchAllocations', this.get('watchAllocations').perform(model));
    35    },
    36  
    37    watch: watchRecord('node'),
    38    watchAllocations: watchRelationship('allocations'),
    39  
    40    watchers: collect('watch', 'watchAllocations'),
    41  });