Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #333, can now set profiles on containers en-masse
- Loading branch information
Showing
5 changed files
with
182 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 34 additions & 2 deletions
36
hawtio-web/src/main/webapp/app/fabric/html/assignProfiles.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
<div> | ||
<div ng-controller="Fabric.AssignProfilesController"> | ||
|
||
<div class="row-fluid"> | ||
<div class="pull-left"> | ||
<a class='btn' ng-href="#/fabric/containers"><i class='icon-remove'></i> Cancel</a> | ||
<a class='btn inline-block' ng-href="#/fabric/containers"><i class='icon-remove'></i> Cancel</a> | ||
</div> | ||
<div class="pull-right"> | ||
<a ng-disabled="canApply()" class="btn btn-danger" href="" ng-click="showApply = true"><i class="icon-cogs"></i> Apply Changes</a> | ||
</div> | ||
</div> | ||
|
||
<div class="row-fluid form-horizontal"> | ||
<div class="span8 offset2"> | ||
<div class="control-group"> | ||
<label class="inline-block">1. Select the version containing the profiles and containers to be modified: </label> | ||
<select ng-model="version" ng-options="v.id for v in versions"></select> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="row-fluid"> | ||
<div class="span4 offset2"> | ||
<p>2. Select the profiles to be applied:</p> | ||
<input class="search-query column-filter" type="text" ng-model="profileGridOptions.filterOptions.filterText" placeholder="Filter..."> | ||
<div class="gridStyle" ng-grid="profileGridOptions"></div> | ||
</div> | ||
<div class="span4"> | ||
<p>3. Select the target containers to apply these profiles on:</p> | ||
<input class="search-query column-filter" type="text" ng-model="containerGridOptions.filterOptions.filterText" placeholder="Filter..."> | ||
<div class="gridStyle" ng-grid="containerGridOptions"></div> | ||
</div> | ||
</div> | ||
|
||
<div hawtio-confirm-dialog="showApply" ok-button-text="Yes" cancel-button-text="No" on-ok="applyProfiles()" title="Apply profiles?"> | ||
<div class="dialog-body"> | ||
<p>Are you sure you want to set these {{selectedProfiles.length}} profiles on {{selectedContainers.length}} containers?</p> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
</div> |
143 changes: 143 additions & 0 deletions
143
hawtio-web/src/main/webapp/app/fabric/js/assignProfiles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
module Fabric { | ||
|
||
export function AssignProfilesController($scope, jolokia, $location) { | ||
|
||
$scope.defaultVersion = jolokia.execute(managerMBean, "defaultVersion()"); | ||
$scope.version = { id: $scope.defaultVersion.id }; | ||
|
||
$scope.versions = []; | ||
$scope.profiles = []; | ||
$scope.containers = []; | ||
$scope.versionResponse = []; | ||
$scope.profileIds = []; | ||
$scope.containerIds = []; | ||
|
||
$scope.selectedProfiles = []; | ||
$scope.selectedContainers = []; | ||
|
||
$scope.showApply = false; | ||
|
||
$scope.profileGridOptions = { | ||
data: 'profiles', | ||
selectedItems: $scope.selectedProfiles, | ||
showSelectionCheckbox: true, | ||
multiSelect: true, | ||
keepLastSelected: false, | ||
columnDefs: [{ | ||
field: 'id', | ||
displayName: 'Profile Name' | ||
}], | ||
filterOptions: { | ||
filterText: '' | ||
} | ||
}; | ||
|
||
$scope.containerGridOptions = { | ||
data: 'containers', | ||
selectedItems: $scope.selectedContainers, | ||
showSelectionCheckbox: true, | ||
multiSelect: true, | ||
keepLastSelected: false, | ||
columnDefs: [{ | ||
field: 'id', | ||
displayName: 'Container Name' | ||
}], | ||
filterOptions: { | ||
filterText: '' | ||
} | ||
}; | ||
|
||
$scope.canApply = () => { | ||
return !($scope.selectedProfiles.length > 0 && $scope.selectedContainers.length > 0); | ||
} | ||
|
||
$scope.applyProfiles = () => { | ||
var containerIds = $scope.selectedContainers.map((container) => { return container.id }); | ||
var profileIds = $scope.selectedProfiles.map((profile) => { return profile.id }); | ||
var versionId = $scope.version.id; | ||
|
||
notification('info', "Applying profiles to containers"); | ||
$location.path("/fabric/containers"); | ||
|
||
applyProfiles(jolokia, versionId, profileIds, containerIds, () => { | ||
notification('success', "Successfully applied profiles"); | ||
}, (response) => { | ||
notification('error', "Failed to apply profiles due to " + response.error); | ||
}); | ||
} | ||
|
||
$scope.render = (response) => { | ||
|
||
switch(response.request.operation) { | ||
case 'versions()': | ||
if (!Object.equal($scope.versionResponse, response.value)) { | ||
$scope.versionResponse = response.value | ||
$scope.versions = response.value.map(function(version) { | ||
var v = { | ||
id: version.id, | ||
'defaultVersion': version.defaultVersion | ||
} | ||
|
||
if (v['defaultVersion']) { | ||
$scope.defaultVersion = v; | ||
} | ||
|
||
return v; | ||
}); | ||
$scope.version = setSelect($scope.version, $scope.versions); | ||
|
||
$scope.$apply(); | ||
} | ||
break; | ||
|
||
case 'getProfileIds(java.lang.String)': | ||
if (!Object.equal($scope.profileIds, response.value)) { | ||
$scope.profileIds = response.value; | ||
$scope.profiles = []; | ||
|
||
$scope.profileIds.each((profile) => { | ||
$scope.profiles.push({ | ||
id: profile | ||
}); | ||
}); | ||
|
||
$scope.$apply(); | ||
} | ||
break; | ||
|
||
case 'containerIdsForVersion(java.lang.String)': | ||
if (!Object.equal($scope.containerIds, response.value)) { | ||
$scope.containerIds = response.value; | ||
$scope.containers = []; | ||
|
||
$scope.containerIds.each((container) => { | ||
$scope.containers.push({ | ||
id: container | ||
}); | ||
}); | ||
|
||
$scope.$apply(); | ||
} | ||
|
||
break; | ||
|
||
} | ||
}; | ||
|
||
$scope.$watch('version', (oldValue, newValue) => { | ||
|
||
if (oldValue === newValue) { | ||
notification('info', "Please wait, fetching data for version " + $scope.version.id); | ||
} | ||
|
||
Core.unregister(jolokia, $scope); | ||
Core.register(jolokia, $scope, [ | ||
{type: 'exec', mbean: managerMBean, operation: 'versions()'}, | ||
{type: 'exec', mbean: managerMBean, operation: 'getProfileIds(java.lang.String)', arguments: [$scope.version.id]}, | ||
{type: 'exec', mbean: managerMBean, operation: 'containerIdsForVersion(java.lang.String)', arguments: [$scope.version.id]} | ||
], onSuccess($scope.render)); | ||
}); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters