Skip to content

Commit

Permalink
Set version & add profiles button added, fix up delete versiondialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed May 29, 2013
1 parent 12beca6 commit ca72ff9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 77 deletions.
21 changes: 9 additions & 12 deletions hawtio-web/src/main/webapp/app/fabric/html/fabricView.html
Expand Up @@ -35,13 +35,13 @@
<i ng-show="container.selected" class="icon-circle clickable" title="Selected" ng-click="container.selected = false"></i>

<div ng-click="setActiveContainer(container)">
{{container.id}}
{{container.versionId}} / {{container.id}}
</div>
</div>

<div class="box-right">
<i class="icon1point5x icon-signin clickable" ng-show="container.jolokiaUrl && container.alive" title="Open a new window and connect to this container" ng-click="connect(container)"></i>
<i class="icon1point5x" title="{{getTitle(container)}}" ng-class='statusIcon(container)'></i>
<i class="icon1point5x" title="{{getStatusTitle(container)}}" ng-class='statusIcon(container)'></i>
</div>

</div>
Expand All @@ -59,22 +59,17 @@
</div>
<div class="section-controls">

<i class="icon-circle-blank clickable" tytpe="Clear Selection" ng-click="setActiveVersionId('')"></i>

<i class="icon-plus clickable"
title="Create new Version"
ng-click="createVersionDialog = true"></i>
<i class="icon-chevron-sign-right clickable" title="Apply to selected containers" ng-click="applyVersionToContainers()" ng-show="showMigrateButton()"></i>
<i class="icon-circle-blank clickable" title="Clear Selection" ng-click="setActiveVersionId('')"></i>
<i class="icon-plus clickable" title="Create new Version" ng-click="createVersionDialog = true"></i>

<!--
<a ng-href="#/wiki/branch/{{version.id}}/view/" ng-show="hasFabricWiki()"
title="View, edit or create configuration files for the profiles in this version">
<i class="icon-edit"></i>
</a>-->

<i class="icon-minus clickable"
ng-disabled="versionCanBeDeleted()"
ng-click="deleteVersionDialog = true"
title="Delete this Version"></i>
<i class="icon-minus clickable" title="Delete this Version" ng-click="deleteVersionDialog = true" ng-show="activeVersionId && activeVersionId != '' && versionCanBeDeleted()"></i>


</div>
Expand All @@ -95,6 +90,8 @@
Profiles
</div>
<div class="section-controls">

<i class="icon-chevron-sign-right clickable" title="Apply to selected containers" ng-click="addProfilesToContainers()" ng-show="showProfileAddButton()"></i>
<i class="icon-circle-blank clickable" tytpe="Clear Selection" ng-click="clearSelection(profiles)"></i>
<i class="icon-plus clickable" title="Create new Profile" ng-click="createProfileDialog = true"></i>

Expand Down Expand Up @@ -179,7 +176,7 @@
<!-- dialogs -->
<div hawtio-confirm-dialog="deleteVersionDialog" ok-button-text="Yes" cancel-button-text="No" on-ok="deleteVersion()">
<div class="dialog-body">
<p>Delete version {{version.id}}?</p>
<p>Delete version {{activeVersionId}}?</p>
</div>
</div>

Expand Down
110 changes: 45 additions & 65 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricView.ts
Expand Up @@ -139,37 +139,6 @@ module Fabric {
}, true);


// drag/drop handling
$scope.handleDrop = (event, element) => {

//console.log("event: ", event);
//console.log("element: ", element);

var sourceElement = element.draggable.get(0);
var targetElement = event.target;

//console.log("sourceElement: ", sourceElement);
//console.log("targetElement: ", targetElement);

var temp = targetElement.id.split('#');

var targetType = temp[0];
var targetName = temp[1];

temp = sourceElement.id.split('#');

var sourceType = temp[0];
var sourceName = temp[1];

switch(targetType) {
case 'container':
$scope.alterContainer(targetName, sourceType, sourceName);
break;
}

};


// create profile dialog action
$scope.doCreateProfile = () => {
$scope.createProfileDialog = false;
Expand Down Expand Up @@ -217,8 +186,9 @@ module Fabric {
// delete version dialog action
$scope.deleteVersion = () => {

deleteVersion(jolokia, $scope.version.id, function() {
deleteVersion(jolokia, $scope.activeVersionId, function() {
notification('success', "Deleted version " + $scope.version.id);
$scope.activeVersionId = '';
$scope.$apply();
}, function(response) {
notification('error', "Failed to delete version " + $scope.version.id + " due to " + response.error);
Expand All @@ -227,33 +197,6 @@ module Fabric {
};



$scope.alterContainer = (targetName, sourceType, sourceName) => {
switch(sourceType) {
case 'profile':
if ($scope.selectedContainers.length > 0) {
$scope.selectedContainers.each((c) => {
$scope.addProfile(c.id, sourceName);
});
} else {
$scope.addProfile(targetName, sourceName);
}

break;
case 'version':
if ($scope.selectedContainers.length > 0) {
$scope.selectedContainers.each((c) => {
$scope.migrateVersion(c.id, sourceName);
});
} else {
$scope.migrateVersion(targetName, sourceName);
}

break;
}
};


$scope.migrateVersion = (targetName, sourceName) => {
notification('info', "Moving " + targetName + " to " + sourceName);

Expand All @@ -265,13 +208,13 @@ module Fabric {
}


$scope.addProfile = (targetName, sourceName) => {
notification('info', "Adding " + sourceName + " to " + targetName);
$scope.addProfiles = (targetName, profiles) => {
notification('info', "Adding " + profiles.join(', ') + " to " + targetName);

addProfilesToContainer(jolokia, targetName, [sourceName], () => {
notification('success', "Added " + sourceName + " to " + targetName);
addProfilesToContainer(jolokia, targetName, profiles, () => {
notification('success', "Added " + profiles.join(', ') + " to " + targetName);
}, (response) => {
notification('error', "Failed to add " + sourceName + " to " + targetName + " due to " + response.error);
notification('error', "Failed to add " + profiles.join(', ') + " to " + targetName + " due to " + response.error);
});
};

Expand Down Expand Up @@ -360,6 +303,35 @@ module Fabric {
};


$scope.showMigrateButton = () => {
return $scope.selectedContainers.length > 0 && $scope.activeVersionId && $scope.activeVersionId !== '';
};


$scope.applyVersionToContainers = () => {
$scope.selectedContainers.each((c) => {
$scope.migrateVersion(c.id, $scope.activeVersionId);
});
};


$scope.showProfileAddButton = () => {
return $scope.selectedProfiles.length > 0 &&
$scope.selectedContainers.length > 0 &&
$scope.selectedContainers.every((c) => { return c.versionId === $scope.activeVersionId });
};


$scope.addProfilesToContainers = () => {

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

$scope.selectedContainers.each((c) => {
$scope.addProfiles(c.id, profileIds);
});
}


$scope.currentVersionProfiles = (id) => {
if (id === '') {
return [];
Expand Down Expand Up @@ -446,6 +418,14 @@ module Fabric {
};


$scope.versionCanBeDeleted = () => {
return $scope.containers.none((c) => { return c.versionId === $scope.activeVersionId });
};

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


$scope.connect = (row) => {
if (row) {
Expand All @@ -457,7 +437,7 @@ module Fabric {
};


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

if (!container.alive) {
Expand Down

0 comments on commit ca72ff9

Please sign in to comment.