Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change profile parents implemented for #32
  • Loading branch information
gashcrumb committed Aug 5, 2013
1 parent b5cf79b commit 28b180b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
16 changes: 15 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -42,10 +42,11 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
<dd>
<ul class="unstyled">
<li ng-repeat="profile in row.parentIds">
<i class="red clickable icon-remove" title="Remove parent {{profile}}" ng-click="removeParentProfile(profile)"></i>
<a href="#/fabric/profile/{{versionId}}/{{profile}}{{hash}}">{{profile}}</a>
</li>
<li>
<i class="clickable icon-edit" ng-click="newFileDialog = true" title="Edit features"></i>
<i class="clickable icon-edit" ng-click="showChangeParentsDialog()" title="Change parent profiles"></i>
</ul>
</dd>
</dl>
Expand Down Expand Up @@ -166,6 +167,19 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
</div>
</div>

<div hawtio-confirm-dialog="removeParentDialog" ok-button-text="Remove" on-ok="doRemoveParentProfile()">
<div class="dialog-body">
<p>Remove parent {{markedForDeletion}}?</p>
</div>
</div>

<div hawtio-confirm-dialog="changeParentsDialog" title="Change {{row.id}} parent profiles..." ok-button-text="Change Parents" on-ok="doChangeParents()">
<div class="dialog-body">
<p>Select what profiles this profile should inherit from.</p>
<div fabric-profile-selector="selectedParents" version-id="versionId"></div>
</div>
</div>

<div modal="newFileDialog">
<form name="newFile" class="form-horizontal no-bottom-margin" ng-submit="doCreateFile()">
<div class="modal-header"><h4>Create new configuration file...</h4></div>
Expand Down
@@ -1,4 +1,4 @@
<div ng-show="profiles.length > 0">
<div class="ng-cloak">
<div class="profile-list">
<table class="table table-striped">
<thead>
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -100,6 +100,10 @@ module Fabric {
doAction('applyVersionToContainers(java.lang.String, java.util.List)', jolokia, [version, containers], success, error);
}

export function changeProfileParents(jolokia, version, id, parents, success, error) {
doAction('changeProfileParents(java.lang.String, java.lang.String, java.util.List)', jolokia, [version, id, parents], success, error);
}

export function createProfile(jolokia, version, id, parents, success, error) {
doAction('createProfile(java.lang.String, java.lang.String, java.util.List)', jolokia, [version, id, parents], success, error);
}
Expand Down
45 changes: 45 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/profile.ts
Expand Up @@ -17,7 +17,10 @@ module Fabric {
$scope.newProfileName = '';
$scope.addThingDialog = false;
$scope.deleteThingDialog = false;
$scope.changeParentsDialog = false;
$scope.removeParentDialog = false;
$scope.newThingName = '';
$scope.selectedParents = [];

if (angular.isDefined($scope.versionId) && angular.isDefined($scope.profileId)) {
Core.register(jolokia, $scope, {
Expand All @@ -27,6 +30,48 @@ module Fabric {
}, onSuccess(render));
}

$scope.showChangeParentsDialog = () => {
$scope.selectedParents = $scope.row.parentIds.map((parent) => {
return {
id: parent,
selected: true
};
});
$scope.changeParentsDialog = true;
}

$scope.removeParentProfile = (parent) => {
$scope.markedForDeletion = parent;
$scope.removeParentDialog = true;

}

$scope.doRemoveParentProfile = () => {
var parents = $scope.row.parentIds.exclude($scope.markedForDeletion);
changeProfileParents(jolokia, $scope.versionId, $scope.profileId, parents, () => {
notification('success', 'Removed parent profile ' + $scope.markedForDeletion + ' from ' + $scope.profileId);
Core.$apply($scope);
}, (response) => {
notification('error', 'Failed to change parent profiles of ' + $scope.profileId + ' due to ' + response.error);
Core.$apply($scope);
});
}


$scope.doChangeParents = () => {
$scope.changeParentsDialog = false;
var parents = $scope.selectedParents.map((parent) => {
return parent.id;
});
changeProfileParents(jolokia, $scope.versionId, $scope.profileId, parents, () => {
notification('success', 'Successfully changed parent profiles of ' + $scope.profileId);
Core.$apply($scope);
}, (response) => {
notification('error', 'Failed to change parent profiles of ' + $scope.profileId + ' due to ' + response.error);
Core.$apply($scope);
});
}


$scope.goto = (location) => {
$location.url(location);
Expand Down

0 comments on commit 28b180b

Please sign in to comment.