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-02-28 02:58:25 +00:00
|
|
|
evaluations: this.get('watchEvaluations').perform(model),
|
2018-03-20 18:35:31 +00:00
|
|
|
deployments: model.get('supportsDeployments') && this.get('watchDeployments').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-02-28 02:58:25 +00:00
|
|
|
watchEvaluations: watchRelationship('evaluations'),
|
|
|
|
watchDeployments: watchRelationship('deployments'),
|
|
|
|
|
2018-03-20 20:51:42 +00:00
|
|
|
watchers: collect('watch', 'watchAll', 'watchSummary', 'watchEvaluations', 'watchDeployments'),
|
2018-02-28 02:58:25 +00:00
|
|
|
});
|