github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/jobs/job/index.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 { 5 watchRecord, 6 watchRelationship, 7 watchAll, 8 watchQuery, 9 } from 'nomad-ui/utils/properties/watch'; 10 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 11 12 export default class IndexRoute extends Route.extend(WithWatchers) { 13 @service can; 14 @service store; 15 16 async model() { 17 return this.modelFor('jobs.job'); 18 } 19 20 startWatchers(controller, model) { 21 if (!model) { 22 return; 23 } 24 controller.set('watchers', { 25 model: this.watch.perform(model), 26 summary: this.watchSummary.perform(model.get('summary')), 27 allocations: this.watchAllocations.perform(model), 28 evaluations: this.watchEvaluations.perform(model), 29 latestDeployment: 30 model.get('supportsDeployments') && 31 this.watchLatestDeployment.perform(model), 32 list: 33 model.get('hasChildren') && 34 this.watchAllJobs.perform({ 35 namespace: model.namespace.get('name'), 36 meta: true, 37 }), 38 nodes: 39 model.get('hasClientStatus') && 40 this.can.can('read client') && 41 this.watchNodes.perform(), 42 }); 43 } 44 45 setupController(controller, model) { 46 // Parameterized and periodic detail pages, which list children jobs, 47 // should sort by submit time. 48 if (model && ['periodic', 'parameterized'].includes(model.templateType)) { 49 controller.setProperties({ 50 sortProperty: 'submitTime', 51 sortDescending: true, 52 }); 53 } 54 return super.setupController(...arguments); 55 } 56 57 @watchRecord('job') watch; 58 @watchQuery('job') watchAllJobs; 59 @watchAll('node') watchNodes; 60 @watchRecord('job-summary') watchSummary; 61 @watchRelationship('allocations') watchAllocations; 62 @watchRelationship('evaluations') watchEvaluations; 63 @watchRelationship('latestDeployment') watchLatestDeployment; 64 65 @collect( 66 'watch', 67 'watchAllJobs', 68 'watchSummary', 69 'watchAllocations', 70 'watchEvaluations', 71 'watchLatestDeployment', 72 'watchNodes' 73 ) 74 watchers; 75 }