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
|
|
|
|
2018-03-01 00:27:15 +00:00
|
|
|
export default 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', {
|
|
|
|
model: this.get('watch').perform(model),
|
2018-03-23 01:59:53 +00:00
|
|
|
summary: this.get('watchSummary').perform(model.get('summary')),
|
2018-07-20 21:28:57 +00:00
|
|
|
allocations: this.get('watchAllocations').perform(model),
|
2018-02-28 02:58:25 +00:00
|
|
|
evaluations: this.get('watchEvaluations').perform(model),
|
2018-07-28 00:40:09 +00:00
|
|
|
latestDeployment:
|
|
|
|
model.get('supportsDeployments') && this.get('watchLatestDeployment').perform(model),
|
2018-03-20 20:51:42 +00:00
|
|
|
list: model.get('hasChildren') && this.get('watchAll').perform(),
|
2018-02-28 02:58:25 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: watchRecord('job'),
|
2018-03-20 20:51:42 +00:00
|
|
|
watchAll: watchAll('job'),
|
2018-03-23 01:59:53 +00:00
|
|
|
watchSummary: watchRecord('job-summary'),
|
2018-07-20 21:28:57 +00:00
|
|
|
watchAllocations: watchRelationship('allocations'),
|
2018-02-28 02:58:25 +00:00
|
|
|
watchEvaluations: watchRelationship('evaluations'),
|
2018-07-28 00:40:09 +00:00
|
|
|
watchLatestDeployment: watchRelationship('latestDeployment'),
|
2018-02-28 02:58:25 +00:00
|
|
|
|
2018-07-28 00:40:09 +00:00
|
|
|
watchers: collect(
|
|
|
|
'watch',
|
|
|
|
'watchAll',
|
|
|
|
'watchSummary',
|
2018-07-20 21:28:57 +00:00
|
|
|
'watchAllocations',
|
2018-07-28 00:40:09 +00:00
|
|
|
'watchEvaluations',
|
|
|
|
'watchLatestDeployment'
|
|
|
|
),
|
2018-02-28 02:58:25 +00:00
|
|
|
});
|