-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularizing existing code such as to have VisNodeModel, VisEdgeModel…
…, VisTooltipModel, ContrailVisView. Feature developers planning to use VisJS may use ContrailVisView - Wrapper for VisJS Network module. VisNodeModel - represents VisJS Node. VisEdgeModel - represents VisJS Edge. VisTooltipModel - Creates 'popover' tooltip on hovering VisNodeModel. Change-Id: I3decfbad5859b570470ba4d7747f16466fbcda69 Partial-Bug:#1575591 Closes-Bug: #1557441 Closes-Bug: #1557869 Closes-Bug: #1554501 Closes-Bug: #1554495 Closes-Bug: #1550407 Closes-Bug: #1550255 Closes-Bug: #1546052
- Loading branch information
Balaji Kumar AS
committed
Apr 28, 2016
1 parent
bca5ea6
commit e5319f2
Showing
18 changed files
with
435 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
define(['underscore', 'contrail-model', 'vis-tooltip-model'], | ||
function(_, ContrailModel, VisTooltipModel) { | ||
var visEdgeModel = ContrailModel.extend({ | ||
defaultConfig: { | ||
"element_id" : null, | ||
"endpoints" : null, | ||
"link_type" : null, | ||
"tooltip" : null, | ||
"title" : "", | ||
"arrows" : null, | ||
"tooltipConfig" : null, | ||
"color" : "rgba(57,57,57,.6)" | ||
}, | ||
constructor: function(edgeData, nodesCollection) { | ||
var modelConfig = { | ||
"from" : null, | ||
"to" : null | ||
}; | ||
if(edgeData.hasOwnProperty("endpoints") && | ||
edgeData["endpoints"].length == 2) { | ||
var fromNode = | ||
_.filter(nodesCollection.models, function(model) { | ||
return (model.attributes.name() == edgeData["endpoints"][0]); | ||
}); | ||
if(fromNode && fromNode.length > 0) { | ||
modelConfig["from"] = fromNode[0].attributes.element_id(); | ||
} | ||
var toNode = | ||
_.filter(nodesCollection.models, function(model) { | ||
return (model.attributes.name() == edgeData["endpoints"][1]); | ||
}); | ||
if(toNode && toNode.length > 0) { | ||
modelConfig["to"] = toNode[0].attributes.element_id(); | ||
} | ||
|
||
} | ||
edgeData = $.extend(true, {}, modelConfig, edgeData); | ||
ContrailModel.prototype.constructor.call(this, edgeData); | ||
return this; | ||
}, | ||
formatModelConfig: function(modelConfig) { | ||
var self = this; | ||
if(modelConfig.hasOwnProperty("from") && | ||
modelConfig["from"].trim() !== "" && | ||
modelConfig.hasOwnProperty("to") && | ||
modelConfig["to"].trim() !== "") { | ||
modelConfig["element_id"] = UUIDjs.create().hex; | ||
} | ||
return modelConfig; | ||
}, | ||
validateAttr: {}, | ||
validations: {} | ||
}); | ||
return visEdgeModel; | ||
}); |
Oops, something went wrong.