Browse Source

ui fixes

develop
Robin Thoni 9 years ago
parent
commit
df237a554c

+ 6
- 3
luticate/controllers/groups.controller.js View File

@@ -1,6 +1,6 @@
1 1
 angular.module('luticate')
2
-    .controller('GroupsController', ['$scope', 'luticateAuthGroups',
3
-        function($scope, luticateAuthGroups) {
2
+    .controller('GroupsController', ['$scope', 'luticateAuthGroups', 'luticateAuthCache',
3
+        function($scope, luticateAuthGroups, luticateAuthCache) {
4 4
 
5 5
             $scope.luTable = {
6 6
                 columns: [
@@ -17,7 +17,10 @@ angular.module('luticate')
17 17
 
18 18
                 canDel: 'LU_GROUP_DEL',
19 19
 
20
-                canEdit: 'LU_GROUP_EDIT',
20
+                canEdit: function()
21
+                {
22
+                    return true;
23
+                },
21 24
 
22 25
                 getLoadPagePromise: function (page, perPage, query, promise) {
23 26
                     return luticateAuthGroups.getAll({page: page, perPage: perPage, query: query}, promise);

+ 72
- 2
luticate/controllers/home.controller.js View File

@@ -1,5 +1,75 @@
1 1
 angular.module('luticate')
2
-    .controller('HomeController', ['$scope', 'luticateAuthCache',
3
-        function($scope, luticateAuthCache) {
2
+    .controller('HomeController', ['$scope', 'luticateAuthCache', 'luticateDialogErrorHelper', 'luticateAuthUsers', '$state',
3
+        function($scope, luticateAuthCache, luticateDialogErrorHelper, luticateAuthUsers, $state) {
4 4
             $scope.user = luticateAuthCache.getUser();
5
+
6
+            $scope.userPassword = {
7
+                old: "",
8
+                value: "",
9
+                confirm: ""
10
+            };
11
+            $scope.passwordValidation = {
12
+                length: '$value.length >= 5 || $value.length == 0'
13
+            };
14
+            $scope.password2Validation = {
15
+                same_passwords: 'userPassword.value==$value'
16
+            };
17
+
18
+            $scope.submit = function()
19
+            {
20
+                var promiseEditUser = {
21
+                    id: "promiseEditUser",
22
+                    loaderGroups: ["form"]
23
+                };
24
+                if (luticateAuthCache.hasEffectivePermission("LU_USER_EDIT_ME")) {
25
+                    luticateAuthUsers.editMe({
26
+                            email: $scope.user.Email,
27
+                            firstname: $scope.user.Firstname,
28
+                            lastname: $scope.user.Lastname
29
+                        }, promiseEditUser)
30
+                        .then(function(data)
31
+                        {
32
+                            $scope.load();
33
+                            $scope.mayEditPassword();
34
+                        }, luticateDialogErrorHelper.errorDialog);
35
+                }
36
+                else {
37
+                    $scope.mayEditPassword();
38
+                }
39
+            };
40
+
41
+            $scope.mayEditPassword = function()
42
+            {
43
+                var promiseSetPassword = {
44
+                    id: "promiseSetPassword",
45
+                    loaderGroups: ["form"]
46
+                };
47
+                if ($scope.userPassword.value != ""
48
+                    && luticateAuthCache.hasEffectivePermission("LU_USER_SET_PASSWORD_ME")) {
49
+                    luticateAuthUsers.setPasswordMe({
50
+                            oldPassword: $scope.userPassword.old,
51
+                            password: $scope.userPassword.value
52
+                        }, promiseSetPassword)
53
+                        .then(function(data)
54
+                        {
55
+                            luticateAuthCache.removeUser();
56
+                            $state.go('login');
57
+                        }, luticateDialogErrorHelper.errorDialog);
58
+                }
59
+            };
60
+
61
+            $scope.load = function()
62
+            {
63
+                var promiseLoadMe = {
64
+                    id: "promiseLoadMe",
65
+                    groups: ["form"]
66
+                };
67
+                luticateAuthUsers.getMe(promiseLoadMe)
68
+                    .then(function(user)
69
+                    {
70
+                        $scope.user = user;
71
+                    }, luticateDialogErrorHelper.errorDialog);
72
+            };
73
+
74
+            $scope.load();
5 75
     }]);

+ 37
- 18
luticate/controllers/modals/groupedit.controller.js View File

@@ -3,8 +3,8 @@
3 3
  */
4 4
 
5 5
 angular.module('luticate')
6
-    .controller('GroupEditController', ['$scope', 'luticateAuthGroups', 'data', 'dialogs',
7
-        function($scope, luticateAuthGroups, data, dialogs) {
6
+    .controller('GroupEditController', ['$scope', 'luticateAuthGroups', 'data', 'dialogs', '$q', 'luticateAuthCache',
7
+        function($scope, luticateAuthGroups, data, dialogs, $q, luticateAuthCache) {
8 8
             if (data != null) {
9 9
                 $scope.group = data;
10 10
                 $scope.permission = "LU_GROUP_EDIT";
@@ -18,27 +18,46 @@ angular.module('luticate')
18 18
 
19 19
             $scope.submitForm = function()
20 20
             {
21
-                if ($scope.group.Id != null) {
22
-                    var promiseEditGroup = {
23
-                        id: "promiseEditGroup",
24
-                        loaderGroups: ["modal"]
25
-                    };
26
-                    return luticateAuthGroups.edit({
27
-                        group_id: $scope.group.Id,
28
-                        group_name: $scope.group.Name
29
-                    }, promiseEditGroup);
21
+                if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
22
+                    if ($scope.group.Id != null) {
23
+                        var promiseEditGroup = {
24
+                            id: "promiseEditGroup",
25
+                            loaderGroups: ["modal"]
26
+                        };
27
+                        return luticateAuthGroups.edit({
28
+                            group_id: $scope.group.Id,
29
+                            group_name: $scope.group.Name
30
+                        }, promiseEditGroup);
31
+                    }
32
+                    else {
33
+                        var promiseAddGroup = {
34
+                            id: "promiseAddGroup",
35
+                            loaderGroups: ["modal"]
36
+                        };
37
+                        return luticateAuthGroups.add({
38
+                            group_name: $scope.group.Name
39
+                        }, promiseAddGroup);
40
+                    }
30 41
                 }
31 42
                 else {
32
-                    var promiseAddGroup = {
33
-                        id: "promiseAddGroup",
34
-                        loaderGroups: ["modal"]
35
-                    };
36
-                    return luticateAuthGroups.add({
37
-                        group_name: $scope.group.Name
38
-                    }, promiseAddGroup);
43
+                    var defer = $q.defer();
44
+                    defer.resolve();
45
+                    return defer.promise;
39 46
                 }
40 47
             };
41 48
 
49
+            $scope.canEditUsers = function()
50
+            {
51
+                return $scope.group.Id != null &&
52
+                    (luticateAuthCache.hasEffectivePermission('LU_GROUP_USER_DEL') ||
53
+                    luticateAuthCache.hasAllEffectivePermissions(['LU_GROUP_USER_ADD', 'LU_USER_GET']));
54
+            };
55
+
56
+            $scope.canEditPermissions = function()
57
+            {
58
+                return $scope.group.Id != null && luticateAuthCache.hasEffectivePermission('LU_PERM_GROUP_GET');
59
+            };
60
+
42 61
             $scope.editPermissions = function(group)
43 62
             {
44 63
                 dialogs.create('views/modals/grouppermissions.html', 'GroupPermissionsController', group);

+ 14
- 7
luticate/controllers/modals/permissionedit.controller.js View File

@@ -3,8 +3,8 @@
3 3
  */
4 4
 
5 5
 angular.module('luticate')
6
-    .controller('PermissionEditController', ['$scope', 'luticateAuthPermissions', 'data',
7
-        function($scope, luticateAuthPermissions, data) {
6
+    .controller('PermissionEditController', ['$scope', 'luticateAuthPermissions', 'data', 'luticateAuthCache', '$q',
7
+        function($scope, luticateAuthPermissions, data, luticateAuthCache, $q) {
8 8
             if (data != null) {
9 9
                 $scope.permission = data;
10 10
                 $scope.permission.IsNew = false;
@@ -26,11 +26,18 @@ angular.module('luticate')
26 26
                     permission_value: $scope.permission.Value
27 27
                 };
28 28
                 if (!$scope.permission.IsNew) {
29
-                    var promiseEditPermission = {
30
-                        id: "promiseEditPermission",
31
-                        loaderGroups: ["modal"]
32
-                    };
33
-                    return luticateAuthPermissions.edit(perm, promiseEditPermission);
29
+                    if (luticateAuthCache.hasEffectivePermission("LU_PERM_EDIT")) {
30
+                        var promiseEditPermission = {
31
+                            id: "promiseEditPermission",
32
+                            loaderGroups: ["modal"]
33
+                        };
34
+                        return luticateAuthPermissions.edit(perm, promiseEditPermission);
35
+                    }
36
+                    else {
37
+                        var defer = $q.defer();
38
+                        defer.resolve();
39
+                        return defer.promise;
40
+                    }
34 41
                 }
35 42
                 else {
36 43
                     var promiseAddPermission = {

+ 5
- 0
luticate/controllers/modals/useredit.controller.js View File

@@ -100,4 +100,9 @@ angular.module('luticate')
100 100
             {
101 101
                 dialogs.create('views/modals/usereffectivepermissions.html', 'UserEffectivePermissionsController', user);
102 102
             };
103
+
104
+            $scope.canEditPermissions = function()
105
+            {
106
+                return $scope.user.Id != null && luticateAuthCache.hasEffectivePermission("LU_PERM_USER_GET");
107
+            }
103 108
         }]);

+ 5
- 4
luticate/controllers/navbar.controller.js View File

@@ -5,13 +5,14 @@
5 5
 angular.module('luticate')
6 6
     .controller('NavBarController', ['$scope', 'luticateAuthCache', 'luticateAuthUsers', '$state',
7 7
         function($scope, luticateAuthCache, luticateAuthUsers, $state) {
8
-            var promiseLogout = {
9
-                id: "promiseLogout",
10
-                loaderGroups: ["body"]
11
-            };
8
+
12 9
 
13 10
             $scope.logout = function()
14 11
             {
12
+                var promiseLogout = {
13
+                    id: "promiseLogout",
14
+                    loaderGroups: ["body"]
15
+                };
15 16
                 luticateAuthUsers.logout(promiseLogout).finally(function()
16 17
                 {
17 18
                     $state.go('login');

+ 4
- 1
luticate/controllers/permissions.controller.js View File

@@ -23,7 +23,10 @@ angular.module('luticate')
23 23
 
24 24
                 canDel: 'LU_PERM_DEL',
25 25
 
26
-                canEdit: 'LU_PERM_EDIT',
26
+                canEdit: function()
27
+                {
28
+                    return true;
29
+                },
27 30
 
28 31
                 getLoadPagePromise: function (page, perPage, query, promise) {
29 32
                     return luticateAuthPermissions.getAll({page: page, perPage: perPage, query: query}, promise);

+ 4
- 1
luticate/controllers/users.controller.js View File

@@ -35,7 +35,10 @@ angular.module('luticate')
35 35
 
36 36
                 canDel: 'LU_USER_DEL',
37 37
 
38
-                canEdit: 'LU_USER_EDIT',
38
+                canEdit: function()
39
+                {
40
+                    return true;
41
+                },
39 42
 
40 43
                 getLoadPagePromise: function (page, perPage, query, promise) {
41 44
                     return luticateAuthUsers.getAll({page: page, perPage: perPage, query: query}, promise);

+ 13
- 3
luticate/views/home.html View File

@@ -1,8 +1,8 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3
-    <form ng-submit="submit()">
3
+    <form name="form" ng-submit="submit()">
4 4
         <div class="form-group">
5
-            <div class="row co-sm-8 col-sm-offset-2">
5
+            <div class="row co-sm-8 col-sm-offset-2" lu-busy="form">
6 6
                 <div class="form-group">
7 7
                     <label for="email" class="col-sm-2 control-label">Email</label>
8 8
                     <div class="col-sm-9">
@@ -21,8 +21,14 @@
21 21
                         <input id="lastname" class="form-control" ng-model="user.Lastname" lu-enable-permission="LU_USER_EDIT_ME"/>
22 22
                     </div>
23 23
                 </div>
24
+
24 25
                 <div class="form-group" lu-show-permission="LU_USER_SET_PASSWORD_ME">
25
-                    <label for="password" class="col-sm-2 control-label">Password</label>
26
+                    <label for="oldPassword" class="col-sm-2 control-label">Old Password</label>
27
+                    <div class="col-sm-9">
28
+                        <input id="oldPassword" class="form-control" type="password" ng-model="userPassword.old"
29
+                               name="oldPassword"/>
30
+                    </div>
31
+                    <label for="password" class="col-sm-2 control-label">New Password</label>
26 32
                     <div class="col-sm-9">
27 33
                         <input id="password" class="form-control" type="password" ng-model="userPassword.value"
28 34
                                name="password" ui-validate="passwordValidation"/>
@@ -39,6 +45,10 @@
39 45
                         <p class="error" ng-show="form.password2.$error.same_passwords">Passwords do not match</p>
40 46
                     </div>
41 47
                 </div>
48
+                <div class="clearfix"></div>
49
+                <div class="form-group" class="col-sm-12">
50
+                    <button class="btn btn-default">Edit</button>
51
+                </div>
42 52
             </div>
43 53
         </div>
44 54
     </form>

+ 4
- 4
luticate/views/modals/groupedit.html View File

@@ -7,12 +7,12 @@
7 7
     </div>
8 8
     <div class="form-group">
9 9
         <div class="col-sm-2"></div>
10
-        <button type="button" class="btn btn-default" lu-show-permission="LU_PERM_GROUP_GET,LU_PERM_GET"
11
-                ng-click="editPermissions(group)" ng-show="group.Id != null">
10
+        <button type="button" class="btn btn-default"
11
+                ng-click="editPermissions(group)" ng-show="canEditPermissions()">
12 12
             Edit permissions
13 13
         </button>
14
-        <button type="button" class="btn btn-default" lu-show-permission="LU_PERM_GROUP_GET,LU_PERM_GET"
15
-                ng-click="editUsers(group)" ng-show="group.Id != null">
14
+        <button type="button" class="btn btn-default"
15
+                ng-click="editUsers(group)" ng-show="canEditUsers()">
16 16
             Edit users
17 17
         </button>
18 18
     </div>

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

@@ -43,11 +43,11 @@
43 43
     </div>
44 44
     <div class="form-group">
45 45
         <div class="col-sm-2"></div>
46
-        <button type="button" class="btn btn-default" lu-show-permission="LU_PERM_USER_GET,LU_PERM_GET"
47
-                ng-click="editPermissions(user)" ng-show="user.Id != null">
46
+        <button type="button" class="btn btn-default"
47
+                ng-click="editPermissions(user)" ng-show="canEditPermissions()">
48 48
             Edit permissions
49 49
         </button>
50
-        <button type="button" class="btn btn-default" lu-show-permission="LU_PERM_EFFECTIVE_GET"
50
+        <button type="button" class="btn btn-default" lu-show-permission="LU_PERM_EFFECTIVE_GET,LU_PERM_GET"
51 51
                 ng-click="showEffectivePermissions(user)" ng-show="user.Id != null">
52 52
             Show effective permissions
53 53
         </button>

Loading…
Cancel
Save