open-consul/ui/packages/consul-ui/app/routes/dc/services/index.js
John Cowen 7083c39b96
ui: Support Route optional parameters/segments (#10212)
Moves our URLs with 'optional namespace segment' into a separately abstracted 'optional URL segment' feature
2021-05-26 17:43:46 +01:00

39 lines
913 B
JavaScript

import { inject as service } from '@ember/service';
import Route from 'consul-ui/routing/route';
export default class IndexRoute extends Route {
@service('data-source/service') data;
queryParams = {
sortBy: 'sort',
status: 'status',
source: 'source',
kind: 'kind',
searchproperty: {
as: 'searchproperty',
empty: [['Name', 'Tags']],
},
search: {
as: 'filter',
replace: true,
},
};
async model(params, transition) {
const nspace = this.optionalParams().nspace;
const dc = this.modelFor('dc').dc.Name;
const items = this.data.source(uri => uri`/${nspace}/${dc}/services`);
return {
dc,
nspace,
items: await items,
searchProperties: this.queryParams.searchproperty.empty[0],
};
}
setupController(controller, model) {
super.setupController(...arguments);
controller.setProperties(model);
}
}