github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/routes/jobs/job/index.js (about) 1 import Route from '@ember/routing/route'; 2 import { collect } from '@ember/object/computed'; 3 import { watchRecord, watchRelationship, watchAll } from 'nomad-ui/utils/properties/watch'; 4 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 5 6 export default class IndexRoute extends Route.extend(WithWatchers) { 7 startWatchers(controller, model) { 8 if (!model) { 9 return; 10 } 11 controller.set('watchers', { 12 model: this.watch.perform(model), 13 summary: this.watchSummary.perform(model.get('summary')), 14 allocations: this.watchAllocations.perform(model), 15 evaluations: this.watchEvaluations.perform(model), 16 latestDeployment: 17 model.get('supportsDeployments') && this.watchLatestDeployment.perform(model), 18 list: model.get('hasChildren') && this.watchAll.perform(), 19 }); 20 } 21 22 setupController(controller, model) { 23 // Parameterized and periodic detail pages, which list children jobs, 24 // should sort by submit time. 25 if (model && ['periodic', 'parameterized'].includes(model.templateType)) { 26 controller.setProperties({ 27 sortProperty: 'submitTime', 28 sortDescending: true, 29 }); 30 } 31 return super.setupController(...arguments); 32 } 33 34 @watchRecord('job') watch; 35 @watchAll('job') watchAll; 36 @watchRecord('job-summary') watchSummary; 37 @watchRelationship('allocations') watchAllocations; 38 @watchRelationship('evaluations') watchEvaluations; 39 @watchRelationship('latestDeployment') watchLatestDeployment; 40 41 @collect( 42 'watch', 43 'watchAll', 44 'watchSummary', 45 'watchAllocations', 46 'watchEvaluations', 47 'watchLatestDeployment' 48 ) 49 watchers; 50 }