Merge "fixed os_global_config meta data issue and add subnet bug"

This commit is contained in:
Jenkins 2015-04-21 21:58:30 +00:00 committed by Gerrit Code Review
commit 7c25e25238
2 changed files with 34 additions and 11 deletions

View File

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

View File

@ -43,9 +43,10 @@ define(['./baseService'], ()->
if preConfigData
wizardFactory.preConfig(data[name])
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.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.security
wizardFactory.setServiceCredentials(oldConfig.package_config.security.service_credentials) if oldConfig.package_config.security.service_credentials
@ -82,7 +83,7 @@ define(['./baseService'], ()->
setSubnetworks: ->
wizardFactory = @wizardFactory
@dataService.getSubnetConfig().success (data) ->
wizardFactory.setSubnetworks data
wizardFactory.setSubnetworks(data)
getServerColumns: ->
@dataService.getServerColumns()
@ -182,12 +183,21 @@ define(['./baseService'], ()->
updateSubnetConfig = @dataService.putSubnetConfig(subnet.id, requestData)
promises.push(updateSubnetConfig)
@$q.all(promises).then ->
$modalInstance.close $scope.subnetworks
findNewSubnetId = @findNewSubnetId
@$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) ->
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) ->
switch rule
when "host"
@ -537,9 +547,18 @@ define(['./baseService'], ()->
# "username": $scope.server_credentials.username
# "password": $scope.server_credentials.password
wizardFactory = @wizardFactory
submitData = {}
submitData =
os_config: {}
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
@dataService.updateClusterConfig($scope.cluster.id, submitData).success (configData) ->
wizardFactory.setCommitState({
@ -1012,8 +1031,11 @@ define(['./baseService'], ()->
$scope[key][category.name][content.name] = $scope.os_global_config[category.name][content.name]
else
$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',[
'dataService'
@ -1025,4 +1047,4 @@ define(['./baseService'], ()->
'$modal'
(dataService, $state, wizardFactory, $filter, $q, ngTableParams, $modal) -> new WizardService(dataService, $state, wizardFactory, $filter, $q, ngTableParams, $modal)
]
)
)