1 var modules = ['app/gbp/gbp.module',
\r
2 'app/gbp/gbp.services'
\r
6 define(modules, function(gbp) {
\r
8 gbp.register.controller('gbpCtrl', ['$scope', '$rootScope', '$http', '$timeout', 'PGNServices', 'TopoServices', 'GBPTenantServices', 'GBPConstants', 'DesignGbpFactory',
\r
9 function ($scope, $rootScope, $http, $timeout, PGNServices, TopoServices, GBPTenantServices, GBPConstants, DesignGbpFactory) {
\r
10 $rootScope['section_logo'] = 'logo_yangui';
\r
11 $scope.view_path = 'src/app/gbp/views/';
\r
12 $scope.topologyData = { nodes: [], links: [] };
\r
13 $scope.topologyType = null;
\r
15 $scope.showLegend = false;
\r
17 var reloadShowLegend = function() {
\r
18 $scope.showLegend = !$.isEmptyObject($scope.legend);
\r
21 $scope.settingsSigma = {
\r
22 defaultLabelColor: '#fff',
\r
23 doubleClickEnabled: false,
\r
27 $scope.settingsAtlas = {
\r
52 $scope.tenantList = [];
\r
53 $scope.selectedTenant = null;
\r
54 $scope.tenantDisplayLabel = ['name' , 'id'];
\r
56 $scope.mandatoryProperties = [];
\r
57 $scope.loadTopology = function(type, args) {
\r
58 if ( $scope.selectedTenant ) {
\r
60 $scope.topologyData = { nodes: [], links: [] };
\r
61 $scope.topologyType = type;
\r
63 TopoServices.loadTopology(type, function(nodes, links) {
\r
64 $scope.topologyData = { nodes: nodes, links: links };
\r
65 $scope.viewTopo.box = true;
\r
66 $scope.viewTopo.button = type !== 'L2L3' && type !== null ? true : false;
\r
67 $scope.legend = TopoServices.getLegend(type);
\r
77 $scope.toggleExpanded = function(expand, show) {
\r
78 $scope.view[expand] = show ? true : !$scope.view[expand];
\r
79 for ( var property in $scope.view ) {
\r
80 $scope.view[property] = expand !== property ? false : $scope.view[expand];
\r
83 $scope.$broadcast('EV_INIT'+expand.toUpperCase());
\r
86 $scope.topologyCustfunc = function(sigmaIstance, getSlowDownNum, dragListener, resize){
\r
88 sigmaIstance.bind('clickStage', function(e){
\r
89 sigmaIstance.killForceAtlas2();
\r
93 // sigmaIstance.bind('overNode outNode clickNode doubleClickNode rightClickNode', function(e) {
\r
94 // console.log(e.type, e.data.node.label, e.data.captor);
\r
96 // sigmaIstance.bind('overEdge outEdge clickEdge doubleClickEdge rightClickEdge', function(e) {
\r
97 // console.log(e.type, e.data.edge, e.data.captor);
\r
99 // sigmaIstance.bind('clickStage', function(e) {
\r
100 // console.log(e.type, e.data.captor);
\r
102 // sigmaIstance.bind('doubleClickStage rightClickStage', function(e) {
\r
103 // console.log(e.type, e.data.captor);
\r
108 $scope.setTenant = function() {
\r
109 $scope.$broadcast('GBP_TENANT_RELOAD');
\r
110 if($scope.selectedTenant) {
\r
111 $scope.loadTopology($scope.topologyType, { tenantId: $scope.selectedTenant.id });
\r
115 $scope.loadTenants = function() {
\r
116 GBPTenantServices.load(
\r
117 function(tenants) {
\r
118 $scope.tenantList = tenants;
\r
124 DesignGbpFactory.setMainClass();
\r
127 $scope.sendReloadEventFromRoot = function(eventName) {
\r
128 $scope.$broadcast(eventName);
\r
131 $scope.getDisplayLabelsFromCtrl = function(eventName, val) {
\r
132 $scope.$broadcast(eventName, val);
\r
135 $scope.validateMandatory = function(newObj, mandatoryProps){
\r
137 notFilledProps = [];
\r
139 mandatoryProps.forEach(function(el){
\r
140 if(newObj[el] === '' || newObj[el] === null || newObj[el] === undefined){
\r
141 notFilledProps.push(el);
\r
146 return {'status' : ret, 'notFilledProps' : notFilledProps};
\r
149 $scope.getDisplayLabel = function(obj, labelArray){
\r
152 if((typeof labelArray) === 'string'){
\r
153 ret = obj[labelArray];
\r
154 } else if (angular.isFunction(labelArray)) {
\r
155 ret = labelArray(obj);
\r
157 labelArray.some(function(labelParam) {
\r
158 if(angular.isFunction(labelParam)) {
\r
159 ret = labelParam(obj);
\r
160 } else if(obj.hasOwnProperty(labelParam)) {
\r
161 ret = obj[labelParam];
\r
170 $scope.validateForm = function(form) {
\r
171 return form.$valid;
\r
174 $scope.loadTenants();
\r
176 $scope.$on('GBP_GLOBAL_TENANT_RELOAD',function(){
\r
177 $scope.loadTenants();
\r
181 gbp.register.controller('topoDataCtrl',['$scope', 'TopoServices', function($scope, TopoServices){
\r
182 $scope.showTable = false;
\r
184 $scope.getConsProvLabel = function(edge){
\r
185 return TopoServices.getConsProvLabel(edge, $scope.topologyData);
\r
188 $scope.show = function(){
\r
189 $scope.showTable = true;
\r
192 $scope.close = function(){
\r
193 $scope.showTable = false;
\r
199 gbp.register.controller('crudCtrl',['$scope', function($scope){
\r
200 $scope.selectedObj = null;
\r
203 $scope.add = function() {
\r
204 $scope.selectedObj = null;
\r
208 $scope.modify = function() {
\r
209 $scope.$emit('PGN_EDIT_ELEM');
\r
212 $scope.init = function(label) {
\r
213 $scope.label = label;
\r
216 $scope.$on('EV_SET_SEL_CLASS', function(event, selObj){
\r
217 $scope.selectedObj = selObj;
\r
221 gbp.register.controller('contractCtrl', ['$scope','GBPContractServices', '$filter', function($scope, GBPContractServices, $filter){
\r
223 $scope.contractView = false;
\r
224 $scope.selectedContract = null;
\r
225 $scope.newContractObj = GBPContractServices.createObj();
\r
226 $scope.displayLabel = 'id';
\r
227 $scope.crudLabel = 'Contract list';
\r
230 mandatoryProperties = [];
\r
232 $scope.init = function() {
\r
233 if ( $scope.selectedTenant ) {
\r
234 $scope.selectedContract = null;
\r
235 path = GBPContractServices.createPathObj($scope.selectedTenant.id);
\r
237 GBPContractServices.load(path, function(data){
\r
238 $scope.list = data;
\r
239 // $scope.$broadcast('GBP_CONTRACT_RELOAD');
\r
240 $scope.sendReloadEventFromRoot('GBP_CONTRACT_RELOAD');
\r
247 $scope.save = function(){
\r
248 var resp = $scope.validateMandatory($scope.newContractObj, mandatoryProperties);
\r
250 path = GBPContractServices.createPathObj($scope.selectedTenant.id, $scope.newContractObj.id);
\r
251 GBPContractServices.send(path, $scope.newContractObj, function(data){
\r
253 $scope.contractView = false;
\r
254 $scope.reloadNewObj();
\r
259 alert($filter('translate')('GBP_MANDATORY_NOT_FILLED')+': '+resp.notFilledProps.join(', '));
\r
263 $scope.delete = function() {
\r
264 if ( $scope.selectedContract ) {
\r
265 path = GBPContractServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id);
\r
266 GBPContractServices.delete(path, function(data){
\r
268 $scope.selectedContract = null;
\r
275 $scope.reloadNewObj = function() {
\r
276 $scope.newContractObj = GBPContractServices.createObj();
\r
279 $scope.reload = function(selectedObj) {
\r
280 $scope.selectedContract = selectedObj;
\r
281 if($scope.contractView) {
\r
282 angular.copy(selectedObj, $scope.newContractObj);
\r
284 $scope.sendReloadEventFromRoot('GBP_CONTRACT_RELOAD');
\r
287 $scope.showForm = function() {
\r
288 $scope.reloadNewObj();
\r
289 $scope.contractView = true;
\r
290 $scope.selectedContract = null;
\r
293 $scope.close = function(){
\r
294 $scope.contractView = false;
\r
297 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
298 if(!event.defaultPrevented) {
\r
299 if ( $scope.selectedContract ) {
\r
300 $scope.contractView = true;
\r
301 angular.copy($scope.selectedContract, $scope.newContractObj);
\r
303 event.defaultPrevented = true;
\r
307 $scope.$on('GBP_TENANT_RELOAD',function(event){
\r
311 $scope.$on('GBP_CONTRACTS_LABEL', function(event, obj){
\r
312 obj.labels = $scope.displayLabel;
\r
316 gbp.register.controller('clauseCtrl', ['$scope','GBPClauseServices', 'GBPSubjectServices',
\r
317 function($scope, GBPClauseServices, GBPSubjectServices){
\r
319 $scope.selectedClause = null;
\r
320 $scope.newClauseObj = GBPClauseServices.createObj();
\r
325 $scope.displayLabel = 'name';
\r
326 $scope.crudLabel = 'Clause list';
\r
328 $scope.subjects = {'options' : [], 'labels' : null};
\r
329 $scope.getDisplayLabelsFromCtrl('GBP_SUBJECTS_LABEL', $scope.subjects);
\r
333 //move to separate ctrl \/
\r
334 $scope.addNewElem = function(templateObj) {
\r
335 if($scope.newClauseObj && $scope.newClauseObj['subject-refs']) {
\r
336 var objToPush = templateObj || "";
\r
337 $scope.newClauseObj['subject-refs'].push(objToPush);
\r
341 $scope.deleteElemAt = function(index) {
\r
342 if($scope.newClauseObj && $scope.newClauseObj['subject-refs']) {
\r
343 $scope.newClauseObj['subject-refs'].splice(index, 1);
\r
347 $scope.updateAt = function(index, value) {
\r
348 if($scope.newClauseObj && $scope.newClauseObj['subject-refs'] && $scope.newClauseObj['subject-refs'].length >= index) {
\r
349 $scope.newClauseObj['subject-refs'][index] = value;
\r
352 //move to separate ctrl /\
\r
354 var loadSubjects = function() {
\r
355 $scope.getDisplayLabelsFromCtrl('GBP_SUBJECTS_LABEL', $scope.subjects);
\r
357 GBPSubjectServices.load(path, function(data){
\r
358 $scope.subjects.options = data;
\r
364 $scope.init = function() {
\r
365 if ( $scope.selectedContract ) {
\r
366 path = GBPClauseServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id);
\r
368 GBPClauseServices.load(path, function(data){
\r
369 $scope.list = data;
\r
376 $scope.save = function(){
\r
377 if($scope.validateForm($scope.clauseForm)){
\r
378 path = GBPClauseServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.newClauseObj.name);
\r
379 GBPClauseServices.send(path, $scope.newClauseObj, function(data){
\r
381 $scope.view.clause = false;
\r
382 $scope.reloadNewObj();
\r
389 $scope.delete = function() {
\r
390 if ( $scope.selectedClause ) {
\r
391 path = GBPClauseServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedClause.name);
\r
392 GBPClauseServices.delete(path, function(data){
\r
394 $scope.selectedClause = null;
\r
401 $scope.reloadNewObj = function() {
\r
402 $scope.newClauseObj = GBPClauseServices.createObj();
\r
405 $scope.reload = function(selectedObj) {
\r
406 $scope.selectedClause = selectedObj;
\r
407 if($scope.view.clause) {
\r
408 angular.copy(selectedObj, $scope.newClauseObj);
\r
412 $scope.showForm = function() {
\r
413 $scope.reloadNewObj();
\r
414 $scope.view.clause = true;
\r
415 $scope.view.edit = false;
\r
416 $scope.selectedClause = null;
\r
419 $scope.close = function(){
\r
420 $scope.view.clause = false;
\r
421 $scope.view.edit = false;
\r
424 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
425 if (!event.defaultPrevented) {
\r
426 if ( $scope.selectedClause ) {
\r
427 $scope.view.clause = true;
\r
428 $scope.view.edit = true;
\r
429 angular.copy($scope.selectedClause, $scope.newClauseObj);
\r
431 event.defaultPrevented = true;
\r
435 $scope.$on('GBP_CONTRACT_RELOAD',function(){
\r
439 $scope.$on('GBP_SUBJECT_RELOAD',function(){
\r
444 gbp.register.controller('subjectCtrl', ['$scope','GBPSubjectServices', '$filter', function($scope, GBPSubjectServices, $filter){
\r
446 $scope.selectedSubject = null;
\r
447 $scope.newSubjectObj = GBPSubjectServices.createObj();
\r
448 $scope.displayLabel = 'name';
\r
453 $scope.crudLabel = 'Subject list';
\r
457 mandatoryProperties = ['order'];
\r
459 $scope.init = function() {
\r
460 if ( $scope.selectedContract ) {
\r
461 $scope.selectedSubject = null;
\r
462 path = GBPSubjectServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id);
\r
464 GBPSubjectServices.load(path, function(data){
\r
465 $scope.list = data;
\r
466 $scope.sendReloadEventFromRoot('GBP_SUBJECT_RELOAD');
\r
473 $scope.save = function(){
\r
474 if($scope.validateForm($scope.subjectForm)){
\r
475 path = GBPSubjectServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.newSubjectObj.name);
\r
476 GBPSubjectServices.send(path, $scope.newSubjectObj, function(data){
\r
478 $scope.view.subject = false;
\r
479 $scope.reloadNewObj();
\r
486 $scope.delete = function() {
\r
487 if ( $scope.selectedSubject ) {
\r
488 path = GBPSubjectServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name);
\r
489 GBPSubjectServices.delete(path, function(data){
\r
491 $scope.selectedSubject = null;
\r
498 $scope.reloadNewObj = function() {
\r
499 $scope.newSubjectObj = GBPSubjectServices.createObj();
\r
502 $scope.reload = function(selectedObj) {
\r
503 $scope.selectedSubject = selectedObj;
\r
504 if($scope.view.subject) {
\r
505 angular.copy(selectedObj, $scope.newSubjectObj);
\r
507 $scope.sendReloadEventFromRoot('GBP_SUBJECT_RELOAD');
\r
510 $scope.showForm = function() {
\r
511 $scope.reloadNewObj();
\r
512 $scope.view.subject = true;
\r
513 $scope.view.edit = false;
\r
514 $scope.selectedSubject = null;
\r
517 $scope.close = function(){
\r
518 $scope.view.subject = false;
\r
519 $scope.view.edit = false;
\r
522 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
523 if (!event.defaultPrevented) {
\r
524 if ( $scope.selectedSubject ) {
\r
525 $scope.view.subject = true;
\r
526 $scope.view.edit = true;
\r
527 angular.copy($scope.selectedSubject, $scope.newSubjectObj);
\r
529 event.defaultPrevented = true;
\r
533 $scope.$on('GBP_CONTRACT_RELOAD',function(){
\r
537 $scope.$on('GBP_SUBJECTS_LABEL', function(event, obj){
\r
538 obj.labels = $scope.displayLabel;
\r
542 gbp.register.controller('ruleCtrl', ['$scope','GBPRuleServices', '$filter', function($scope, GBPRuleServices, $filter){
\r
544 $scope.selectedRule = null;
\r
545 $scope.newRuleObj = GBPRuleServices.createObj();
\r
546 $scope.displayLabel = 'name';
\r
551 $scope.crudLabel = 'Rule list';
\r
554 mandatoryProperties = ['order'];
\r
556 $scope.init = function() {
\r
557 if ( $scope.selectedSubject ) {
\r
558 $scope.selectedRule = null;
\r
559 path = GBPRuleServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name);
\r
561 GBPRuleServices.load(path, function(data){
\r
562 $scope.list = data;
\r
569 $scope.save = function(){
\r
570 if($scope.validateForm($scope.rulesForm)){
\r
571 path = GBPRuleServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.newRuleObj.name);
\r
572 GBPRuleServices.send(path, $scope.newRuleObj, function(data){
\r
574 $scope.view.rule = false;
\r
575 $scope.reloadNewObj();
\r
582 $scope.delete = function() {
\r
583 if ( $scope.selectedRule ) {
\r
584 path = GBPRuleServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name);
\r
585 GBPRuleServices.delete(path, function(data){
\r
587 $scope.selectedRule = null;
\r
594 $scope.reloadNewObj = function() {
\r
595 $scope.newRuleObj = GBPRuleServices.createObj();
\r
598 $scope.reload = function(selectedObj) {
\r
599 $scope.selectedRule = selectedObj;
\r
600 if($scope.view.rule) {
\r
601 angular.copy(selectedObj, $scope.newRuleObj);
\r
603 $scope.$broadcast('GBP_RULE_RELOAD');
\r
606 $scope.showForm = function() {
\r
607 $scope.reloadNewObj();
\r
608 $scope.view.rule = true;
\r
609 $scope.view.edit = false;
\r
610 $scope.selectedRule = null;
\r
613 $scope.close = function(){
\r
614 $scope.view.rule = false;
\r
615 $scope.view.edit = false;
\r
618 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
619 if (!event.defaultPrevented) {
\r
620 if ( $scope.selectedRule ) {
\r
621 $scope.view.rule = true;
\r
622 $scope.view.edit = true;
\r
623 angular.copy($scope.selectedRule, $scope.newRuleObj);
\r
625 event.defaultPrevented = true;
\r
629 $scope.$on('GBP_SUBJECT_RELOAD',function(){
\r
634 gbp.register.controller('actionRefCtrl', ['$scope','GBPActionRefsServices', 'GBPActionInstanceServices', '$filter', function($scope, GBPActionRefsServices, GBPActionInstanceServices, $filter){
\r
636 $scope.selectedActionRef = null;
\r
637 $scope.newActionRefObj = GBPActionRefsServices.createObj();
\r
638 $scope.displayLabel = 'name';
\r
643 $scope.crudLabel = 'Action ref list';
\r
645 $scope.actionInstanceNames = {'options' : [], 'labels' : $scope.displayLabel};
\r
648 mandatoryProperties = ['order'];
\r
650 var actionInstanceNamesLoad = function() {
\r
651 var actionInstancePath = GBPActionInstanceServices.createPathObj($scope.selectedTenant.id);
\r
652 GBPActionInstanceServices.load(actionInstancePath, function(data){
\r
653 $scope.actionInstanceNames.options = data;
\r
659 $scope.init = function() {
\r
660 if ( $scope.selectedRule ) {
\r
661 $scope.selectedActionRef = null;
\r
662 path = GBPActionRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name);
\r
664 GBPActionRefsServices.load(path, function(data){
\r
665 $scope.list = data;
\r
670 actionInstanceNamesLoad();
\r
674 $scope.save = function(){
\r
675 if($scope.validateForm($scope.actionRefForm)){
\r
676 path = GBPActionRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name, $scope.newActionRefObj.name);
\r
677 GBPActionRefsServices.send(path, $scope.newActionRefObj, function(data){
\r
679 $scope.view.actionRef = false;
\r
680 $scope.reloadNewObj();
\r
687 $scope.delete = function() {
\r
688 if ( $scope.selectedActionRef ) {
\r
689 path = GBPActionRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name, $scope.selectedActionRef.name);
\r
690 GBPActionRefsServices.delete(path, function(data){
\r
692 $scope.selectedActionRef = null;
\r
699 $scope.reloadNewObj = function() {
\r
700 $scope.newActionRefObj = GBPActionRefsServices.createObj();
\r
703 $scope.reload = function(selectedObj) {
\r
704 $scope.selectedActionRef = selectedObj;
\r
705 if($scope.view.actionRef) {
\r
706 angular.copy(selectedObj, $scope.newActionRefObj);
\r
710 $scope.showForm = function() {
\r
711 $scope.reloadNewObj();
\r
712 $scope.view.actionRef = true;
\r
713 $scope.view.edit = false;
\r
714 $scope.selectedActionRef = null;
\r
717 $scope.close = function(){
\r
718 $scope.view.actionRef = false;
\r
719 $scope.view.edit = false;
\r
722 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
723 if (!event.defaultPrevented) {
\r
724 if ( $scope.selectedActionRef ) {
\r
725 $scope.view.actionRef = true;
\r
726 $scope.view.edit = true;
\r
727 angular.copy($scope.selectedActionRef, $scope.newActionRefObj);
\r
729 event.defaultPrevented = true;
\r
733 $scope.$on('GBP_RULE_RELOAD',function(){
\r
737 $scope.$on('GBP_ACTION_INSTANCE_RELOAD',function(){
\r
738 actionInstanceNamesLoad();
\r
742 gbp.register.controller('classifierRefCtrl', ['$scope','GBPClassifierRefsServices', 'GBPClassifierInstanceServices', '$filter', function($scope, GBPClassifierRefsServices, GBPClassifierInstanceServices, $filter){
\r
744 $scope.selectedClassifierRef = null;
\r
745 $scope.newClassifierRefObj = GBPClassifierRefsServices.createObj();
\r
746 $scope.displayLabel = 'name';
\r
748 classifierRef : false,
\r
752 $scope.instanceNames = {'options' : [], 'labels' : $scope.displayLabel};
\r
754 $scope.formDirections = ['in', 'out', 'bidirectional'];
\r
755 $scope.formConnectionTracking = ['normal', 'reflexive'];
\r
757 $scope.crudLabel = 'Classifier ref list';
\r
761 var instanceNamesLoad = function() {
\r
762 var classifierInstancePath = GBPClassifierInstanceServices.createPathObj($scope.selectedTenant.id);
\r
763 GBPClassifierInstanceServices.load(classifierInstancePath, function(data){
\r
764 $scope.instanceNames.options = data;
\r
770 $scope.init = function() {
\r
771 if ( $scope.selectedRule ) {
\r
772 $scope.selectedClassifierRef = null;
\r
773 path = GBPClassifierRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name);
\r
777 GBPClassifierRefsServices.load(path, function(data){
\r
778 $scope.list = data;
\r
783 instanceNamesLoad();
\r
787 $scope.save = function(){
\r
788 if($scope.validateForm($scope.classifierRefForm)){
\r
789 path = GBPClassifierRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name, $scope.newClassifierRefObj.name);
\r
790 GBPClassifierRefsServices.send(path, $scope.newClassifierRefObj, function(data){
\r
792 $scope.view.classifierRef = false;
\r
793 $scope.reloadNewObj();
\r
800 $scope.delete = function() {
\r
801 if ( $scope.selectedClassifierRef ) {
\r
802 path = GBPClassifierRefsServices.createPathObj($scope.selectedTenant.id, $scope.selectedContract.id, $scope.selectedSubject.name, $scope.selectedRule.name, $scope.selectedClassifierRef.name);
\r
803 GBPClassifierRefsServices.delete(path, function(data){
\r
805 $scope.selectedClassifierRef = null;
\r
812 $scope.reloadNewObj = function() {
\r
813 $scope.newClassifierRefObj = GBPClassifierRefsServices.createObj();
\r
816 $scope.reload = function(selectedObj) {
\r
817 $scope.selectedClassifierRef = selectedObj;
\r
818 if($scope.view.classifierRef) {
\r
819 angular.copy(selectedObj, $scope.newClassifierRefObj);
\r
823 $scope.showForm = function() {
\r
824 $scope.reloadNewObj();
\r
825 $scope.view.classifierRef = true;
\r
826 $scope.view.edit = false;
\r
827 $scope.selectedClassifierRef = null;
\r
830 $scope.close = function(){
\r
831 $scope.view.classifierRef = false;
\r
832 $scope.view.edit = false;
\r
835 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
836 if (!event.defaultPrevented) {
\r
837 if ( $scope.selectedClassifierRef ) {
\r
838 $scope.view.classifierRef = true;
\r
839 $scope.view.edit = true;
\r
840 angular.copy($scope.selectedClassifierRef, $scope.newClassifierRefObj);
\r
842 event.defaultPrevented = true;
\r
846 $scope.$on('GBP_RULE_RELOAD',function(){
\r
850 $scope.$on('GBP_CLASSIFIER_INSTANCE_RELOAD',function(){
\r
851 instanceNamesLoad();
\r
855 gbp.register.controller('tenantCtrl', ['$scope', 'GBPTenantServices', '$filter', function($scope, GBPTenantServices, $filter){
\r
857 $scope.tenantView = false;
\r
858 $scope.selectedTenantObj = null;
\r
859 $scope.newTenantObj = GBPTenantServices.createObj();
\r
860 $scope.displayLabel = ['name' , 'id'];
\r
861 $scope.crudLabel = 'Tenants list';
\r
863 $scope.init = function() {
\r
864 GBPTenantServices.load(
\r
866 $scope.list = data;
\r
867 $scope.newTenantObj = GBPTenantServices.createObj();
\r
868 $scope.selectedTenantObj = null;
\r
875 $scope.save = function(){
\r
876 if($scope.validateForm($scope.tenantForm)){
\r
877 path = GBPTenantServices.createPathObj($scope.newTenantObj.id);
\r
878 GBPTenantServices.send(path, $scope.newTenantObj, function(data){
\r
880 $scope.tenantView = false;
\r
881 $scope.$emit('GBP_GLOBAL_TENANT_RELOAD');
\r
888 $scope.delete = function() {
\r
889 if($scope.selectedTenantObj) {
\r
890 path = GBPTenantServices.createPathObj($scope.selectedTenantObj.id);
\r
892 GBPTenantServices.delete(path, function(data){
\r
894 $scope.tenantView = false;
\r
895 $scope.$emit('GBP_GLOBAL_TENANT_RELOAD');
\r
902 $scope.reload = function(selectedObj) {
\r
903 $scope.selectedTenantObj = selectedObj;
\r
904 if ($scope.tenantView) {
\r
905 angular.copy(selectedObj, $scope.newTenantObj);
\r
909 $scope.showForm = function() {
\r
910 $scope.newTenantObj = GBPTenantServices.createObj();
\r
911 $scope.selectedTenantObj = null;
\r
912 $scope.tenantView = true;
\r
915 $scope.close = function(){
\r
916 $scope.tenantView = false;
\r
919 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
920 if (!event.defaultPrevented) {
\r
921 if ( $scope.selectedTenantObj ) {
\r
922 $scope.tenantView = true;
\r
923 angular.copy($scope.selectedTenantObj, $scope.newTenantObj);
\r
925 event.defaultPrevented = true;
\r
929 // $scope.$on('GBP_TENANT_RELOAD',function(){
\r
934 gbp.register.controller('epgCtrl',['$scope', 'GBPEpgServices', 'GBPContractServices', '$filter',
\r
935 function($scope, GBPEpgServices, GBPContractServices, $filter){
\r
936 $scope.selectedEpg = null;
\r
937 $scope.newEpgObj = GBPEpgServices.createObj();
\r
938 $scope.epgView = false;
\r
939 $scope.displayLabel = ['name', 'id'];
\r
940 $scope.crudLabel = 'Group list';
\r
942 $scope.igpOpts = ['allow', 'require-contract'];
\r
944 $scope.contracts = {'options' : [], 'labels' : null};
\r
945 $scope.getDisplayLabelsFromCtrl('GBP_CONTRACTS_LABEL', $scope.contracts);
\r
949 var loadContracts = function() {
\r
950 GBPContractServices.load(path, function(data){
\r
951 $scope.contracts.options = data;
\r
957 var mandatoryProperties = ['name'];
\r
959 $scope.init = function() {
\r
960 if ($scope.selectedTenant) {
\r
961 path = GBPEpgServices.createPathObj($scope.selectedTenant.id);
\r
963 GBPEpgServices.load(path, function(data){
\r
964 $scope.list = data;
\r
965 // $scope.$broadcast('GBP_EPG_RELOAD');
\r
966 $scope.sendReloadEventFromRoot('GBP_EPG_RELOAD');
\r
975 $scope.save = function(){
\r
976 if($scope.validateForm($scope.epgForm)){
\r
977 path = GBPEpgServices.createPathObj($scope.selectedTenant.id, $scope.newEpgObj.id);
\r
978 GBPEpgServices.send(path, $scope.newEpgObj, function(data){
\r
980 $scope.epgView = false;
\r
981 $scope.reloadNewObj();
\r
988 $scope.delete = function() {
\r
989 if($scope.selectedTenant && $scope.selectedEpg) {
\r
990 path = GBPEpgServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id);
\r
991 GBPEpgServices.delete(path, function(data){
\r
999 $scope.showForm = function() {
\r
1000 $scope.epgView = true;
\r
1001 $scope.reloadNewObj();
\r
1002 $scope.selectedEpg = null;
\r
1005 $scope.reloadNewObj = function() {
\r
1006 $scope.newEpgObj = GBPEpgServices.createObj();
\r
1009 $scope.reload = function(selectedObj) {
\r
1010 $scope.selectedEpg = selectedObj;
\r
1011 if($scope.epgView) {
\r
1012 angular.copy(selectedObj, $scope.newEpgObj);
\r
1014 $scope.sendReloadEventFromRoot('GBP_EPG_RELOAD');
\r
1017 $scope.close = function(){
\r
1018 $scope.epgView = false;
\r
1020 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1021 if (!event.defaultPrevented) {
\r
1022 if ( $scope.selectedEpg ) {
\r
1023 $scope.epgView = true;
\r
1024 angular.copy($scope.selectedEpg, $scope.newEpgObj);
\r
1026 event.defaultPrevented = true;
\r
1030 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
1034 $scope.$on('GBP_CONTRACT_RELOAD',function(){
\r
1038 $scope.$on('GBP_EPG_LABEL', function(event, obj){
\r
1039 obj.labels = $scope.displayLabel;
\r
1043 gbp.register.controller('cnsCtrl',['$scope', 'GBPConNamedSelServices', function($scope, GBPConNamedSelServices){
\r
1045 $scope.selectedCNS = null;
\r
1046 $scope.newCNSObj = GBPConNamedSelServices.createObj();
\r
1051 $scope.displayLabel = 'name';
\r
1052 $scope.crudLabel = 'Consumer named selectors list';
\r
1054 //move to separate ctrl \/
\r
1055 $scope.addNewElem = function(templateObj) {
\r
1056 if($scope.newCNSObj && $scope.newCNSObj.contract) {
\r
1057 var objToPush = templateObj || "";
\r
1058 $scope.newCNSObj.contract.push(objToPush);
\r
1062 $scope.deleteElemAt = function(index) {
\r
1063 if($scope.newCNSObj && $scope.newCNSObj.contract) {
\r
1064 $scope.newCNSObj.contract.splice(index, 1);
\r
1068 $scope.updateAt = function(index, value) {
\r
1069 if($scope.newCNSObj && $scope.newCNSObj.contract && $scope.newCNSObj.contract.length >= index) {
\r
1070 $scope.newCNSObj.contract[index] = value;
\r
1073 //move to separate ctrl /\
\r
1075 $scope.init = function() {
\r
1076 if ($scope.selectedTenant && $scope.selectedEpg) {
\r
1077 path = GBPConNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id);
\r
1079 GBPConNamedSelServices.load(path, function(data){
\r
1080 $scope.list = data;
\r
1087 $scope.save = function(){
\r
1088 if($scope.validateForm($scope.cnsForm)){
\r
1089 path = GBPConNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id, $scope.newCNSObj.name);
\r
1090 GBPConNamedSelServices.send(path, $scope.newCNSObj, function(data){
\r
1092 $scope.view.cns = false;
\r
1094 $scope.reloadNewObj();
\r
1101 $scope.delete = function() {
\r
1102 if($scope.selectedTenant && $scope.selectedEpg && $scope.selectedCNS) {
\r
1103 path = GBPConNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id, $scope.selectedCNS.name);
\r
1104 GBPConNamedSelServices.delete(path, function(data){
\r
1112 $scope.showForm = function() {
\r
1113 $scope.reloadNewObj();
\r
1114 $scope.selectedCNS = null;
\r
1115 $scope.view.cns = true;
\r
1116 $scope.view.edit = false;
\r
1119 $scope.reloadNewObj = function() {
\r
1120 $scope.newCNSObj = GBPConNamedSelServices.createObj();
\r
1123 $scope.reload = function(selectedObj) {
\r
1124 $scope.selectedCNS = selectedObj;
\r
1125 if($scope.view.cns) {
\r
1126 angular.copy(selectedObj, $scope.newCNSObj);
\r
1130 $scope.close = function(){
\r
1131 $scope.view.cns = false;
\r
1132 $scope.view.edit = false;
\r
1135 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1136 if (!event.defaultPrevented) {
\r
1137 if ( $scope.selectedEpg ) {
\r
1138 $scope.view.cns = true;
\r
1139 $scope.view.edit = true;
\r
1140 angular.copy($scope.selectedCNS, $scope.newCNSObj);
\r
1142 event.defaultPrevented = true;
\r
1146 $scope.$on('GBP_EPG_RELOAD',function(){
\r
1151 gbp.register.controller('pnsCtrl',['$scope', 'GBPProNamedSelServices', function($scope, GBPProNamedSelServices){
\r
1153 $scope.selectedPNS = null;
\r
1154 $scope.newPNSObj = GBPProNamedSelServices.createObj();
\r
1155 $scope.displayLabel = 'name';
\r
1156 $scope.crudLabel = 'Provider named selectors list';
\r
1162 //move to separate ctrl \/
\r
1163 $scope.addNewElem = function(templateObj) {
\r
1164 if($scope.newPNSObj && $scope.newPNSObj.contract) {
\r
1165 var objToPush = templateObj || "";
\r
1166 $scope.newPNSObj.contract.push(objToPush);
\r
1170 $scope.deleteElemAt = function(index) {
\r
1171 if($scope.newPNSObj && $scope.newPNSObj.contract) {
\r
1172 $scope.newPNSObj.contract.splice(index, 1);
\r
1176 $scope.updateAt = function(index, value) {
\r
1177 if($scope.newPNSObj && $scope.newPNSObj.contract && $scope.newPNSObj.contract.length >= index) {
\r
1178 $scope.newPNSObj.contract[index] = value;
\r
1181 //move to separate ctrl /\
\r
1183 $scope.init = function() {
\r
1184 if ($scope.selectedTenant && $scope.selectedEpg) {
\r
1185 path = GBPProNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id);
\r
1187 GBPProNamedSelServices.load(path, function(data){
\r
1188 $scope.list = data;
\r
1195 $scope.save = function(){
\r
1196 if($scope.validateForm($scope.pnsForm)){
\r
1197 path = GBPProNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id, $scope.newPNSObj.name);
\r
1198 GBPProNamedSelServices.send(path, $scope.newPNSObj, function(data){
\r
1200 $scope.view.pns = false;
\r
1201 $scope.reloadNewObj();
\r
1208 $scope.delete = function() {
\r
1209 if($scope.selectedTenant && $scope.selectedEpg && $scope.selectedPNS) {
\r
1210 path = GBPProNamedSelServices.createPathObj($scope.selectedTenant.id, $scope.selectedEpg.id, $scope.selectedPNS.name);
\r
1211 GBPProNamedSelServices.delete(path, function(data){
\r
1219 $scope.showForm = function() {
\r
1220 $scope.reloadNewObj();
\r
1221 $scope.view.pns = true;
\r
1222 $scope.view.edit = false;
\r
1223 $scope.selectedPNS = null;
\r
1226 $scope.reloadNewObj = function() {
\r
1227 $scope.newPNSObj = GBPProNamedSelServices.createObj();
\r
1230 $scope.reload = function(selectedObj) {
\r
1231 $scope.selectedPNS = selectedObj;
\r
1232 if($scope.view.pns) {
\r
1233 angular.copy(selectedObj, $scope.newPNSObj);
\r
1237 $scope.close = function(){
\r
1238 $scope.view.pns = false;
\r
1239 $scope.view.edit = false;
\r
1241 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1242 if (!event.defaultPrevented) {
\r
1243 if ( $scope.selectedEpg ) {
\r
1244 $scope.view.pns = true;
\r
1245 $scope.view.edit = true;
\r
1246 angular.copy($scope.selectedPNS, $scope.newPNSObj);
\r
1248 event.defaultPrevented = true;
\r
1252 $scope.$on('GBP_EPG_RELOAD',function(){
\r
1257 gbp.register.controller('l2FloodCtrl', ['$scope', 'GBPL2FloodDomainServices', 'GBPL2BridgeDomainServices', '$filter', function($scope, GBPL2FloodDomainServices, GBPL2BridgeDomainServices, $filter){
\r
1259 $scope.l2FloodView = false;
\r
1260 $scope.selectedL2Flood = null;
\r
1261 $scope.newL2FloodObj = GBPL2FloodDomainServices.createObj();
\r
1262 $scope.displayLabel = ['name', 'id'];
\r
1263 $scope.crudLabel = 'L2 Flood Domain list';
\r
1265 $scope.l2bridge = {'options' : [], 'labels' : null};
\r
1266 $scope.getDisplayLabelsFromCtrl('GBP_L2BRIDGE_LABEL', $scope.l2bridge);
\r
1270 var loadL2BridgeList = function() {
\r
1271 GBPL2BridgeDomainServices.load(GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id), function(data){
\r
1272 $scope.l2bridge.options = data;
\r
1278 $scope.init = function() {
\r
1279 if ( $scope.selectedTenant ) {
\r
1280 path = GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id);
\r
1282 GBPL2FloodDomainServices.load(path, function(data){
\r
1283 $scope.list = data;
\r
1285 $scope.newL2FloodObj = GBPL2FloodDomainServices.createObj();
\r
1286 $scope.selectedL2Flood = null;
\r
1291 loadL2BridgeList();
\r
1295 $scope.save = function(){
\r
1296 if($scope.validateForm($scope.l2FloodForm)){
\r
1297 path = GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id, $scope.newL2FloodObj.id);
\r
1298 GBPL2FloodDomainServices.send(path, $scope.newL2FloodObj, function(data){
\r
1300 $scope.l2FloodView = false;
\r
1301 $scope.sendReloadEventFromRoot('GBP_L2FLOOD_RELOAD');
\r
1308 $scope.delete = function() {
\r
1309 if($scope.selectedTenant && $scope.selectedL2Flood) {
\r
1310 path = GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id, $scope.selectedL2Flood.id);
\r
1311 GBPL2FloodDomainServices.delete(path, function(data){
\r
1313 $scope.l2FloodView = false;
\r
1314 $scope.sendReloadEventFromRoot('GBP_L2FLOOD_RELOAD');
\r
1321 $scope.reload = function(selectedObj) {
\r
1322 $scope.selectedL2Flood = selectedObj;
\r
1323 if ($scope.l2FloodView) {
\r
1324 angular.copy(selectedObj, $scope.newL2FloodObj);
\r
1326 $scope.sendReloadEventFromRoot('GBP_L2FLOOD_RELOAD');
\r
1329 $scope.showForm = function() {
\r
1330 $scope.newL2FloodObj = GBPL2FloodDomainServices.createObj();
\r
1331 $scope.selectedL2Flood = null;
\r
1332 $scope.l2FloodView = true;
\r
1335 $scope.close = function(){
\r
1336 $scope.l2FloodView = false;
\r
1339 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1340 if (!event.defaultPrevented) {
\r
1341 if ( $scope.selectedL2Flood ) {
\r
1342 $scope.l2FloodView = true;
\r
1343 angular.copy($scope.selectedL2Flood, $scope.newL2FloodObj);
\r
1345 event.defaultPrevented = true;
\r
1349 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
1353 $scope.$on('GBP_L2BRIDGE_RELOAD',function(){
\r
1354 loadL2BridgeList();
\r
1357 $scope.$on('GBP_L2FLOOD_LABEL', function(event, obj){
\r
1358 obj.labels = $scope.displayLabel;
\r
1362 gbp.register.controller('l2BridgeCtrl', ['$scope', 'GBPL2BridgeDomainServices', 'GBPL3ContextServices', '$filter', function($scope, GBPL2BridgeDomainServices, GBPL3ContextServices, $filter){
\r
1364 $scope.l2BridgeView = false;
\r
1365 $scope.selectedL2Bridge = null;
\r
1366 $scope.newL2BridgeObj = GBPL2BridgeDomainServices.createObj();
\r
1367 $scope.displayLabel = ['name', 'id'];
\r
1368 $scope.crudLabel = 'L2 Bridge Domain list';
\r
1370 $scope.l3context = {'options' : [], 'labels' : null};
\r
1371 $scope.getDisplayLabelsFromCtrl('GBP_L3CONTEXT_LABEL', $scope.l3context);
\r
1375 var loadL3ContextList = function() {
\r
1376 GBPL3ContextServices.load(GBPL3ContextServices.createPathObj($scope.selectedTenant.id), function(data){
\r
1377 $scope.l3context.options = data;
\r
1378 //$scope.$broadcast('GBP_L2BRIDGE_RELOAD');
\r
1384 $scope.init = function() {
\r
1385 if ( $scope.selectedTenant ) {
\r
1386 path = GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id);
\r
1388 GBPL2BridgeDomainServices.load(path, function(data){
\r
1389 $scope.list = data;
\r
1390 $scope.newL2BridgeObj = GBPL2BridgeDomainServices.createObj();
\r
1391 $scope.selectedL2Bridge = null;
\r
1392 // $scope.$broadcast('GBP_L2BRIDGE_RELOAD');
\r
1397 loadL3ContextList();
\r
1403 $scope.save = function(){
\r
1404 if($scope.validateForm($scope.l2BridgeForm)){
\r
1405 path = GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id, $scope.newL2BridgeObj.id);
\r
1406 GBPL2BridgeDomainServices.send(path, $scope.newL2BridgeObj, function(data){
\r
1408 $scope.l2BridgeView = false;
\r
1409 $scope.sendReloadEventFromRoot('GBP_L2BRIDGE_RELOAD');
\r
1416 $scope.delete = function() {
\r
1417 if($scope.selectedTenant && $scope.selectedL2Bridge) {
\r
1418 path = GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id, $scope.selectedL2Bridge.id);
\r
1419 GBPL2BridgeDomainServices.delete(path, function(data){
\r
1421 $scope.l2BridgeView = false;
\r
1422 $scope.sendReloadEventFromRoot('GBP_L2BRIDGE_RELOAD');
\r
1429 $scope.reload = function(selectedObj) {
\r
1430 $scope.selectedL2Bridge = selectedObj;
\r
1431 if ($scope.l2BridgeView) {
\r
1432 angular.copy(selectedObj, $scope.newL2BridgeObj);
\r
1434 $scope.sendReloadEventFromRoot('GBP_L2BRIDGE_RELOAD');
\r
1437 $scope.showForm = function() {
\r
1438 $scope.newL2BridgeObj = GBPL2BridgeDomainServices.createObj();
\r
1439 $scope.selectedL2Bridge = null;
\r
1440 $scope.l2BridgeView = true;
\r
1443 $scope.close = function(){
\r
1444 $scope.l2BridgeView = false;
\r
1447 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1448 if (!event.defaultPrevented) {
\r
1449 if ( $scope.selectedL2Bridge ) {
\r
1450 $scope.l2BridgeView = true;
\r
1451 angular.copy($scope.selectedL2Bridge, $scope.newL2BridgeObj);
\r
1453 event.defaultPrevented = true;
\r
1457 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
1461 $scope.$on('GBP_L3CONTEXT_RELOAD',function(){
\r
1462 loadL3ContextList();
\r
1465 $scope.$on('GBP_L2BRIDGE_LABEL', function(event, obj){
\r
1466 obj.labels = $scope.displayLabel;
\r
1470 gbp.register.controller('l3ContextCtrl', ['$scope', 'GBPL3ContextServices', '$filter', function($scope, GBPL3ContextServices, $filter){ //GBPContractServices
\r
1472 $scope.l3ContextView = false;
\r
1473 $scope.selectedL3Context = null;
\r
1474 $scope.newL3ContextObj = GBPL3ContextServices.createObj();
\r
1475 $scope.displayLabel = ['name', 'id'];
\r
1476 $scope.crudLabel = 'L3 Context list';
\r
1480 $scope.init = function() {
\r
1481 if ( $scope.selectedTenant ) {
\r
1482 path = GBPL3ContextServices.createPathObj($scope.selectedTenant.id);
\r
1484 GBPL3ContextServices.load(path, function(data){
\r
1485 $scope.list = data;
\r
1486 $scope.newL3ContextObj = GBPL3ContextServices.createObj();
\r
1487 $scope.selectedL3Context = null;
\r
1494 $scope.save = function(){
\r
1495 if($scope.validateForm($scope.l3ContextForm)){
\r
1496 path = GBPL3ContextServices.createPathObj($scope.selectedTenant.id, $scope.newL3ContextObj.id);
\r
1497 GBPL3ContextServices.send(path, $scope.newL3ContextObj, function(data){
\r
1499 $scope.l3ContextView = false;
\r
1500 $scope.sendReloadEventFromRoot('GBP_L3CONTEXT_RELOAD');
\r
1507 $scope.delete = function() {
\r
1508 if($scope.selectedTenant && $scope.selectedL3Context) {
\r
1509 path = GBPL3ContextServices.createPathObj($scope.selectedTenant.id, $scope.selectedL3Context.id);
\r
1510 GBPL3ContextServices.delete(path, function(data){
\r
1512 $scope.l3ContextView = false;
\r
1513 $scope.sendReloadEventFromRoot('GBP_L3CONTEXT_RELOAD');
\r
1520 $scope.reload = function(selectedObj) {
\r
1521 $scope.selectedL3Context = selectedObj;
\r
1522 if($scope.l3ContextView) {
\r
1523 angular.copy(selectedObj, $scope.newL3ContextObj);
\r
1525 $scope.sendReloadEventFromRoot('GBP_L3CONTEXT_RELOAD');
\r
1528 $scope.showForm = function() {
\r
1529 $scope.newL3ContextObj = GBPL3ContextServices.createObj();
\r
1530 $scope.selectedL3Context = null;
\r
1531 $scope.l3ContextView = true;
\r
1534 $scope.close = function(){
\r
1535 $scope.l3ContextView = false;
\r
1538 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1539 if (!event.defaultPrevented) {
\r
1540 if ( $scope.selectedL3Context ) {
\r
1541 $scope.l3ContextView = true;
\r
1542 angular.copy($scope.selectedL3Context, $scope.newL3ContextObj);
\r
1544 event.defaultPrevented = true;
\r
1548 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
1552 $scope.$on('GBP_L3CONTEXT_LABEL', function(event, obj){
\r
1553 obj.labels = $scope.displayLabel;
\r
1557 gbp.register.controller('subnetCtrl', ['$scope', 'GBPSubnetServices', 'GBPL2FloodDomainServices', 'GBPL2BridgeDomainServices', 'GBPL3ContextServices', '$filter', function($scope, GBPSubnetServices, GBPL2FloodDomainServices, GBPL2BridgeDomainServices, GBPL3ContextServices, $filter){
\r
1559 $scope.subnetView = false;
\r
1560 $scope.selectedSubnet = null;
\r
1561 $scope.newSubnetObj = GBPSubnetServices.createObj();
\r
1562 $scope.displayLabel = ['name', 'id'];
\r
1563 $scope.crudLabel = 'Subnet list';
\r
1565 $scope.l2L3List = {'options' : [], 'labels' : null};
\r
1566 $scope.getDisplayLabelsFromCtrl('GBP_L2FLOOD_LABEL', $scope.l2L3List);
\r
1571 var loadL2L3List = function() {
\r
1572 $scope.l2L3List.options = [];
\r
1574 GBPL3ContextServices.load(GBPL3ContextServices.createPathObj($scope.selectedTenant.id), function(l3ContextData){
\r
1575 $scope.l2L3List.options = $scope.l2L3List.options.concat(l3ContextData);
\r
1580 GBPL2FloodDomainServices.load(GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id), function(l2FloodData){
\r
1581 $scope.l2L3List.options = $scope.l2L3List.options.concat(l2FloodData);
\r
1586 GBPL2BridgeDomainServices.load(GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id), function(l2BridgeData){
\r
1587 $scope.l2L3List.options = $scope.l2L3List.options.concat(l2BridgeData);
\r
1593 $scope.init = function() {
\r
1594 if ( $scope.selectedTenant ) {
\r
1595 path = GBPSubnetServices.createPathObj($scope.selectedTenant.id);
\r
1597 GBPSubnetServices.load(path, function(data){
\r
1598 $scope.list = data;
\r
1599 $scope.newSubnetObj = GBPSubnetServices.createObj();
\r
1600 $scope.selectedSubnet = null;
\r
1601 //$scope.sendReloadEventFromRoot('GBP_L2BRIDGE_RELOAD');
\r
1610 $scope.save = function(){
\r
1611 if($scope.validateForm($scope.subnetForm)){
\r
1612 path = GBPSubnetServices.createPathObj($scope.selectedTenant.id, $scope.newSubnetObj.id);
\r
1613 GBPSubnetServices.send(path, $scope.newSubnetObj, function(data){
\r
1615 $scope.subnetView = false;
\r
1622 $scope.delete = function() {
\r
1623 if($scope.selectedTenant && $scope.selectedSubnet) {
\r
1624 path = GBPSubnetServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id);
\r
1625 GBPSubnetServices.delete(path, function(data){
\r
1627 $scope.subnetView = false;
\r
1634 $scope.reload = function(selectedObj) {
\r
1635 $scope.selectedSubnet = selectedObj;
\r
1636 if($scope.subnetView) {
\r
1637 angular.copy(selectedObj, $scope.newSubnetObj);
\r
1639 $scope.sendReloadEventFromRoot('GBP_SUBNET_RELOAD');
\r
1642 $scope.showForm = function() {
\r
1643 $scope.newSubnetObj = GBPSubnetServices.createObj();
\r
1644 $scope.selectedSubnet = null;
\r
1645 $scope.subnetView = true;
\r
1648 $scope.close = function(){
\r
1649 $scope.subnetView = false;
\r
1652 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1653 if (!event.defaultPrevented) {
\r
1654 if ( $scope.selectedSubnet ) {
\r
1655 $scope.subnetView = true;
\r
1656 angular.copy($scope.selectedSubnet, $scope.newSubnetObj);
\r
1658 event.defaultPrevented = true;
\r
1662 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
1666 $scope.$on('GBP_GATEWAY_RELOAD',function(){
\r
1670 $scope.$on('GBP_L3CONTEXT_RELOAD',function(){
\r
1674 $scope.$on('GBP_L2BRIDGE_RELOAD',function(){
\r
1678 $scope.$on('GBP_L2FLOOD_RELOAD',function(){
\r
1682 $scope.$on('GBP_PREFIX_RELOAD',function(){
\r
1688 gbp.register.controller('gatewayCtrl', ['$scope', 'GBPGatewayServices', function($scope, GBPGatewayServices){
\r
1690 $scope.gatewayView = false;
\r
1691 $scope.selectedGateway = null;
\r
1692 $scope.newGatewayObj = GBPGatewayServices.createObj();
\r
1693 $scope.displayLabel = 'gateway';
\r
1694 $scope.crudLabel = 'Gateway list';
\r
1703 $scope.init = function() {
\r
1704 if ( $scope.selectedTenant && $scope.selectedSubnet ) {
\r
1705 path = GBPGatewayServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id);
\r
1707 GBPGatewayServices.load(path, function(data){
\r
1708 $scope.list = data;
\r
1709 $scope.newGatewayObj = GBPGatewayServices.createObj();
\r
1710 $scope.view.gateway = false;
\r
1711 $scope.selectedGateway = null;
\r
1718 $scope.save = function(){
\r
1719 if($scope.validateForm($scope.gatewayForm)){
\r
1720 path = GBPGatewayServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id, $scope.newGatewayObj.gateway);
\r
1721 GBPGatewayServices.send(path, $scope.newGatewayObj, function(data){
\r
1723 $scope.view.gateway = false;
\r
1724 $scope.sendReloadEventFromRoot('GBP_GATEWAY_RELOAD');
\r
1731 $scope.delete = function() {
\r
1732 if($scope.selectedTenant && $scope.selectedSubnet && $scope.selectedGateway) {
\r
1733 path = GBPGatewayServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id, $scope.selectedGateway.gateway);
\r
1734 GBPGatewayServices.delete(path, function(data){
\r
1736 $scope.view.gateway = false;
\r
1737 $scope.sendReloadEventFromRoot('GBP_GATEWAY_RELOAD');
\r
1744 $scope.reload = function(selectedObj) {
\r
1745 $scope.selectedGateway = selectedObj;
\r
1746 angular.copy(selectedObj, $scope.newGatewayObj);
\r
1747 $scope.sendReloadEventFromRoot('GBP_GATEWAY_SET');
\r
1750 $scope.showForm = function() {
\r
1751 $scope.newGatewayObj = GBPGatewayServices.createObj();
\r
1752 $scope.view.gateway = true;
\r
1753 $scope.view.edit = false;
\r
1754 $scope.selectedGateway = null;
\r
1757 $scope.close = function(){
\r
1758 $scope.view.gateway = false;
\r
1761 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1762 if (!event.defaultPrevented) {
\r
1763 if ( $scope.selectedGateway ) {
\r
1764 $scope.view.gateway = true;
\r
1765 $scope.view.edit = true;
\r
1766 angular.copy($scope.selectedGateway, $scope.newGatewayObj);
\r
1768 event.defaultPrevented = true;
\r
1772 $scope.$on('GBP_SUBNET_RELOAD',function(){
\r
1776 $scope.$on('GBP_PREFIX_RELOAD',function(){
\r
1781 gbp.register.controller('prefixCtrl', ['$scope', 'GBPPrefixServices', function($scope, GBPPrefixServices){
\r
1783 $scope.selectedPrefix = null;
\r
1784 $scope.newPrefixObj = GBPPrefixServices.createObj();
\r
1785 $scope.displayLabel = 'prefix';
\r
1786 $scope.crudLabel = 'Prefix list';
\r
1795 $scope.init = function() {
\r
1796 if ( $scope.selectedTenant && $scope.selectedSubnet && $scope.selectedGateway) {
\r
1797 path = GBPPrefixServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id, $scope.selectedGateway.gateway);
\r
1799 GBPPrefixServices.load(path, function(data){
\r
1800 $scope.list = data;
\r
1801 $scope.newPrefixObj = GBPPrefixServices.createObj();
\r
1802 $scope.view.prefix = false;
\r
1803 $scope.selectedPrefix = null;
\r
1810 $scope.save = function(){
\r
1811 if($scope.validateForm($scope.prefixForm)){
\r
1812 path = GBPPrefixServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id, $scope.selectedGateway.gateway, $scope.newPrefixObj.prefix);
\r
1813 GBPPrefixServices.send(path, $scope.newPrefixObj, function(data){
\r
1815 $scope.view.prefix = false;
\r
1816 $scope.sendReloadEventFromRoot('GBP_PREFIX_RELOAD');
\r
1823 $scope.delete = function() {
\r
1824 path = GBPPrefixServices.createPathObj($scope.selectedTenant.id, $scope.selectedSubnet.id, $scope.selectedGateway.gateway, $scope.selectedPrefix.prefix);
\r
1825 GBPPrefixServices.delete(path, function(data){
\r
1827 $scope.view.prefix = false;
\r
1828 $scope.sendReloadEventFromRoot('GBP_PREFIX_RELOAD');
\r
1834 $scope.reload = function(selectedObj) {
\r
1835 $scope.selectedPrefix = selectedObj;
\r
1836 angular.copy(selectedObj, $scope.newPrefixObj);
\r
1839 $scope.showForm = function() {
\r
1840 $scope.newPrefixObj = GBPPrefixServices.createObj();
\r
1841 $scope.view.prefix = true;
\r
1842 $scope.view.edit = false;
\r
1843 $scope.selectedPrefix = null;
\r
1846 $scope.close = function(){
\r
1847 $scope.view.prefix = false;
\r
1850 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1851 if (!event.defaultPrevented) {
\r
1852 if ( $scope.selectedPrefix ) {
\r
1853 $scope.view.prefix = true;
\r
1854 $scope.view.edit = true;
\r
1855 angular.copy($scope.selectedPrefix, $scope.newPrefixObj);
\r
1857 event.defaultPrevented = true;
\r
1861 $scope.$on('GBP_GATEWAY_SET',function(){
\r
1866 gbp.register.controller('renderersCtrl', ['$scope', 'GPBServices', function($scope, GPBServices){ //GBPContractServices
\r
1867 $scope.classifierDefinitions = {'options' : [], 'labels' : null};
\r
1868 $scope.actionDefinitions = {'options' : [], 'labels' : null};
\r
1870 //reload on event?
\r
1872 var loadDefinitions = function() {
\r
1873 GPBServices.getDefinitions(function(classifierDefs, actionDefs) {
\r
1874 $scope.classifierDefinitions.options = classifierDefs;
\r
1875 $scope.getDisplayLabelsFromCtrl('GBP_CLASSIFIERS_LABEL', $scope.classifierDefinitions);
\r
1877 $scope.actionDefinitions.options = actionDefs;
\r
1878 $scope.getDisplayLabelsFromCtrl('GBP_ACTIONS_LABEL', $scope.actionDefinitions);
\r
1882 loadDefinitions();
\r
1885 gbp.register.controller('paramCtrl', ['$scope', 'GPBServices', function($scope, GPBServices){
\r
1886 $scope.value = null;
\r
1888 $scope.init = function(param, paramValues) {
\r
1889 $scope.parameter = param;
\r
1892 paramValues.forEach(function(p) {
\r
1893 if($scope.parameter.name === p.name) {
\r
1894 $scope.value = GPBServices.getInstanceParamValue(p);
\r
1900 $scope.$on('GBP_SAVE_PARAM', function(event){
\r
1901 if($scope.value !== '' && $scope.value !== null) {
\r
1902 $scope.addParam($scope.parameter.name, $scope.parameter.type, $scope.value);
\r
1906 $scope.$on('GBP_SET_PARAM_VALUE', function(event, name, intVal, strVal) {
\r
1907 console.info($scope.parameter, ' got GBP_SET_PARAM_VALUE', name, intVal, strVal, event);
\r
1912 gbp.register.controller('classifiersCtrl', ['$scope', 'GBPClassifierInstanceServices', 'GPBServices', '$filter',
\r
1913 function($scope, GBPClassifierInstanceServices, GPBServices, $filter){
\r
1915 $scope.classifiersView = false;
\r
1916 $scope.displayLabel = 'name';
\r
1917 $scope.selectedClassifier = null;
\r
1918 $scope.crudLabel = 'Classifiers';
\r
1919 $scope.newClassifierObj = GBPClassifierInstanceServices.createObj();
\r
1920 $scope.edit = false;
\r
1922 var mandatoryProperties = ['name'];
\r
1924 $scope.getDefinitionObjParams = function(id){
\r
1925 return GPBServices.getDefinitionObjParams($scope.classifierDefinitions.options, id);
\r
1928 $scope.reloadDefs = function(){
\r
1929 $scope.defs = angular.copy($scope.getDefinitionObjParams($scope.newClassifierObj['classifier-definition-id']));
\r
1932 $scope.addParam = function(name, type, value) {
\r
1933 $scope.newClassifierObj['parameter-value'].push(GPBServices.createParamObj(name, type, value));
\r
1936 var saveParams = function() {
\r
1937 $scope.newClassifierObj['parameter-value'] = [];
\r
1938 $scope.$broadcast('GBP_SAVE_PARAM');
\r
1942 $scope.init = function() {
\r
1943 if ( $scope.selectedTenant ) {
\r
1944 path = GBPClassifierInstanceServices.createPathObj($scope.selectedTenant.id);
\r
1945 GBPClassifierInstanceServices.load(path, function(data){
\r
1946 $scope.list = data;
\r
1947 $scope.reloadDefs();
\r
1954 $scope.save = function(){
\r
1955 if($scope.validateForm($scope.classifierForm)){
\r
1956 path = GBPClassifierInstanceServices.createPathObj($scope.selectedTenant.id, $scope.newClassifierObj.name);
\r
1958 GBPClassifierInstanceServices.send(path, $scope.newClassifierObj, function(data){
\r
1960 $scope.classifiersView = false;
\r
1961 $scope.sendReloadEventFromRoot('GBP_CLASSIFIER_INSTANCE_RELOAD');
\r
1968 $scope.showForm = function() {
\r
1969 $scope.newClassifierObj = GBPClassifierInstanceServices.createObj();
\r
1970 $scope.selectedClassifier = null;
\r
1971 $scope.classifiersView = true;
\r
1972 $scope.edit = false;
\r
1973 $scope.reloadDefs();
\r
1976 $scope.reload = function(selectedObj){
\r
1977 $scope.selectedClassifier = selectedObj;
\r
1978 if($scope.classifiersView) {
\r
1979 angular.copy(selectedObj, $scope.newClassifierObj);
\r
1981 $scope.sendReloadEventFromRoot('GBP_CLASSIFIER_INSTANCE_RELOAD');
\r
1982 $scope.reloadDefs();
\r
1985 $scope.close = function(){
\r
1986 $scope.classifiersView = false;
\r
1987 $scope.edit = false;
\r
1990 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
1991 if (!event.defaultPrevented) {
\r
1992 if ( $scope.selectedClassifier ) {
\r
1993 $scope.classifiersView = true;
\r
1994 angular.copy($scope.selectedClassifier, $scope.newClassifierObj);
\r
1995 $scope.edit = true;
\r
1996 $scope.reloadDefs();
\r
1998 event.defaultPrevented = true;
\r
2002 $scope.delete = function(){
\r
2003 path = GBPClassifierInstanceServices.createPathObj($scope.selectedTenant.id, $scope.selectedClassifier.name);
\r
2004 GBPClassifierInstanceServices.delete(path, function(data){
\r
2006 $scope.classifiersView = false;
\r
2007 $scope.sendReloadEventFromRoot('GBP_CLASSIFIER_INSTANCE_RELOAD');
\r
2013 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
2017 $scope.$on('GBP_CLASSIFIERS_LABEL', function(event, obj){
\r
2018 obj.labels = $scope.displayLabel;
\r
2022 gbp.register.controller('actionsCtrl', ['$scope', 'GBPActionInstanceServices', 'GPBServices', '$filter',
\r
2023 function($scope, GBPActionInstanceServices, GPBServices, $filter){
\r
2025 $scope.actionsView = false;
\r
2026 $scope.displayLabel = 'name';
\r
2027 $scope.selectedAction = null;
\r
2028 $scope.crudLabel = 'Actions';
\r
2029 $scope.newActionObj = GBPActionInstanceServices.createObj();
\r
2030 $scope.edit = false;
\r
2032 var mandatoryProperties = ['name'];
\r
2034 $scope.getDefinitionObjParams = function(id){
\r
2035 return GPBServices.getDefinitionObjParams($scope.actionDefinitions.options, id);
\r
2038 $scope.reloadDefs = function(){
\r
2039 $scope.defs = angular.copy($scope.getDefinitionObjParams($scope.newActionObj['action-definition-id']));
\r
2042 $scope.addParam = function(name, type, value) {
\r
2043 $scope.newActionObj['parameter-value'].push(GPBServices.createParamObj(name, type, value));
\r
2046 var saveParams = function() {
\r
2047 $scope.newActionObj['parameter-value'] = [];
\r
2048 $scope.$broadcast('GBP_SAVE_PARAM');
\r
2052 $scope.init = function() {
\r
2053 if ( $scope.selectedTenant ) {
\r
2054 path = GBPActionInstanceServices.createPathObj($scope.selectedTenant.id);
\r
2055 GBPActionInstanceServices.load(path, function(data){
\r
2056 $scope.list = data;
\r
2057 $scope.reloadDefs();
\r
2064 $scope.save = function(){
\r
2065 if($scope.validateForm($scope.actionsForm)){
\r
2066 path = GBPActionInstanceServices.createPathObj($scope.selectedTenant.id, $scope.newActionObj.name);
\r
2069 GBPActionInstanceServices.send(path, $scope.newActionObj, function(data){
\r
2071 $scope.actionsView = false;
\r
2072 $scope.sendReloadEventFromRoot('GBP_ACTION_INSTANCE_RELOAD');
\r
2079 $scope.showForm = function() {
\r
2080 $scope.newActionObj = GBPActionInstanceServices.createObj();
\r
2081 $scope.selectedAction = null;
\r
2082 $scope.actionsView = true;
\r
2083 $scope.edit = false;
\r
2084 $scope.reloadDefs();
\r
2087 $scope.reload = function(selectedObj){
\r
2088 $scope.selectedAction = selectedObj;
\r
2089 if($scope.actionsView) {
\r
2090 angular.copy(selectedObj, $scope.newActionObj);
\r
2092 $scope.sendReloadEventFromRoot('GBP_ACTION_INSTANCE_RELOAD');
\r
2093 $scope.reloadDefs();
\r
2096 $scope.close = function(){
\r
2097 $scope.actionsView = false;
\r
2098 $scope.edit = false;
\r
2101 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
2102 if (!event.defaultPrevented) {
\r
2103 if ( $scope.selectedAction ) {
\r
2104 $scope.actionsView = true;
\r
2105 angular.copy($scope.selectedAction, $scope.newActionObj);
\r
2106 $scope.edit = true;
\r
2107 $scope.reloadDefs();
\r
2109 event.defaultPrevented = true;
\r
2113 $scope.delete = function(){
\r
2114 path = GBPActionInstanceServices.createPathObj($scope.selectedTenant.id, $scope.selectedAction.name);
\r
2115 GBPActionInstanceServices.delete(path, function(data){
\r
2117 $scope.actionsView = false;
\r
2118 $scope.sendReloadEventFromRoot('GBP_ACTION_INSTANCE_RELOAD');
\r
2124 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
2128 $scope.$on('GBP_ACTIONS_LABEL', function(event, obj){
\r
2129 obj.labels = $scope.displayLabel;
\r
2133 gbp.register.controller('endpointCtrl', ['$scope', 'GBPEndpointServices', 'GPBServices', 'GBPL2FloodDomainServices', 'GBPL2BridgeDomainServices', 'GBPL3ContextServices', 'GBPEpgServices', '$filter',
\r
2134 function($scope, GBPEndpointServices, GPBServices, GBPL2FloodDomainServices, GBPL2BridgeDomainServices, GBPL3ContextServices, GBPEpgServices, $filter){
\r
2136 $scope.selectedEndpoint = null;
\r
2137 $scope.newEndpointObj = GBPEndpointServices.createObj();
\r
2138 $scope.endpointView = false;
\r
2139 $scope.displayLabel = function(obj) {
\r
2140 return obj['mac-address'] + ':' + obj['l2-context'];
\r
2142 $scope.crudLabel = 'Endpoint list';
\r
2144 $scope.l2context = {'options' : [], 'labels' : null};
\r
2145 $scope.getDisplayLabelsFromCtrl('GBP_L2FLOOD_LABEL', $scope.l2context);
\r
2147 $scope.l3context = {'options' : [], 'labels' : null};
\r
2148 $scope.getDisplayLabelsFromCtrl('GBP_L3CONTEXT_LABEL', $scope.l3context);
\r
2150 $scope.epg = {'options' : [], 'labels' : null};
\r
2151 $scope.getDisplayLabelsFromCtrl('GBP_EPG_LABEL', $scope.epg);
\r
2154 mandatoryProperties = [];
\r
2156 var loadEpgOptions = function() {
\r
2157 $scope.epg.options = [];
\r
2159 path = GBPEpgServices.createPathObj($scope.selectedTenant.id);
\r
2160 GBPEpgServices.load(path, function(data){
\r
2161 $scope.epg.options = data;
\r
2167 var loadL2ContextOptions = function() {
\r
2168 $scope.l2context.options = [];
\r
2170 path = GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id);
\r
2172 GBPL2FloodDomainServices.load(path, function(data){
\r
2173 $scope.l2context.options = $scope.l2context.options.concat(data);
\r
2178 path = GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id);
\r
2179 GBPL2BridgeDomainServices.load(path, function(data){
\r
2180 $scope.l2context.options = $scope.l2context.options.concat(data);
\r
2186 var loadL3ContextOptions = function(){
\r
2187 $scope.l3context.options = [];
\r
2189 GBPL3ContextServices.load(GBPL3ContextServices.createPathObj($scope.selectedTenant.id), function(data){
\r
2190 $scope.l3context.options = data;
\r
2196 $scope.init = function() {
\r
2197 if ($scope.selectedTenant) {
\r
2199 GBPEndpointServices.load(path, function(data){
\r
2200 $scope.list = data;
\r
2206 loadL2ContextOptions();
\r
2207 loadL3ContextOptions();
\r
2211 $scope.addNewL3address = function() {
\r
2212 if($scope.newEndpointObj) {
\r
2213 if(!$scope.newEndpointObj['l3-address']){
\r
2214 $scope.newEndpointObj['l3-address'] = [];
\r
2216 var objToPush = {'l3-context' : '', 'ip-address' : ''};
\r
2217 $scope.newEndpointObj['l3-address'].push(objToPush);
\r
2221 $scope.deleteNewL3address = function(index){
\r
2222 if($scope.newEndpointObj) {
\r
2223 $scope.newEndpointObj['l3-address'].splice(index, 1);
\r
2227 $scope.addNewLeafListEl = function(prop) {
\r
2228 if($scope.newEndpointObj) {
\r
2229 if(!$scope.newEndpointObj[prop]){
\r
2230 $scope.newEndpointObj[prop] = [];
\r
2232 var objToPush = "";
\r
2233 $scope.newEndpointObj[prop].push(objToPush);
\r
2237 $scope.updateLeafListEl = function(index, value, prop) {
\r
2238 if($scope.newEndpointObj && $scope.newEndpointObj[prop] && $scope.newEndpointObj[prop].length >= index) {
\r
2239 $scope.newEndpointObj[prop][index] = value;
\r
2243 $scope.deleteNewLeafListEl = function(index, prop){
\r
2244 if($scope.newEndpointObj) {
\r
2245 $scope.newEndpointObj[prop].splice(index, 1);
\r
2249 $scope.save = function(){
\r
2250 if($scope.validateForm($scope.endpointForm)){
\r
2251 GBPEndpointServices.send(path, $scope.newEndpointObj, function(data){
\r
2253 $scope.endpointView = false;
\r
2254 $scope.reloadNewObj();
\r
2261 $scope.delete = function() {
\r
2262 if($scope.selectedTenant && $scope.selectedEndpoint) {
\r
2263 GBPEndpointServices.delete(path, $scope.selectedEndpoint, function(data){
\r
2265 $scope.endpointView = false;
\r
2272 $scope.showForm = function() {
\r
2273 $scope.endpointView = true;
\r
2274 $scope.reloadNewObj();
\r
2275 $scope.selectedEndpoint = null;
\r
2278 $scope.reloadNewObj = function() {
\r
2279 $scope.newEndpointObj = GBPEndpointServices.createObj();
\r
2282 $scope.reload = function(selectedObj) {
\r
2283 $scope.selectedEndpoint = selectedObj;
\r
2284 if($scope.endpointView) {
\r
2285 angular.copy(selectedObj, $scope.newEndpointObj);
\r
2289 $scope.close = function(){
\r
2290 $scope.endpointView = false;
\r
2293 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
2294 if (!event.defaultPrevented) {
\r
2295 if ( $scope.selectedEndpoint ) {
\r
2296 $scope.endpointView = true;
\r
2297 angular.copy($scope.selectedEndpoint, $scope.newEndpointObj);
\r
2299 event.defaultPrevented = true;
\r
2303 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
2307 $scope.$on('GBP_EPG_RELOAD',function(){
\r
2311 $scope.$on('GBP_L2BRIDGE_RELOAD',function(){
\r
2312 loadL2ContextOptions();
\r
2315 $scope.$on('GBP_L2FLOOD_RELOAD',function(){
\r
2316 loadL2ContextOptions();
\r
2319 $scope.$on('GBP_L3CONTEXT_RELOAD',function(){
\r
2320 loadL3ContextOptions();
\r
2324 gbp.register.controller('l3EndpointCtrl', ['$scope', 'GBPEndpointL3Services', 'GPBServices', 'GBPEpgServices', 'GBPL3ContextServices', 'GBPL2FloodDomainServices', 'GBPL2BridgeDomainServices', '$filter',
\r
2325 function($scope, GBPEndpointL3Services, GPBServices, GBPEpgServices, GBPL3ContextServices, GBPL2FloodDomainServices, GBPL2BridgeDomainServices, $filter){
\r
2327 $scope.selectedEndpoint = null;
\r
2328 $scope.newEndpointObj = GBPEndpointL3Services.createObj($scope.selectedTenant ? $scope.selectedTenant.id : null);
\r
2329 $scope.endpointView = false;
\r
2330 $scope.displayLabel = function(obj) {
\r
2331 return obj['ip-prefix'] + ':' + obj['l3-context'];
\r
2333 $scope.crudLabel = 'L3 Prefix endpoint list';
\r
2335 $scope.l2context = {'options' : [], 'labels' : null};
\r
2336 $scope.getDisplayLabelsFromCtrl('GBP_L2FLOOD_LABEL', $scope.l2context);
\r
2338 $scope.l3context = {'options' : [], 'labels' : null};
\r
2339 $scope.getDisplayLabelsFromCtrl('GBP_L3CONTEXT_LABEL', $scope.l3context);
\r
2341 $scope.epg = {'options' : [], 'labels' : null};
\r
2342 $scope.getDisplayLabelsFromCtrl('GBP_EPG_LABEL', $scope.epg);
\r
2346 mandatoryProperties = [];
\r
2348 var loadEpgOptions = function() {
\r
2349 $scope.epg.options = [];
\r
2351 path = GBPEpgServices.createPathObj($scope.selectedTenant.id);
\r
2352 GBPEpgServices.load(path, function(data){
\r
2353 $scope.epg.options = data;
\r
2359 var loadL2ContextOptions = function() {
\r
2360 $scope.l2context.options = [];
\r
2362 path = GBPL2FloodDomainServices.createPathObj($scope.selectedTenant.id);
\r
2364 GBPL2FloodDomainServices.load(path, function(data){
\r
2365 $scope.l2context.options = $scope.l2context.options.concat(data);
\r
2370 path = GBPL2BridgeDomainServices.createPathObj($scope.selectedTenant.id);
\r
2371 GBPL2BridgeDomainServices.load(path, function(data){
\r
2372 $scope.l2context.options = $scope.l2context.options.concat(data);
\r
2378 var loadL3ContextOptions = function(){
\r
2379 $scope.l3context.options = [];
\r
2381 GBPL3ContextServices.load(GBPL3ContextServices.createPathObj($scope.selectedTenant.id), function(data){
\r
2382 $scope.l3context.options = data;
\r
2388 $scope.init = function() {
\r
2389 if ($scope.selectedTenant) {
\r
2391 GBPEndpointL3Services.load(path, function(data){
\r
2392 $scope.list = data;
\r
2398 loadL2ContextOptions();
\r
2399 loadL3ContextOptions();
\r
2403 $scope.addNewL2gateways = function() {
\r
2404 if($scope.newEndpointObj) {
\r
2405 if(!$scope.newEndpointObj['endpoint-l2-gateways']){
\r
2406 $scope.newEndpointObj['endpoint-l2-gateways'] = [];
\r
2408 var objToPush = {'l2-context' : '', 'mac-address' : ''};
\r
2409 $scope.newEndpointObj['endpoint-l2-gateways'].push(objToPush);
\r
2413 $scope.deleteNewL2gateways = function(index){
\r
2414 if($scope.newEndpointObj) {
\r
2415 $scope.newEndpointObj['endpoint-l2-gateways'].splice(index, 1);
\r
2419 $scope.addNewL3gateways = function() {
\r
2420 if($scope.newEndpointObj) {
\r
2421 if(!$scope.newEndpointObj['endpoint-l3-gateways']){
\r
2422 $scope.newEndpointObj['endpoint-l3-gateways'] = [];
\r
2424 var objToPush = {'l3-context' : '', 'ip-address' : ''};
\r
2425 $scope.newEndpointObj['endpoint-l3-gateways'].push(objToPush);
\r
2429 $scope.deleteNewL3gateways = function(index){
\r
2430 if($scope.newEndpointObj) {
\r
2431 $scope.newEndpointObj['endpoint-l3-gateways'].splice(index, 1);
\r
2435 $scope.addNewLeafListEl = function(prop) {
\r
2436 if($scope.newEndpointObj) {
\r
2437 if(!$scope.newEndpointObj[prop]){
\r
2438 $scope.newEndpointObj[prop] = [];
\r
2440 var objToPush = "";
\r
2441 $scope.newEndpointObj[prop].push(objToPush);
\r
2445 $scope.updateLeafListEl = function(index, value, prop) {
\r
2446 if($scope.newEndpointObj && $scope.newEndpointObj[prop] && $scope.newEndpointObj[prop].length >= index) {
\r
2447 $scope.newEndpointObj[prop][index] = value;
\r
2451 $scope.deleteNewLeafListEl = function(index, prop){
\r
2452 if($scope.newEndpointObj) {
\r
2453 $scope.newEndpointObj[prop].splice(index, 1);
\r
2457 $scope.save = function(){
\r
2458 if($scope.validateForm($scope.l3EndpointForm)){
\r
2459 GBPEndpointL3Services.send(path, $scope.newEndpointObj, function(data){
\r
2461 $scope.endpointView = false;
\r
2462 $scope.reloadNewObj();
\r
2469 $scope.delete = function() {
\r
2470 if($scope.selectedTenant && $scope.selectedEndpoint) {
\r
2471 GBPEndpointL3Services.delete(path, $scope.selectedEndpoint, function(data){
\r
2479 $scope.showForm = function() {
\r
2480 $scope.endpointView = true;
\r
2481 $scope.reloadNewObj();
\r
2482 $scope.selectedEndpoint = null;
\r
2485 $scope.reloadNewObj = function() {
\r
2486 $scope.newEndpointObj = GBPEndpointL3Services.createObj($scope.selectedTenant.id);
\r
2489 $scope.reload = function(selectedObj) {
\r
2490 $scope.selectedEndpoint = selectedObj;
\r
2491 if($scope.endpointView) {
\r
2492 angular.copy(selectedObj, $scope.newEndpointObj);
\r
2496 $scope.close = function(){
\r
2497 $scope.endpointView = false;
\r
2500 $scope.$on('PGN_EDIT_ELEM', function(event){
\r
2501 if (!event.defaultPrevented) {
\r
2502 if ( $scope.selectedEndpoint ) {
\r
2503 $scope.endpointView = true;
\r
2504 angular.copy($scope.selectedEndpoint, $scope.newEndpointObj);
\r
2506 event.defaultPrevented = true;
\r
2510 $scope.$on('GBP_TENANT_RELOAD',function(){
\r
2514 $scope.$on('GBP_EPG_RELOAD',function(){
\r
2518 $scope.$on('GBP_L2BRIDGE_RELOAD',function(){
\r
2519 loadL2ContextOptions();
\r
2522 $scope.$on('GBP_L2FLOOD_RELOAD',function(){
\r
2523 loadL2ContextOptions();
\r
2526 $scope.$on('GBP_L3CONTEXT_RELOAD',function(){
\r
2527 loadL3ContextOptions();
\r