Run js-beautify and fixjsstyle on code
Found this pointer on stackoverflow:
https://stackoverflow.com/a/31660434/5508494
End goal is to get the code formatted well enough that
clang format will run correctly against it.
Change-Id: I80053e78d253d8eee49233e42d55e5807ae8fdc8
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 0db5ad3..b28d61f 100644
--- a/app/server-health/controllers/diagnostics-controller.js
+++ b/app/server-health/controllers/diagnostics-controller.js
@@ -6,20 +6,19 @@
* @name diagnosticsController
*/
-window.angular && (function (angular) {
- 'use strict';
+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 5fca94f..17c9057 100644
--- a/app/server-health/controllers/inventory-controller.js
+++ b/app/server-health/controllers/inventory-controller.js
@@ -6,23 +6,22 @@
* @name inventoryController
*/
-window.angular && (function (angular) {
- 'use strict';
+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 7dc89af..a0dad75 100644
--- a/app/server-health/controllers/inventory-overview-controller.js
+++ b/app/server-health/controllers/inventory-overview-controller.js
@@ -6,70 +6,71 @@
* @name inventoryOverviewController
*/
-window.angular && (function (angular) {
- 'use strict';
+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 = {};
- $scope.customSearch = "";
- $scope.searchTerms = [];
- $scope.loading = false;
+ 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.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.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(" ");
- }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.filterBySearchTerms = function(hardware){
-
- 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;
- }
+ $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.filterBySearchTerms = function(hardware) {
+
+ 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;
+ };
+ }
+ ]);
})(angular);
diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js
index 8c5df7c..1a01242 100644
--- a/app/server-health/controllers/log-controller.js
+++ b/app/server-health/controllers/log-controller.js
@@ -6,192 +6,192 @@
* @name logController
*/
-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;
+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;
- 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;
- }
+ if (sensorType == 'high') {
+ $scope.selectedSeverity.all = false;
+ $scope.selectedSeverity.high = true;
+ }
- $scope.selectedStatus = {
- all: true,
- resolved: false
- };
+ $scope.selectedStatus = {
+ all: true,
+ resolved: false
+ };
- $scope.customSearch = "";
- $scope.searchItems = [];
- $scope.selectedEvents = [];
+ $scope.customSearch = '';
+ $scope.searchItems = [];
+ $scope.selectedEvents = [];
- if(eventId){
- $scope.customSearch = "#"+eventId;
- $scope.searchItems.push("#"+eventId);
- }
+ 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;
- });
+ $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($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;
- });
- });
-
- 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.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();
+ 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 ($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;
+ });
+ });
+
+ 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.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 9e035d6..9a74e6d 100644
--- a/app/server-health/controllers/power-consumption-controller.js
+++ b/app/server-health/controllers/power-consumption-controller.js
@@ -6,20 +6,19 @@
* @name powerConsumptionController
*/
-window.angular && (function (angular) {
- 'use strict';
+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 c0ad76e..70f3e9c 100644
--- a/app/server-health/controllers/sensors-controller.js
+++ b/app/server-health/controllers/sensors-controller.js
@@ -6,133 +6,136 @@
* @name sensorsController
*/
-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 = [];
+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 = [];
- $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 &&
- $scope.selectedSeverity.critical){
- $scope.selectedSeverity.all = true;
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
- }else{
- $scope.selectedSeverity.all = false;
- }
- }
+ 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.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);
- }
- }
-
- if(!dataService.sensorData.sensors){
- APIUtils.getAllSensorStatus(function(data, originalData){
- dataService.sensorData = data;
- setSensorData();
- });
- }else{
- setSensorData();
- }
-
+ $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 = [];
}
- ]
- );
+ }
+ };
-})(angular);
\ No newline at end of file
+ $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);
+ }
+ }
+
+ 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 9218476..683d071 100644
--- a/app/server-health/controllers/sensors-overview-controller.js
+++ b/app/server-health/controllers/sensors-overview-controller.js
@@ -6,138 +6,140 @@
* @name sensorsOverviewController
*/
-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;
+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;
- $scope.dropdown_selected = false;
+ $scope.dropdown_selected = false;
- $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.$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.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(" ");
- }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;
-
- 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];
-
- 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.all = true;
- $scope.selectedSeverity.normal = false;
- $scope.selectedSeverity.warning = false;
- $scope.selectedSeverity.critical = false;
- }else{
- $scope.selectedSeverity.all = false;
- }
- }
-
- $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;
- }
-
- $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();
+ $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 = [];
}
- ]
- );
+ }
+ };
-})(angular);
\ No newline at end of file
+ $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;
+
+ 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];
+
+ 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.all = true;
+ $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.warning = false;
+ $scope.selectedSeverity.critical = false;
+ }
+ else {
+ $scope.selectedSeverity.all = false;
+ }
+ };
+
+ $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;
+ };
+
+ $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 806f024..4cd8055 100644
--- a/app/server-health/controllers/unit-id-controller.js
+++ b/app/server-health/controllers/unit-id-controller.js
@@ -6,41 +6,40 @@
* @name unitIdController
*/
-window.angular && (function (angular) {
- 'use strict';
+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);
diff --git a/app/server-health/index.js b/app/server-health/index.js
index 57670ce..c090f82 100644
--- a/app/server-health/index.js
+++ b/app/server-health/index.js
@@ -5,68 +5,68 @@
* @exports app/server-health/index
*/
-window.angular && (function (angular) {
- 'use strict';
+window.angular && (function(angular) {
+ 'use strict';
- angular
- .module('app.serverHealth', [
- 'ngRoute',
- 'app.constants',
- 'app.common.services'
- ])
- // Route configuration
- .config(['$routeProvider', function ($routeProvider) {
- $routeProvider
- .when('/server-health/event-log', {
- 'template': require('./controllers/log-controller.html'),
- 'controller': 'logController',
- authenticated: true
- })
- .when('/server-health/event-log/:type', {
- 'template': require('./controllers/log-controller.html'),
- 'controller': 'logController',
- authenticated: true
- })
- .when('/server-health/event-log/:type/:id', {
- 'template': require('./controllers/log-controller.html'),
- 'controller': 'logController',
- authenticated: true
- })
- .when('/server-health/inventory-overview', {
- 'template': require('./controllers/inventory-overview-controller.html'),
- 'controller': 'inventoryOverviewController',
- authenticated: true
- })
- .when('/server-health/inventory', {
- 'template': require('./controllers/inventory-controller.html'),
- 'controller': 'inventoryController',
- authenticated: true
- })
- .when('/server-health/sensors-overview', {
- 'template': require('./controllers/sensors-overview-controller.html'),
- 'controller': 'sensorsOverviewController',
- authenticated: true
- })
- .when('/server-health/sensors/:type', {
- 'template': require('./controllers/sensors-controller.html'),
- 'controller': 'sensorsController',
- authenticated: true
- })
- .when('/server-health/power-consumption', {
- 'template': require('./controllers/power-consumption-controller.html'),
- 'controller': 'powerConsumptionController',
- authenticated: true
- })
- .when('/server-health/diagnostics', {
- 'template': require('./controllers/diagnostics-controller.html'),
- 'controller': 'diagnosticsController',
- authenticated: true
- })
- .when('/server-health', {
- 'template': require('./controllers/log-controller.html'),
- 'controller': 'logController',
- authenticated: true
- });
- }]);
+ angular
+ .module('app.serverHealth', [
+ 'ngRoute',
+ 'app.constants',
+ 'app.common.services'
+ ])
+ // Route configuration
+ .config(['$routeProvider', function($routeProvider) {
+ $routeProvider
+ .when('/server-health/event-log', {
+ 'template': require('./controllers/log-controller.html'),
+ 'controller': 'logController',
+ authenticated: true
+ })
+ .when('/server-health/event-log/:type', {
+ 'template': require('./controllers/log-controller.html'),
+ 'controller': 'logController',
+ authenticated: true
+ })
+ .when('/server-health/event-log/:type/:id', {
+ 'template': require('./controllers/log-controller.html'),
+ 'controller': 'logController',
+ authenticated: true
+ })
+ .when('/server-health/inventory-overview', {
+ 'template': require('./controllers/inventory-overview-controller.html'),
+ 'controller': 'inventoryOverviewController',
+ authenticated: true
+ })
+ .when('/server-health/inventory', {
+ 'template': require('./controllers/inventory-controller.html'),
+ 'controller': 'inventoryController',
+ authenticated: true
+ })
+ .when('/server-health/sensors-overview', {
+ 'template': require('./controllers/sensors-overview-controller.html'),
+ 'controller': 'sensorsOverviewController',
+ authenticated: true
+ })
+ .when('/server-health/sensors/:type', {
+ 'template': require('./controllers/sensors-controller.html'),
+ 'controller': 'sensorsController',
+ authenticated: true
+ })
+ .when('/server-health/power-consumption', {
+ 'template': require('./controllers/power-consumption-controller.html'),
+ 'controller': 'powerConsumptionController',
+ authenticated: true
+ })
+ .when('/server-health/diagnostics', {
+ 'template': require('./controllers/diagnostics-controller.html'),
+ 'controller': 'diagnosticsController',
+ authenticated: true
+ })
+ .when('/server-health', {
+ 'template': require('./controllers/log-controller.html'),
+ 'controller': 'logController',
+ authenticated: true
+ });
+ }]);
})(window.angular);