diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2017-06-28 11:36:51 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2017-06-28 11:36:51 -0700 |
| commit | b61d589966402ce4c245ced81929c92a1f830a2f (patch) | |
| tree | 81a58fb074af3f6536e71855fa94e36f8edb33a4 /static/js | |
| parent | 5fceeb4563c08468e9623cef1e3d7f4de9373d2f (diff) | |
| download | bmcweb-b61d589966402ce4c245ced81929c92a1f830a2f.tar.gz bmcweb-b61d589966402ce4c245ced81929c92a1f830a2f.zip | |
Fix issue in release builds for sensorController
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/sensorController.js | 101 |
1 files changed, 53 insertions, 48 deletions
diff --git a/static/js/sensorController.js b/static/js/sensorController.js index 0fa9045..bcfb1c9 100644 --- a/static/js/sensorController.js +++ b/static/js/sensorController.js @@ -1,54 +1,59 @@ -angular.module('bmcApp').controller('sensorController', [ - '$scope', '$http', '$location', 'websocketService', - function($scope, $http, $location, websocketService) { - $scope.smartTablePageSize = 10; - $scope.next_id = 0; - websocketService.start('/sensorws', function(evt) { - var obj = JSON.parse(evt.data); +angular.module('bmcApp') + .controller( + 'sensorController', + [ + '$scope', '$http', '$location', 'websocketService', + function($scope, $http, $location, websocketService) { + $scope.smartTablePageSize = 10; + $scope.next_id = 0; + websocketService.start('/sensorws', function(evt) { + var obj = JSON.parse(evt.data); - $scope.$apply(function() { - for (var sensor_name in obj) { - var found = false; - for (var sensor_index in $scope.rowCollection) { - var sensor_object = $scope.rowCollection[sensor_index]; - if (sensor_object.name === sensor_name) { - sensor_object.value = obj[sensor_name]; - found = true; - break; - } - } - if (!found) { - console.log(sensor_name + ' -> ' + obj[sensor_name]); - $scope.next_id = $scope.next_id + 1; + $scope.$apply(function() { + for (var sensor_name in obj) { + var found = false; + for (var sensor_index in $scope.rowCollection) { + var sensor_object = $scope.rowCollection[sensor_index]; + if (sensor_object.name === sensor_name) { + sensor_object.value = obj[sensor_name]; + found = true; + break; + } + } + if (!found) { + console.log(sensor_name + ' -> ' + obj[sensor_name]); + $scope.next_id = $scope.next_id + 1; - $scope.rowCollection.push({ - id : $scope.next_id, - name : sensor_name, - value : obj[sensor_name], + $scope.rowCollection.push({ + id : $scope.next_id, + name : sensor_name, + value : obj[sensor_name], + }); + } + }; + }); }); - } - }; - }); - }); - - $scope.rowCollection = []; - } -]); + $scope.rowCollection = []; -app.factory('websocketService', function($location) { - return { - start: function(url, callback) { - var host = $location.host(); - var port = 18080; - var protocol = 'wss://'; - if ($location.protocol() === 'http') { - protocol = 'ws://'; + } + ]) + .factory('websocketService', [ + '$location', + function($location) { + return { + start: function(url, callback) { + var host = $location.host(); + var port = 18080; + var protocol = 'wss://'; + if ($location.protocol() === 'http') { + protocol = 'ws://'; + } + var websocket = new WebSocket(protocol + host + ':' + port + url); + websocket.onopen = function() {}; + websocket.onclose = function() {}; + websocket.onmessage = function(evt) { callback(evt); }; + } } - var websocket = new WebSocket(protocol + host + ':' + port + url); - websocket.onopen = function() {}; - websocket.onclose = function() {}; - websocket.onmessage = function(evt) { callback(evt); }; - } - } -});
\ No newline at end of file + } + ]);
\ No newline at end of file |

