Add namespaces and active namespace to the system service

This commit is contained in:
Michael Lange 2017-10-09 18:50:49 -07:00
parent 4481e04d43
commit 3a0d292337

View file

@ -6,6 +6,7 @@ const { Service, computed, inject } = Ember;
export default Service.extend({
token: inject.service(),
store: inject.service(),
leader: computed(function() {
const token = this.get('token');
@ -22,4 +23,23 @@ export default Service.extend({
}),
});
}),
namespaces: computed(function() {
return this.get('store').findAll('namespace');
}),
activeNamespace: computed('namespaces.[]', {
get() {
const namespaceId = window.localStorage.nomadActiveNamespace || 'default';
return this.get('namespaces').findBy('id', namespaceId);
},
set(key, value) {
if (value == null) {
window.localStorage.removeItem('nomadActiveNamespace');
} else {
window.localStorage.nomadActiveNamespace = value;
}
return this.get('namespaces').findBy('id', value);
},
}),
});