Sfoglia il codice sorgente

settings ui

develop
Robin Thoni 8 anni fa
parent
commit
1769846ce7

+ 2
- 2
controllers/modals/settingedit.controller.js Vedi File

@@ -15,8 +15,8 @@ angular.module('luticate')
15 15
                     "Name": "",
16 16
                     "Type": "string",
17 17
                     "Value": "",
18
-                    "IsBlocked": true,
19
-                    "IsAdmin": true,
18
+                    "IsBlocked": false,
19
+                    "IsAdmin": false,
20 20
                     "IsNew": true
21 21
                 };
22 22
                 $scope.neededPermission = "LU_SETTING_ADD";

+ 8
- 3
controllers/modals/useredit.controller.js Vedi File

@@ -101,8 +101,13 @@ angular.module('luticate')
101 101
                 dialogs.create('views/modals/usereffectivepermissions.html', 'UserEffectivePermissionsController', user);
102 102
             };
103 103
 
104
-            $scope.canEditPermissions = function()
104
+            $scope.editSettings = function(user)
105 105
             {
106
-                return $scope.user.Id != null && luticateAuthCache.hasEffectivePermission("LU_PERM_USER_GET");
107
-            }
106
+                dialogs.create('views/modals/usersettings.html', 'UserSettingsController', user);
107
+            };
108
+
109
+            $scope.showEffectiveSettings = function(user)
110
+            {
111
+                dialogs.create('views/modals/usereffectivesettings.html', 'UserEffectiveSettingsController', user);
112
+            };
108 113
         }]);

+ 96
- 0
controllers/modals/usersettings.controller.js Vedi File

@@ -0,0 +1,96 @@
1
+/**
2
+ * Created by robin on 11/2/15.
3
+ */
4
+
5
+angular.module('luticate')
6
+    .controller('UserSettingsController', ['$scope', 'luticateAuthSettingsUser', 'luticateAuthSettings', 'luticateAuthCache', 'luticateDialogErrorHelper', 'data',
7
+        function($scope, luticateAuthSettingsUser, luticateAuthSettings, luticateAuthCache, luticateDialogErrorHelper, data) {
8
+
9
+            $scope.user = data;
10
+
11
+            $scope.userSettings = {};
12
+            $scope.userEffectiveSettings = {};
13
+            $scope.tmpSetting = {
14
+                Value: "",
15
+                Type: "string",
16
+                Name: "",
17
+                IsBlocked: false
18
+            };
19
+
20
+            $scope.loadSettings = function()
21
+            {
22
+                var promiseLoadSettings = {
23
+                    id: "promiseLoadSettings",
24
+                    loaderGroups: ["modal"]
25
+                };
26
+
27
+                luticateAuthSettingsUser.getAll({user_id: $scope.user.Id}, promiseLoadSettings)
28
+                    .then(function (user_settings) {
29
+                        $scope.userEffectiveSettings = luticateAuthCache.getEffectiveSettings();
30
+                        $scope.userSettings = {};
31
+                        for (var i = 0; i < user_settings.Data.length; ++i) {
32
+                            var s = user_settings.Data[i];
33
+                            $scope.userSettings[s.Name] = s;
34
+                        }
35
+
36
+                        var settings = Object.keys($scope.userEffectiveSettings);
37
+                        if ($scope.userEffectiveSettings[$scope.tmpSetting.Name] != null) {
38
+                            $scope.setTmpSetting($scope.tmpSetting.Name);
39
+                        }
40
+                        else if (settings.length > 0) {
41
+                            $scope.setTmpSetting(settings[0]);
42
+                        }
43
+                    });
44
+            };
45
+
46
+            $scope.setTmpSetting = function(setting_name)
47
+            {
48
+                var setting = $scope.userEffectiveSettings[setting_name];
49
+                $scope.tmpSetting.Value = setting.Value;
50
+                $scope.tmpSetting.Type = setting.Type;
51
+                $scope.tmpSetting.Name = setting.Name;
52
+            };
53
+
54
+            $scope.editSetting = function(setting)
55
+            {
56
+                var promiseEditSettings = {
57
+                    id: "promiseEditSettings",
58
+                    loaderGroups: ["modal"]
59
+                };
60
+                luticateAuthSettingsUser.edit({
61
+                    user_id: $scope.user.Id,
62
+                    setting_name: setting.Name,
63
+                    setting: setting
64
+                }, promiseEditSettings).then($scope.loadFullSettings, luticateDialogErrorHelper.errorDialog);
65
+            };
66
+
67
+            $scope.resetSetting = function(setting)
68
+            {
69
+                setting.Value = null;
70
+                var promiseEditSettings = {
71
+                    id: "promiseEditSettings",
72
+                    loaderGroups: ["modal"]
73
+                };
74
+                luticateAuthSettingsUser.edit({
75
+                    user_id: $scope.user.Id,
76
+                    setting_name: setting.Name,
77
+                    setting: setting
78
+                }, promiseEditSettings).then($scope.loadFullSettings, luticateDialogErrorHelper.errorDialog);
79
+            };
80
+
81
+            $scope.loadFullSettings = function()
82
+            {
83
+                var promiseLoadSettings = {
84
+                    id: "promiseLoadSettings",
85
+                    loaderGroups: ["modal"]
86
+                };
87
+                luticateAuthSettings.loadSettings(promiseLoadSettings)
88
+                    .then(function()
89
+                    {
90
+                        $scope.loadSettings();
91
+                    }, luticateDialogErrorHelper.errorDialog);
92
+            };
93
+
94
+            $scope.loadSettings();
95
+
96
+        }]);

+ 1
- 1
index.html Vedi File

@@ -62,9 +62,9 @@
62 62
     <script src="controllers/modals/grouppermissions.controller.js"></script>
63 63
     <script src="controllers/modals/groupusers.controller.js"></script>
64 64
     <script src="controllers/modals/settingedit.controller.js"></script>
65
+    <script src="controllers/modals/usersettings.controller.js"></script>
65 66
 
66 67
     <!-- SDK -->
67
-    <script src="sdk/cache.js"></script>
68 68
 
69 69
     <!-- Directives -->
70 70
 

+ 0
- 11
sdk/cache.js Vedi File

@@ -1,11 +0,0 @@
1
-(function () {
2
-    'use strict';
3
-
4
-    angular.module('luticate')
5
-        .factory('ServiceCache', ['localStorageService', function (localStorageService) {
6
-
7
-            var ServiceCache = {};
8
-
9
-            return ServiceCache;
10
-        }]);
11
-})();

+ 1
- 1
views/home.html Vedi File

@@ -1,7 +1,7 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3 3
     <div class="row co-sm-8 col-sm-offset-2" lu-busy="form">
4
-        <form name="form" ng-submit="submit()">
4
+        <form name="form" ng-submit="submit()" class="form-horizontal">
5 5
             <div class="form-group">
6 6
                 <label for="email" class="col-sm-2 control-label">Email</label>
7 7
                 <div class="col-sm-9">

+ 34
- 10
views/modals/useredit.html Vedi File

@@ -51,15 +51,39 @@
51 51
         </div>
52 52
     </div>
53 53
 
54
-    <div class="form-group">
55
-        <div class="col-sm-2"></div>
56
-        <button type="button" class="btn btn-primary"
57
-                ng-click="editPermissions(user)" ng-show="canEditPermissions()">
58
-            Edit permissions
59
-        </button>
60
-        <button type="button" class="btn btn-info" lu-show-permission="LU_PERM_EFFECTIVE_GET,LU_PERM_GET"
61
-                ng-click="showEffectivePermissions(user)" ng-show="user.Id != null">
62
-            Show effective permissions
63
-        </button>
54
+    <div class="form-group" ng-show="user.Id != null">
55
+        <div class="col-sm-offset-2 col-sm-9">
56
+            <div class="col-sm-6">
57
+                <button type="button" class="btn btn-primary btn-block" ng-click="editPermissions(user)"
58
+                        lu-show-permission="LU_PERM_USER_GET">
59
+                    Edit permissions
60
+                </button>
61
+            </div>
62
+            <div class="col-sm-6">
63
+                <button type="button" class="btn btn-info btn-block" ng-click="showEffectivePermissions(user)"
64
+                        lu-show-permission="LU_PERM_EFFECTIVE_GET,LU_PERM_GET">
65
+                    Show effective permissions
66
+                </button>
67
+            </div>
68
+        </div>
69
+        <div class="clearfix"></div>
70
+    </div>
71
+
72
+    <div class="form-group" ng-show="user.Id != null">
73
+        <div class="col-sm-offset-2 col-sm-9">
74
+            <div class="col-sm-6">
75
+                <button type="button" class="btn btn-primary btn-block" ng-click="editSettings(user)"
76
+                        lu-show-permission="LU_SETTING_USER_GET">
77
+                    Edit settings
78
+                </button>
79
+            </div>
80
+            <div class="col-sm-6">
81
+                <button type="button" class="btn btn-info btn-block" ng-click="showEffectiveSettings(user)"
82
+                        lu-show-permission="LU_SETTING_EFFECTIVE_GET,LU_SETTING_GET">
83
+                    Show effective settings
84
+                </button>
85
+            </div>
86
+        </div>
87
+        <div class="clearfix"></div>
64 88
     </div>
65 89
 </dialog-ok-cancel>

+ 74
- 0
views/modals/usersettings.html Vedi File

@@ -0,0 +1,74 @@
1
+<!-- Page Content -->
2
+<dialog-close title="Edit {{ user.Username }} settings">
3
+
4
+    <div class="form-group">
5
+        <label class="col-sm-2 control-label">Name</label>
6
+        <div class="col-sm-9">
7
+            <button type="button" class="btn btn-primary dropdown-toggle btn-select btn-block" data-toggle="dropdown" href="">
8
+                <span class="pull-left">{{ tmpSetting.Name }} {{ userSettings[tmpSetting.Name] == null ? '' : '*' }}</span>
9
+                <span class="caret pull-right text-center"></span>
10
+            </button>
11
+            <ul class="dropdown-menu col-sm-12">
12
+                <li>
13
+                    <a href="" ng-repeat="setting in userEffectiveSettings" ng-click="setTmpSetting(setting.Name)">
14
+                        {{ setting.Name }} {{ userSettings[setting.Name] == null ? '' : '*' }}
15
+                    </a>
16
+                </li>
17
+            </ul>
18
+        </div>
19
+    </div>
20
+
21
+    <div class="form-group">
22
+        <label class="col-sm-2 control-label">Blocked</label>
23
+        <div class="col-sm-9">
24
+            <button type="button" class="btn btn-primary dropdown-toggle btn-select btn-block" data-toggle="dropdown" href="">
25
+                <span class="pull-left">{{ tmpSetting.IsBlocked ? 'Yes' : 'No' }}</span>
26
+                <span class="caret pull-right"></span>
27
+            </button>
28
+            <ul class="dropdown-menu col-sm-12">
29
+                <li><a href="" ng-click="tmpSetting.IsBlocked = false">No</a></li>
30
+                <li><a href="" ng-click="tmpSetting.IsBlocked = true">Yes</a></li>
31
+            </ul>
32
+        </div>
33
+    </div>
34
+
35
+    <div class="form-group">
36
+        <label class="col-sm-2 control-label" for="Value">Value</label>
37
+        <div class="col-sm-9">
38
+            <textarea id="Value" ng-model="tmpSetting.Value" ng-if="tmpSetting.Type == 'string'" class="form-control"
39
+                      ng-disabled="userEffectiveSettings.length == 0"></textarea>
40
+
41
+            <input id="Value" ng-model="tmpSetting.Value" ng-if="tmpSetting.Type == 'int' || tmpSetting.Type == 'float'"
42
+                   class="form-control" type="number" required ng-disabled="userEffectiveSettings.length == 0"/>
43
+
44
+            <div class="col-sm-9" ng-if="tmpSetting.Type == 'object'" ng-disabled="userEffectiveSettings.length == 0">{{ tmpSetting.Value }}</div>
45
+
46
+            <div class="btn-group" ng-if="tmpSetting.Type == 'bool'">
47
+                <button type="button" class="btn btn-primary dropdown-toggle btn-select" data-toggle="dropdown" href=""
48
+                        ng-disabled="userEffectiveSettings.length == 0">
49
+                    {{ tmpSetting.Value ? 'Yes' : 'No' }} <span class="caret"></span>
50
+                </button>
51
+                <ul class="dropdown-menu">
52
+                    <li><a href="" ng-click="tmpSetting.Value = false">No</a></li>
53
+                    <li><a href="" ng-click="tmpSetting.Value = true">Yes</a></li>
54
+                </ul>
55
+            </div>
56
+        </div>
57
+    </div>
58
+
59
+    <div class="form-group">
60
+        <div class="col-sm-9 col-sm-offset-2">
61
+            <div class="col-sm-6">
62
+                <button type="button" class="btn btn-primary btn-block" href="" ng-click="editSetting(tmpSetting)">
63
+                    Save
64
+                </button>
65
+            </div>
66
+            <div class="col-sm-6">
67
+                <button type="button" class="btn btn-danger btn-block" href="" ng-click="resetSetting(tmpSetting)">
68
+                    Reset
69
+                </button>
70
+            </div>
71
+        </div>
72
+    </div>
73
+
74
+</dialog-close>

Loading…
Annulla
Salva