Skip to content

Commit

Permalink
smart complete all groups / networks from the same list; so you can c…
Browse files Browse the repository at this point in the history
…reate 1 group "us-east" networked to "us-west, emea" then the 2nd broker you create can smart complete the group to any of those 3 groups; plus adding networks explicitly filters out your currentn group. so an "us-east" group broker can only network to "us-west" or "emea". Though we allow creating new group names in the network section; so you can network to broker groups that don't yet exist
  • Loading branch information
jstrachan committed Oct 11, 2013
1 parent b5ebb4a commit 7d3dde5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/js/createBroker.ts
Expand Up @@ -5,6 +5,7 @@ module Fabric {
Fabric.initScope($scope, $location, jolokia, workspace);

$scope.groups = [];
$scope.possibleNetworks = [];
$scope.profiles = [];
$scope.parentProfiles = [];
$scope.entity = {};
Expand All @@ -26,6 +27,18 @@ module Fabric {
return name && $scope.brokerNames.indexOf(name) >= 0;
};


function updatePossibleNetworks() {
var group = $scope.entity.group;
$scope.possibleNetworks = [].concat($scope.groups);
if (group) {
$scope.possibleNetworks = $scope.possibleNetworks.remove(group);
}
}

$scope.$watch("entity.group", updatePossibleNetworks);


// default parameters from the URL
angular.forEach(["group", "profile"], (param) => {
var value = $routeParams[param];
Expand Down Expand Up @@ -83,7 +96,7 @@ module Fabric {
Core.pathSet(schema.properties, ['minimumInstances', 'input-attributes', "placeholder"], "{{" + isStandalone + " ? 1 : 2}}");

Core.pathSet(schema.properties, ['networksPassword', 'type'], 'password');
Core.pathSet(schema.properties, ['networks', 'items', 'input-attributes', 'typeahead'], 'title for title in groups | filter:$viewValue');
Core.pathSet(schema.properties, ['networks', 'items', 'input-attributes', 'typeahead'], 'title for title in possibleNetworks | filter:$viewValue');
Core.pathSet(schema.properties, ['networks', 'items', 'input-attributes', 'typeahead-editable'], 'true');

schema['tabs'] = {
Expand All @@ -93,10 +106,15 @@ module Fabric {
}

function onBrokerData(brokerStatuses) {
$scope.groups = brokerStatuses.map(s => s.group).unique().sort();
var networkNames = brokerStatuses.map(s => s.networks).flatten().unique();
var groups = brokerStatuses.map(s => s.group).unique();

$scope.groups = networkNames.concat(groups).unique().sort();
$scope.profiles = brokerStatuses.map(s => s.profile).unique().sort();
$scope.brokerNames = brokerStatuses.map(s => s.brokerName).unique().sort();

updatePossibleNetworks();

var version = brokerStatuses.map(s => s.version).find(s => s) || "1.0";
jolokia.execute(Fabric.managerMBean, "getProfiles(java.lang.String,java.util.List)", version, ["id", "abstract"], onSuccess(onProfileData));
Core.$apply($scope);
Expand Down

0 comments on commit 7d3dde5

Please sign in to comment.