-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Related-Bug: #1528133 Implement route table in MVC. 1. Added t…
…wo tabs (network/interface route table)"
- Loading branch information
Showing
18 changed files
with
1,525 additions
and
6 deletions.
There are no files selected for viewing
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
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
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,28 @@ | ||
<!-- | ||
Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
--> | ||
<urlLists> | ||
<require> | ||
<define>parseURLReq</define> | ||
<path>process.mainModule.exports["corePath"] + '/src/serverroot/common/parseURLRequire'</path> | ||
</require> | ||
<require> | ||
<define>rtTableApi</define> | ||
<path>./routetable.api</path> | ||
</require> | ||
<!-- API / Feature definition for Security Group configuration --> | ||
<!-- 1. List Security Group - | ||
--> | ||
<item> | ||
<url>/api/tenants/config/route-table/:type</url> | ||
<method>post</method> | ||
<feature>rtTableConfig</feature> | ||
<callback>rtTableApi.createRouteTable</callback> | ||
</item> | ||
<item> | ||
<url>/api/tenants/config/route-table/:type/:id</url> | ||
<method>put</method> | ||
<feature>rtTableConfig</feature> | ||
<callback>rtTableApi.updateRouteTable</callback> | ||
</item> | ||
</urlLists> |
60 changes: 60 additions & 0 deletions
60
webroot/config/networking/routetable/api/routetable.api.js
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,60 @@ | ||
/* | ||
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
/** | ||
* @routetable.api.js | ||
* - Handlers for Route Table Configuration | ||
* - Interfaces with config api server | ||
*/ | ||
|
||
var logutils = require(process.mainModule.exports["corePath"] + | ||
'/src/serverroot/utils/log.utils'); | ||
var commonUtils = require(process.mainModule.exports["corePath"] + | ||
'/src/serverroot/utils/common.utils'); | ||
var messages = require(process.mainModule.exports["corePath"] + | ||
'/src/serverroot/common/messages'); | ||
var util = require('util'); | ||
var configApiServer = require(process.mainModule.exports["corePath"] + | ||
'/src/serverroot/common/configServer.api'); | ||
var jsonDiff = require(process.mainModule.exports["corePath"] + | ||
'/src/serverroot/common/jsondiff'); | ||
|
||
|
||
/** | ||
* Bail out if called directly as "nodejs routetable.api.js" | ||
*/ | ||
if (!module.parent) | ||
{ | ||
logutils.logger.warn(util.format(messages.warn.invalid_mod_call, | ||
module.filename)); | ||
process.exit(1); | ||
} | ||
|
||
function createRouteTable (req, res, appData) | ||
{ | ||
var type = req.param('type'); | ||
var rtCreateURL = '/' + type + 's'; | ||
var postData = req.body; | ||
|
||
configApiServer.apiPost(rtCreateURL, postData, appData, | ||
function(error, data) { | ||
commonUtils.handleJSONResponse(error, res, data); | ||
}); | ||
} | ||
|
||
function updateRouteTable (req, res, appData) | ||
{ | ||
var id = req.param('id'); | ||
var type = req.param('type'); | ||
var putData = req.body; | ||
var rtEditURL = '/' + type + '/' + id; | ||
jsonDiff.getConfigDiffAndMakeCall(rtEditURL, appData, putData, | ||
function(error, data) { | ||
commonUtils.handleJSONResponse(error, res, data); | ||
}); | ||
} | ||
|
||
exports.createRouteTable = createRouteTable; | ||
exports.updateRouteTable = updateRouteTable; | ||
|
153 changes: 153 additions & 0 deletions
153
webroot/config/networking/routetable/ui/js/RtTableUtils.js
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,153 @@ | ||
/* | ||
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
define([ | ||
'underscore' | ||
], function (_) { | ||
var rtTableUtils = function() { | ||
var self = this; | ||
|
||
self.getRtsHopCollectionView = function() { | ||
return { | ||
columns: [{ | ||
elementId: 'prefix', | ||
view: 'FormInputView', | ||
class: "", width: 375, | ||
viewConfig: { | ||
label: 'Prefix', | ||
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW, | ||
path: 'prefix', | ||
dataBindValue: 'prefix()' | ||
} | ||
}, | ||
{ | ||
elementId: 'next_hop', | ||
view: 'FormInputView', | ||
class: "", width: 375, | ||
viewConfig: { | ||
label: 'Next Hop', | ||
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW, | ||
path: 'next_hop', | ||
dataBindValue: 'next_hop()' | ||
} | ||
}, | ||
{ | ||
elementId: 'next_hop_type', | ||
view: 'FormInputView', | ||
class: "", width: 375, | ||
viewConfig: { | ||
label: 'Next Hop Type', | ||
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW, | ||
path: 'next_hop_type', | ||
dataBindValue: 'next_hop_type()' | ||
} | ||
}, | ||
{ | ||
elementId: 'community_attr', | ||
view: 'FormTextAreaView', | ||
class: "", width: 375, | ||
viewConfig: { | ||
scrollHeight: 200, | ||
height: 200, | ||
label: 'Community Attribute', | ||
templateId: cowc.TMPL_EDITABLE_GRID_TEXTAREA_VIEW, | ||
path: 'community_attr', | ||
dataBindValue: 'community_attr()' | ||
} | ||
}] | ||
} | ||
}, | ||
self.getRtsCommAttrCollectionView = function() { | ||
return { | ||
columns: [{ | ||
elementId: 'community-attr-collection', | ||
view: "FormCollectionView", | ||
viewConfig: { | ||
colSpan: "2", | ||
path: 'communityAttrs', | ||
collection: 'communityAttrs()', | ||
templateId: cowc.TMPL_GEN_COLLECTION_VIEW, | ||
collectionActions: { | ||
add: {onClick: "addCommunityAttr()", | ||
iconClass: 'icon-plus', | ||
buttonTitle: 'Add Community Attributes', | ||
} | ||
}, | ||
rows: [{ | ||
rowActions: [ | ||
{onClick: "deleteCommunityAttr()", | ||
iconClass: 'icon-minus'} | ||
], | ||
columns: [{ | ||
elementId: 'community_attr', | ||
view: 'FormComboboxView', | ||
class: "", width: 385, | ||
viewConfig: { | ||
label: 'Community Attribute', | ||
templateId: | ||
cowc.TMPL_EDITABLE_GRID_COMBOBOX_VIEW, | ||
path: 'community_attr', | ||
dataBindValue: 'community_attr()', | ||
elementConfig: { | ||
placeholder: 'Select or Enter ' + | ||
'Community Attribute ' + | ||
'String', | ||
dataTextField : "text", | ||
dataValueField : "id", | ||
dataSource: { | ||
type: 'local', | ||
data : [ | ||
{'text': 'no-export', | ||
'id': 'no-export'}, | ||
{'text': 'accept-own', | ||
'id': 'accept-own'}, | ||
{'text': 'no-advertise', | ||
'id': 'no-advertise'}, | ||
{'text': 'no-export-subconfed', | ||
'id': 'no-export-subconfed'}, | ||
{'text': 'no-reoriginate', | ||
'id': 'no-reoriginate'} | ||
] | ||
} | ||
} | ||
} | ||
}] | ||
}] | ||
} | ||
}] | ||
} | ||
}, | ||
self.getRtTableView = function () { | ||
return { | ||
elementId: 'rtTypesCollection', | ||
view: 'AccordianView', | ||
viewConfig: [{ | ||
elementId: 'rtTypesCollectionAccordian', | ||
title: 'Routes', | ||
view: 'SectionView', | ||
viewConfig: { | ||
rows: [{ | ||
columns: [{ | ||
elementId: 'route-collection', | ||
view: "FormEditableGridView", | ||
viewConfig: { | ||
path: 'routes', | ||
collection: 'routes()', | ||
collectionActions: { | ||
add: {onClick: "$root.addRtTable()", | ||
iconClass: 'icon-plus', | ||
buttonTitle: 'Add Static Routes' | ||
} | ||
}, | ||
validations: 'routesValidation', | ||
} | ||
}] | ||
}] | ||
} | ||
}] | ||
} | ||
} | ||
}; | ||
return rtTableUtils; | ||
}); | ||
|
46 changes: 46 additions & 0 deletions
46
webroot/config/networking/routetable/ui/js/models/CommAttrModel.js
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,46 @@ | ||
/* | ||
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
define([ | ||
'underscore', | ||
'contrail-model' | ||
], function (_, ContrailModel) { | ||
var CommAttrModel = ContrailModel.extend({ | ||
|
||
defaultConfig: { | ||
community_attr: '' | ||
}, | ||
validateAttr: function (attributePath, validation, data) { | ||
var model = data.model().attributes.model(), | ||
attr = cowu.getAttributeFromPath(attributePath), | ||
errors = model.get(cowc.KEY_MODEL_ERRORS), | ||
attrErrorObj = {}, isValid; | ||
|
||
isValid = model.isValid(attributePath, validation); | ||
|
||
attrErrorObj[attr + cowc.ERROR_SUFFIX_ID] = (isValid == true) ? false : isValid; | ||
errors.set(attrErrorObj); | ||
}, | ||
validations: { | ||
commAttrValidation: { | ||
} | ||
}, | ||
deleteCommunityAttr: function(data, attr) { | ||
var coll = this.model().collection; | ||
var item = this.model(); | ||
coll.remove(item); | ||
}, | ||
addCommunityAttr: function(data, obj) { | ||
var coll = this.model().collection; | ||
var commAttr = | ||
this.model().attributes.model().get('next_hop'); | ||
|
||
var newCommAttr = | ||
new CommAttrModel({'prefix': "", 'next_hop': nextHop}); | ||
coll.add([newCommAttr]); | ||
} | ||
}); | ||
|
||
return CommAttrModel; | ||
}); | ||
|
Oops, something went wrong.