2020-10-01 08:33:22 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2020-12-16 09:18:29 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-04-08 09:56:36 +00:00
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class RoutingRoute extends Route {
|
2020-12-16 09:18:29 +00:00
|
|
|
@service('data-source/service') data;
|
|
|
|
|
|
|
|
async model(params, transition) {
|
2020-04-08 09:56:36 +00:00
|
|
|
const parent = this.routeName
|
|
|
|
.split('.')
|
|
|
|
.slice(0, -1)
|
|
|
|
.join('.');
|
2020-12-16 09:18:29 +00:00
|
|
|
const model = this.modelFor(parent);
|
2021-03-08 12:15:54 +00:00
|
|
|
const chain = this.data.source(
|
|
|
|
uri => uri`/${model.nspace}/${model.dc.Name}/discovery-chain/${model.slug}`
|
|
|
|
);
|
2020-12-16 09:18:29 +00:00
|
|
|
return {
|
|
|
|
...model,
|
2021-03-08 12:15:54 +00:00
|
|
|
chain: await chain,
|
2020-12-16 09:18:29 +00:00
|
|
|
};
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2020-12-16 09:18:29 +00:00
|
|
|
async afterModel(model, transition) {
|
2020-04-08 09:56:36 +00:00
|
|
|
if (!get(model, 'chain')) {
|
|
|
|
const parent = this.routeName
|
|
|
|
.split('.')
|
|
|
|
.slice(0, -1)
|
|
|
|
.join('.');
|
|
|
|
this.replaceWith(parent);
|
|
|
|
}
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
super.setupController(...arguments);
|
2020-04-08 09:56:36 +00:00
|
|
|
controller.setProperties(model);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|