open-vault/ui/lib/replication/addon/routes/application.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { setProperties } from '@ember/object';
import { hash } from 'rsvp';
import Route from '@ember/routing/route';
2018-04-03 14:16:57 +00:00
import ClusterRoute from 'vault/mixins/cluster-route';
export default Route.extend(ClusterRoute, {
version: service(),
store: service(),
2018-04-03 14:16:57 +00:00
beforeModel() {
return this.get('version')
.fetchFeatures()
.then(() => {
return this._super(...arguments);
});
2018-04-03 14:16:57 +00:00
},
model() {
return this.store.findRecord('cluster', 'vault');
2018-04-03 14:16:57 +00:00
},
afterModel(model) {
return hash({
canEnablePrimary: this.store
.findRecord('capabilities', 'sys/replication/primary/enable')
.then(c => c.get('canUpdate')),
canEnableSecondary: this.store
.findRecord('capabilities', 'sys/replication/secondary/enable')
.then(c => c.get('canUpdate')),
}).then(({ canEnablePrimary, canEnableSecondary }) => {
setProperties(model, {
canEnablePrimary,
canEnableSecondary,
2018-04-03 14:16:57 +00:00
});
return model;
});
2018-04-03 14:16:57 +00:00
},
actions: {
refresh() {
this.refresh();
},
},
2018-04-03 14:16:57 +00:00
});