Skip to content

Commit

Permalink
Make the remainder text configurable or even be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Sep 20, 2013
1 parent 20c969e commit 0f38fc8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
49 changes: 29 additions & 20 deletions hawtio-web/src/main/webapp/app/jmx/js/donutChart.ts
Expand Up @@ -25,7 +25,7 @@ module Jmx {
$scope.attribute = $routeParams['attribute'];
$scope.terms = $routeParams['terms'];

$scope.remainder = "Remaining";
$scope.remainder = $routeParams['remaining'];

$scope.template = "";
$scope.termsArray = $scope.terms.split(",");
Expand Down Expand Up @@ -58,10 +58,12 @@ module Jmx {
});
}

$scope.data.terms.push({
term: $scope.remainder,
count: 0
});
if ($scope.remainder && $scope.remainder !== "-") {
$scope.data.terms.push({
term: $scope.remainder,
count: 0
});
}

/*
$scope.data = {
Expand All @@ -79,9 +81,12 @@ module Jmx {
$scope.render = (response) => {
//console.log("got: ", response);

var freeTerm = $scope.data.terms.find((term) => {
return term.term === $scope.remainder;
});
var freeTerm = null;
if ($scope.remainder && $scope.remainder !== "-") {
freeTerm = $scope.data.terms.find((term) => {
return term.term === $scope.remainder;
});
}

if (!$scope.attribute) {
if (response.request.attribute === $scope.total) {
Expand All @@ -94,12 +99,14 @@ module Jmx {
term.count = response.value;
}

freeTerm.count = $scope.data.total;
$scope.data.terms.forEach((term) => {
if (term.term !== $scope.remainder) {
freeTerm.count = freeTerm.count - term.count;
}
});
if (freeTerm) {
freeTerm.count = $scope.data.total;
$scope.data.terms.forEach((term) => {
if (term.term !== $scope.remainder) {
freeTerm.count = freeTerm.count - term.count;
}
});
}
}
} else {
if (response.request.attribute === $scope.attribute) {
Expand All @@ -111,12 +118,14 @@ module Jmx {
}
});

freeTerm.count = $scope.data.total;
$scope.data.terms.forEach((term) => {
if (term.term !== $scope.remainder) {
freeTerm.count = freeTerm.count - term.count;
}
});
if (freeTerm) {
freeTerm.count = $scope.data.total;
$scope.data.terms.forEach((term) => {
if (term.term !== $scope.remainder) {
freeTerm.count = freeTerm.count - term.count;
}
});
}
}
}
if ($scope.template === "") {
Expand Down
22 changes: 10 additions & 12 deletions hawtio-web/src/main/webapp/app/jmx/js/widgetRepository.ts
Expand Up @@ -40,43 +40,41 @@ module Jmx {
mbean: "java.lang:type=Memory",
attribute: "HeapMemoryUsage",
total: "Max",
terms: "Used"
terms: "Used",
remaining: "Free"
},
{
type: "donut",
title: "Java Non Heap Memory",
mbean: "java.lang:type=Memory",
attribute: "NonHeapMemoryUsage",
total: "Max",
terms: "Used"
terms: "Used",
remaining: "Free"
},
{
type: "donut",
title: "File Descriptor Usage",
mbean: "java.lang:type=OperatingSystem",
total: "MaxFileDescriptorCount",
terms: "OpenFileDescriptorCount"
terms: "OpenFileDescriptorCount",
remaining: "Free"
},
{
type: "donut",
title: "Loaded Clases",
mbean: "java.lang:type=ClassLoading",
total: "TotalLoadedClassCount",
terms: "LoadedClassCount,UnloadedClassCount"
},
{
type: "donut",
title: "Free Memory",
mbean: "java.lang:type=OperatingSystem",
total: "TotalPhysicalMemorySize",
terms: "FreePhysicalMemorySize"
terms: "LoadedClassCount,UnloadedClassCount",
remaining: "-"
},
{
type: "donut",
title: "Swap Size",
mbean: "java.lang:type=OperatingSystem",
total: "TotalSwapSpaceSize",
terms: "FreeSwapSpaceSize"
terms: "FreeSwapSpaceSize",
remaining: "Used Swap"
}
];

Expand Down

0 comments on commit 0f38fc8

Please sign in to comment.