open-consul/ui/packages/consul-ui/app/routes/dc/services/show/services.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

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