Skip to content

Commit

Permalink
Add copy profile button to profile detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed May 31, 2013
1 parent 802765c commit 2b017f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -19,7 +19,8 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
-->
</div>
<div class="pull-right">
<a class="btn" ng-href="#/fabric/containers/createContainer?versionId={{versionId}}&profileIds={{profileId}}"><i class="icon-truck"></i> Create Container</a>
<a class="btn" ng-href="#/fabric/containers/createContainer?versionId={{versionId}}&profileIds={{profileId}}" title="Deploy this profile to a new container"><i class="icon-truck"></i> Create Container</a>
<a class="btn" href="" title="Create a new profile that is a copy of this one" ng-click="copyProfileDialog = true"><i class="icon-copy"></i> Copy</a>
<a ng-href="#/wiki/branch/{{versionId}}/view/{{row.id}}" class="btn" ng-show="hasFabricWiki()"
title="View, edit or create configuration files in this profile"><i class="icon-edit"></i> Configuration</a>
</div>
Expand Down Expand Up @@ -115,6 +116,14 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
</div>
</div>


<div hawtio-confirm-dialog="copyProfileDialog" ok-button-text="Copy" on-ok="copyProfile()">
<div class="dialog-body">
<p>Enter a new profile name to copy this profile to</p>
<input type="text" ng-model="newProfileName">
</div>
</div>

<div hawtio-confirm-dialog="deleteFileDialog" ok-button-text="Delete" on-ok="doDeleteFile()">
<div class="dialog-body">
<p>Delete file {{markedForDeletion}}?</p>
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -52,6 +52,10 @@ module Fabric {
doAction('createProfile(java.lang.String, java.lang.String, java.util.List)', jolokia, [version, id, parents], success, error);
}

export function copyProfile(jolokia, version, sourceName, targetName, force, success, error) {
doAction('copyProfile(java.lang.String, java.lang.String, java.lang.String, boolean)', jolokia, [version, sourceName, targetName, force], success, error);
}

export function createVersionWithParentAndId(jolokia, base, id, success, error) {
doAction('createVersion(java.lang.String, java.lang.String)', jolokia, [base, id], success, error);
}
Expand Down
16 changes: 16 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/profile.ts
Expand Up @@ -11,6 +11,8 @@ module Fabric {
$scope.newFileName = '';
$scope.markedForDeletion = '';

$scope.newProfileName = '';

if (angular.isDefined($scope.versionId) && angular.isDefined($scope.profileId)) {
Core.register(jolokia, $scope, {
type: 'exec', mbean: managerMBean,
Expand Down Expand Up @@ -46,6 +48,20 @@ module Fabric {
notification('error', 'Failed to create ' + $scope.newFileName + ' due to ' + response.error);
})
};

$scope.copyProfile = () => {
$scope.copyProfileDialog = false;
notification('info', 'Copying ' + $scope.profileId + ' to ' + $scope.newProfileName);

copyProfile(jolokia, $scope.versionId, $scope.profileId, $scope.newProfileName, true, () => {
notification('success', 'Created new profile ' + $scope.newProfileName);
$location.url("/fabric/profile/" + $scope.versionId + "/" + $scope.newProfileName);
$scope.$apply();
}, (response) => {
notification('error', 'Failed to create new profile ' + $scope.newProfileName + ' due to ' + response.error);
$scope.$apply();
});
}

function render(response) {
if (!Object.equal($scope.row, response.value)) {
Expand Down

0 comments on commit 2b017f6

Please sign in to comment.