WebUI: Sensors page modifications
Modified sensors page to use Redfish as backend.
Also added threshold sensor values in page view.
Tested By:
Loaded webui page and tested all operations.
- Sensors page load and layout.
- Search Filter and Severity filters.
- Export functionality.
Change-Id: Ic799453ffcd17e9a69e073a12173b4e97a928458
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/app/server-health/controllers/sensors-overview-controller.js b/app/server-health/controllers/sensors-overview-controller.js
index 40e0b58..96349d2 100644
--- a/app/server-health/controllers/sensors-overview-controller.js
+++ b/app/server-health/controllers/sensors-overview-controller.js
@@ -9,27 +9,27 @@
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', '$q', '$window', 'APIUtils', 'dataService', 'Constants',
+ function($scope, $q, $window, APIUtils, dataService, Constants) {
$scope.dataService = dataService;
- $scope.dropdown_selected = false;
-
- $scope.$log = $log;
+ $scope.loading = false;
+ $scope.componentList = [];
+ $scope.sensorsInfo = {};
+ $scope.fullSensorsInfo = [];
+ $scope.selectedComponent = {};
+ $scope.showThresholds = true; // TODO: add button to toggle this..
+ $scope.showCompDropdown = false;
$scope.customSearch = '';
$scope.searchTerms = [];
$scope.messages = Constants.MESSAGES.SENSOR;
+ $scope.filteredVoltSensors = [];
+ $scope.filteredTempSensors = [];
+ $scope.filteredFanSensors = [];
+
$scope.selectedSeverity =
- {all: true, normal: false, warning: false, critical: false};
+ {all: true, ok: 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 = '';
@@ -64,7 +64,7 @@
$scope.selectedSeverity.all = !$scope.selectedSeverity.all;
if ($scope.selectedSeverity.all) {
- $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.ok = false;
$scope.selectedSeverity.warning = false;
$scope.selectedSeverity.critical = false;
}
@@ -73,9 +73,9 @@
$scope.toggleSeverity = function(severity) {
$scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
- if (['normal', 'warning', 'critical'].indexOf(severity) > -1) {
+ if (['ok', 'warning', 'critical'].indexOf(severity) > -1) {
if ($scope.selectedSeverity[severity] == false &&
- (!$scope.selectedSeverity.normal &&
+ (!$scope.selectedSeverity.ok &&
!$scope.selectedSeverity.warning &&
!$scope.selectedSeverity.critical)) {
$scope.selectedSeverity.all = true;
@@ -83,10 +83,10 @@
}
}
- if ($scope.selectedSeverity.normal && $scope.selectedSeverity.warning &&
+ if ($scope.selectedSeverity.ok && $scope.selectedSeverity.warning &&
$scope.selectedSeverity.critical) {
$scope.selectedSeverity.all = true;
- $scope.selectedSeverity.normal = false;
+ $scope.selectedSeverity.ok = false;
$scope.selectedSeverity.warning = false;
$scope.selectedSeverity.critical = false;
} else {
@@ -98,31 +98,87 @@
if ($scope.selectedSeverity.all) return true;
return (
- (sensor.severity_flags.normal && $scope.selectedSeverity.normal) ||
- (sensor.severity_flags.warning &&
+ ((sensor.Status.Health == 'OK') && $scope.selectedSeverity.ok) ||
+ ((sensor.Status.Health == 'Warning') &&
$scope.selectedSeverity.warning) ||
- (sensor.severity_flags.critical &&
+ ((sensor.Status.Health == '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)
+ // TODO: Form it while getting data
+ var search_text = sensor.Name.toLowerCase();
+ if (search_text.indexOf($scope.searchTerms[i].toLowerCase()) == -1)
return false;
}
return true;
};
+ $scope.selectComponent = function(index) {
+ $scope.loading = true;
+ $scope.showCompDropdown = false;
+ if (index == -1) {
+ // Flattened sensor data to display all sensors.
+ $scope.selectedComponent = {'Name': 'All'};
+ $scope.sensorsInfo = {'Temperatures': [], 'Fans': [], 'Voltages': []};
+ // Looping through all chassis collections to flattened sensors data
+ angular.forEach($scope.fullSensorsInfo, function(record) {
+ $scope.sensorsInfo.Temperatures = [].concat(
+ $scope.sensorsInfo.Temperatures, record.sensors.Temperatures);
+ $scope.sensorsInfo.Fans =
+ [].concat($scope.sensorsInfo.Fans, record.sensors.Fans);
+ $scope.sensorsInfo.Voltages =
+ [].concat($scope.sensorsInfo.Voltages, record.sensors.Voltages);
+ });
+ } else {
+ $scope.selectedComponent = $scope.fullSensorsInfo[index];
+ $scope.sensorsInfo = $scope.selectedComponent['sensors'];
+ }
+ $scope.loading = false;
+ };
+
+ function getComponentSensors(component) {
+ var data = component;
+ data['sensors'] = {'Temperatures': [], 'Fans': [], 'Voltages': []};
+ APIUtils.getSensorsInfo(component.Thermal['@odata.id'])
+ .then(function(res) {
+ if (res.hasOwnProperty('Temperatures')) {
+ data.sensors['Temperatures'] = res.Temperatures;
+ }
+ if (res.hasOwnProperty('Fans')) {
+ data.sensors['Fans'] = res.Fans;
+ }
+ return;
+ });
+ APIUtils.getSensorsInfo(component.Power['@odata.id'])
+ .then(function(res) {
+ if (res.hasOwnProperty('Voltages')) {
+ data.sensors['Voltages'] = res.Voltages;
+ }
+ return;
+ });
+ return data;
+ };
+
$scope.loadSensorData = function() {
$scope.loading = true;
- APIUtils.getAllSensorStatus(function(data, originalData) {
- $scope.data = data;
- $scope.originalData = originalData;
- $scope.export_data = JSON.stringify(originalData);
- $scope.loading = false;
- });
+ APIUtils.getAllChassisCollection()
+ .then(
+ function(chassisList) {
+ angular.forEach(chassisList, function(chassis) {
+ var resData = getComponentSensors(chassis);
+ $scope.fullSensorsInfo.push(resData);
+ });
+ },
+ function(error) {
+ console.log(JSON.stringify(error));
+ })
+ .finally(function() {
+ $scope.selectComponent(0);
+ $scope.loading = false;
+ });
};
$scope.loadSensorData();