Skip to content

Commit

Permalink
The active memory and swap charts will now show a danger highlight if…
Browse files Browse the repository at this point in the history
… above the memory threshold.
  • Loading branch information
xcjs committed Aug 30, 2016
1 parent 0b25001 commit 26a251a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/app/pages/memory/memory.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
'$interval',
'refreshInterval',
'MemoryResource',
'memoryPercentageThreshold',
MemoryController]);

function MemoryController($scope, $interval, refreshInterval, MemoryResource) {
function MemoryController($scope, $interval, refreshInterval, MemoryResource, memoryPercentageThreshold) {
var vm = this;

vm.memory = {};
vm.memoryPercentageThreshold = memoryPercentageThreshold;

vm.activeChartData = [];
vm.activeChartLabels = [];

vm.usedMemoryPercent = 0;

vm.detailedChartData = [];
vm.detailedChartLabels = [];

Expand All @@ -25,6 +29,8 @@
vm.swapChartData = [];
vm.swapChartLabels = [];

vm.usedSwapPercent = 0;

vm.chartOptions = {
animation: false,
showTooltips: false
Expand All @@ -47,6 +53,8 @@
vm.activeChartData[0] = vm.memory.used;
vm.activeChartLabels[0] = buildChartLabel('Used', vm.memory.used);

vm.usedMemoryPercent = calcTotalMemPercent(vm.memory.used);

vm.activeChartData[1] = (vm.memory.total - vm.memory.used).toFixed(0);
vm.activeChartLabels[1] = buildChartLabel('Available', vm.activeChartData[1]);

Expand All @@ -69,6 +77,8 @@
vm.swapChartData[0] = vm.memory.swap.used;
vm.swapChartLabels[0] = buildChartLabel('Used', vm.memory.swap.used, calcSwapPercent);

vm.usedSwapPercent = calcSwapPercent(vm.swapChartData[0]);

vm.swapChartData[1] = (vm.memory.swap.total - vm.memory.swap.used).toFixed(2);
vm.swapChartLabels[1] = buildChartLabel('Free', vm.swapChartData[1], calcSwapPercent);
});
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/memory/memory.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="row">

<div ng-if="vm.activeChartData.length > 0" class="col-md-4">
<div ba-panel ba-panel-title="Active Memory Utilization" ba-panel-class="with-scroll ">
<div ba-panel ba-panel-title="Active Memory Utilization" ba-panel-class="with-scroll "
ng-class="{'panel-danger': vm.usedMemoryPercent >= vm.memoryPercentageThreshold}">
<h4>{{vm.memory.total}} MB</h4>
<canvas id="pie" class="chart chart-pie" chart-data="vm.activeChartData" chart-labels="vm.activeChartLabels"
chart-legend="true" chart-options="vm.chartOptions"></canvas>
Expand All @@ -17,7 +18,8 @@ <h4>{{vm.memory.total}} MB</h4>
</div>

<div ng-if="vm.swapChartData.length > 0" class="col-md-4">
<div ba-panel ba-panel-title="Swap Utilization" ba-panel-class="with-scroll ">
<div ba-panel ba-panel-title="Swap Utilization" ba-panel-class="with-scroll "
ng-class="{'panel-danger': vm.usedSwapPrecent >= vm.memoryPercentageThreshold}">
<h4>{{vm.memory.swap.total}} MB</h4>
<canvas id="pie" class="chart chart-pie" chart-data="vm.swapChartData" chart-labels="vm.swapChartLabels"
chart-legend="true" chart-options="vm.chartOptions"></canvas>
Expand Down

0 comments on commit 26a251a

Please sign in to comment.