open-nomad/ui/app/controllers/jobs.js
2017-10-23 17:42:36 -07:00

37 lines
1 KiB
JavaScript

import Ember from 'ember';
const { Controller, inject, observer, run } = Ember;
export default Controller.extend({
system: inject.service(),
queryParams: {
jobNamespace: 'namespace',
},
jobNamespace: 'default',
// The namespace query param should act as an alias to the system active namespace.
// But query param defaults can't be CPs: https://github.com/emberjs/ember.js/issues/9819
syncNamespaceService: observer('jobNamespace', function() {
const newNamespace = this.get('jobNamespace');
const currentNamespace = this.get('system.activeNamespace.id');
const bothAreDefault =
(currentNamespace == undefined || currentNamespace === 'default') &&
(newNamespace == undefined || newNamespace === 'default');
if (currentNamespace !== newNamespace && !bothAreDefault) {
this.set('system.activeNamespace', newNamespace);
run.next(() => {
this.send('refreshRoute');
});
}
}),
actions: {
refreshRoute() {
return true;
},
},
});