Browse Source

sensors error

develop
Robin Thoni 9 years ago
parent
commit
b150981d58
1 changed files with 30 additions and 5 deletions
  1. 30
    5
      camotion/controllers/sensors.controller.js

+ 30
- 5
camotion/controllers/sensors.controller.js View File

@@ -1,6 +1,6 @@
1 1
 angular.module('camotion')
2
-    .controller('SensorsController', ['$scope', 'SensorsService', '$timeout',
3
-        function($scope, SensorsService, $timeout) {
2
+    .controller('SensorsController', ['$scope', 'SensorsService', '$timeout', 'luticateDialogErrorHelper',
3
+        function($scope, SensorsService, $timeout, luticateDialogErrorHelper) {
4 4
 
5 5
             $scope.values = {};
6 6
             $scope.interval = 1000;
@@ -23,7 +23,8 @@ angular.module('camotion')
23 23
                         name: "Value",
24 24
                         width: 2,
25 25
                         getValue: function (item) {
26
-                            return $scope.values[item.Id].value.Value;
26
+                            var value = $scope.values[item.Id];
27
+                            return value.error == null ? value.value.Value : 'Error';
27 28
                         }
28 29
                     }
29 30
                 ],
@@ -43,10 +44,25 @@ angular.module('camotion')
43 44
                         var item = angular.copy(items[i]);
44 45
                         $scope.values[item.Id] = {
45 46
                             value: 0,
46
-                            timerId: 0
47
+                            timerId: 0,
48
+                            error: null
47 49
                         };
48 50
                         $scope.updateSensor(item);
49 51
                     }
52
+                },
53
+
54
+                canClick: function(sensor)
55
+                {
56
+                    var value = $scope.values[sensor.Id];
57
+                    return value.error != null;
58
+                },
59
+
60
+                onItemClicked: function(sensor)
61
+                {
62
+                    var value = $scope.values[sensor.Id];
63
+                    if (value.error != null) {
64
+                        luticateDialogErrorHelper.errorDialog(value.error);
65
+                    }
50 66
                 }
51 67
             };
52 68
 
@@ -63,11 +79,20 @@ angular.module('camotion')
63 79
                                     }, $scope.interval)
64 80
                                 }
65 81
                             }
82
+                        }, function(error)
83
+                        {
84
+                            if (typeof $scope.values[sensor.Id] != 'undefined') {
85
+                                $scope.values[sensor.Id] = {
86
+                                    value: 0,
87
+                                    timerId: 0,
88
+                                    error: error
89
+                                }
90
+                            }
66 91
                         });
67 92
                 }
68 93
             };
69 94
 
70
-            $scope.$on('$destroy', function(){
95
+            $scope.$on('$destroy', function() {
71 96
                 $scope.values = {};
72 97
             });
73 98
     }]);

Loading…
Cancel
Save