Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bit of work on an alternative fabric view, look at #/fabric/view to s…
…ee it
- Loading branch information
Showing
7 changed files
with
528 additions
and
2 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
hawtio-web/src/main/webapp/app/fabric/html/fabricView.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div ng-controller="Fabric.FabricViewController"> | ||
<div class="row-fluid"> | ||
|
||
<div class="span2"> | ||
<ul> | ||
<li> | ||
<a href="" ng-click="setActiveVersionId('')">Show All</a> | ||
</li> | ||
<li ng-repeat="version in versions"> | ||
<div class="version#{{version.id}}" data-drag="true" jqyoui-draggable="{animate:true, placeholder: keep, index: $index}" data-jqyoui-options="{revert: 'invalid'}"> | ||
<a href="" ng-click="setActiveVersionId(version.id)">{{version.id}} {{containersForVersion(version.id)}}</a> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<div class="span2" ng-show="profiles.length > 0"> | ||
<ul> | ||
<li> | ||
<a href="" ng-click="setActiveProfileId('')">Show All</a> | ||
</li> | ||
<li ng-repeat="profile in profiles"> | ||
<div class="profile#{{profile}}" data-drag="true" jqyoui-draggable="{animate:true, placeholder: keep, index: $index}" data-jqyoui-options="{revert: 'invalid'}"> | ||
<a href="" ng-click="setActiveProfileId(profile)">{{profile}} {{containersForProfile(profile)}}</a> | ||
</div> | ||
</li> | ||
</ul> | ||
|
||
</div> | ||
|
||
<div class="span2"> | ||
<ul> | ||
<li> | ||
<a href="" ng-click="setActiveContainerId('')">Show All</a> | ||
</li> | ||
<li ng-repeat="container in containers"> | ||
<div class="container#{{container.id}}" data-drop="true" jqyoui-droppable="{multiple: false, stack: true, onDrop: 'handleDrop', index: $index}" ng-model="dropContainer"> | ||
<a href="" ng-click="setActiveContainerId(container.id)">{{container.id}}</a> | ||
</div> | ||
</li> | ||
</ul> | ||
|
||
</div> | ||
|
||
<div class="span2"> | ||
<ul> | ||
<li> | ||
<a href="" ng-click="setActiveProfileId('')">Show All</a> | ||
</li> | ||
<li ng-repeat="profile in activeProfiles"> | ||
<a href="" ng-click="setActiveProfileId(profile.id)">{{profile.id}} ({{profile.count}})</a> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
|
||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
module Fabric { | ||
|
||
export function FabricViewController($scope, jolokia) { | ||
|
||
$scope.containerArgs = ["id", "alive", "profileIds", "versionId", "provisionResult", "jolokiaUrl"]; | ||
$scope.versionsOp = 'versions()'; | ||
$scope.containersOp = 'containers(java.util.List)'; | ||
|
||
$scope.activeVersionId = ''; | ||
$scope.activeProfileId = ''; | ||
$scope.versions = []; | ||
$scope.containers = []; | ||
|
||
$scope.profiles = []; | ||
$scope.activeProfiles = []; | ||
|
||
|
||
$scope.$watch('activeVersionId', () => { | ||
$scope.profiles = $scope.currentVersionProfiles($scope.activeVersionId); | ||
}); | ||
|
||
$scope.handleDrop = (event, element) => { | ||
|
||
var sourceElement = $(event.srcElement); | ||
var targetElement = $(event.target); | ||
|
||
console.log("Source: ", sourceElement); | ||
console.log("target: ", targetElement); | ||
|
||
var temp = targetElement.attr('class').split('#'); | ||
|
||
var targetType = temp[0]; | ||
var targetName = temp[1]; | ||
|
||
temp = sourceElement.attr('class').split('#'); | ||
|
||
var sourceType = temp[0]; | ||
var sourceName = temp[1]; | ||
|
||
switch(targetType) { | ||
case 'container': | ||
|
||
switch(sourceType) { | ||
case 'profile': | ||
addProfilesToContainer(jolokia, targetName, [sourceName], () => { | ||
notification('success', "Added " + sourceName + " to " + targetName); | ||
}, (response) => { | ||
notification('error', "Failed to add " + sourceName + " to " + targetName + " due to " + response.error); | ||
}); | ||
break; | ||
case 'version': | ||
migrateContainers(jolokia, sourceName, [targetName], () => { | ||
notification('success', "Moved " + targetName + " to version " + sourceName); | ||
}, (response) => { | ||
notification('error', "Failed to move " + targetName + " to version " + sourceName + " due to " + response.error); | ||
}); | ||
break; | ||
} | ||
|
||
break; | ||
} | ||
|
||
}; | ||
|
||
|
||
$scope.currentVersionProfiles = (id) => { | ||
if (id === '') { | ||
return []; | ||
} | ||
var version = $scope.versions.find((version) => { return version.id === $scope.activeVersionId }); | ||
if (!version) { | ||
return []; | ||
} | ||
return version.profiles; | ||
}; | ||
|
||
|
||
$scope.currentActiveProfiles = () => { | ||
var answer = []; | ||
|
||
$scope.containers.each((container) => { | ||
container.profileIds.each((profile) => { | ||
|
||
var activeProfile = answer.find((o) => { return o.versionId === container.versionId && o.id === profile }); | ||
if (activeProfile) { | ||
activeProfile.count++; | ||
} else { | ||
answer.push({ | ||
id: profile, | ||
count: 1, | ||
version: container.versionId | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
return answer; | ||
}; | ||
|
||
$scope.containersForVersion = (id) => { | ||
var count = $scope.containers.findAll((container) => { return container.versionId === id }).length; | ||
if (count === 0) { | ||
return ''; | ||
} | ||
return "(" + count + ")"; | ||
}; | ||
|
||
|
||
$scope.containersForProfile = (id) => { | ||
var profile = $scope.currentActiveProfiles().find((profile) => { return profile.id === id }); | ||
if (profile) { | ||
return "(" + profile.count + ")"; | ||
} else { | ||
return ""; | ||
} | ||
}; | ||
|
||
|
||
$scope.setActiveProfileId = (id) => { | ||
$scope.activeProfileId = id; | ||
}; | ||
|
||
|
||
$scope.setActiveVersionId = (id) => { | ||
$scope.activeVersionId = id; | ||
}; | ||
|
||
|
||
$scope.updateVersions = (newVersions) => { | ||
var response = angular.toJson(newVersions); | ||
if ($scope.versionsResponse !== response) { | ||
$scope.versionsResponse = response; | ||
$scope.versions = newVersions; | ||
if ($scope.activeVersion !== '') { | ||
$scope.profiles = $scope.currentVersionProfiles($scope.activeVersion); | ||
} | ||
Core.$apply($scope); | ||
} | ||
}; | ||
|
||
|
||
$scope.updateContainers = (newContainers) => { | ||
var response = angular.toJson(newContainers); | ||
if ($scope.containersResponse !== response) { | ||
$scope.containersResponse = response; | ||
$scope.containers = newContainers; | ||
$scope.activeProfiles = $scope.currentActiveProfiles(); | ||
Core.$apply($scope); | ||
} | ||
}; | ||
|
||
|
||
$scope.dispatch = (response) => { | ||
switch (response.request.operation) { | ||
case($scope.versionsOp): | ||
$scope.updateVersions(response.value); | ||
break; | ||
case($scope.containersOp): | ||
$scope.updateContainers(response.value); | ||
break; | ||
} | ||
}; | ||
|
||
|
||
Core.register(jolokia, $scope, [ | ||
{type: 'exec', mbean: managerMBean, operation: $scope.versionsOp }, | ||
{type: 'exec', mbean: managerMBean, operation: $scope.containersOp, arguments: [$scope.containerArgs]} | ||
], onSuccess($scope.dispatch)); | ||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.