Add namespaces and active namespace to the system service
This commit is contained in:
parent
4481e04d43
commit
3a0d292337
|
@ -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);
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue