2020-10-05 13:48:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-11-09 09:25:35 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2020-05-12 21:34:47 +00:00
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class ServicesRoute extends Route {
|
2020-12-01 15:45:09 +00:00
|
|
|
@service('data-source/service') data;
|
|
|
|
|
|
|
|
queryParams = {
|
|
|
|
sortBy: 'sort',
|
|
|
|
instance: 'instance',
|
|
|
|
searchproperty: {
|
|
|
|
as: 'searchproperty',
|
|
|
|
empty: [['Name', 'Tags']],
|
|
|
|
},
|
|
|
|
search: {
|
|
|
|
as: 'filter',
|
|
|
|
replace: true,
|
|
|
|
},
|
|
|
|
};
|
2020-11-09 09:25:35 +00:00
|
|
|
|
2020-12-02 15:42:18 +00:00
|
|
|
async model(params, transition) {
|
2020-10-05 13:48:26 +00:00
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
|
|
const nspace = this.modelFor('nspace').nspace.substr(1);
|
2020-05-12 21:34:47 +00:00
|
|
|
const parent = this.routeName
|
|
|
|
.split('.')
|
|
|
|
.slice(0, -1)
|
|
|
|
.join('.');
|
2020-10-19 14:20:27 +00:00
|
|
|
const name = this.modelFor(parent).slug;
|
2021-01-25 18:13:54 +00:00
|
|
|
const items = await this.data.source(uri => uri`/${nspace}/${dc}/gateways/for-service/${name}`);
|
2020-12-02 15:42:18 +00:00
|
|
|
return {
|
|
|
|
dc,
|
|
|
|
nspace,
|
2021-01-25 18:13:54 +00:00
|
|
|
items,
|
|
|
|
searchProperties: this.queryParams.searchproperty.empty[0],
|
2020-12-02 15:42:18 +00:00
|
|
|
};
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
super.setupController(...arguments);
|
2020-05-12 21:34:47 +00:00
|
|
|
controller.setProperties(model);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|