From 7a5ee710801542f58678e8cccabc226ed90eb07c Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Mon, 26 Jan 2015 17:22:57 -0500 Subject: [PATCH] Use Monitor's WebColour in Host 'Disk Usage' graph --- web/api/app/Controller/HostController.php | 21 +++++++++++--- web/skins/bootstrap/js/controllers.js | 34 +++++++++++------------ web/skins/bootstrap/views/host.php | 10 +++---- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index 6f9cd80ea..973caf286 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -61,23 +61,36 @@ class HostController extends AppController { // Get disk usage for $mid $usage = shell_exec ("du -sh0 $zm_dir_events/$mid | awk '{print $1}'"); } else { - $monitors = $this->Monitor->find('list'); + $monitors = $this->Monitor->find('all', array( + 'fields' => array('Id', 'Name', 'WebColour') + )); $usage = array(); // Add each monitor's usage to array - foreach ($monitors as $id => $name) { + foreach ($monitors as $key => $value) { + $id = $value['Monitor']['Id']; + $name = $value['Monitor']['Name']; + $color = $value['Monitor']['WebColour']; + $space = shell_exec ("du -s0 $zm_dir_events/$id | awk '{print $1}'"); if ($space == null) { $space = 0; } $space = $space/1024/1024; - $usage[$name] = rtrim($space); + + $usage[$name] = array( + 'space' => rtrim($space), + 'color' => $color + ); } // Add total usage to array $space = shell_exec( "df $zm_dir_events |tail -n1 | awk '{print $3 }'"); $space = $space/1024/1024; - $usage['Total'] = rtrim($space); + $usage['Total'] = array( + 'space' => rtrim($space), + 'color' => '#F7464A' + ); } $this->set(array( diff --git a/web/skins/bootstrap/js/controllers.js b/web/skins/bootstrap/js/controllers.js index 1005fae21..71d31c895 100644 --- a/web/skins/bootstrap/js/controllers.js +++ b/web/skins/bootstrap/js/controllers.js @@ -333,19 +333,31 @@ ZoneMinder.controller('ConfigController', function($scope, $http, Config) { }); ZoneMinder.controller('HostController', function($scope, Host) { - Host.getDiskPercent(function(diskPercent) { + Host.getDiskPercent(function(diskPercent) { var array = []; angular.forEach(diskPercent.usage, function(value, key) { var a = { - 'value' : Math.floor(value), + 'value' : Math.floor(value.space), 'label' : key, - 'color' : '#F7464A', - 'highlight' : '#FFC870', + 'color' : value.color }; array.push(a); }); $scope.ddata = array; - }); + + $scope.doptions = { + responsive: false, + segmentShowStroke : true, + segmentStrokeColor : '#fff', + segmentStrokeWidth : 2, + percentageInnerCutout : 50, // This is 0 for Pie charts + animationSteps : 1, + animationEasing : 'easeOutBounce', + animateRotate : false, + animateScale : false, + legendTemplate : '' + }; + }); Host.getLoad(function(load) { $scope.loadData = { @@ -363,16 +375,4 @@ ZoneMinder.controller('HostController', function($scope, Host) { }; }); - $scope.doptions = { - responsive: false, - segmentShowStroke : true, - segmentStrokeColor : '#fff', - segmentStrokeWidth : 2, - percentageInnerCutout : 50, // This is 0 for Pie charts - animationSteps : 1, - animationEasing : 'easeOutBounce', - animateRotate : false, - animateScale : false, - legendTemplate : '' - }; }); diff --git a/web/skins/bootstrap/views/host.php b/web/skins/bootstrap/views/host.php index d7383154b..2a27fefbb 100644 --- a/web/skins/bootstrap/views/host.php +++ b/web/skins/bootstrap/views/host.php @@ -9,20 +9,18 @@ xhtmlHeaders( __FILE__, 'Host' );
-
+

Disk Usage in Gigabytes

-
-
-
+
-
+

CPU Load

- +