Browse Source

users ui

develop
Robin Thoni 9 years ago
parent
commit
4f84ae1eb0

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

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

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

@@ -3,10 +3,12 @@
3 3
  */
4 4
 
5 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 8
             if (data != null) {
9 9
                 $scope.user = data;
10
+                $scope.permission = "LU_USER_EDIT";
11
+                $scope.permissionPassword = "LU_USER_SET_PASSWORD";
10 12
             }
11 13
             else {
12 14
                 $scope.user = {
@@ -15,6 +17,8 @@ angular.module('luticate')
15 17
                     Firstname: "",
16 18
                     Lastname: ""
17 19
                 };
20
+                $scope.permission = "LU_USER_ADD";
21
+                $scope.permissionPassword = "LU_USER_ADD";
18 22
             }
19 23
             $scope.userPassword = {
20 24
                 value: "",
@@ -44,25 +48,21 @@ angular.module('luticate')
44 48
             {
45 49
                 if ($scope.user.Id != null) {
46 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 66
                     return defer.promise;
67 67
                 }
68 68
                 else {
@@ -77,6 +77,21 @@ angular.module('luticate')
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 95
             $scope.editPermissions = function(user)
81 96
             {
82 97
                 dialogs.create('views/modals/userpermissions.html', 'UserPermissionsController', user);

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

@@ -11,6 +11,12 @@ angular.module('luticate')
11 11
             $scope.luPermissionEdit = {
12 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 20
                 getGetAllPromise: function (page, perPage, promise) {
15 21
                     return luticateAuthPermissionsUser.getAll({
16 22
                         user_id: this.item.Id,

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

@@ -10,15 +10,6 @@ angular.module('luticate')
10 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 13
             $scope.logout = function()
23 14
             {
24 15
                 luticateAuthUsers.logout(promiseLogout).finally(function()

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

@@ -2,48 +2,51 @@ angular.module('luticate')
2 2
     .controller('UsersController', ['$scope', 'luticateAuthUsers',
3 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,6 +29,7 @@
29 29
     <script src="../bower_components/luticate-utils/src/lubusy.js"></script>
30 30
     <script src="../bower_components/luticate-utils/src/lutable.js"></script>
31 31
     <script src="../bower_components/luticate-utils/src/lupermissionsedit.js"></script>
32
+    <script src="../bower_components/luticate-utils/src/luhaspermission.js"></script>
32 33
     <script src="../bower_components/luticate-utils/src/modals/dialogerror.js"></script>
33 34
     <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
34 35
     <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>

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

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

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

@@ -15,9 +15,9 @@
15 15
         <!-- Collect the nav links, forms, and other content for toggling -->
16 16
         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
17 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 21
             </ul>
22 22
             <ul class="nav navbar-nav navbar-right">
23 23
                 <li><a href="" ng-click="logout()">Logout</a></li>

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

@@ -1,4 +1,4 @@
1 1
 <!-- Page Content -->
2 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 4
 </div>

Loading…
Cancel
Save