Skip to content

Commit

Permalink
add an auto-scaler UI so folks can click on the 'Scale' button on the…
Browse files Browse the repository at this point in the history
… Profiles view to define min/max instances
  • Loading branch information
jstrachan committed Oct 2, 2013
1 parent 34d2ef4 commit 245b32b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Expand Up @@ -12,7 +12,7 @@
<a href="" title="Create a new container" ng-click="createContainer()">
<i class="icon-plus"></i> Create
</a>
<a href="" ng-click="editRequirementsDialog.open()" title="Configure the required number of instances of each profile which are then either created by an auto-scaler or created manually">
<a href="" ng-click="editRequirementsDialogOpen(null)" title="Configure the required number of instances of each profile which are then either created by an auto-scaler or created manually">
<i class="icon-resize-vertical"></i>
Scale
</a>
Expand Down Expand Up @@ -42,7 +42,7 @@
</div>

<div class="active-profile-requirements">
<a ng-click="editRequirementsDialog.open()">
<a ng-click="editRequirementsDialogOpen(profile)">
<span ng-show="profile.requirements.minimumInstances" class="badge">
{{profile.requirements.minimumInstances}}
</span>
Expand Down Expand Up @@ -93,7 +93,7 @@
</div>
</div>
<div modal="editRequirementsDialog.show">
<form name="requirementsForm" class="form-inline no-bottom-margin" ng-submit="updateRequirements(requirements)">
<form name="requirementsForm" class="form-inline no-bottom-margin" ng-submit="updateRequirements(editRequirementsEntity)">
<div class="modal-header"><h4>Edit Requirements</h4></div>
<div class="modal-body">
<table>
Expand All @@ -103,7 +103,7 @@
<th title="Maixmum number of instances">Maximum</th>
</thead>
<tbody>
<tr ng-repeat="requirement in requirements.profileRequirements">
<tr ng-repeat="requirement in editRequirementsEntity.profileRequirements">
<td class="property-name">{{requirement.profile}}</td>
<td>
<input name="minimumInstances" type="number" ng-model="requirement.minimumInstances" ng-required="false" class="input-small">
Expand Down
26 changes: 26 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/containerDirective.ts
Expand Up @@ -407,8 +407,34 @@ module Fabric {
return container.id.has($scope.searchFilter) || !container.profileIds.filter((id) => {return id.has($scope.searchFilter);}).isEmpty();
};

$scope.editRequirementsDialogOpen = (profile) => {
// lets make sure the requirements are pre-populated with values
var editRequirementsEntity = {
profileRequirements: []
};
if ($scope.requirements) {
angular.copy($scope.requirements, editRequirementsEntity);
}
var profileRequirements = editRequirementsEntity.profileRequirements;
if (profileRequirements) {
angular.forEach($scope.activeProfiles, (profile) => {
var currentRequirements = profile.requirements;
if (!currentRequirements) {
currentRequirements = {
profile: profile.id
};
profile.requirements = currentRequirements;
profileRequirements.push(currentRequirements);
}
});
}
$scope.editRequirementsEntity = editRequirementsEntity;
$scope.editRequirementsDialog.open();
};

$scope.updateRequirements = (requirements) => {
function onRequirementsSaved(response) {
$scope.requirements = requirements;
notification("success", "Updated the requirements");
$scope.updateActiveContainers();
Core.$apply($scope);
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/css/site-base.css
Expand Up @@ -1871,7 +1871,7 @@ dd.file-list {

.active-profile-requirements {
position: absolute;
right: 130px;
right: 75px;
}

.active-profile-create {
Expand Down

0 comments on commit 245b32b

Please sign in to comment.