Browse Source

users add/del/edit

develop
Robin Thoni 9 years ago
parent
commit
23a3cbf1a3

+ 2
- 2
luticate/app.js View File

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

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

@@ -1,67 +0,0 @@
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,14 +40,8 @@ angular.module('luticate')
40 40
                 loaderGroups: ["modal"]
41 41
             };
42 42
 
43
-            $scope.onCanceled = function()
44
-            {
45
-                console.log($scope.userPassword);
46
-            };
47
-
48 43
             $scope.submitForm = function()
49 44
             {
50
-                console.log($scope.userPassword);
51 45
                 if ($scope.user.Id != null) {
52 46
                     var defer = $q.defer();
53 47
                     luticateAuthUsers.edit({
@@ -58,7 +52,6 @@ angular.module('luticate')
58 52
                     }, promiseEditUser)
59 53
                         .then(function(data)
60 54
                         {
61
-                            console.log($scope.userPassword);
62 55
                             if ($scope.userPassword.value != "") {
63 56
                                 luticateAuthUsers.setPassword({
64 57
                                     user_id: $scope.user.Id,

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

@@ -1,20 +1,24 @@
1 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 4
             $scope.page = 0;
5 5
             $scope.perPage = 15;
6 6
             $scope.users = [];
7 7
             $scope.pages = [];
8 8
             $scope.selectedUsers = [];
9 9
 
10
-            var promiseUsers = {
11
-                id: "promiseUsers",
10
+            var promiseLoadUsers = {
11
+                id: "promiseLoadUsers",
12 12
                 groups: ['userList']
13 13
             };
14
+            var promiseDelUsers = {
15
+                id: "promiseDelUsers",
16
+                loadGroups: ['userList']
17
+            };
14 18
 
15 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 22
                     .then(function(users)
19 23
                     {
20 24
                         $scope.page = page;
@@ -40,7 +44,23 @@ angular.module('luticate')
40 44
 
41 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 66
             $scope.addUser = function()

+ 3
- 1
luticate/index.html View File

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

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

@@ -1,18 +0,0 @@
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