Browse Source

users ui

develop
Robin Thoni 9 years ago
parent
commit
4f84ae1eb0

+ 0
- 1
luticate/controllers/home.controller.js View File

1
 angular.module('luticate')
1
 angular.module('luticate')
2
     .controller('HomeController', ['$scope', '$state', 'luticatePromises',
2
     .controller('HomeController', ['$scope', '$state', 'luticatePromises',
3
         function($scope, $state, luticatePromises) {
3
         function($scope, $state, luticatePromises) {
4
-
5
     }]);
4
     }]);

+ 36
- 21
luticate/controllers/modals/useredit.controller.js View File

3
  */
3
  */
4
 
4
 
5
 angular.module('luticate')
5
 angular.module('luticate')
6
-    .controller('UserEditController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs',
7
-        function($scope, luticateAuthUsers, data, $q, dialogs) {
6
+    .controller('UserEditController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs', 'luticateAuthCache',
7
+        function($scope, luticateAuthUsers, data, $q, dialogs, luticateAuthCache) {
8
             if (data != null) {
8
             if (data != null) {
9
                 $scope.user = data;
9
                 $scope.user = data;
10
+                $scope.permission = "LU_USER_EDIT";
11
+                $scope.permissionPassword = "LU_USER_SET_PASSWORD";
10
             }
12
             }
11
             else {
13
             else {
12
                 $scope.user = {
14
                 $scope.user = {
15
                     Firstname: "",
17
                     Firstname: "",
16
                     Lastname: ""
18
                     Lastname: ""
17
                 };
19
                 };
20
+                $scope.permission = "LU_USER_ADD";
21
+                $scope.permissionPassword = "LU_USER_ADD";
18
             }
22
             }
19
             $scope.userPassword = {
23
             $scope.userPassword = {
20
                 value: "",
24
                 value: "",
44
             {
48
             {
45
                 if ($scope.user.Id != null) {
49
                 if ($scope.user.Id != null) {
46
                     var defer = $q.defer();
50
                     var defer = $q.defer();
47
-                    luticateAuthUsers.edit({
48
-                        user_id: $scope.user.Id,
49
-                        email: $scope.user.Email,
50
-                        firstname: $scope.user.Firstname,
51
-                        lastname: $scope.user.Lastname
52
-                    }, promiseEditUser)
53
-                        .then(function(data)
54
-                        {
55
-                            if ($scope.userPassword.value != "") {
56
-                                luticateAuthUsers.setPassword({
57
-                                    user_id: $scope.user.Id,
58
-                                    password: $scope.userPassword.value
59
-                                }, promiseSetPassword)
60
-                                    .then(defer.resolve, defer.reject);
61
-                            }
62
-                            else {
63
-                                defer.resolve(data);
64
-                            }
65
-                        }, defer.reject);
51
+                    if (luticateAuthCache.hasEffectivePermissions("LU_USER_EDIT")) {
52
+                        luticateAuthUsers.edit({
53
+                            user_id: $scope.user.Id,
54
+                            email: $scope.user.Email,
55
+                            firstname: $scope.user.Firstname,
56
+                            lastname: $scope.user.Lastname
57
+                        }, promiseEditUser)
58
+                            .then(function(data)
59
+                            {
60
+                                $scope.mayEditPassword(defer);
61
+                            }, defer.reject);
62
+                    }
63
+                    else {
64
+                        $scope.mayEditPassword(defer);
65
+                    }
66
                     return defer.promise;
66
                     return defer.promise;
67
                 }
67
                 }
68
                 else {
68
                 else {
77
                 }
77
                 }
78
             };
78
             };
79
 
79
 
80
+            $scope.mayEditPassword = function(defer)
81
+            {
82
+                if ($scope.userPassword.value != ""
83
+                    && luticateAuthCache.hasEffectivePermissions("LU_USER_SET_PASSWORD")) {
84
+                    luticateAuthUsers.setPassword({
85
+                        user_id: $scope.user.Id,
86
+                        password: $scope.userPassword.value
87
+                    }, promiseSetPassword)
88
+                        .then(defer.resolve, defer.reject);
89
+                }
90
+                else {
91
+                    defer.resolve(data);
92
+                }
93
+;            }
94
+
80
             $scope.editPermissions = function(user)
95
             $scope.editPermissions = function(user)
81
             {
96
             {
82
                 dialogs.create('views/modals/userpermissions.html', 'UserPermissionsController', user);
97
                 dialogs.create('views/modals/userpermissions.html', 'UserPermissionsController', user);

+ 6
- 0
luticate/controllers/modals/userpermissions.controller.js View File

11
             $scope.luPermissionEdit = {
11
             $scope.luPermissionEdit = {
12
                 item: $scope.user,
12
                 item: $scope.user,
13
 
13
 
14
+                permissions: {
15
+                    add: 'LU_PERM_USER_ADD',
16
+                    del: 'LU_PERM_USER_DEL',
17
+                    edit: 'LU_PERM_USER_EDIT'
18
+                },
19
+
14
                 getGetAllPromise: function (page, perPage, promise) {
20
                 getGetAllPromise: function (page, perPage, promise) {
15
                     return luticateAuthPermissionsUser.getAll({
21
                     return luticateAuthPermissionsUser.getAll({
16
                         user_id: this.item.Id,
22
                         user_id: this.item.Id,

+ 0
- 9
luticate/controllers/navbar.controller.js View File

10
                 loaderGroups: ["body"]
10
                 loaderGroups: ["body"]
11
             };
11
             };
12
 
12
 
13
-            $scope.hasPermission = function(permission)
14
-            {
15
-                var permissions = luticateAuthCache.getEffectivePermissions();
16
-                if (permissions == null || permissions[permission] == null) {
17
-                    return false;
18
-                }
19
-                return permissions[permission];
20
-            };
21
-
22
             $scope.logout = function()
13
             $scope.logout = function()
23
             {
14
             {
24
                 luticateAuthUsers.logout(promiseLogout).finally(function()
15
                 luticateAuthUsers.logout(promiseLogout).finally(function()

+ 42
- 39
luticate/controllers/users.controller.js View File

2
     .controller('UsersController', ['$scope', 'luticateAuthUsers',
2
     .controller('UsersController', ['$scope', 'luticateAuthUsers',
3
         function($scope, luticateAuthUsers) {
3
         function($scope, luticateAuthUsers) {
4
 
4
 
5
-            $scope.columns = [
6
-                {
7
-                    name: "Username",
8
-                    width: 3,
9
-                    getValue: function(item) {
10
-                        return item.Username;
5
+            $scope.luTable = {
6
+                columns: [
7
+                    {
8
+                        name: "Username",
9
+                        width: 3,
10
+                        getValue: function (item) {
11
+                            return item.Username;
12
+                        }
13
+                    }, {
14
+                        name: "Email",
15
+                        width: 3,
16
+                        getValue: function (item) {
17
+                            return item.Email;
18
+                        }
19
+                    }, {
20
+                        name: "Firstname",
21
+                        width: 3,
22
+                        getValue: function (item) {
23
+                            return item.Firstname;
24
+                        }
25
+                    }, {
26
+                        name: "Lastname",
27
+                        width: 3,
28
+                        getValue: function (item) {
29
+                            return item.Lastname;
30
+                        }
11
                     }
31
                     }
12
-                }, {
13
-                    name: "Email",
14
-                    width: 3,
15
-                    getValue: function(item) {
16
-                        return item.Email;
17
-                    }
18
-                }, {
19
-                    name: "Firstname",
20
-                    width: 3,
21
-                    getValue: function(item) {
22
-                        return item.Firstname;
23
-                    }
24
-                }, {
25
-                    name: "Lastname",
26
-                    width: 3,
27
-                    getValue: function(item) {
28
-                        return item.Lastname;
29
-                    }
30
-                }
31
-            ];
32
-
33
-            $scope.getLoadPagePromise = function(page, perPage, promise)
34
-            {
35
-                return luticateAuthUsers.getAll({page: page, perPage: perPage}, promise);
36
-            };
32
+                ],
37
 
33
 
38
-            $scope.getDelPromise = function(id, promise)
39
-            {
40
-                return luticateAuthUsers.del({user_id: id}, promise);
41
-            };
34
+                permissions: {
35
+                    add: 'LU_USER_ADD',
36
+                    del: 'LU_USER_DEL',
37
+                    edit: 'LU_USER_EDIT'
38
+                },
42
 
39
 
43
-            $scope.getEditController = function()
44
-            {
45
-                return "UserEdit";
46
-            };
40
+                getLoadPagePromise: function (page, perPage, promise) {
41
+                    return luticateAuthUsers.getAll({page: page, perPage: perPage}, promise);
42
+                },
47
 
43
 
44
+                getDelPromise: function (id, promise) {
45
+                    return luticateAuthUsers.del({user_id: id}, promise);
46
+                },
48
 
47
 
48
+                getEditController: function () {
49
+                    return "UserEdit";
50
+                }
51
+            };
49
     }]);
52
     }]);

+ 1
- 0
luticate/index.html View File

29
     <script src="../bower_components/luticate-utils/src/lubusy.js"></script>
29
     <script src="../bower_components/luticate-utils/src/lubusy.js"></script>
30
     <script src="../bower_components/luticate-utils/src/lutable.js"></script>
30
     <script src="../bower_components/luticate-utils/src/lutable.js"></script>
31
     <script src="../bower_components/luticate-utils/src/lupermissionsedit.js"></script>
31
     <script src="../bower_components/luticate-utils/src/lupermissionsedit.js"></script>
32
+    <script src="../bower_components/luticate-utils/src/luhaspermission.js"></script>
32
     <script src="../bower_components/luticate-utils/src/modals/dialogerror.js"></script>
33
     <script src="../bower_components/luticate-utils/src/modals/dialogerror.js"></script>
33
     <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
34
     <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
34
     <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>
35
     <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>

+ 5
- 5
luticate/views/modals/useredit.html View File

8
     <div class="form-group">
8
     <div class="form-group">
9
         <label for="email" class="col-sm-2 control-label">Email</label>
9
         <label for="email" class="col-sm-2 control-label">Email</label>
10
         <div class="col-sm-9">
10
         <div class="col-sm-9">
11
-            <input id="email" class="form-control" ng-model="user.Email" />
11
+            <input id="email" class="form-control" ng-model="user.Email" lu-enable-permission="{{ permission }}"/>
12
         </div>
12
         </div>
13
     </div>
13
     </div>
14
     <div class="form-group">
14
     <div class="form-group">
15
         <label for="firstname" class="col-sm-2 control-label">Firstname</label>
15
         <label for="firstname" class="col-sm-2 control-label">Firstname</label>
16
         <div class="col-sm-9">
16
         <div class="col-sm-9">
17
-            <input id="firstname" class="form-control" ng-model="user.Firstname" />
17
+            <input id="firstname" class="form-control" ng-model="user.Firstname" lu-enable-permission="{{ permission }}"/>
18
         </div>
18
         </div>
19
     </div>
19
     </div>
20
     <div class="form-group">
20
     <div class="form-group">
21
         <label for="lastname" class="col-sm-2 control-label">Lastname</label>
21
         <label for="lastname" class="col-sm-2 control-label">Lastname</label>
22
         <div class="col-sm-9">
22
         <div class="col-sm-9">
23
-            <input id="lastname" class="form-control" ng-model="user.Lastname" />
23
+            <input id="lastname" class="form-control" ng-model="user.Lastname" lu-enable-permission="{{ permission }}"/>
24
         </div>
24
         </div>
25
     </div>
25
     </div>
26
-    <div class="form-group">
26
+    <div class="form-group" lu-show-permission="{{ permissionPassword }}">
27
         <label for="password" class="col-sm-2 control-label">Password</label>
27
         <label for="password" class="col-sm-2 control-label">Password</label>
28
         <div class="col-sm-9">
28
         <div class="col-sm-9">
29
             <input id="password" class="form-control" type="password" ng-model="userPassword.value"
29
             <input id="password" class="form-control" type="password" ng-model="userPassword.value"
41
             <p class="error" ng-show="form.password2.$error.same_passwords">Passwords do not match</p>
41
             <p class="error" ng-show="form.password2.$error.same_passwords">Passwords do not match</p>
42
         </div>
42
         </div>
43
     </div>
43
     </div>
44
-    <div class="form-group">
44
+    <div class="form-group" lu-show-permission="LU_PERM_USER_GET">
45
         <button type="button" class="btn btn-default col-sm-offset-2"
45
         <button type="button" class="btn btn-default col-sm-offset-2"
46
                 ng-click="editPermissions(user)" ng-show="user.Id != null">
46
                 ng-click="editPermissions(user)" ng-show="user.Id != null">
47
             Edit Permissions
47
             Edit Permissions

+ 3
- 3
luticate/views/navbar.html View File

15
         <!-- Collect the nav links, forms, and other content for toggling -->
15
         <!-- Collect the nav links, forms, and other content for toggling -->
16
         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
16
         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
17
             <ul class="nav navbar-nav navbar-left">
17
             <ul class="nav navbar-nav navbar-left">
18
-                <li><a href="#/users" ng-show="hasPermission('LU_USER_GET')">Users</a></li>
19
-                <li><a href="#/groups" ng-show="hasPermission('LU_GROUP_GET')">Groups</a></li>
20
-                <li><a href="#/permissions" ng-show="hasPermission('LU_PERM_GET')">Permissions</a></li>
18
+                <li><a href="#/users" lu-show-permission="LU_USER_GET">Users</a></li>
19
+                <li><a href="#/groups" lu-show-permission="LU_GROUP_GET">Groups</a></li>
20
+                <li><a href="#/permissions" lu-show-permission="LU_PERM_GET">Permissions</a></li>
21
             </ul>
21
             </ul>
22
             <ul class="nav navbar-nav navbar-right">
22
             <ul class="nav navbar-nav navbar-right">
23
                 <li><a href="" ng-click="logout()">Logout</a></li>
23
                 <li><a href="" ng-click="logout()">Logout</a></li>

+ 1
- 1
luticate/views/users.html View File

1
 <!-- Page Content -->
1
 <!-- Page Content -->
2
 <div class="container">
2
 <div class="container">
3
-    <lu-table class="row col-sm-8 col-sm-offset-2" ></lu-table>
3
+    <lu-table options="luTable" class="row col-sm-8 col-sm-offset-2" ></lu-table>
4
 </div>
4
 </div>

Loading…
Cancel
Save