diff --git a/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js b/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js index a55556390..a360d1a4f 100644 --- a/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js +++ b/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js @@ -141,6 +141,10 @@ underlayModel.prototype.formTree = function() { this.setTree(tree); } +underlayModel.prototype.getFlowPath = function() { + return this.flowPath; +} + underlayModel.prototype.getNodes = function() { return this.nodes; } @@ -257,6 +261,14 @@ underlayModel.prototype.getVNsUnderVrouter = function(vrouter) { return this.getChildren(vrouter, "virtual-network"); } +underlayModel.prototype.setFlowPath = function(response) { + if(null !== response && typeof response !== "undefined") { + this.flowPath = response; + } else { + this.flowPath = {}; + } +} + underlayModel.prototype.setTors = function(tors) { if(null !== tors && typeof tors !== "undefined" && tors.length > 0) { @@ -1719,8 +1731,8 @@ underlayView.prototype.highlightPath = function(response, data) { var elementMap = _this.getElementMap(); var conElements = _this.getConnectedElements(); var graph = _this.getGraph(); - var nodes = response.nodes; - var links = response.links; + var nodes = ifNull(response.nodes,[]); + var links = ifNull(response.links,[]); var adjList = this.prepareData("virtual-router"); var nodeNames = []; for(var i=0; i 0) { + connectionWrapElem = $(connectionWrapElem[0]); + } else { + return; + } + var linkId = $(connectionWrapElem).parent().attr('model-id'); + var linkAttrs = this.getGraph().getCell(linkId).attributes; + var sourceId = linkAttrs.source.id; + var destId = linkAttrs.target.id; + var srcEl = this.getGraph().getCell(sourceId); + var destEl = this.getGraph().getCell(destId); + var srcNodeName = getValueByJsonPath(srcEl,'attributes;nodeDetails;name','-'); + var destNodeName = getValueByJsonPath(destEl,'attributes;nodeDetails;name','-'); + var isDirectionCrt = false,links = getValueByJsonPath(flowPath,'links',[]); + for(var i = 0; i < links.length; i ++) { + if(srcNodeName == getValueByJsonPath(links[i],'endpoints;0','-') && + destNodeName == getValueByJsonPath(links[i],'endpoints;1','-')) { + isDirectionCrt = true + break; + } + } + return isDirectionCrt; +} + +underlayView.prototype.addOffsetPath = function(connectionWrapId, offsetWidth,isDirectionCrt) { var connectionWrapElem = $('#' + connectionWrapId); - if(connectionWrapElem.length > 0) + if(connectionWrapElem.length > 0) { connectionWrapElem = $(connectionWrapElem[0]); - else + } else { return; + } var path = connectionWrapElem.attr('d'); var pathCoords; if(typeof(path) == 'string') { @@ -2989,29 +3090,49 @@ underlayView.prototype.addOffsetPath = function(connectionWrapId, offsetWidth) { pathCoords = $.map(pathCoords,function(val) { return parseFloat(val); }); - var offsetPath; + var offsetPath; if(offsetWidth < 0) { offsetPath = connectionWrapElem.clone().prop('id',connectionWrapId + '_down'); } else { offsetPath = connectionWrapElem.clone().prop('id',connectionWrapId + '_up'); } var curve = new Bezier(pathCoords); - offsetPath.attr('marker-end',"url(#head)"); + var inclinedVerticalLine = false; if(curve._linear != true) { + if(isDirectionCrt) { + offsetWidth = -offsetWidth; + offsetPath.attr('marker-start',"url(#bezierUp)"); + } else { + offsetPath.attr('marker-end',"url(#bezierDown)"); + } + //Hack,till we fix the issue,links b/w TOR and SPINES are not vertical + if(Math.abs(pathCoords[pathCoords.length - 2] - pathCoords[0]) <= 10) { + inclinedVerticalLine = true; + if(isDirectionCrt) { + offsetPath.attr('marker-start','url(#upDeviated)'); + } else { + offsetPath.attr('marker-end','url(#downDeviated)'); + } + } var offsetPathStr = this.getOffsetBezierPath(pathCoords,offsetWidth); var offsetPathCords = offsetPathStr.split(' '); var offsetPathCordsLen = offsetPathCords.length; var lastX = offsetPathCords[offsetPathCords.length - 2]; - lastX = parseFloat(lastX) - 10; - offsetPathCords[offsetPathCords.length - 2] = lastX; + if(!isDirectionCrt && !inclinedVerticalLine) { + lastX = parseFloat(lastX) - 10; + offsetPathCords[offsetPathCords.length - 2] = lastX; + } else if (isDirectionCrt && !inclinedVerticalLine) { + lastX = parseFloat(lastX) + 10; + offsetPathCords[offsetPathCords.length - 2] = lastX; + } offsetPath.attr('d',offsetPathCords.join(' ')); } else { //Vertical line if(pathCoords[0] == pathCoords[6]) { //Pointing upwards/downwards - if(pathCoords[1] > pathCoords[7]) { + if(isDirectionCrt) { offsetPath.attr('transform','translate(' + offsetWidth + ',0)'); - offsetPath.attr('marker-end',"url(#up)"); + offsetPath.attr('marker-start',"url(#up)"); } else { offsetPath.attr('transform','translate(-' + offsetWidth + ',0)'); offsetPath.attr('marker-end',"url(#down)"); @@ -3023,10 +3144,10 @@ underlayView.prototype.addOffsetPath = function(connectionWrapId, offsetWidth) { } } - if(offsetWidth < 0) { - offsetPath.attr('class','connection-wrap-down'); - } else { + if(isDirectionCrt) { offsetPath.attr('class','connection-wrap-up'); + } else { + offsetPath.attr('class','connection-wrap-down'); } offsetPath.insertAfter(connectionWrapElem); } @@ -3059,8 +3180,6 @@ underlayView.prototype.destroy = function() { } } - - var underlayController = function (model, view) { this.model = model || new underlayModel({nodes:[], links:[]}); this.view = view || new new underlayView(this._model); @@ -3098,7 +3217,9 @@ underlayController.prototype.getModelData = function(cfg) { //Enabling the below tabs only on success of ajax calls. $("#underlay_tabstrip").tabs('enable'); //Rendering the first search flows tab - underlayView.prototype.renderFlowRecords(); + if(typeof underlayRenderer === "object"){ + underlayRenderer.getView().renderFlowRecords(); + } } }, failureCallback : function (err) {