Browse Source

camera data add/edit

develop
Robin Thoni 9 years ago
parent
commit
4f13b313ec

+ 2
- 1
admin/app.js View File

9
     'luticateAuth',
9
     'luticateAuth',
10
     'LocalStorageModule',
10
     'LocalStorageModule',
11
     'dialogs.main',
11
     'dialogs.main',
12
-    'ngSanitize'
12
+    'ngSanitize',
13
+    'JSONedit'
13
 ]);
14
 ]);
14
 
15
 
15
 camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
16
 camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',

+ 13
- 1
admin/controllers/modals/cameraedit.controller.js View File

7
         function($scope, CamerasService, data, dialogs, $q, luticateAuthCache, HelperService) {
7
         function($scope, CamerasService, data, dialogs, $q, luticateAuthCache, HelperService) {
8
             if (data != null) {
8
             if (data != null) {
9
                 $scope.camera = data;
9
                 $scope.camera = data;
10
+                $scope.camera.Data = JSON.parse($scope.camera.Data);
10
                 $scope.camera.camera_id = $scope.camera.Id;
11
                 $scope.camera.camera_id = $scope.camera.Id;
11
                 $scope.permission = "CAMOTION_CAMERA_EDIT";
12
                 $scope.permission = "CAMOTION_CAMERA_EDIT";
12
             }
13
             }
14
                 $scope.camera = {
15
                 $scope.camera = {
15
                     Name: "",
16
                     Name: "",
16
                     Description: "",
17
                     Description: "",
17
-                    Token: "",
18
+                    Data: null,
18
                     HostId: null,
19
                     HostId: null,
19
                     EntityTypeId: null
20
                     EntityTypeId: null
20
                 };
21
                 };
39
                     }keys = Object.keys($scope.entityTypes);
40
                     }keys = Object.keys($scope.entityTypes);
40
                     if (keys.length != 0) {
41
                     if (keys.length != 0) {
41
                         $scope.camera.EntityTypeId = $scope.entityTypes[keys[0]].Id;
42
                         $scope.camera.EntityTypeId = $scope.entityTypes[keys[0]].Id;
43
+                        $scope.setEntityType($scope.entityTypes[keys[0]]);
42
                     }
44
                     }
43
                 }
45
                 }
46
+                else if ($scope.camera.Data == null) {
47
+                    $scope.setEntityType($scope.entityTypes[$scope.camera.EntityTypeId]);
48
+                }
44
             });
49
             });
45
 
50
 
46
             $scope.submitForm = function()
51
             $scope.submitForm = function()
47
             {
52
             {
48
                 if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
53
                 if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
54
+                    $scope.camera.Data = JSON.stringify($scope.camera.Data);
49
                     if ($scope.camera.Id != null) {
55
                     if ($scope.camera.Id != null) {
50
                         var promiseEditCamera = {
56
                         var promiseEditCamera = {
51
                             id: "promiseEditCamera",
57
                             id: "promiseEditCamera",
67
                     return defer.promise;
73
                     return defer.promise;
68
                 }
74
                 }
69
             };
75
             };
76
+
77
+            $scope.setEntityType = function(entityType)
78
+            {
79
+                $scope.camera.EntityTypeId = entityType.Id;
80
+                $scope.camera.Data = JSON.parse($scope.entityTypes[$scope.camera.EntityTypeId].DefaultData);
81
+            };
70
         }]);
82
         }]);

+ 3
- 0
admin/index.html View File

9
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css">
9
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css">
10
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
10
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
11
     <link rel="stylesheet" href="../bower_components/luticate-utils/src/lubusy.css">
11
     <link rel="stylesheet" href="../bower_components/luticate-utils/src/lubusy.css">
12
+    <link rel="stylesheet" href="../bower_components/JSONedit/css/styles.css"/>
12
     <link rel="stylesheet/less" href="css/app.less">
13
     <link rel="stylesheet/less" href="css/app.less">
13
     <!-- endbuild -->
14
     <!-- endbuild -->
14
 
15
 
28
     <script src="../bower_components/luticate-auth/dist/luticate-auth.min.js"></script>
29
     <script src="../bower_components/luticate-auth/dist/luticate-auth.min.js"></script>
29
     <script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>
30
     <script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>
30
     <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
31
     <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
32
+    <script src="../bower_components/JSONedit/bower_components/angular-ui-sortable/sortable.min.js"></script>
33
+    <script src="../bower_components/JSONedit/js/directives.js"></script>
31
 
34
 
32
     <!-- scripts -->
35
     <!-- scripts -->
33
     <script src="app.js"></script>
36
     <script src="app.js"></script>

+ 7
- 1
admin/views/modals/cameraedit.html View File

31
                 <span class="caret"></span>
31
                 <span class="caret"></span>
32
             </button>
32
             </button>
33
             <ul class="dropdown-menu">
33
             <ul class="dropdown-menu">
34
-                <li ng-repeat="type in entityTypes"><a ng-click="camera.EntityTypeId = type.Id" href="">{{ type.Name }}</a></li>
34
+                <li ng-repeat="type in entityTypes"><a ng-click="setEntityType(type)" href="">{{ type.Name }}</a></li>
35
             </ul>
35
             </ul>
36
         </div>
36
         </div>
37
     </div>
37
     </div>
38
+    <div class="form-group">
39
+        <label for="data" class="col-sm-2 control-label">Data</label>
40
+        <div class="col-sm-9 jsonView">
41
+            <json id="data" child="camera.Data" default-collapsed="false" type="object"></json>
42
+        </div>
43
+    </div>
38
 </dialog-ok-cancel>
44
 </dialog-ok-cancel>

+ 2
- 1
bower.json View File

14
     "less": "1.7.x",
14
     "less": "1.7.x",
15
     "angular-local-storage": "0.2.3",
15
     "angular-local-storage": "0.2.3",
16
     "luticate-utils": "https://git.rthoni.com/repos/luticate-front/utils.git#0.1.x",
16
     "luticate-utils": "https://git.rthoni.com/repos/luticate-front/utils.git#0.1.x",
17
-    "luticate-auth": "https://git.rthoni.com/repos/luticate-front/auth.git#0.1.x"
17
+    "luticate-auth": "https://git.rthoni.com/repos/luticate-front/auth.git#0.1.x",
18
+    "JSONedit": "json-edit#~0.2.1"
18
   },
19
   },
19
   "resolutions": {
20
   "resolutions": {
20
     "angular": "1.4.x"
21
     "angular": "1.4.x"

Loading…
Cancel
Save