Browse Source

users add/del/edit

develop
Robin Thoni 9 years ago
parent
commit
23a3cbf1a3

+ 2
- 2
luticate/app.js View File

60
                     return config;
60
                     return config;
61
                 },
61
                 },
62
                 'responseError': function(rejection) {
62
                 'responseError': function(rejection) {
63
-                    if (rejection.status == 401) {
63
+                    /*if (rejection.status == 401) {
64
                         luticateAuthCache.removeUser();
64
                         luticateAuthCache.removeUser();
65
                         $injector.get('$state').transitionTo('login');
65
                         $injector.get('$state').transitionTo('login');
66
-                    }
66
+                    }*/
67
                     return $q.reject(rejection);
67
                     return $q.reject(rejection);
68
                 }
68
                 }
69
             };
69
             };

+ 0
- 67
luticate/controllers/directives/dialogokcancel.js View File

1
-/**
2
- * Created by robin on 11/2/15.
3
- */
4
-
5
-
6
-angular.module('luticate')
7
-    .directive('dialogOkCancel', [
8
-        function () {
9
-            return {
10
-                restrict: 'EA',
11
-                transclude: true,
12
-                templateUrl: 'views/directives/dialogokcancel.html',
13
-                link: function link($scope, element, attrs) {
14
-                    $scope.title = attrs.title;
15
-                    $scope.model = {};
16
-                    $scope.pending = false;
17
-                    $scope.submitted = false;
18
-                    $scope.errorString = "";
19
-
20
-                    $scope.__submit = function()
21
-                    {
22
-                        $scope.submitted = true;
23
-                        $scope.errorString = "";
24
-                        if ($scope.form.$valid) {
25
-                            $scope.pending = true;
26
-                            $scope.promise = $scope.submitForm();
27
-                            if ($scope.promise)
28
-                            {
29
-                                $scope.promise.then(function(data) {
30
-                                    if ($scope.onDone) {
31
-                                        $scope.onDone(data);
32
-                                    }
33
-                                    $scope.$close(data);
34
-                                    $scope.pending = false;
35
-                                })
36
-                                    .catch(function(error)
37
-                                    {
38
-                                        if ($scope.onError) {
39
-                                            $scope.onError(error);
40
-                                        }
41
-                                        if (error.Data) {
42
-                                            $scope.errorString = error.Data;
43
-                                        }
44
-                                        else {
45
-                                            $scope.errorString = error;
46
-                                        }
47
-                                        $scope.pending = false;
48
-                                    });
49
-                            }
50
-                            else {
51
-                                $scope.$close();
52
-                                $scope.pending = false;
53
-                            }
54
-                        }
55
-                    };
56
-
57
-                    $scope.__cancel = function()
58
-                    {
59
-                        if ($scope.onCanceled) {
60
-                            $scope.onCanceled();
61
-                        }
62
-                        $scope.$dismiss();
63
-                        $scope.pending = false;
64
-                    };
65
-                }
66
-            };
67
-        }]);

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

40
                 loaderGroups: ["modal"]
40
                 loaderGroups: ["modal"]
41
             };
41
             };
42
 
42
 
43
-            $scope.onCanceled = function()
44
-            {
45
-                console.log($scope.userPassword);
46
-            };
47
-
48
             $scope.submitForm = function()
43
             $scope.submitForm = function()
49
             {
44
             {
50
-                console.log($scope.userPassword);
51
                 if ($scope.user.Id != null) {
45
                 if ($scope.user.Id != null) {
52
                     var defer = $q.defer();
46
                     var defer = $q.defer();
53
                     luticateAuthUsers.edit({
47
                     luticateAuthUsers.edit({
58
                     }, promiseEditUser)
52
                     }, promiseEditUser)
59
                         .then(function(data)
53
                         .then(function(data)
60
                         {
54
                         {
61
-                            console.log($scope.userPassword);
62
                             if ($scope.userPassword.value != "") {
55
                             if ($scope.userPassword.value != "") {
63
                                 luticateAuthUsers.setPassword({
56
                                 luticateAuthUsers.setPassword({
64
                                     user_id: $scope.user.Id,
57
                                     user_id: $scope.user.Id,

+ 26
- 6
luticate/controllers/users.controller.js View File

1
 angular.module('luticate')
1
 angular.module('luticate')
2
-    .controller('UsersController', ['$scope', '$state', 'luticateAuthUsers', 'dialogs',
3
-        function($scope, $state, luticateAuthUsers, dialogs) {
2
+    .controller('UsersController', ['$scope', '$state', 'luticateAuthUsers', 'dialogs', '$q', 'luticateDialogErrorHelper',
3
+        function($scope, $state, luticateAuthUsers, dialogs, $q, luticateDialogErrorHelper) {
4
             $scope.page = 0;
4
             $scope.page = 0;
5
             $scope.perPage = 15;
5
             $scope.perPage = 15;
6
             $scope.users = [];
6
             $scope.users = [];
7
             $scope.pages = [];
7
             $scope.pages = [];
8
             $scope.selectedUsers = [];
8
             $scope.selectedUsers = [];
9
 
9
 
10
-            var promiseUsers = {
11
-                id: "promiseUsers",
10
+            var promiseLoadUsers = {
11
+                id: "promiseLoadUsers",
12
                 groups: ['userList']
12
                 groups: ['userList']
13
             };
13
             };
14
+            var promiseDelUsers = {
15
+                id: "promiseDelUsers",
16
+                loadGroups: ['userList']
17
+            };
14
 
18
 
15
             $scope.loadPage = function(page)
19
             $scope.loadPage = function(page)
16
             {
20
             {
17
-                luticateAuthUsers.getAll({page: page, perPage: $scope.perPage}, promiseUsers)
21
+                luticateAuthUsers.getAll({page: page, perPage: $scope.perPage}, promiseLoadUsers)
18
                     .then(function(users)
22
                     .then(function(users)
19
                     {
23
                     {
20
                         $scope.page = page;
24
                         $scope.page = page;
40
 
44
 
41
             $scope.removeUsers = function()
45
             $scope.removeUsers = function()
42
             {
46
             {
43
-                console.log($scope.selectedUsers);
47
+                if ($scope.selectedUsers.length == 0) {
48
+                    $scope.loadPage($scope.page);
49
+                    return;
50
+                }
51
+                luticateAuthUsers.del({user_id: $scope.selectedUsers[0]}, promiseDelUsers)
52
+                    .then(function(data)
53
+                    {
54
+                        $scope.selectedUsers.splice(0, 1);
55
+                        $scope.removeUsers();
56
+                    }, function(error)
57
+                    {
58
+                        luticateDialogErrorHelper.errorDialog(error)
59
+                            .result.then(function(data)
60
+                            {
61
+                                $scope.loadPage($scope.page);
62
+                            }, function(error) {});
63
+                    });
44
             };
64
             };
45
 
65
 
46
             $scope.addUser = function()
66
             $scope.addUser = function()

+ 3
- 1
luticate/index.html View File

27
     <script src="../bower_components/luticate-utils/src/promises.js"></script>
27
     <script src="../bower_components/luticate-utils/src/promises.js"></script>
28
     <script src="../bower_components/luticate-utils/src/request.js"></script>
28
     <script src="../bower_components/luticate-utils/src/request.js"></script>
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/modals/dialogerror.js"></script>
31
+    <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
32
+    <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>
30
     <script src="../bower_components/luticate-auth/src/luticateauth.js"></script>
33
     <script src="../bower_components/luticate-auth/src/luticateauth.js"></script>
31
     <script src="../bower_components/luticate-auth/src/users.js"></script>
34
     <script src="../bower_components/luticate-auth/src/users.js"></script>
32
     <script src="../bower_components/luticate-auth/src/cache.js"></script>
35
     <script src="../bower_components/luticate-auth/src/cache.js"></script>
47
 
50
 
48
     <!-- SDK -->
51
     <!-- SDK -->
49
     <script src="../sdk/cache.js"></script>
52
     <script src="../sdk/cache.js"></script>
50
-    <script src="controllers/directives/dialogokcancel.js"></script>
51
 
53
 
52
     <!-- Directives -->
54
     <!-- Directives -->
53
 
55
 

+ 0
- 18
luticate/views/directives/dialogokcancel.html View File

1
-<div class="popin modal-content" xmlns="http://www.w3.org/1999/html">
2
-    <form name="form" class="form-horizontal" ng-submit="__submit()">
3
-        <div class="modal-header">{{ title }}</div>
4
-        <div class="modal-body" lu-busy="modal">
5
-            <div class="form-group">
6
-                <ng-transclude></ng-transclude>
7
-            </div>
8
-            <div class="clearfix"></div>
9
-            <span class="error" ng-show="submitted">
10
-                <p class="error">{{ errorString }}</p>
11
-            </span>
12
-        </div>
13
-        <div class="modal-footer">
14
-            <button type="button" class="btn btn-default" ng-click="__cancel()">Cancel</button>
15
-            <button type="submit" class="btn btn-default" ng-enabled="!pending">OK</button>
16
-        </div>
17
-    </form>
18
-</div>

Loading…
Cancel
Save