Format code using clang-format-5.0
Once merged, this repository will have CI enforce
the coding guidelines in the .clang-format file.
Change-Id: I96a05972665f9c67625c6850c3da25edc540be06
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/app/server-health/controllers/diagnostics-controller.js b/app/server-health/controllers/diagnostics-controller.js
index b28d61f..0f6763f 100644
--- a/app/server-health/controllers/diagnostics-controller.js
+++ b/app/server-health/controllers/diagnostics-controller.js
@@ -9,16 +9,11 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .controller('diagnosticsController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
- }
- ]);
+ angular.module('app.serverHealth').controller('diagnosticsController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/inventory-controller.js b/app/server-health/controllers/inventory-controller.js
index 17c9057..df9ca1c 100644
--- a/app/server-health/controllers/inventory-controller.js
+++ b/app/server-health/controllers/inventory-controller.js
@@ -9,19 +9,14 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .controller('inventoryController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
+ angular.module('app.serverHealth').controller('inventoryController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
- // Force to top of page when viewing single group
- $window.scrollTo(0, 0);
- }
- ]);
+ // Force to top of page when viewing single group
+ $window.scrollTo(0, 0);
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/inventory-overview-controller.js b/app/server-health/controllers/inventory-overview-controller.js
index a0dad75..9705395 100644
--- a/app/server-health/controllers/inventory-overview-controller.js
+++ b/app/server-health/controllers/inventory-overview-controller.js
@@ -9,68 +9,64 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .controller('inventoryOverviewController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
- $scope.hardwares = [];
- $scope.originalData = {};
+ angular.module('app.serverHealth').controller('inventoryOverviewController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
+ $scope.hardwares = [];
+ $scope.originalData = {};
+ $scope.customSearch = '';
+ $scope.searchTerms = [];
+ $scope.loading = false;
+
+ $scope.loading = true;
+ APIUtils.getHardwares(function(data, originalData) {
+ $scope.hardwares = data;
+ $scope.originalData = JSON.stringify(originalData);
+ $scope.loading = false;
+ });
+
+ $scope.clear = function() {
$scope.customSearch = '';
$scope.searchTerms = [];
- $scope.loading = false;
+ };
- $scope.loading = true;
- APIUtils.getHardwares(function(data, originalData) {
- $scope.hardwares = data;
- $scope.originalData = JSON.stringify(originalData);
- $scope.loading = false;
- });
-
- $scope.clear = function() {
- $scope.customSearch = '';
- $scope.searchTerms = [];
- };
-
- $scope.doSearchOnEnter = function(event) {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (event.keyCode === 13 &&
- search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
+ $scope.doSearchOnEnter = function(event) {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (event.keyCode === 13 && search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
}
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
- }
- };
+ }
+ };
- $scope.doSearchOnClick = function() {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
+ $scope.doSearchOnClick = function() {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
}
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
- }
- };
+ }
+ };
- $scope.filterBySearchTerms = function(hardware) {
+ $scope.filterBySearchTerms = function(hardware) {
- if (!$scope.searchTerms.length) return true;
+ if (!$scope.searchTerms.length) return true;
- for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
- if (hardware.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
- }
- return true;
- };
- }
- ]);
+ for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+ if (hardware.search_text.indexOf(
+ $scope.searchTerms[i].toLowerCase()) == -1)
+ return false;
+ }
+ return true;
+ };
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js
index 1a01242..4359c9c 100644
--- a/app/server-health/controllers/log-controller.js
+++ b/app/server-health/controllers/log-controller.js
@@ -8,190 +8,183 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .config(function(paginationTemplateProvider) {
- paginationTemplateProvider.setString(require('../../common/directives/dirPagination.tpl.html'));
- })
- .controller('logController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- 'Constants',
- '$routeParams',
- '$filter',
- function($scope, $window, APIUtils, dataService, Constants, $routeParams, $filter) {
- $scope.dataService = dataService;
- $scope.logs = [];
- $scope.tmz = 'EDT';
- $scope.itemsPerPage = Constants.PAGINATION.LOG_ITEMS_PER_PAGE;
- $scope.loading = false;
- var expandedSelectedIdOnce = false;
+ angular.module('app.serverHealth')
+ .config(function(paginationTemplateProvider) {
+ paginationTemplateProvider.setString(
+ require('../../common/directives/dirPagination.tpl.html'));
+ })
+ .controller('logController', [
+ '$scope', '$window', 'APIUtils', 'dataService', 'Constants',
+ '$routeParams', '$filter',
+ function(
+ $scope, $window, APIUtils, dataService, Constants, $routeParams,
+ $filter) {
+ $scope.dataService = dataService;
+ $scope.logs = [];
+ $scope.tmz = 'EDT';
+ $scope.itemsPerPage = Constants.PAGINATION.LOG_ITEMS_PER_PAGE;
+ $scope.loading = false;
+ var expandedSelectedIdOnce = false;
- var sensorType = $routeParams.type;
- var eventId = $routeParams.id;
+ var sensorType = $routeParams.type;
+ var eventId = $routeParams.id;
- // priority buttons
- $scope.selectedSeverity = {
- all: true,
- low: false,
- medium: false,
- high: false
- };
+ // priority buttons
+ $scope.selectedSeverity =
+ {all: true, low: false, medium: false, high: false};
- if (sensorType == 'high') {
- $scope.selectedSeverity.all = false;
- $scope.selectedSeverity.high = true;
- }
-
- $scope.selectedStatus = {
- all: true,
- resolved: false
- };
-
- $scope.customSearch = '';
- $scope.searchItems = [];
- $scope.selectedEvents = [];
-
-
- if (eventId) {
- $scope.customSearch = '#' + eventId;
- $scope.searchItems.push('#' + eventId);
- }
-
- $scope.loadLogs = function() {
- $scope.loading = true;
- APIUtils.getLogs().then(function(result) {
- if (eventId && expandedSelectedIdOnce == false) {
- var log = result.data.filter(function(item) {
- return item.Id == eventId;
- });
-
- if (log.length) {
- log[0].meta = true;
- }
- expandedSelectedIdOnce = true;
- }
- dataService.updateServerHealth(result.data);
- $scope.logs = result.data;
- $scope.originalData = result.original;
- $scope.loading = false;
- });
- };
- $scope.jsonData = function(data) {
- return JSON.stringify(data);
- };
-
- $scope.filterBySeverity = function(log) {
- if ($scope.selectedSeverity.all) return true;
-
- return ((log.severity_flags.low && $scope.selectedSeverity.low) ||
- (log.severity_flags.medium && $scope.selectedSeverity.medium) ||
- (log.severity_flags.high && $scope.selectedSeverity.high)
- );
- };
-
- $scope.filterByStatus = function(log) {
- if ($scope.selectedStatus.all) return true;
- return ((log.Resolved && $scope.selectedStatus.resolved) ||
- (!log.Resolved && !$scope.selectedStatus.resolved)
- );
- };
-
- $scope.filterByDate = function(log) {
- var endDate;
- if ($scope.end_date && typeof $scope.end_date.getTime === 'function') {
- endDate = new Date($scope.end_date.getTime());
- endDate.setTime(endDate.getTime() + 86399000);
+ if (sensorType == 'high') {
+ $scope.selectedSeverity.all = false;
+ $scope.selectedSeverity.high = true;
}
- if ($scope.start_date && endDate) {
- var date = new Date($filter('date')(log.Timestamp, 'MM/dd/yyyy HH:mm:ss', $scope.tmz));
- return (date >= $scope.start_date &&
- date <= endDate);
- }
- else {
- return true;
- }
- };
+ $scope.selectedStatus = {all: true, resolved: false};
- $scope.filterBySearchTerms = function(log) {
- if (!$scope.searchItems.length) return true;
-
- for (var i = 0, length = $scope.searchItems.length; i < length; i++) {
- if (log.search_text.indexOf($scope.searchItems[i].toLowerCase()) == -1) return false;
- }
- return true;
- };
-
- $scope.addSearchItem = function(searchTerms) {
- var terms = searchTerms.split(' ');
- terms.forEach(function(searchTerm) {
- if ($scope.searchItems.indexOf(searchTerm) == -1) {
- $scope.searchItems.push(searchTerm);
- }
- });
- };
-
- $scope.clearSearchItem = function(searchTerm) {
+ $scope.customSearch = '';
$scope.searchItems = [];
- };
+ $scope.selectedEvents = [];
- $scope.removeSearchItem = function(searchTerm) {
- var termIndex = $scope.searchItems.indexOf(searchTerm);
-
- if (termIndex > -1) {
- $scope.searchItems.splice(termIndex, 1);
+ if (eventId) {
+ $scope.customSearch = '#' + eventId;
+ $scope.searchItems.push('#' + eventId);
}
- };
- $scope.$watch('all', function() {
- $scope.logs.forEach(function(item) {
- item.selected = $scope.all;
- });
- });
+ $scope.loadLogs = function() {
+ $scope.loading = true;
+ APIUtils.getLogs().then(function(result) {
+ if (eventId && expandedSelectedIdOnce == false) {
+ var log = result.data.filter(function(item) {
+ return item.Id == eventId;
+ });
- function updateExportData() {
- $scope.export_name = ($scope.selectedEvents.length == 1) ? $scope.selectedEvents[0].Id + '.json' : 'export.json';
- var data = {};
- $scope.selectedEvents.forEach(function(item) {
- data[item.data.key] = item.data.value;
- });
- $scope.export_data = JSON.stringify(data);
- }
+ if (log.length) {
+ log[0].meta = true;
+ }
+ expandedSelectedIdOnce = true;
+ }
+ dataService.updateServerHealth(result.data);
+ $scope.logs = result.data;
+ $scope.originalData = result.original;
+ $scope.loading = false;
+ });
+ };
+ $scope.jsonData = function(data) {
+ return JSON.stringify(data);
+ };
+ $scope.filterBySeverity = function(log) {
+ if ($scope.selectedSeverity.all) return true;
- $scope.accept = function() {
- APIUtils.deleteLogs($scope.selectedEvents).then(function() {
- $scope.confirm = false;
- $scope.loadLogs();
- });
- };
+ return (
+ (log.severity_flags.low && $scope.selectedSeverity.low) ||
+ (log.severity_flags.medium && $scope.selectedSeverity.medium) ||
+ (log.severity_flags.high && $scope.selectedSeverity.high));
+ };
- $scope.resolve = function() {
- var events = $scope.selectedEvents.filter(function(item) {
- return item.Resolved != 1;
- });
+ $scope.filterByStatus = function(log) {
+ if ($scope.selectedStatus.all) return true;
+ return (
+ (log.Resolved && $scope.selectedStatus.resolved) ||
+ (!log.Resolved && !$scope.selectedStatus.resolved));
+ };
- if (!events.length) return;
+ $scope.filterByDate = function(log) {
+ var endDate;
+ if ($scope.end_date &&
+ typeof $scope.end_date.getTime === 'function') {
+ endDate = new Date($scope.end_date.getTime());
+ endDate.setTime(endDate.getTime() + 86399000);
+ }
- APIUtils.resolveLogs(events).then(function() {
- events.forEach(function(item) {
- item.Resolved = 1;
+ if ($scope.start_date && endDate) {
+ var date = new Date($filter('date')(
+ log.Timestamp, 'MM/dd/yyyy HH:mm:ss', $scope.tmz));
+ return (date >= $scope.start_date && date <= endDate);
+ } else {
+ return true;
+ }
+ };
+
+ $scope.filterBySearchTerms = function(log) {
+ if (!$scope.searchItems.length) return true;
+
+ for (var i = 0, length = $scope.searchItems.length; i < length;
+ i++) {
+ if (log.search_text.indexOf(
+ $scope.searchItems[i].toLowerCase()) == -1)
+ return false;
+ }
+ return true;
+ };
+
+ $scope.addSearchItem = function(searchTerms) {
+ var terms = searchTerms.split(' ');
+ terms.forEach(function(searchTerm) {
+ if ($scope.searchItems.indexOf(searchTerm) == -1) {
+ $scope.searchItems.push(searchTerm);
+ }
+ });
+ };
+
+ $scope.clearSearchItem = function(searchTerm) {
+ $scope.searchItems = [];
+ };
+
+ $scope.removeSearchItem = function(searchTerm) {
+ var termIndex = $scope.searchItems.indexOf(searchTerm);
+
+ if (termIndex > -1) {
+ $scope.searchItems.splice(termIndex, 1);
+ }
+ };
+
+ $scope.$watch('all', function() {
+ $scope.logs.forEach(function(item) {
+ item.selected = $scope.all;
});
});
- };
- $scope.$watch('logs', function() {
- $scope.selectedEvents = $scope.logs.filter(function(item) {
- return item.selected;
- });
- updateExportData();
- }, true);
+ function updateExportData() {
+ $scope.export_name = ($scope.selectedEvents.length == 1) ?
+ $scope.selectedEvents[0].Id + '.json' :
+ 'export.json';
+ var data = {};
+ $scope.selectedEvents.forEach(function(item) {
+ data[item.data.key] = item.data.value;
+ });
+ $scope.export_data = JSON.stringify(data);
+ }
- $scope.loadLogs();
- }
- ]);
+ $scope.accept = function() {
+ APIUtils.deleteLogs($scope.selectedEvents).then(function() {
+ $scope.confirm = false;
+ $scope.loadLogs();
+ });
+ };
+
+ $scope.resolve = function() {
+ var events = $scope.selectedEvents.filter(function(item) {
+ return item.Resolved != 1;
+ });
+
+ if (!events.length) return;
+
+ APIUtils.resolveLogs(events).then(function() {
+ events.forEach(function(item) {
+ item.Resolved = 1;
+ });
+ });
+ };
+
+ $scope.$watch('logs', function() {
+ $scope.selectedEvents = $scope.logs.filter(function(item) {
+ return item.selected;
+ });
+ updateExportData();
+ }, true);
+
+ $scope.loadLogs();
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/power-consumption-controller.js b/app/server-health/controllers/power-consumption-controller.js
index 9a74e6d..51882e4 100644
--- a/app/server-health/controllers/power-consumption-controller.js
+++ b/app/server-health/controllers/power-consumption-controller.js
@@ -9,16 +9,11 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .controller('powerConsumptionController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
- }
- ]);
+ angular.module('app.serverHealth').controller('powerConsumptionController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/sensors-controller.js b/app/server-health/controllers/sensors-controller.js
index 70f3e9c..5f687a0 100644
--- a/app/server-health/controllers/sensors-controller.js
+++ b/app/server-health/controllers/sensors-controller.js
@@ -9,133 +9,122 @@
window.angular && (function(angular) {
'use strict';
var sensorData = [];
- angular
- .module('app.overview')
- .controller('sensorsController', [
- '$scope',
- '$log',
- '$window',
- 'APIUtils',
- 'dataService',
- '$routeParams',
- function($scope, $log, $window, APIUtils, dataService, $routeParams) {
- $scope.dataService = dataService;
- $scope.customSearch = '';
- $scope.dropdown_selected = false;
- $scope.$log = $log;
- $scope.data = {};
- $scope.searchTerms = [];
+ angular.module('app.overview').controller('sensorsController', [
+ '$scope', '$log', '$window', 'APIUtils', 'dataService', '$routeParams',
+ function($scope, $log, $window, APIUtils, dataService, $routeParams) {
+ $scope.dataService = dataService;
+ $scope.customSearch = '';
+ $scope.dropdown_selected = false;
+ $scope.$log = $log;
+ $scope.data = {};
+ $scope.searchTerms = [];
- $scope.selectedSeverity = {
- all: true,
- normal: false,
- warning: false,
- critical: false
- };
+ $scope.selectedSeverity =
+ {all: true, normal: false, warning: false, critical: false};
- var sensorType = $routeParams.type;
+ var sensorType = $routeParams.type;
- $scope.export_name = sensorType + '_sensors.json';
+ $scope.export_name = sensorType + '_sensors.json';
- $scope.toggleSeverityAll = function() {
- $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+ $scope.toggleSeverityAll = function() {
+ $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
- if ($scope.selectedSeverity.all) {
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
- }
- };
+ if ($scope.selectedSeverity.all) {
+ $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.warning = false;
+ $scope.selectedSeverity.critical = false;
+ }
+ };
- $scope.toggleSeverity = function(severity) {
- $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
+ $scope.toggleSeverity = function(severity) {
+ $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
- if ($scope.selectedSeverity.normal &&
- $scope.selectedSeverity.warning &&
+ if ($scope.selectedSeverity.normal && $scope.selectedSeverity.warning &&
$scope.selectedSeverity.critical) {
- $scope.selectedSeverity.all = true;
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
- }
- else {
- $scope.selectedSeverity.all = false;
- }
- };
+ $scope.selectedSeverity.all = true;
+ $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.warning = false;
+ $scope.selectedSeverity.critical = false;
+ } else {
+ $scope.selectedSeverity.all = false;
+ }
+ };
- $scope.doSearchOnEnter = function(event) {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (event.keyCode === 13 &&
- search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
- }
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
- }
- };
-
- $scope.doSearchOnClick = function() {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
- }
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
- }
- };
-
- $scope.jsonData = function(data) {
- var dt = {};
- data.data.forEach(function(item) {
- dt[item.original_data.key] = item.original_data.value;
- });
- return JSON.stringify(dt);
- };
-
- $scope.filterBySeverity = function(sensor) {
- if ($scope.selectedSeverity.all) return true;
-
- return ((sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
- (sensor.severity_flags.warning && $scope.selectedSeverity.warning) ||
- (sensor.severity_flags.critical && $scope.selectedSeverity.critical)
- );
- };
- $scope.filterBySearchTerms = function(sensor) {
-
- if (!$scope.searchTerms.length) return true;
-
- for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
- if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
- }
- return true;
- };
-
- function setSensorData() {
- var data = dataService.sensorData.sensors.filter(function(item) {
- return item.type == sensorType;
- });
- if (data.length) {
- sensorData = data[0];
- $scope.data = sensorData;
- $scope.export_data = $scope.jsonData($scope.data);
+ $scope.doSearchOnEnter = function(event) {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (event.keyCode === 13 && search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
}
}
+ };
- if (!dataService.sensorData.sensors) {
- APIUtils.getAllSensorStatus(function(data, originalData) {
- dataService.sensorData = data;
- setSensorData();
- });
+ $scope.doSearchOnClick = function() {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
+ }
}
- else {
- setSensorData();
- }
+ };
+ $scope.jsonData = function(data) {
+ var dt = {};
+ data.data.forEach(function(item) {
+ dt[item.original_data.key] = item.original_data.value;
+ });
+ return JSON.stringify(dt);
+ };
+
+ $scope.filterBySeverity = function(sensor) {
+ if ($scope.selectedSeverity.all) return true;
+
+ return (
+ (sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
+ (sensor.severity_flags.warning &&
+ $scope.selectedSeverity.warning) ||
+ (sensor.severity_flags.critical &&
+ $scope.selectedSeverity.critical));
+ };
+ $scope.filterBySearchTerms = function(sensor) {
+
+ if (!$scope.searchTerms.length) return true;
+
+ for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+ if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) ==
+ -1)
+ return false;
+ }
+ return true;
+ };
+
+ function setSensorData() {
+ var data = dataService.sensorData.sensors.filter(function(item) {
+ return item.type == sensorType;
+ });
+ if (data.length) {
+ sensorData = data[0];
+ $scope.data = sensorData;
+ $scope.export_data = $scope.jsonData($scope.data);
+ }
}
- ]);
+
+ if (!dataService.sensorData.sensors) {
+ APIUtils.getAllSensorStatus(function(data, originalData) {
+ dataService.sensorData = data;
+ setSensorData();
+ });
+ } else {
+ setSensorData();
+ }
+
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/sensors-overview-controller.js b/app/server-health/controllers/sensors-overview-controller.js
index 683d071..77d2978 100644
--- a/app/server-health/controllers/sensors-overview-controller.js
+++ b/app/server-health/controllers/sensors-overview-controller.js
@@ -8,138 +8,127 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.overview')
- .controller('sensorsOverviewController', [
- '$scope',
- '$log',
- '$window',
- 'APIUtils',
- 'dataService',
- 'Constants',
- function($scope, $log, $window, APIUtils, dataService, Constants) {
- $scope.dataService = dataService;
+ angular.module('app.overview').controller('sensorsOverviewController', [
+ '$scope', '$log', '$window', 'APIUtils', 'dataService', 'Constants',
+ function($scope, $log, $window, APIUtils, dataService, Constants) {
+ $scope.dataService = dataService;
- $scope.dropdown_selected = false;
+ $scope.dropdown_selected = false;
- $scope.$log = $log;
+ $scope.$log = $log;
+ $scope.customSearch = '';
+ $scope.searchTerms = [];
+ $scope.messages = Constants.MESSAGES.SENSOR;
+ $scope.selectedSeverity =
+ {all: true, normal: false, warning: false, critical: false};
+ $scope.export_name = 'sensors.json';
+ $scope.loading = false;
+ $scope.jsonData = function(data) {
+ var dt = {};
+ data.data.forEach(function(item) {
+ dt[item.original_data.key] = item.original_data.value;
+ });
+ return JSON.stringify(dt);
+ };
+
+ $scope.clear = function() {
$scope.customSearch = '';
$scope.searchTerms = [];
- $scope.messages = Constants.MESSAGES.SENSOR;
- $scope.selectedSeverity = {
- all: true,
- normal: false,
- warning: false,
- critical: false
- };
- $scope.export_name = 'sensors.json';
- $scope.loading = false;
- $scope.jsonData = function(data) {
- var dt = {};
- data.data.forEach(function(item) {
- dt[item.original_data.key] = item.original_data.value;
- });
- return JSON.stringify(dt);
- };
+ };
- $scope.clear = function() {
- $scope.customSearch = '';
- $scope.searchTerms = [];
- };
-
- $scope.doSearchOnEnter = function(event) {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (event.keyCode === 13 &&
- search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
+ $scope.doSearchOnEnter = function(event) {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (event.keyCode === 13 && search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
}
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
+ }
+ };
+
+ $scope.doSearchOnClick = function() {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
}
- };
+ }
+ };
- $scope.doSearchOnClick = function() {
- var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
- if (search.length >= 2) {
- $scope.searchTerms = $scope.customSearch.split(' ');
- }
- else {
- if (search.length == 0) {
- $scope.searchTerms = [];
- }
- }
- };
+ $scope.toggleSeverityAll = function() {
+ $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
- $scope.toggleSeverityAll = function() {
- $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+ if ($scope.selectedSeverity.all) {
+ $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.warning = false;
+ $scope.selectedSeverity.critical = false;
+ }
+ };
- if ($scope.selectedSeverity.all) {
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
- }
- };
+ $scope.toggleSeverity = function(severity) {
+ $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
- $scope.toggleSeverity = function(severity) {
- $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
-
- if (['normal', 'warning', 'critical'].indexOf(severity) > -1) {
- if ($scope.selectedSeverity[severity] == false &&
+ if (['normal', 'warning', 'critical'].indexOf(severity) > -1) {
+ if ($scope.selectedSeverity[severity] == false &&
(!$scope.selectedSeverity.normal &&
- !$scope.selectedSeverity.warning &&
- !$scope.selectedSeverity.critical
- )) {
- $scope.selectedSeverity.all = true;
- return;
- }
- }
-
- if ($scope.selectedSeverity.normal &&
- $scope.selectedSeverity.warning &&
- $scope.selectedSeverity.critical) {
+ !$scope.selectedSeverity.warning &&
+ !$scope.selectedSeverity.critical)) {
$scope.selectedSeverity.all = true;
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
+ return;
}
- else {
- $scope.selectedSeverity.all = false;
- }
- };
+ }
- $scope.filterBySeverity = function(sensor) {
- if ($scope.selectedSeverity.all) return true;
+ if ($scope.selectedSeverity.normal && $scope.selectedSeverity.warning &&
+ $scope.selectedSeverity.critical) {
+ $scope.selectedSeverity.all = true;
+ $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.warning = false;
+ $scope.selectedSeverity.critical = false;
+ } else {
+ $scope.selectedSeverity.all = false;
+ }
+ };
- return ((sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
- (sensor.severity_flags.warning && $scope.selectedSeverity.warning) ||
- (sensor.severity_flags.critical && $scope.selectedSeverity.critical)
- );
- };
- $scope.filterBySearchTerms = function(sensor) {
+ $scope.filterBySeverity = function(sensor) {
+ if ($scope.selectedSeverity.all) return true;
- if (!$scope.searchTerms.length) return true;
+ return (
+ (sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
+ (sensor.severity_flags.warning &&
+ $scope.selectedSeverity.warning) ||
+ (sensor.severity_flags.critical &&
+ $scope.selectedSeverity.critical));
+ };
+ $scope.filterBySearchTerms = function(sensor) {
- for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
- if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1) return false;
- }
- return true;
- };
+ if (!$scope.searchTerms.length) return true;
- $scope.loadSensorData = function() {
- $scope.loading = true;
- APIUtils.getAllSensorStatus(function(data, originalData) {
- $scope.data = data;
- $scope.originalData = originalData;
- dataService.sensorData = data;
- $scope.export_data = JSON.stringify(originalData);
- $scope.loading = false;
- });
- };
+ for (var i = 0, length = $scope.searchTerms.length; i < length; i++) {
+ if (sensor.search_text.indexOf($scope.searchTerms[i].toLowerCase()) ==
+ -1)
+ return false;
+ }
+ return true;
+ };
- $scope.loadSensorData();
- }
- ]);
+ $scope.loadSensorData = function() {
+ $scope.loading = true;
+ APIUtils.getAllSensorStatus(function(data, originalData) {
+ $scope.data = data;
+ $scope.originalData = originalData;
+ dataService.sensorData = data;
+ $scope.export_data = JSON.stringify(originalData);
+ $scope.loading = false;
+ });
+ };
+
+ $scope.loadSensorData();
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/unit-id-controller.js b/app/server-health/controllers/unit-id-controller.js
index 4cd8055..7af4ca1 100644
--- a/app/server-health/controllers/unit-id-controller.js
+++ b/app/server-health/controllers/unit-id-controller.js
@@ -9,37 +9,35 @@
window.angular && (function(angular) {
'use strict';
- angular
- .module('app.serverHealth')
- .controller('unitIdController', [
- '$scope',
- '$window',
- 'APIUtils',
- 'dataService',
- function($scope, $window, APIUtils, dataService) {
- $scope.dataService = dataService;
+ angular.module('app.serverHealth').controller('unitIdController', [
+ '$scope', '$window', 'APIUtils', 'dataService',
+ function($scope, $window, APIUtils, dataService) {
+ $scope.dataService = dataService;
- APIUtils.getLEDState().then(function(state) {
- $scope.displayLEDState(state);
- });
+ APIUtils.getLEDState().then(function(state) {
+ $scope.displayLEDState(state);
+ });
- $scope.displayLEDState = function(state) {
- if (state == APIUtils.LED_STATE.on) {
- dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
- }
- else {
- dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
- }
- };
+ $scope.displayLEDState = function(state) {
+ if (state == APIUtils.LED_STATE.on) {
+ dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
+ } else {
+ dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
+ }
+ };
- $scope.toggleLED = function() {
- var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
- APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
- dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
- APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
- APIUtils.setLEDState(toggleState, function(status) {});
- };
- }
- ]);
+ $scope.toggleLED = function() {
+ var toggleState =
+ (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
+ APIUtils.LED_STATE.off :
+ APIUtils.LED_STATE.on;
+ dataService.LED_state =
+ (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
+ APIUtils.LED_STATE_TEXT.off :
+ APIUtils.LED_STATE_TEXT.on;
+ APIUtils.setLEDState(toggleState, function(status) {});
+ };
+ }
+ ]);
})(angular);