diff --git a/webroot/monitor/infrastructure/underlay/ui/js/models/UnderlayGraphModel.js b/webroot/monitor/infrastructure/underlay/ui/js/models/UnderlayGraphModel.js index d39a36a2a..30c9c79fe 100644 --- a/webroot/monitor/infrastructure/underlay/ui/js/models/UnderlayGraphModel.js +++ b/webroot/monitor/infrastructure/underlay/ui/js/models/UnderlayGraphModel.js @@ -45,7 +45,12 @@ define(['underscore', 'backbone', 'contrail-model', 'vis-node-model', 'vis-edge- modelConfig.nodesCollection = bbCollectionNodes; self.nodesCollection = bbCollectionNodes; _.each(modelConfigEdges, function(modelConfigEdge, idx) { - edgeModels.push(new VisEdgeModel(modelConfigEdge, bbCollectionNodes)); + var existingEdge = _.filter(edgeModels, function(edge) { + return (edge.endpoints().sort().join(",") == + modelConfigEdge.endpoints.sort().join(",")); + }); + if(existingEdge.length == 0) + edgeModels.push(new VisEdgeModel(modelConfigEdge, bbCollectionNodes)); }); bbCollectionEdges = new Backbone.Collection(edgeModels); self.edgesCollection = bbCollectionEdges; diff --git a/webroot/monitor/infrastructure/underlay/ui/js/views/TraceFlowResultView.js b/webroot/monitor/infrastructure/underlay/ui/js/views/TraceFlowResultView.js index 30716c0a5..f713ee8a9 100644 --- a/webroot/monitor/infrastructure/underlay/ui/js/views/TraceFlowResultView.js +++ b/webroot/monitor/infrastructure/underlay/ui/js/views/TraceFlowResultView.js @@ -221,7 +221,7 @@ define([ iconClass: 'icon-contrail-trace-flow', onClick: function(rowId,targetElement){ var graphModel = underlayUtils.getUnderlayGraphModel(); - graphModel.lastInteracted(new Date().getTime()); + graphModel.lastInteracted = new Date().getTime(); resetLoadingIcon(); $(targetElement).toggleClass('icon-cog icon-spinner icon-spin'); $("#"+gridId + " div.selected-slick-row").each( @@ -245,7 +245,7 @@ define([ iconClass: 'icon-contrail-reverse-flow', onClick: function(rowId,targetElement){ var graphModel = underlayUtils.getUnderlayGraphModel(); - graphModel.lastInteracted(new Date().getTime()); + graphModel.lastInteracted = new Date().getTime(); resetLoadingIcon(); $(targetElement).toggleClass('icon-cog icon-spinner icon-spin'); $("#"+gridId + " div.selected-slick-row").each( @@ -641,7 +641,7 @@ define([ } }).done(function(response) { if(postData['startAt'] != null && - graphModel.lastInteracted() > postData['startAt']) { + graphModel.lastInteracted > postData['startAt']) { if (deferredObj != null) { deferredObj.resolve(false); } @@ -708,7 +708,7 @@ define([ $('html,body').animate({scrollTop:0}, 500); }).fail(function(error,status) { if(postData['startAt'] != null && - graphModel.lastInteracted() > postData['startAt']) { + graphModel.lastInteracted > postData['startAt']) { if (deferredObj != null) { deferreObj.resolve(false); } diff --git a/webroot/monitor/infrastructure/underlay/ui/js/views/UnderlayGraphView.js b/webroot/monitor/infrastructure/underlay/ui/js/views/UnderlayGraphView.js index 42feafa0e..93f72cf95 100644 --- a/webroot/monitor/infrastructure/underlay/ui/js/views/UnderlayGraphView.js +++ b/webroot/monitor/infrastructure/underlay/ui/js/views/UnderlayGraphView.js @@ -692,18 +692,15 @@ define([ graphModel.selectedElement().model().set({ 'nodeType': ctwc.PROUTER, 'nodeDetail': nodeDetails}); - var children = graphModel.getChildren( - nodeDetails['name'], ctwc.VROUTER, - graphModel.nodesCollection, - graphModel.edgesCollection); + var children = dblClickedElement.options.model.attributes.children; var adjList = _.clone( graphModel.underlayAdjacencyList()); - if (children.length > 0) { - var childrenName = []; - for (var i = 0; i < children.length; i++) { - childrenName.push(children[i].attributes.name()); - adjList[children[i].attributes.name()] = []; - } + var childrenName = []; + _.each(children, function(child) { + childrenName.push(child.name()); + adjList[child.name()] = []; + }); + if (childrenName.length > 0) { adjList[nodeDetails['name']] = childrenName; graphModel.adjacencyList(adjList); self.removeUnderlayEffects(); @@ -756,13 +753,14 @@ define([ siblings = graphModel.getChildren(parentName, ctwc.VROUTER, graphModel.nodesCollection, graphModel.edgesCollection); parentNode = - self.network.getNode(self.model.elementMap.node[parentName]); + self.network.getNode(self.model.elementMap().node[parentName]); } } - var children = graphModel.getChildren(nodeDetails.name, + /*var children = graphModel.getChildren(nodeDetails.name, ctwc.VIRTUALMACHINE, graphModel.nodesCollection, - graphModel.edgesCollection); + graphModel.edgesCollection);*/ + var children = dblClickedElement.options.model.attributes.children; var newAdjList = {}; var oldAdjList = {}; if(self.underlayPathIds.nodes.length > 0 || @@ -784,14 +782,13 @@ define([ oldAdjList = _.clone(newAdjList); oldAdjList[parentNode['name']] = []; } - if (children.length > 0) { - var childrenName = []; - for (var i = 0; i < children.length; i++) { - childrenName.push(children[i].attributes.name()); - newAdjList[children[i].attributes.name()] = []; - } + var childrenName = []; + _.each(children, function(child) { + childrenName.push(child.name()); + newAdjList[child.name()] = []; + }); + if(childrenName.length > 0) newAdjList[nodeDetails['name']] = childrenName; - } graphModel.adjacencyList(newAdjList); self.removeUnderlayEffects(); self.removeUnderlayPathIds(); @@ -930,7 +927,8 @@ define([ } } var parentNode = _.filter(nodesCollection.models, function(node) { - return (node.attributes.name() == parentElementLabel); + return (node.attributes.name() == parentElementLabel && + !(node.attributes.model().attributes.hasOwnProperty("hidden"))); }); if (false !== parentNode && parentNode.length === 1) { parentNode = parentNode[0]; @@ -946,7 +944,8 @@ define([ _.each(adjacencyList, function(edges, parentElementLabel) { var parentNode = _.filter(nodesCollection.models, function(node) { - return (node.attributes.name() == parentElementLabel); + return (node.attributes.name() == parentElementLabel && + !(node.attributes.model().attributes.hasOwnProperty("hidden"))); }); if (false !== parentNode && parentNode.length === 1) { parentNode = parentNode[0]; @@ -981,7 +980,8 @@ define([ } } var childNode = _.filter(nodesCollection.models, function(node) { - return (node.attributes.name() == childElementLabel); + return (node.attributes.name() == childElementLabel && + !(node.attributes.model().attributes.hasOwnProperty("hidden"))); }); if (false !== childNode && childNode.length === 1) { childNode = childNode[0]; @@ -1078,12 +1078,7 @@ define([ } else { continue; } - var newLinkModel = self.model.addEdge({ - link_type: linkModel.attributes.link_type(), - endpoints: linkModel.attributes.endpoints(), - more_attributes: linkModel.attributes.more_attributes - }); - var newLink = self.createLink(self.model.edgesCollection.last(), + var newLink = self.createLink(linkModel, link_type, endpoint0NodeId, endpoint1NodeId); var currentLinkId = newLink.attributes.element_id(); linkElements.push(newLink); @@ -1367,17 +1362,21 @@ define([ removeUnderlayPathIds: function() { var network = this.network; var graphModel = this.model; - var elementMap = this.model.elementMap(); + var elementMap = graphModel.elementMap(); var pathIds = this.underlayPathIds; var edgeIds = network.getEdgeIds(); var edges = []; if(pathIds && pathIds.hasOwnProperty('links')) { for (var i = 0; i < pathIds.links.length; i++) { + graphModel.edgesCollection.remove( + graphModel.getEdge(pathIds.links[i])[0]); network.removeEdge(pathIds.links[i]); } } if(pathIds && pathIds.hasOwnProperty('nodes')) { for (var i = 0; i < pathIds.nodes.length; i++) { + graphModel.nodesCollection.remove( + graphModel.getNode(pathIds.nodes[i])[0]); network.removeNode(pathIds.nodes[i]); } }