open-consul/ui/packages/consul-ui/app/routes/dc/services/instance.js
John Cowen 23adad684b
ui: HealthCheck Search/Sort/Filtering (#9314)
* Adds model layer changes around HealthChecks

1. Makes a HealthCheck model fragment and uses it in ServiceInstances and
Nodes
2. Manually adds a relationship between a ServiceInstance and its
potential ServiceInstanceProxy
3. Misc changes related to the above such as an Exposed property on
MeshChecks, MeshChecks itself

* Add a potential temporary endpoint to distinguish ProxyServiceInstance

* Fix up Node search bar class

* Add search/sort/filter logic

* Fixup Service default sort key

* Add Healthcheck search/sort/filtering

* Tweak CSS add a default Type of 'Serf' when type is blank

* Fix up tests and new test support

* Add ability to search on Service/Node name depending on where you are

* Fixup CheckID search predicate

* Use computed for DataCollection to use caching

* Alpha sort the Type menu

* Temporary fix for new non-changing style Ember Proxys

* Only special case EventSource proxies
2020-12-07 09:14:30 +00:00

51 lines
1.5 KiB
JavaScript

import { inject as service } from '@ember/service';
import Route from 'consul-ui/routing/route';
import { get } from '@ember/object';
export default class InstanceRoute extends Route {
@service('data-source/service') data;
async model(params, transition) {
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1) || 'default';
const item = await this.data.source(
uri => uri`/${nspace}/${dc}/service-instance/${params.id}/${params.node}/${params.name}`
);
let proxyMeta, proxy;
if (get(item, 'IsOrigin')) {
proxyMeta = await this.data.source(
uri => uri`/${nspace}/${dc}/proxy-instance/${params.id}/${params.node}/${params.name}`
);
if (typeof get(proxyMeta, 'ServiceID') !== 'undefined') {
const proxyParams = {
id: get(proxyMeta, 'ServiceID'),
node: get(proxyMeta, 'Node'),
name: get(proxyMeta, 'ServiceName'),
};
// Proxies have identical dc/nspace as their parent instance
// so no need to use Proxy's dc/nspace response
// the proxy itself is just a normal service model
proxy = await this.data.source(
uri =>
uri`/${nspace}/${dc}/proxy-service-instance/${proxyParams.id}/${proxyParams.node}/${proxyParams.name}`
);
}
}
return {
dc,
nspace,
item,
proxyMeta,
proxy,
};
}
setupController(controller, model) {
super.setupController(...arguments);
controller.setProperties(model);
}
}