2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import RSVP from 'rsvp';
|
2017-10-24 23:07:43 +00:00
|
|
|
import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
|
|
|
|
import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
|
2018-02-16 19:02:43 +00:00
|
|
|
import { watchAll } from 'nomad-ui/utils/properties/watch';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-10-24 23:07:43 +00:00
|
|
|
export default Route.extend(WithForbiddenState, {
|
2017-12-15 21:39:18 +00:00
|
|
|
store: service(),
|
|
|
|
system: service(),
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
beforeModel() {
|
|
|
|
return this.get('system.leader');
|
|
|
|
},
|
|
|
|
|
|
|
|
model() {
|
|
|
|
return RSVP.hash({
|
|
|
|
nodes: this.get('store').findAll('node'),
|
|
|
|
agents: this.get('store').findAll('agent'),
|
2017-10-24 23:07:43 +00:00
|
|
|
}).catch(notifyForbidden(this));
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
2018-02-16 19:02:43 +00:00
|
|
|
|
|
|
|
setupController(controller) {
|
|
|
|
controller.set('modelWatch', this.get('watch').perform());
|
|
|
|
return this._super(...arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
this.get('watch').cancelAll();
|
|
|
|
this._super(...arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: watchAll('node'),
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|