Skip to content

Commit

Permalink
support smart completion of root containers (and use nested "input-at…
Browse files Browse the repository at this point in the history
…tributes" map to easily configure any <input> control), and default the root container if there's only 1
  • Loading branch information
jstrachan committed Oct 1, 2013
1 parent 3e7922c commit efabf95
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/createContainer.ts
Expand Up @@ -87,6 +87,14 @@ module Fabric {
});

Forms.defaultValues($scope.entity, $scope.schema);

if ($scope.selectedProvider.id === 'child' && !$scope.entity["parent"]) {
// lets default a parent container if we have a single root container
var rootContainers = $scope.rootContainers();
if (rootContainers && rootContainers.length === 1) {
$scope.entity["parent"] = rootContainers[0];
}
}
}
}, true);

Expand Down Expand Up @@ -133,6 +141,10 @@ module Fabric {
});


$scope.rootContainers = () => {
return Fabric.getRootContainers(jolokia);
};

$scope.init = () => {

var tab = $location.search()['tab'];
Expand Down
7 changes: 7 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -455,6 +455,13 @@ module Fabric {
}


export function getRootContainers(jolokia) {
var fields = ["id", "root"];
var answer = jolokia.execute(Fabric.managerMBean, "containers(java.util.List)", fields, { method: 'POST' });
return answer.filter({root: true}).map(v => v["id"]);
}


export function filterProfiles(jolokia, versionId, profileIds) {
var profiles = jolokia.execute(Fabric.managerMBean, "getProfiles(java.lang.String, java.util.List)", versionId, ['id', 'hidden', 'abstract'], { method: 'POST' });

Expand Down
5 changes: 5 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/schemaConfigure.ts
Expand Up @@ -39,6 +39,11 @@ module Fabric {
'type': 'boolean'
};

Core.pathSet(schema.properties, ['parent', 'label'], 'Parent Container');
Core.pathSet(schema.properties, ['parent', 'tooltip'], 'The name of the parent container used to create the child container');
Core.pathSet(schema.properties, ['parent', 'input-attributes', 'typeahead'], "title for title in rootContainers() | filter:$viewValue");
Core.pathSet(schema.properties, ['parent', 'input-attributes', 'typeahead-editable'], "false");

bulkSet(schema, ["jmxUser", "jmxPassword", "parent"], 'required', true);
schema['tabs'] = {
'Default': ['name', 'parent', 'jmxUser', 'jmxPassword', 'saveJmxCredentials', 'number', '*']
Expand Down
9 changes: 9 additions & 0 deletions hawtio-web/src/main/webapp/app/forms/js/mappingRegistry.ts
Expand Up @@ -10,6 +10,15 @@ module Forms {
var group = null;

function copyAttributes() {
var propertyAttributes = property["input-attributes"];
if (propertyAttributes) {
angular.forEach(propertyAttributes, function (value, key) {
if (angular.isString(value)) {
var html = Core.escapeHtml(value);
input.attr(key, html);
}
});
}
angular.forEach(property, function (value, key) {
if (angular.isString(value) && key.indexOf("$") < 0 && key !== "type") {
var html = Core.escapeHtml(value);
Expand Down

0 comments on commit efabf95

Please sign in to comment.