Skip to content

Commit 26a251a

Browse files
committed
The active memory and swap charts will now show a danger highlight if above the memory threshold.
1 parent 0b25001 commit 26a251a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/app/pages/memory/memory.controller.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
'$interval',
77
'refreshInterval',
88
'MemoryResource',
9+
'memoryPercentageThreshold',
910
MemoryController]);
1011

11-
function MemoryController($scope, $interval, refreshInterval, MemoryResource) {
12+
function MemoryController($scope, $interval, refreshInterval, MemoryResource, memoryPercentageThreshold) {
1213
var vm = this;
1314

1415
vm.memory = {};
16+
vm.memoryPercentageThreshold = memoryPercentageThreshold;
1517

1618
vm.activeChartData = [];
1719
vm.activeChartLabels = [];
1820

21+
vm.usedMemoryPercent = 0;
22+
1923
vm.detailedChartData = [];
2024
vm.detailedChartLabels = [];
2125

@@ -25,6 +29,8 @@
2529
vm.swapChartData = [];
2630
vm.swapChartLabels = [];
2731

32+
vm.usedSwapPercent = 0;
33+
2834
vm.chartOptions = {
2935
animation: false,
3036
showTooltips: false
@@ -47,6 +53,8 @@
4753
vm.activeChartData[0] = vm.memory.used;
4854
vm.activeChartLabels[0] = buildChartLabel('Used', vm.memory.used);
4955

56+
vm.usedMemoryPercent = calcTotalMemPercent(vm.memory.used);
57+
5058
vm.activeChartData[1] = (vm.memory.total - vm.memory.used).toFixed(0);
5159
vm.activeChartLabels[1] = buildChartLabel('Available', vm.activeChartData[1]);
5260

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

80+
vm.usedSwapPercent = calcSwapPercent(vm.swapChartData[0]);
81+
7282
vm.swapChartData[1] = (vm.memory.swap.total - vm.memory.swap.used).toFixed(2);
7383
vm.swapChartLabels[1] = buildChartLabel('Free', vm.swapChartData[1], calcSwapPercent);
7484
});

src/app/pages/memory/memory.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="row">
22

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

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

0 commit comments

Comments
 (0)