manually add one machine to a switch
Change-Id: Ia266933c9b0cd928d48660f42994055167707a14
This commit is contained in:
parent
1d8eeaac99
commit
b40905200b
|
@ -93,4 +93,15 @@ define(['./baseController'], ()->
|
||||||
$scope.cancel = ->
|
$scope.cancel = ->
|
||||||
$modalInstance.dismiss('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')
|
||||||
|
]
|
||||||
);
|
);
|
|
@ -74,6 +74,16 @@ define(['./baseController'], ()->
|
||||||
allMachines: ->
|
allMachines: ->
|
||||||
return $scope.foundResults
|
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
|
#watch and add newly found servers to allservers array
|
||||||
wizardService.watchAndAddNewServers($scope)
|
wizardService.watchAndAddNewServers($scope)
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3 class="modal-title">
|
||||||
|
<i class="ace-icon fa fa-plus light-green"></i>
|
||||||
|
Add a New Machine
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" >
|
||||||
|
<div class="form-group" style="overflow:auto">
|
||||||
|
<label class="col-sm-3 control-label no-padding-right">
|
||||||
|
Select a switch:
|
||||||
|
<span class="text-danger">*</span>
|
||||||
|
</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select ng-model="selected_switch"
|
||||||
|
class="col-xs-10 col-sm-5" style="width: 300px"
|
||||||
|
ng-options="option as option.ip for option in switchOptions">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" style="overflow:auto">
|
||||||
|
<label class="col-sm-3 control-label no-padding-right">
|
||||||
|
MAC Address:
|
||||||
|
</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input ng-model="newMac" type="text" class="col-xs-10 col-sm-5" placeholder="" style="width: 300px">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer" style="clear:both;">
|
||||||
|
<!-- <button class="btn btn-primary" ng-click="ok()" ng-disabled="createClusterForm.$invalid">Create</button> -->
|
||||||
|
<button class="btn btn-primary" ng-click="ok()">Add</button>
|
||||||
|
<button class="btn btn-grey" ng-click="cancel()">Close</button>
|
||||||
|
</div>
|
|
@ -52,6 +52,9 @@
|
||||||
<div class="pull-right side-padding-20">
|
<div class="pull-right side-padding-20">
|
||||||
<span class="uploadContainer" tooltip="Upload Switch/Machines File" ng-click="uploadFile()"><i class=" ace-icon fa fa-upload uploadFile"></i></span>
|
<span class="uploadContainer" tooltip="Upload Switch/Machines File" ng-click="uploadFile()"><i class=" ace-icon fa fa-upload uploadFile"></i></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pull-right side-padding-20">
|
||||||
|
<span class="uploadContainer" tooltip="add new servers" ng-click="addNewMachines()"><i class=" ace-icon fa fa-plus uploadFile"></i></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -798,6 +798,18 @@ define(['angular', 'angularMocks'], function() {
|
||||||
}];
|
}];
|
||||||
return [200, machines, {}];
|
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) {
|
$httpBackend.whenPOST(settings.apiUrlBase + '/switch-filters').respond(function(method, url, data) {
|
||||||
|
|
|
@ -118,11 +118,17 @@ define(['./baseService'], () ->
|
||||||
|
|
||||||
getOsGlobalConfigMetaData: (id) ->
|
getOsGlobalConfigMetaData: (id) ->
|
||||||
return @$http.get(@settings.apiUrlBase + '/oses/'+ id + '/ui_metadata')
|
return @$http.get(@settings.apiUrlBase + '/oses/'+ id + '/ui_metadata')
|
||||||
|
|
||||||
getPackageConfigUiElements: (id) ->
|
getPackageConfigUiElements: (id) ->
|
||||||
return @$http.get(@settings.apiUrlBase + '/flavors/' + id + '/ui_metadata')
|
return @$http.get(@settings.apiUrlBase + '/flavors/' + id + '/ui_metadata')
|
||||||
|
|
||||||
uploadSwitches: (data) ->
|
uploadSwitches: (data) ->
|
||||||
return @$http.post(@settings.apiUrlBase + '/switchesbatch', angular.toJson(data))
|
return @$http.post(@settings.apiUrlBase + '/switchesbatch', angular.toJson(data))
|
||||||
|
|
||||||
uploadMachines: (data) ->
|
uploadMachines: (data) ->
|
||||||
return @$http.post(@settings.apiUrlBase + '/switches/machines', angular.toJson(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)])
|
angular.module('compass.services').service('dataService', ['$http', 'settings', ($http,settings) -> new DS($http,settings)])
|
||||||
)
|
)
|
|
@ -1096,6 +1096,17 @@ define(['./baseService'], ()->
|
||||||
reader.onload = (e) ->
|
reader.onload = (e) ->
|
||||||
$scope[target] = reader.result
|
$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',[
|
angular.module('compass.services').service 'wizardService',[
|
||||||
'dataService'
|
'dataService'
|
||||||
'$state'
|
'$state'
|
||||||
|
|
Loading…
Reference in New Issue