Skip to content

Commit

Permalink
Merge "Fixing few bugs noticed."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 4, 2016
2 parents e283400 + b2762aa commit ae146ba
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
Expand Up @@ -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;
Expand Down
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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();
Expand Down Expand Up @@ -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 ||
Expand All @@ -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();
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
}
}
Expand Down

0 comments on commit ae146ba

Please sign in to comment.