aboutsummaryrefslogtreecommitdiffstats
path: root/ui/imports/ui/components/network-graph-manager/network-graph-manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/imports/ui/components/network-graph-manager/network-graph-manager.js')
-rw-r--r--ui/imports/ui/components/network-graph-manager/network-graph-manager.js29
1 files changed, 13 insertions, 16 deletions
diff --git a/ui/imports/ui/components/network-graph-manager/network-graph-manager.js b/ui/imports/ui/components/network-graph-manager/network-graph-manager.js
index 7022bcc..16637ea 100644
--- a/ui/imports/ui/components/network-graph-manager/network-graph-manager.js
+++ b/ui/imports/ui/components/network-graph-manager/network-graph-manager.js
@@ -1,11 +1,3 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
-// /
-// All rights reserved. This program and the accompanying materials /
-// are made available under the terms of the Apache License, Version 2.0 /
-// which accompanies this distribution, and is available at /
-// http://www.apache.org/licenses/LICENSE-2.0 /
-/////////////////////////////////////////////////////////////////////////////////////////
/*
* Template Component: NetworkGraphManager
*/
@@ -229,10 +221,14 @@ function addNodeToGraph(node, graphData) {
name: node._id._str,
};
- newNode = R.ifElse(R.isNil,
- R.always(newNode),
- R.assocPath(['_osmeta', 'host'], R.__, newNode)
- )(node.host);
+ let groupMarkers = ['host', 'switch'];
+ let groupKey = R.find((key) => {
+ if (R.isNil(R.path([key], node))) { return false; }
+ return true;
+ })(groupMarkers);
+ if (groupKey) {
+ newNode = R.assocPath(['_osmeta', 'groupId'], node[groupKey], newNode);
+ }
let nodes = R.unionWith(R.eqBy(R.prop('_osid')), graphData.nodes, [newNode]);
let links = expandLinks(graphData.links, nodes);
@@ -253,18 +249,19 @@ function calcIsReady(graphData) {
function calcGroups(nodes) {
return R.reduce((accGroups, node) => {
- let host = R.path(['_osmeta', 'host'], node);
- if (R.isNil(host)) {
+ let groupId = R.path(['_osmeta', 'groupId'], node);
+ if (R.isNil(groupId)) {
return accGroups;
}
- let groupIndex = R.findIndex(R.propEq('_osid', host), accGroups);
+ let groupIndex = R.findIndex(R.propEq('_osid', groupId), accGroups);
let group = null;
if (groupIndex < 0) {
let group = {
- _osid: host,
+ _osid: groupId,
leaves: [node],
isExpanded: true,
+ name: groupId,
};
accGroups = R.append(group, accGroups);