Skip to content

Commit

Permalink
Fix #746, needs more testing with multiple containers when fabric is…
Browse files Browse the repository at this point in the history
… working better.
  • Loading branch information
gashcrumb committed Nov 12, 2013
1 parent b75295e commit 43ca653
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 25 deletions.
20 changes: 13 additions & 7 deletions hawtio-web/src/main/webapp/app/fabric/html/assignProfile.html
@@ -1,15 +1,20 @@
<div class="controller-section" ng-controller="Fabric.AssignProfileController">

<div class="row-fluid">
<div class="span12">
<div class="span12" ng-show="containers.length > 0">
<div class="pull-left">
Select the containers to assign "{{profileId}}" from version "{{versionId}}" to:
</div>
<div class="pull-right">
<button class="btn btn-primary" ng-disabled="selected.length == 0" ng-click="assignProfiles()">Assign</button>
</div>
</div>
</div>

<div class="row-fluid">
<div class="span6">

<div class="section-header">
<div class="section-header" ng-show="containers.length > 0">

<div class="selection-controls">
<i class="icon-circle-blank clickable" title="Clear Selection" ng-click="setActiveContainer(null)"></i>
Expand All @@ -22,15 +27,16 @@
</div>
</div>

<div fabric-container-list at-version="versionId" without-profile="profileId"></div>
<div fabric-container-list at-version="versionId" without-profile="profileId" ng-show="containers.length > 0"></div>
<div ng-hide="containers.length > 0" class="alert">No available containers to assign "<b>{{profileId}}</b>" from version "<b>{{versionId}}</b>" to, <a href="" ng-click="gotoCreate()">create one</a>?</div>
</div>

<div class="span6">
<div class="row-fluid">
<div class="row-fluid" ng-show="containers.length > 0">
<h6>Selected Containers</h6>
<ul class="zebra-list">
<li ng-repeat="id in selectedContainerIds">{{id}}</li>
</ul>
<ol class="zebra-list">
<li ng-repeat="c in selected">{{c.id}}</li>
</ol>
</div>
</div>

Expand Down
@@ -1,6 +1,6 @@
<div>

<div ng-repeat="container in containers">
<div ng-repeat="container in containers" ng-show="filterContainer(container)">
<div class="box" ng-class="getSelectedClass(container)">

<div class="box-left">
Expand Down
44 changes: 41 additions & 3 deletions hawtio-web/src/main/webapp/app/fabric/js/assignProfile.ts
@@ -1,10 +1,14 @@
module Fabric {

export function AssignProfileController($scope, jolokia, $location, $routeParams) {
export function AssignProfileController($scope, jolokia, $location, $routeParams, workspace) {

$scope.profileId = $routeParams['pid'];
$scope.versionId = $routeParams['vid'];

Fabric.initScope($scope, $location, jolokia, workspace);

$scope.containerIdFilter = '';

var valid = true;

if (Core.isBlank($scope.profileId)) {
Expand All @@ -21,15 +25,49 @@ module Fabric {
$location.path("/fabric/view");
}

$scope.gotoCreate = () => {
$location.path('/fabric/containers/createContainer').search({
versionId: $scope.versionId,
profileIds: $scope.profileId
});
};

$scope.$on('$routeChangeSuccess', () => {
log.debug("RouteParams: ", $routeParams);
log.debug("Scope: ", $scope);

});

$scope.$watch('selectedContainerIds', (newValue, oldValue) => {
log.debug("selected containers: ", newValue);
$scope.$watch('containers', (newValue, oldValue) => {
if (newValue !== oldValue && newValue) {
$scope.selected = newValue.filter((c) => { return c['selected']});
}
}, true);

$scope.assignProfiles = () => {
var requests = [];
$scope.selected.forEach((c) => {
requests.push({
type: 'exec', mbean: Fabric.managerMBean,
operation: 'addProfilesToContainer',
arguments: [c.id, [$scope.profileId]]
});
});
notification('info', "Applying " + $scope.profileId + " to the selected containers");
var outstanding = requests.length;
jolokia.request(requests, onSuccess(() => {
outstanding = outstanding - 1;
if (outstanding === 0) {
notification('success', "Applied " + $scope.profileId);
Core.$apply($scope);
}
}));
setTimeout(() => {
$location.path("/fabric/activeProfiles");
Core.$apply($scope);
}, 30);
}

}

}
Expand Up @@ -127,6 +127,17 @@ module Fabric {
}
};

$scope.getFilteredName = (item) => {
return item.versionId + " / " + item.id;
};

$scope.filterContainer = (container) => {
if (!$scope.getFilteredName(container).has($scope.containerIdFilter)) {
return false;
}
return true;
};

$scope.$watch('editRequirements.addDependentProfileDialogShow', (newValue, oldValue) => {
if (newValue !== oldValue) {
if (newValue) {
Expand Down
15 changes: 3 additions & 12 deletions hawtio-web/src/main/webapp/app/fabric/js/containers.ts
@@ -1,12 +1,10 @@
module Fabric {

export function ContainersController($scope) {
export function ContainersController($scope, $location, jolokia, workspace) {

$scope.containerIdFilter = '';
Fabric.initScope($scope, $location, jolokia, workspace);

$scope.getFilteredName = (item) => {
return item.versionId + " / " + item.id;
}
$scope.containerIdFilter = '';

$scope.addToDashboardLink = () => {
var href = "#/fabric/containers";
Expand All @@ -19,13 +17,6 @@ module Fabric {
"&title=" + encodeURIComponent(title);
};

$scope.filterContainer = (container) => {
if (!$scope.getFilteredName(container).has($scope.containerIdFilter)) {
return false;
}
return true;
};

$scope.$watch('containers', (oldValue, newValue) => {
if (oldValue !== newValue) {
$scope.selectedContainers = $scope.containers.filter((c) => { return c.selected; });
Expand Down
12 changes: 11 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/profile.ts
Expand Up @@ -52,13 +52,23 @@ module Fabric {
icon: "icon-edit",
name: "Edit Features"
});
actions.push({
doAction: () => {
$location.url('/fabric/assignProfile').search({
vid: $scope.versionId,
pid: $scope.profileId
}); },
title: "Assign profile to existing containers",
icon: "icon-truck",
name: "Assign to Container"
});
actions.push({
doAction: () => {
$location.url('/fabric/containers/createContainer').search({
versionId: $scope.versionId,
profileIds: $scope.profileId
}); },
title: "Create Container",
title: "Create a new container with this profile",
icon: "icon-truck",
name: "Create Container"
});
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/wiki/html/viewPage.html
Expand Up @@ -99,7 +99,7 @@
</li>
<li ng-repeat="childAction in childActions">
<a ng-click="childAction.doAction()"
title="((childAction.title))"
title="{{childAction.title}}"
data-placement="bottom">
<i class="{{childAction.icon}}"></i> {{childAction.name}}</a>
</li>
Expand Down

0 comments on commit 43ca653

Please sign in to comment.