diff options
author | 2016-02-06 00:55:22 +0100 | |
---|---|---|
committer | 2016-02-07 18:46:47 +0000 | |
commit | df53da6e0a476db6c0e46b9d5e6c2b5d620c600a (patch) | |
tree | dd2798287ab227df2708fecfb1bfcd5736dce496 /vbd/gui/module/src/main/resources/vpp/controllers | |
parent | 0280a5f3852e30b7d28747fcf43adaa6a11b5a13 (diff) |
vBDManager services initial commit
- added add/get/object definitions for vBD, VPP and Interfaces
Change-Id: Ic639f06fad5700a1722fdb0b1034b8134bdb1c41
Signed-off-by: Daniel Malachovsky <daniel.malachovsky@pantheon.sk>
Diffstat (limited to 'vbd/gui/module/src/main/resources/vpp/controllers')
3 files changed, 232 insertions, 92 deletions
diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js index 02c9879a8..b49fe8af8 100644 --- a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js +++ b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js @@ -11,7 +11,6 @@ define(['app/vpp/vpp.module'], function(vpp) { }]); - vpp.register.controller('TableController', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) { var vm = this; vm.rowCollection = dataService.tableContent; @@ -34,94 +33,110 @@ define(['app/vpp/vpp.module'], function(vpp) { }; }]); - vpp.register.controller('BridgeDomainsController', function(dataService, $location, $mdDialog, toastService) { - var vm = this; - vm.dataService = dataService; - - dataService.nextApp.container(document.getElementById('bridge-domains-next-app')); - dataService.bridgeDomainsTopo.attach(dataService.nextApp); - - window.addEventListener('resize', function () { - if ($location.path() === '/bridgedomains') { - dataService.topo.adaptToContainer(); - } - }); - - vm.bridgedomains = dataService.bridgedomains; - vm.selectedBd = dataService.selectedBd; - - dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) { - console.log(node); - }); - - vm.bdChanged = function() { - dataService.injectBridgeDomainsTopoElements(); - dataService.buildTableContent(); - }; - - vm.addBd = function() { - //show dialog - $mdDialog.show({ - controller: function() { - var vm = this; - vm.bd = {}; - vm.waiting = false; - - //function called when the cancel button ( 'x' in the top right) is clicked - vm.close = function() { - $mdDialog.cancel(); - }; - - vm.isDone = function(status) { + vpp.register.controller('BridgeDomainsController', ['$scope', '$rootScope','$filter', 'dataService', 'bdmBridgeDomainService', 'toastService', + function($scope, $rootScope, $filter, dataService, bdmBridgeDomainService, toastService) { + $scope.addBd = function() { + var obj = bdmBridgeDomainService.createObj('vBD' + ((Math.random() * 100) + 1) ); + + bdmBridgeDomainService.add(obj, + function(data) { + console.log('successadding vbd'); + }, + function() { + console.warn('add bd failed'); + }); + }; + + /*var vm = this; + vm.dataService = dataService; + + dataService.nextApp.container(document.getElementById('bridge-domains-next-app')); + dataService.bridgeDomainsTopo.attach(dataService.nextApp); + + window.addEventListener('resize', function () { + if ($location.path() === '/bridgedomains') { + dataService.topo.adaptToContainer(); + } + }); + + vm.bridgedomains = dataService.bridgedomains; + vm.selectedBd = dataService.selectedBd; + + dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) { + console.log(node); + }); + + vm.bdChanged = function() { + dataService.injectBridgeDomainsTopoElements(); + dataService.buildTableContent(); + }; + + vm.addBd = function() { + //show dialog + $mdDialog.show({ + controller: function() { + var vm = this; + vm.bd = {}; vm.waiting = false; - if (status === 'success') { - dataService.bridgedomains.push(vm.bd); - dataService.selectedBd.name = vm.bd.name; - dataService.injectBridgeDomainsTopoElements(); - dataService.buildTableContent(); - vm.close(); - } - }; - //function called when the update button is clicked - vm.updateConfig = function() { - vm.waiting = true; - //send a POST with the entered content in the form field + //function called when the cancel button ( 'x' in the top right) is clicked + vm.close = function() { + $mdDialog.cancel(); + }; + + vm.isDone = function(status) { + vm.waiting = false; + if (status === 'success') { + dataService.bridgedomains.push(vm.bd); + dataService.selectedBd.name = vm.bd.name; + dataService.injectBridgeDomainsTopoElements(); + dataService.buildTableContent(); + vm.close(); + } + }; + + //function called when the update button is clicked + vm.updateConfig = function() { + vm.waiting = true; + //send a POST with the entered content in the form field + + }; + }, + controllerAs: 'NewBdDialogCtrl', + templateUrl: 'templates/new-bd-dialog.html', + parent: angular.element(document.body), + clickOutsideToClose:false + }) + }; + + + + vm.deploy = function() { + + }; + + vm.removeBd = function() { + if(vm.selectedBd.name) { + var successCallback = function(success) { + if (success) { + console.log(vm.bridgedomains); + _.remove(vm.bridgedomains, { + name: vm.selectedBd.name + }); + toastService.showToast('Bridge Domain Removed!'); + vm.selectedBd.name = ''; + dataService.clearInjectedInterfacesInBridgeDomainTopo(); + dataService.injectBdIntoBridgeDomainsTopo(); + dataService.tableContent.length = 0; + } else { + toastService.showToast('Error removing Bridge Domain!'); + } }; - }, - controllerAs: 'NewBdDialogCtrl', - templateUrl: 'templates/new-bd-dialog.html', - parent: angular.element(document.body), - clickOutsideToClose:false - }) - }; - vm.deploy = function() { - - }; - - vm.removeBd = function() { - if(vm.selectedBd.name) { - var successCallback = function(success) { - if (success) { - console.log(vm.bridgedomains); - _.remove(vm.bridgedomains, { - name: vm.selectedBd.name - }); - toastService.showToast('Bridge Domain Removed!'); - vm.selectedBd.name = ''; - dataService.clearInjectedInterfacesInBridgeDomainTopo(); - dataService.injectBdIntoBridgeDomainsTopo(); - dataService.tableContent.length = 0; - } else { - toastService.showToast('Error removing Bridge Domain!'); - - } - }; - - //... removeBdFromOdl(vm.selectedBd.name, successCallback); - } - }; - }); + //... removeBdFromOdl(vm.selectedBd.name, successCallback); + } + }; + */ + }]); });
\ No newline at end of file diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js index 5ef5c3c6a..69dfd2fcb 100644 --- a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js +++ b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js @@ -7,11 +7,136 @@ */ define(['app/vpp/vpp.module'], function(vpp) { + vpp.register.controller('bdmCtrl', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) { - vpp.register.controller('bdmVppCtrl', ['$scope', '$rootScope', '$timeout' ,'dataService', 'toastService', '$mdSidenav', '$mdDialog', - function ($scope, $rootScope, $timeout ,dataService, toastService, $mdSidenav, $mdDialog) { + }]); - }]); + vpp.register.controller('TableController', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) { + var vm = this; + vm.rowCollection = dataService.tableContent; + vm.displayedCollection = [].concat(vm.rowCollection); + vm.updateAssignment = function(receivedInterface) { + var interf = _.find(dataService.interfaces, {name: receivedInterface.name, 'phys-address': receivedInterface['phys-address']}); + angular.copy(receivedInterface, interf); + if (interf.assigned){ + interf['v3po:l2']['bridge-domain'] = dataService.selectedBd.name; + } else { + interf['v3po:l2']['bridge-domain'] = ''; + } + dataService.injectBridgeDomainsTopoElements(); + dataService.buildTableContent(); + var previouslyChangedInterface = _.find(dataService.changedInterfaces, {name: interf.name, 'phys-address': interf['phys-address']}); + if (!previouslyChangedInterface) { + dataService.changedInterfaces.push(interf); + } + console.log(dataService.changedInterfaces); + }; + }]); + + vpp.register.controller('BridgeDomainsController', ['$scope', '$rootScope','$filter', 'dataService', 'bdmBridgeDomainService', 'toastService', + function($scope, $rootScope, $filter, dataService, bdmBridgeDomainService, toastService) { + $scope.addBd = function() { + var obj = bdmBridgeDomainService.createObj('vBD' + ((Math.random() * 100) + 1) ); + + bdmBridgeDomainService.add(obj, + function(data) { + console.log('successadding vbd'); + }, + function() { + console.warn('add bd failed'); + }); + }; + + /*var vm = this; + vm.dataService = dataService; + + dataService.nextApp.container(document.getElementById('bridge-domains-next-app')); + dataService.bridgeDomainsTopo.attach(dataService.nextApp); + + window.addEventListener('resize', function () { + if ($location.path() === '/bridgedomains') { + dataService.topo.adaptToContainer(); + } + }); + + vm.bridgedomains = dataService.bridgedomains; + vm.selectedBd = dataService.selectedBd; + + dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) { + console.log(node); + }); + + vm.bdChanged = function() { + dataService.injectBridgeDomainsTopoElements(); + dataService.buildTableContent(); + }; + + vm.addBd = function() { + //show dialog + $mdDialog.show({ + controller: function() { + var vm = this; + vm.bd = {}; + vm.waiting = false; + //function called when the cancel button ( 'x' in the top right) is clicked + vm.close = function() { + $mdDialog.cancel(); + }; -}); + vm.isDone = function(status) { + vm.waiting = false; + if (status === 'success') { + dataService.bridgedomains.push(vm.bd); + dataService.selectedBd.name = vm.bd.name; + dataService.injectBridgeDomainsTopoElements(); + dataService.buildTableContent(); + vm.close(); + } + }; + + //function called when the update button is clicked + vm.updateConfig = function() { + vm.waiting = true; + //send a POST with the entered content in the form field + + }; + }, + controllerAs: 'NewBdDialogCtrl', + templateUrl: 'templates/new-bd-dialog.html', + parent: angular.element(document.body), + clickOutsideToClose:false + }) + }; + + + + vm.deploy = function() { + + }; + + vm.removeBd = function() { + if(vm.selectedBd.name) { + var successCallback = function(success) { + if (success) { + console.log(vm.bridgedomains); + _.remove(vm.bridgedomains, { + name: vm.selectedBd.name + }); + toastService.showToast('Bridge Domain Removed!'); + vm.selectedBd.name = ''; + dataService.clearInjectedInterfacesInBridgeDomainTopo(); + dataService.injectBdIntoBridgeDomainsTopo(); + dataService.tableContent.length = 0; + } else { + toastService.showToast('Error removing Bridge Domain!'); + + } + }; + + //... removeBdFromOdl(vm.selectedBd.name, successCallback); + } + }; + */ + }]); +});
\ No newline at end of file diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js index f447bd0fb..8d85cc704 100644 --- a/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js +++ b/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js @@ -8,8 +8,8 @@ define(['app/vpp/vpp.module'], function(vpp) { - vpp.register.controller('InventoryTableController', ['$scope', '$rootScope','$filter', 'toastService', 'VppService', '$mdDialog', 'dataService', 'VppInterfaceService', - function($scope, $rootScope, filter, toastService, VppService, $mdDialog, dataService, VppInterfaceService) { + vpp.register.controller('InventoryTableController', ['$scope', '$rootScope','$filter', 'toastService', 'VppService', '$mdDialog', 'dataService', + function($scope, $rootScope, filter, toastService, VppService, $mdDialog, dataService) { $scope.getVppList = function() { $scope.initVppList(); |