2018-05-22 15:03:45 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-11-09 09:25:35 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2018-05-22 15:03:45 +00:00
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class EditRoute extends Route {
|
2021-01-04 17:22:10 +00:00
|
|
|
@service('repository/intention') repo;
|
|
|
|
@service('env') env;
|
2020-11-09 09:25:35 +00:00
|
|
|
|
2021-01-04 17:22:10 +00:00
|
|
|
async model({ intention_id }, transition) {
|
2019-12-17 18:47:37 +00:00
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
2021-01-04 17:22:10 +00:00
|
|
|
const nspace = this.modelFor('nspace').nspace.substr(1);
|
|
|
|
|
|
|
|
let item;
|
|
|
|
if (typeof intention_id !== 'undefined') {
|
|
|
|
item = await this.repo.findBySlug(intention_id, dc, nspace);
|
|
|
|
} else {
|
|
|
|
const defaultNspace = this.env.var('CONSUL_NSPACES_ENABLED') ? '*' : 'default';
|
|
|
|
item = await this.repo.create({
|
|
|
|
SourceNS: nspace || defaultNspace,
|
|
|
|
DestinationNS: nspace || defaultNspace,
|
|
|
|
Datacenter: dc,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
dc,
|
|
|
|
nspace,
|
|
|
|
item,
|
|
|
|
};
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
super.setupController(...arguments);
|
2018-05-22 15:03:45 +00:00
|
|
|
controller.setProperties(model);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|