open-consul/ui-v2/app/routes/dc/services/show/index.js
Kenia 454ce7166b
ui: Service Mesh - Topology tab and basic layout (#8788)
* Create Topology Tab with foundational layout and styling

* Create Toplogy Metrics component with dynamic SVG

* Add ember-render-modifiers addon

* Implement Topology Metrics comp and fix up styling

* Create topology endpoint with tests

* Move arrow drawing to index.js file

* Add topology to show controller

* Fix up conditional wrapper, tabs positioning, links, and styling

* Group upstreams by dc and fix up styling

* Create service/health-percentage helper

* Add health check percentages to upstreams and downstreams

* Basic Layout

* Upgrade @hashicorp/consul-api-double to v5.2.3

* Renamed endpoint to be service-topology

* Refactor styling

* Update to only show Topology tab when Connect is enabled

* Fix bug and changes from review notes

* Remove unused functions that are replaced with SVG markers

* Refactor to resuse svg-curve helper

* Use the render-template helper for the metrics link

* Add topology default null to services show route

* Removed unused ID

* Fix up tests broken by redirect to /topology
2020-10-05 13:07:35 -04:00

38 lines
976 B
JavaScript

import Route from '@ember/routing/route';
import { get } from '@ember/object';
export default Route.extend({
afterModel: function(model, transition) {
const parent = this.routeName
.split('.')
.slice(0, -1)
.join('.');
// the default selected tab depends on whether you have any healthchecks or not
// so check the length here.
let to = 'topology';
const parentModel = this.modelFor(parent);
const kind = get(parentModel, 'items.firstObject.Service.Kind');
switch (kind) {
case 'ingress-gateway':
if (!get(parentModel, 'topology.Exists')) {
to = 'upstreams';
}
break;
case 'terminating-gateway':
to = 'services';
break;
case 'mesh-gateway':
to = 'instances';
break;
default:
if (!get(parentModel, 'topology.Exists')) {
to = 'instances';
}
}
this.replaceWith(`${parent}.${to}`, parentModel);
},
});