open-vault/ui/app/routes/vault.js

38 lines
936 B
JavaScript
Raw Normal View History

import { later } from '@ember/runloop';
import { Promise } from 'rsvp';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
2018-04-03 14:16:57 +00:00
import Ember from 'ember';
const SPLASH_DELAY = Ember.testing ? 0 : 300;
export default Route.extend({
version: service(),
2018-04-03 14:16:57 +00:00
beforeModel() {
return this.get('version').fetchVersion();
},
model() {
// hardcode single cluster
const fixture = {
data: {
id: '1',
type: 'cluster',
attributes: {
name: 'vault',
},
},
};
this.store.push(fixture);
return new Promise(resolve => {
later(() => {
2018-04-03 14:16:57 +00:00
resolve(this.store.peekAll('cluster'));
}, SPLASH_DELAY);
});
},
redirect(model, transition) {
if (model.get('length') === 1 && transition.targetName === 'vault.index') {
return this.transitionTo('vault.cluster', model.get('firstObject.name'));
}
},
});