github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/jobs/job/clients.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Route from '@ember/routing/route';
     3  import WithWatchers from 'nomad-ui/mixins/with-watchers';
     4  import {
     5    watchRecord,
     6    watchRelationship,
     7    watchAll,
     8  } from 'nomad-ui/utils/properties/watch';
     9  import { collect } from '@ember/object/computed';
    10  
    11  export default class ClientsRoute extends Route.extend(WithWatchers) {
    12    @service can;
    13    @service store;
    14  
    15    beforeModel() {
    16      if (this.can.cannot('read client')) {
    17        this.transitionTo('jobs.job');
    18      }
    19    }
    20  
    21    async model() {
    22      return this.modelFor('jobs.job');
    23    }
    24  
    25    startWatchers(controller, model) {
    26      if (!model) {
    27        return;
    28      }
    29  
    30      controller.set('watchers', {
    31        model: this.watch.perform(model),
    32        allocations: this.watchAllocations.perform(model),
    33        nodes: this.watchNodes.perform(),
    34      });
    35    }
    36  
    37    @watchRecord('job') watch;
    38    @watchAll('node') watchNodes;
    39    @watchRelationship('allocations') watchAllocations;
    40  
    41    @collect('watch', 'watchNodes', 'watchAllocations')
    42    watchers;
    43  }