Skip to content

Commit

Permalink
Also remove empty values when creating a fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Dec 3, 2013
1 parent a4db410 commit 827904b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 1 addition & 5 deletions hawtio-web/src/main/webapp/app/fabric/js/createContainer.ts
Expand Up @@ -303,11 +303,7 @@ module Fabric {
}

// remove possibly dodgy values if they are blank
angular.forEach(json, (value, key) => {
if (value === "") {
delete json[key];
}
});
json = Fabric.sanitizeJson(json);
delete json.saveJmxCredentials;

if ( json.number === 1 ) {
Expand Down
2 changes: 2 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/createFabric.ts
Expand Up @@ -36,6 +36,8 @@ module Fabric {

$scope.onSubmit = (json, form) => {

json = Fabric.sanitizeJson(json);

setTimeout(() => {

jolokia.execute(Fabric.clusterBootstrapManagerMBean, 'createCluster(java.util.Map)', angular.toJson(json), {
Expand Down
17 changes: 17 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricHelpers.ts
Expand Up @@ -978,4 +978,21 @@ module Fabric {
return fn ? answer : onResults(answer);
}

/**
* Removes any attributes from the object that are set to an empty string.
*
* @method sanitizeJson
* @for Fabric
* @param {Object} json
* @return {Object}
*/
export function sanitizeJson(json:Object) {
angular.forEach(json, (value, key) => {
if (value === "") {
delete json[key];
}
});
return json;
}

}

0 comments on commit 827904b

Please sign in to comment.