github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/ui/app/routes/jobs/job/task-group.js (about)

     1  import Route from '@ember/routing/route';
     2  import { collect } from '@ember/object/computed';
     3  import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch';
     4  import WithWatchers from 'nomad-ui/mixins/with-watchers';
     5  
     6  export default Route.extend(WithWatchers, {
     7    model({ name }) {
     8      // If the job is a partial (from the list request) it won't have task
     9      // groups. Reload the job to ensure task groups are present.
    10      return this.modelFor('jobs.job')
    11        .reload()
    12        .then(job => {
    13          return job
    14            .hasMany('allocations')
    15            .reload()
    16            .then(() => {
    17              return job.get('taskGroups').findBy('name', name);
    18            });
    19        });
    20    },
    21  
    22    startWatchers(controller, model) {
    23      const job = model.get('job');
    24      controller.set('watchers', {
    25        job: this.get('watchJob').perform(job),
    26        summary: this.get('watchSummary').perform(job),
    27        allocations: this.get('watchAllocations').perform(job),
    28      });
    29    },
    30  
    31    watchJob: watchRecord('job'),
    32    watchSummary: watchRelationship('summary'),
    33    watchAllocations: watchRelationship('allocations'),
    34  
    35    watchers: collect('watchJob', 'watchSummary', 'watchAllocations'),
    36  });