diff --git a/v2.5/src/app/controllers/modalControllers.coffee b/v2.5/src/app/controllers/modalControllers.coffee index 3cbdf2c..c6e9821 100644 --- a/v2.5/src/app/controllers/modalControllers.coffee +++ b/v2.5/src/app/controllers/modalControllers.coffee @@ -93,4 +93,15 @@ define(['./baseController'], ()-> $scope.cancel = -> $modalInstance.dismiss('cancel') ] + .controller 'addMachineModalInstanceCtrl', ['$scope', '$modalInstance', 'wizardService','allSwitches','allMachines', + ($scope, $modalInstance, wizardService, allSwitches, allMachines) -> + + $scope.switchOptions = allSwitches + $scope.selected_switch = allSwitches[0] + $scope.ok = -> + wizardService.addSingMachine($scope, $modalInstance, allMachines) + + $scope.cancel = -> + $modalInstance.dismiss('cancel') + ] ); \ No newline at end of file diff --git a/v2.5/src/app/controllers/wizardController.coffee b/v2.5/src/app/controllers/wizardController.coffee index 5cfc9c9..61c63b9 100644 --- a/v2.5/src/app/controllers/wizardController.coffee +++ b/v2.5/src/app/controllers/wizardController.coffee @@ -74,6 +74,16 @@ define(['./baseController'], ()-> allMachines: -> return $scope.foundResults ) + $scope.addNewMachines = -> + modalInstance = $modal.open( + templateUrl: "src/app/partials/modalAddNewServers.html" + controller: "addMachineModalInstanceCtrl" + resolve: + allSwitches: -> + return $scope.allAddedSwitches + allMachines: -> + return $scope.foundResults + ) #watch and add newly found servers to allservers array wizardService.watchAndAddNewServers($scope) diff --git a/v2.5/src/app/partials/modalAddNewServers.html b/v2.5/src/app/partials/modalAddNewServers.html new file mode 100644 index 0000000..774d62b --- /dev/null +++ b/v2.5/src/app/partials/modalAddNewServers.html @@ -0,0 +1,33 @@ + + + \ No newline at end of file diff --git a/v2.5/src/app/partials/server_selection.tpl.html b/v2.5/src/app/partials/server_selection.tpl.html index 6682de1..52056fa 100644 --- a/v2.5/src/app/partials/server_selection.tpl.html +++ b/v2.5/src/app/partials/server_selection.tpl.html @@ -52,6 +52,9 @@
+
+ +
diff --git a/v2.5/src/app/server/appDev.js b/v2.5/src/app/server/appDev.js index e7ecba5..46b32c3 100644 --- a/v2.5/src/app/server/appDev.js +++ b/v2.5/src/app/server/appDev.js @@ -798,6 +798,18 @@ define(['angular', 'angularMocks'], function() { }]; return [200, machines, {}]; }); + $httpBackend.whenPOST(/\.*\/switches\/([0-9]|[1-9][0-9])\/machines$/).respond(function(method, url, data) { + console.log(method, url, data); + var index = url.indexOf("switches/"); + var switchId = url.substring(index).split("/")[1]; + var machines = { + "id": 1, + "mac": "28:6e:d4:47:c8:6c", + "vlan": 1, + "port": "10", + } + return [200, machines, {}]; + }); /* $httpBackend.whenPOST(settings.apiUrlBase + '/switch-filters').respond(function(method, url, data) { diff --git a/v2.5/src/app/services/dataService.coffee b/v2.5/src/app/services/dataService.coffee index 110c8ad..4884e88 100644 --- a/v2.5/src/app/services/dataService.coffee +++ b/v2.5/src/app/services/dataService.coffee @@ -118,11 +118,17 @@ define(['./baseService'], () -> getOsGlobalConfigMetaData: (id) -> return @$http.get(@settings.apiUrlBase + '/oses/'+ id + '/ui_metadata') + getPackageConfigUiElements: (id) -> return @$http.get(@settings.apiUrlBase + '/flavors/' + id + '/ui_metadata') + uploadSwitches: (data) -> return @$http.post(@settings.apiUrlBase + '/switchesbatch', angular.toJson(data)) + uploadMachines: (data) -> return @$http.post(@settings.apiUrlBase + '/switches/machines', angular.toJson(data)) + + postSigleMachine: (switch_id, request) -> + return @$http.post(@settings.apiUrlBase + '/switches/'+ switch_id+'/machines', angular.toJson(request)) angular.module('compass.services').service('dataService', ['$http', 'settings', ($http,settings) -> new DS($http,settings)]) ) \ No newline at end of file diff --git a/v2.5/src/app/services/wizardService.coffee b/v2.5/src/app/services/wizardService.coffee index f09fa3b..aaa0568 100644 --- a/v2.5/src/app/services/wizardService.coffee +++ b/v2.5/src/app/services/wizardService.coffee @@ -1096,6 +1096,17 @@ define(['./baseService'], ()-> reader.onload = (e) -> $scope[target] = reader.result + addSingMachine: ($scope, $modalInstance, allMachines) -> + request = {} + request.mac = $scope.newMac + request.port = "0" + @dataService.postSigleMachine($scope.selected_switch.id, request).success (data) -> + data.switch_ip = $scope.selected_switch.ip + allMachines.push(data) + $modalInstance.dismiss('ok') + + + angular.module('compass.services').service 'wizardService',[ 'dataService' '$state'