fixed os_global_config meta data issue and add subnet bug

Change-Id: Ib8e719ae55a14f2f916fcc6cb51ee3b060897bf7
This commit is contained in:
chi zhang
2015-04-16 10:46:34 -07:00
parent b36a14484c
commit f9b71a9484
2 changed files with 33 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ define(['./baseController'], ()->
.controller 'addSubnetModalInstanceCtrl',['$scope','$modalInstance','wizardService','subnets', .controller 'addSubnetModalInstanceCtrl',['$scope','$modalInstance','wizardService','subnets',
($scope, $modalInstance, wizardService, subnets) -> ($scope, $modalInstance, wizardService, subnets) ->
$scope.subnetworks = angular.copy(subnets) $scope.subnetworks = angular.copy(subnets)
wizardService.copyWithHashKey($scope.subnetworks, subnets)
$scope.subnetAllValid = true $scope.subnetAllValid = true
subnet['valid'] = true for subnet in $scope.subnetworks subnet['valid'] = true for subnet in $scope.subnetworks

View File

@@ -43,9 +43,10 @@ define(['./baseService'], ()->
if preConfigData if preConfigData
wizardFactory.preConfig(data[name]) wizardFactory.preConfig(data[name])
if oldConfig.os_config if oldConfig.os_config
wizardFactory.setGeneralConfig(oldConfig.os_config.general) if oldConfig.os_config.general # wizardFactory.setGeneralConfig(oldConfig.os_config.general) if oldConfig.os_config.general
wizardFactory.setPartition(oldConfig.os_config.partition) if oldConfig.os_config.partition wizardFactory.setPartition(oldConfig.os_config.partition) if oldConfig.os_config.partition
wizardFactory.setServerCredentials(oldConfig.os_config.server_credentials) if oldConfig.os_config.server_credentials # wizardFactory.setServerCredentials(oldConfig.os_config.server_credentials) if oldConfig.os_config.server_credentials
wizardFactory.setOsGlobalConfig(oldConfig.os_config)
if oldConfig.package_config if oldConfig.package_config
if oldConfig.package_config.security if oldConfig.package_config.security
wizardFactory.setServiceCredentials(oldConfig.package_config.security.service_credentials) if oldConfig.package_config.security.service_credentials wizardFactory.setServiceCredentials(oldConfig.package_config.security.service_credentials) if oldConfig.package_config.security.service_credentials
@@ -81,7 +82,7 @@ define(['./baseService'], ()->
setSubnetworks: -> setSubnetworks: ->
wizardFactory = @wizardFactory wizardFactory = @wizardFactory
@dataService.getSubnetConfig().success (data) -> @dataService.getSubnetConfig().success (data) ->
wizardFactory.setSubnetworks data wizardFactory.setSubnetworks(data)
getServerColumns: -> getServerColumns: ->
@dataService.getServerColumns() @dataService.getServerColumns()
@@ -181,12 +182,21 @@ define(['./baseService'], ()->
updateSubnetConfig = @dataService.putSubnetConfig(subnet.id, requestData) updateSubnetConfig = @dataService.putSubnetConfig(subnet.id, requestData)
promises.push(updateSubnetConfig) promises.push(updateSubnetConfig)
@$q.all(promises).then -> findNewSubnetId = @findNewSubnetId
$modalInstance.close $scope.subnetworks
@$q.all(promises).then (data)->
for subnet in $scope.subnetworks
if !subnet["id"]
id = findNewSubnetId(subnet.subnet, data)
subnet["id"] = id
$modalInstance.close($scope.subnetworks)
(response) -> (response) ->
console.log "promises error", response console.log "promises error", response
findNewSubnetId: (ip, data) ->
for sub in data
return sub.data.id if sub.data.subnet is ip
return null
fillHostname: ($scope, rule) -> fillHostname: ($scope, rule) ->
switch rule switch rule
when "host" when "host"
@@ -494,9 +504,18 @@ define(['./baseService'], ()->
# "username": $scope.server_credentials.username # "username": $scope.server_credentials.username
# "password": $scope.server_credentials.password # "password": $scope.server_credentials.password
wizardFactory = @wizardFactory wizardFactory = @wizardFactory
submitData = {} submitData =
os_config: {}
for mdata in $scope.metaData for mdata in $scope.metaData
submitData[mdata.name] = $scope.os_global_config[mdata.name] submitData.os_config[mdata.name] = $scope.os_global_config[mdata.name]
# get rid of redundant field (ex: comfirm password should not be sent back to server)
for category in $scope.metaData
console.log("category", category)
for content in category.data
if content.datamatch
delete submitData.os_config[category.name][content.name]
if $scope.generalForm.$valid if $scope.generalForm.$valid
@dataService.updateClusterConfig($scope.cluster.id, submitData).success (configData) -> @dataService.updateClusterConfig($scope.cluster.id, submitData).success (configData) ->
wizardFactory.setCommitState({ wizardFactory.setCommitState({
@@ -908,8 +927,11 @@ define(['./baseService'], ()->
$scope[key][category.name][content.name] = $scope.os_global_config[category.name][content.name] $scope[key][category.name][content.name] = $scope.os_global_config[category.name][content.name]
else else
$scope[key][category.name][content.name] = [""] $scope[key][category.name][content.name] = [""]
copyWithHashKey: (target, source) ->
index = 0
for s in source
target[index]["$$hashKey"] = source[index]["$$hashKey"]
index++
angular.module('compass.services').service 'wizardService',[ angular.module('compass.services').service 'wizardService',[
'dataService' 'dataService'