Browse Source

camera data add/edit

develop
Robin Thoni 8 years ago
parent
commit
4f13b313ec

+ 2
- 1
admin/app.js View File

@@ -9,7 +9,8 @@ var camotion = angular.module('camotionAdmin', [
9 9
     'luticateAuth',
10 10
     'LocalStorageModule',
11 11
     'dialogs.main',
12
-    'ngSanitize'
12
+    'ngSanitize',
13
+    'JSONedit'
13 14
 ]);
14 15
 
15 16
 camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',

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

@@ -7,6 +7,7 @@ angular.module('camotionAdmin')
7 7
         function($scope, CamerasService, data, dialogs, $q, luticateAuthCache, HelperService) {
8 8
             if (data != null) {
9 9
                 $scope.camera = data;
10
+                $scope.camera.Data = JSON.parse($scope.camera.Data);
10 11
                 $scope.camera.camera_id = $scope.camera.Id;
11 12
                 $scope.permission = "CAMOTION_CAMERA_EDIT";
12 13
             }
@@ -14,7 +15,7 @@ angular.module('camotionAdmin')
14 15
                 $scope.camera = {
15 16
                     Name: "",
16 17
                     Description: "",
17
-                    Token: "",
18
+                    Data: null,
18 19
                     HostId: null,
19 20
                     EntityTypeId: null
20 21
                 };
@@ -39,13 +40,18 @@ angular.module('camotionAdmin')
39 40
                     }keys = Object.keys($scope.entityTypes);
40 41
                     if (keys.length != 0) {
41 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 51
             $scope.submitForm = function()
47 52
             {
48 53
                 if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
54
+                    $scope.camera.Data = JSON.stringify($scope.camera.Data);
49 55
                     if ($scope.camera.Id != null) {
50 56
                         var promiseEditCamera = {
51 57
                             id: "promiseEditCamera",
@@ -67,4 +73,10 @@ angular.module('camotionAdmin')
67 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,6 +9,7 @@
9 9
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css">
10 10
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
11 11
     <link rel="stylesheet" href="../bower_components/luticate-utils/src/lubusy.css">
12
+    <link rel="stylesheet" href="../bower_components/JSONedit/css/styles.css"/>
12 13
     <link rel="stylesheet/less" href="css/app.less">
13 14
     <!-- endbuild -->
14 15
 
@@ -28,6 +29,8 @@
28 29
     <script src="../bower_components/luticate-auth/dist/luticate-auth.min.js"></script>
29 30
     <script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>
30 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 35
     <!-- scripts -->
33 36
     <script src="app.js"></script>

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

@@ -31,8 +31,14 @@
31 31
                 <span class="caret"></span>
32 32
             </button>
33 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 35
             </ul>
36 36
         </div>
37 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 44
 </dialog-ok-cancel>

+ 2
- 1
bower.json View File

@@ -14,7 +14,8 @@
14 14
     "less": "1.7.x",
15 15
     "angular-local-storage": "0.2.3",
16 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 20
   "resolutions": {
20 21
     "angular": "1.4.x"

Loading…
Cancel
Save