Displaying the graph also if tenants are not present
Prevent routes from beeing duplicated
Change-Id: Icf6967d450f32e8d80f365c1be3181e3c10c178e
diff --git a/src/app/core/services/navigation.ts b/src/app/core/services/navigation.ts
index e41333c..6fb6883 100644
--- a/src/app/core/services/navigation.ts
+++ b/src/app/core/services/navigation.ts
@@ -58,10 +58,14 @@
throw new Error('[XosNavigation] You can\'t provide both state and url');
}
+ // NOTE factor this out in a separate method an eventually use recursion since we can nest more routes
const routeExist = _.findIndex(this.routes, (r: IXosNavigationRoute) => {
if (r.label === route.label && r.state === route.state && r.parent === route.parent) {
return true;
}
+ else if (_.findIndex(r.children, route) > -1) {
+ return true;
+ }
return false;
}) > -1;
diff --git a/src/app/service-graph/components/coarse/coarse.component.ts b/src/app/service-graph/components/coarse/coarse.component.ts
index fb04e2d..ed5d100 100644
--- a/src/app/service-graph/components/coarse/coarse.component.ts
+++ b/src/app/service-graph/components/coarse/coarse.component.ts
@@ -46,7 +46,7 @@
this.$log.debug(`[XosCoarseTenancyGraph] Coarse Event and render`, res);
// id there are no data, do nothing
- if (!res.nodes || res.nodes.length === 0 || !res.links || res.links.length === 0) {
+ if (!res) {
return;
}
this.graph = res;
@@ -138,9 +138,6 @@
}
private addNodeLinksToForceLayout(data: IXosServiceGraph) {
- if (!data.nodes || !data.links) {
- return;
- }
this.forceLayout
.nodes(data.nodes)
.links(data.links)
diff --git a/src/app/service-graph/components/fine-grained/fine-grained.component.ts b/src/app/service-graph/components/fine-grained/fine-grained.component.ts
index 5647c75..7f69387 100644
--- a/src/app/service-graph/components/fine-grained/fine-grained.component.ts
+++ b/src/app/service-graph/components/fine-grained/fine-grained.component.ts
@@ -55,7 +55,7 @@
(graph) => {
this.$log.debug(`[XosFineGrainedTenancyGraphCtrl] Fine-Grained Event and render`, graph);
- if (!graph.nodes || graph.nodes.length === 0 || !graph.links || graph.links.length === 0) {
+ if (!graph || !graph.nodes || !graph.links) {
return;
}
diff --git a/src/app/service-graph/services/graph.store.ts b/src/app/service-graph/services/graph.store.ts
index 9ab1a5d..2266329 100644
--- a/src/app/service-graph/services/graph.store.ts
+++ b/src/app/service-graph/services/graph.store.ts
@@ -28,9 +28,14 @@
subscribers: []
});
+ private emptyGraph: IXosServiceGraph = {
+ nodes: [],
+ links: []
+ };
+
// representation of the graph as D3 requires
- private d3CoarseGraph = new BehaviorSubject({});
- private d3FineGrainedGraph = new BehaviorSubject({});
+ private d3CoarseGraph = new BehaviorSubject(this.emptyGraph);
+ private d3FineGrainedGraph = new BehaviorSubject(this.emptyGraph);
// storing locally reference to the data model
private services;
@@ -240,7 +245,6 @@
}
private graphDataToFineGrainedGraph(data: IXosFineGrainedGraphData) {
-
try {
data = this.removeUnwantedFineGrainedData(data);
@@ -292,7 +296,7 @@
return links;
}, []);
- if (nodes.length === 0 || links.length === 0) {
+ if (nodes.length === 0 && links.length === 0) {
return;
}
@@ -304,11 +308,9 @@
_.forEach(this.XosServiceGraphExtender.getFinegrained(), (r: IXosServiceGraphReducer) => {
graph = r.reducer(graph);
});
-
this.d3FineGrainedGraph.next(graph);
} catch (e) {
this.d3FineGrainedGraph.error(e);
}
}
-
}