2017-09-19 14:47:10 +00:00
|
|
|
import Ember from 'ember';
|
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';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-10-20 05:04:21 +00:00
|
|
|
const { Route, inject, run } = Ember;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2017-10-24 23:07:43 +00:00
|
|
|
export default Route.extend(WithForbiddenState, {
|
2017-10-10 02:00:40 +00:00
|
|
|
system: inject.service(),
|
2017-09-19 14:47:10 +00:00
|
|
|
store: inject.service(),
|
|
|
|
|
2017-10-10 02:00:40 +00:00
|
|
|
beforeModel() {
|
|
|
|
return this.get('system.namespaces');
|
|
|
|
},
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
model() {
|
2017-10-24 23:07:43 +00:00
|
|
|
return this.get('store')
|
|
|
|
.findAll('job')
|
|
|
|
.catch(notifyForbidden(this));
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
2017-10-10 02:00:40 +00:00
|
|
|
|
2017-10-20 05:04:21 +00:00
|
|
|
syncToController(controller) {
|
|
|
|
const namespace = this.get('system.activeNamespace.id');
|
|
|
|
|
|
|
|
// The run next is necessary to let the controller figure
|
|
|
|
// itself out before updating QPs.
|
|
|
|
// See: https://github.com/emberjs/ember.js/issues/5465
|
|
|
|
run.next(() => {
|
|
|
|
if (namespace && namespace !== 'default') {
|
|
|
|
controller.set('jobNamespace', namespace);
|
|
|
|
} else {
|
|
|
|
controller.set('jobNamespace', 'default');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller) {
|
|
|
|
this.syncToController(controller);
|
|
|
|
return this._super(...arguments);
|
|
|
|
},
|
|
|
|
|
2017-10-10 02:00:40 +00:00
|
|
|
actions: {
|
|
|
|
refreshRoute() {
|
|
|
|
this.refresh();
|
|
|
|
},
|
|
|
|
},
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|