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