Skip to content

Commit

Permalink
Enable deleting profiles too
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed May 29, 2013
1 parent 992033c commit 17eca19
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
9 changes: 3 additions & 6 deletions hawtio-web/src/main/webapp/app/fabric/html/fabricView.html
Expand Up @@ -101,7 +101,7 @@
title="View, edit or create configuration files for the profiles in this version"><i class="icon-edit"></i>
</a>-->

<i class="icon-minus clickable" title="Delete selected Profiles" ng-disabled="selected.length == 0 || selectedHasContainers()" ng-click="deleteProfileDialog = true"></i>
<i class="icon-minus clickable" title="Delete selected Profiles" ng-click="deleteProfileDialog = true" ng-show="selectedProfiles.length > 0 && profilesCanBeDeleted()"></i>

</div>
<div class="section-filter">
Expand Down Expand Up @@ -181,12 +181,9 @@
</div>
</div>

<div hawtio-confirm-dialog="deleteProfileDialog" ok-button-text="Yes" cancel-button-text="No" on-ok="deleteSelected()">
<div hawtio-confirm-dialog="deleteProfileDialog" ok-button-text="Yes" cancel-button-text="No" on-ok="deleteSelectedProfiles()">
<div class="dialog-body">
<p>Are you sure you want to delete the selected profiles:</p>
<ol>
<li ng-repeat="profile in selectedProfiles">{{profile.id}}</li>
</ol>
<p>Are you sure you want to delete the profiles {{getSelectedProfileIds().join(", ")}}</p>
</div>
</div>

Expand Down
33 changes: 31 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricView.ts
Expand Up @@ -197,6 +197,17 @@ module Fabric {
});
};

$scope.deleteSelectedProfiles = () => {
$scope.selectedProfiles.each(function(profile) {
deleteProfile(jolokia, $scope.activeVersionId, profile.id, function() {
notification('success', "Deleted profile " + profile.id);
}, function(response) {
notification('error', "Failed to delete profile " + profile.id + ' due to ' + response.error);
})
});
};



$scope.migrateVersion = (targetName, sourceName) => {
notification('info', "Moving " + targetName + " to " + sourceName);
Expand Down Expand Up @@ -423,9 +434,22 @@ module Fabric {
return $scope.containers.none((c) => { return c.versionId === $scope.activeVersionId });
};


$scope.profilesCanBeDeleted = () => {
return
}

var possibleMatches = $scope.containers.filter((c) => { return c.versionId === $scope.activeVersionId });

if (possibleMatches.length === 0) {
return true;
}

possibleMatches = possibleMatches.filter( (c) => { return $scope.selectedProfiles.some((p) => { return c.profileIds.some(p.id)})});

if (possibleMatches.length === 0) {
return true;
}
return false;
};


$scope.connect = (row) => {
Expand All @@ -438,6 +462,11 @@ module Fabric {
};


$scope.getSelectedProfileIds = () => {
return $scope.selectedProfiles.map((p) => { return p.id });
};


$scope.getStatusTitle = (container) => {
var answer = 'Alive';

Expand Down

0 comments on commit 17eca19

Please sign in to comment.