2018-02-28 02:58:25 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { collect } from '@ember/object/computed';
|
2018-03-20 20:51:42 +00:00
|
|
|
import { watchRecord, watchRelationship, watchAll } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2018-02-28 02:58:25 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class IndexRoute extends Route.extend(WithWatchers) {
|
2018-03-06 22:27:01 +00:00
|
|
|
startWatchers(controller, model) {
|
2018-03-20 18:35:31 +00:00
|
|
|
if (!model) {
|
|
|
|
return;
|
|
|
|
}
|
2018-02-28 02:58:25 +00:00
|
|
|
controller.set('watchers', {
|
2019-03-26 07:46:44 +00:00
|
|
|
model: this.watch.perform(model),
|
|
|
|
summary: this.watchSummary.perform(model.get('summary')),
|
|
|
|
allocations: this.watchAllocations.perform(model),
|
|
|
|
evaluations: this.watchEvaluations.perform(model),
|
2018-07-28 00:40:09 +00:00
|
|
|
latestDeployment:
|
2019-03-26 07:46:44 +00:00
|
|
|
model.get('supportsDeployments') && this.watchLatestDeployment.perform(model),
|
|
|
|
list: model.get('hasChildren') && this.watchAll.perform(),
|
2018-02-28 02:58:25 +00:00
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-28 02:58:25 +00:00
|
|
|
|
2020-09-19 00:59:54 +00:00
|
|
|
setupController(controller, model) {
|
|
|
|
// Parameterized and periodic detail pages, which list children jobs,
|
|
|
|
// should sort by submit time.
|
|
|
|
if (model && ['periodic', 'parameterized'].includes(model.templateType)) {
|
|
|
|
controller.setProperties({
|
|
|
|
sortProperty: 'submitTime',
|
|
|
|
sortDescending: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return super.setupController(...arguments);
|
|
|
|
}
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@watchRecord('job') watch;
|
|
|
|
@watchAll('job') watchAll;
|
|
|
|
@watchRecord('job-summary') watchSummary;
|
|
|
|
@watchRelationship('allocations') watchAllocations;
|
|
|
|
@watchRelationship('evaluations') watchEvaluations;
|
|
|
|
@watchRelationship('latestDeployment') watchLatestDeployment;
|
2018-02-28 02:58:25 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@collect(
|
2018-07-28 00:40:09 +00:00
|
|
|
'watch',
|
|
|
|
'watchAll',
|
|
|
|
'watchSummary',
|
2018-07-20 21:28:57 +00:00
|
|
|
'watchAllocations',
|
2018-07-28 00:40:09 +00:00
|
|
|
'watchEvaluations',
|
|
|
|
'watchLatestDeployment'
|
2020-06-10 13:49:16 +00:00
|
|
|
)
|
|
|
|
watchers;
|
|
|
|
}
|