blob: 272dfeec0a6c03b557f0c666c53668d0b60309c0 [file] [log] [blame]
Ed Tanous911ac312017-08-15 09:37:42 -07001angular.module('bmcApp').controller('sensorController', [
2 '$scope', '$http', '$location', 'dbusWebsocketService',
3 function($scope, $http, $location, dbusWebsocketService) {
4 $scope.smartTablePageSize = 10;
5 $scope.next_id = 0;
6 dbusWebsocketService.start('/xyz/openbmc_project/sensors', function(evt) {
7 var obj = JSON.parse(evt.data);
Ed Tanous4d92cbf2017-06-22 15:41:02 -07008
Ed Tanous911ac312017-08-15 09:37:42 -07009 $scope.$apply(function() {
10 for (var sensor_name in obj) {
11 var found = false;
12 for (var sensor_index in $scope.rowCollection) {
13 var sensor_object = $scope.rowCollection[sensor_index];
14 if (sensor_object.name === sensor_name) {
15 sensor_object.value = obj[sensor_name];
16 found = true;
17 break;
18 }
19 }
20 if (!found) {
21 console.log(sensor_name + ' -> ' + obj[sensor_name]);
22 $scope.next_id = $scope.next_id + 1;
Ed Tanous5fceeb42017-06-28 09:43:09 -070023
Ed Tanous911ac312017-08-15 09:37:42 -070024 $scope.rowCollection.push({
25 id : $scope.next_id,
26 name : sensor_name,
27 value : obj[sensor_name],
Ed Tanous5fceeb42017-06-28 09:43:09 -070028 });
29 }
Ed Tanous911ac312017-08-15 09:37:42 -070030 };
31 });
32 });
33
34 $scope.rowCollection = [];
35
36 }
37]);