Skip to content

Commit

Permalink
Modularizing existing code such as to have VisNodeModel, VisEdgeModel…
Browse files Browse the repository at this point in the history
…, 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
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 0 deletions.
4 changes: 4 additions & 0 deletions webroot/img/router-default.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/router-dimlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/router-error.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/router-highlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/tor-default.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/tor-dimlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/tor-highlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-machine-default.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-machine-dimlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-machine-highlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-router-default.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-router-dimlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/img/virtual-router-highlight.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions webroot/js/common/core.app.utils.js
Expand Up @@ -61,6 +61,7 @@ function getCoreAppPaths(coreBaseDir, coreBuildDir) {
'graph-view' : coreWebDir + '/js/views/GraphView',
'contrail-view' : coreWebDir + '/js/views/ContrailView',
'query-form-view' : coreWebDir + '/js/views/QueryFormView',
'contrail-vis-view' : coreWebDir + '/js/views/ContrailVisView',

'query-form-model' : coreWebDir + '/js/models/QueryFormModel',
'query-or-model' : coreWebDir + '/js/models/QueryOrModel',
Expand All @@ -72,6 +73,9 @@ function getCoreAppPaths(coreBaseDir, coreBuildDir) {
'contrail-list-model' : coreWebDir + '/js/models/ContrailListModel',
'mon-infra-node-list-model' : coreWebDir + '/js/models/NodeListModel',
'mon-infra-log-list-model' : coreWebDir + '/js/models/LogListModel',
'vis-node-model' : coreWebDir + '/js/models/VisNodeModel',
'vis-edge-model' : coreWebDir + '/js/models/VisEdgeModel',
'vis-tooltip-model' : coreWebDir + '/js/models/VisTooltipModel',

// TODO: We need to discuss a criteria on which we should add definations to this file.
'infoboxes' : coreWebDir + '/js/views/InfoboxesView',
Expand Down
55 changes: 55 additions & 0 deletions webroot/js/models/VisEdgeModel.js
@@ -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;
});

0 comments on commit e5319f2

Please sign in to comment.