Pārlūkot izejas kodu

group list

develop
Robin Thoni 9 gadus atpakaļ
vecāks
revīzija
1fc3547eec

+ 27
- 3
luticate/controllers/groups.controller.js Parādīt failu

@@ -1,5 +1,29 @@
1 1
 angular.module('luticate')
2
-    .controller('GroupsController', ['$scope', '$state', 'luticatePromises',
3
-        function($scope, $state, luticatePromises) {
2
+    .controller('GroupsController', ['$scope', 'luticateAuthGroups',
3
+        function($scope, luticateAuthGroups) {
4 4
 
5
-    }]);
5
+            $scope.columns = [
6
+                {
7
+                    name: "Name",
8
+                    width: 11,
9
+                    getValue: function(item) {
10
+                        return item.Name;
11
+                    }
12
+                }
13
+            ];
14
+
15
+            $scope.getLoadPagePromise = function(page, perPage, promise)
16
+            {
17
+                return luticateAuthGroups.getAll({page: page, perPage: perPage}, promise);
18
+            };
19
+
20
+            $scope.getDelPromise = function(id, promise)
21
+            {
22
+                return luticateAuthGroups.del({group_id: id}, promise);
23
+            };
24
+
25
+            $scope.getEditController = function()
26
+            {
27
+                return "GroupEdit";
28
+            };
29
+        }]);

+ 36
- 86
luticate/controllers/users.controller.js Parādīt failu

@@ -1,99 +1,49 @@
1 1
 angular.module('luticate')
2
-    .controller('UsersController', ['$scope', '$state', 'luticateAuthUsers', 'dialogs', '$q', 'luticateDialogErrorHelper',
3
-        function($scope, $state, luticateAuthUsers, dialogs, $q, luticateDialogErrorHelper) {
4
-            $scope.page = 0;
5
-            $scope.perPage = 15;
6
-            $scope.users = [];
7
-            $scope.pages = [];
8
-            $scope.selectedUsers = [];
9
-
10
-            var promiseLoadUsers = {
11
-                id: "promiseLoadUsers",
12
-                groups: ['userList']
13
-            };
14
-            var promiseDelUsers = {
15
-                id: "promiseDelUsers",
16
-                loadGroups: ['userList']
17
-            };
18
-
19
-            $scope.loadPage = function(page)
20
-            {
21
-                luticateAuthUsers.getAll({page: page, perPage: $scope.perPage}, promiseLoadUsers)
22
-                    .then(function(users)
23
-                    {
24
-                        $scope.page = page;
25
-                        $scope.users = users;
26
-                        $scope.pages = [];
27
-                        var start = Math.max(0, $scope.page - 5);
28
-                        var end = Math.min(start + 10, (users.Count / $scope.perPage) + (users.Count % $scope.perPage == 0 ? -1 : 0));
29
-                        for (var i = start; i < end; ++i) {
30
-                            $scope.pages.push(i);
31
-                        }
32
-                    }, function(error)
33
-                    {
34
-                    });
35
-            };
36
-
37
-            $scope.displayUser = function(user)
38
-            {
39
-                dialogs.create('views/modals/useredit.html', 'UserEditController', user)
40
-                    .result.then(function (data) {
41
-                        $scope.loadPage($scope.page);
42
-                    });
43
-            };
44
-
45
-            $scope.removeUsers = function()
46
-            {
47
-                if ($scope.selectedUsers.length == 0) {
48
-                    $scope.loadPage($scope.page);
49
-                    return;
2
+    .controller('UsersController', ['$scope', 'luticateAuthUsers',
3
+        function($scope, luticateAuthUsers) {
4
+
5
+            $scope.columns = [
6
+                {
7
+                    name: "Username",
8
+                    width: 3,
9
+                    getValue: function(item) {
10
+                        return item.Username;
11
+                    }
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
+                    }
50 30
                 }
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
-                    });
64
-            };
31
+            ];
65 32
 
66
-            $scope.addUser = function()
33
+            $scope.getLoadPagePromise = function(page, perPage, promise)
67 34
             {
68
-                dialogs.create('views/modals/useredit.html', 'UserEditController', null)
69
-                    .result.then(function (data) {
70
-                        $scope.loadPage($scope.page);
71
-                    });
35
+                return luticateAuthUsers.getAll({page: page, perPage: perPage}, promise);
72 36
             };
73 37
 
74
-            $scope.toggleSelectedUser = function(id)
38
+            $scope.getDelPromise = function(id, promise)
75 39
             {
76
-                var idx = $scope.selectedUsers.indexOf(id);
77
-                if (idx > -1) {
78
-                    $scope.selectedUsers.splice(idx, 1);
79
-                }
80
-                else {
81
-                    $scope.selectedUsers.push(id);
82
-                }
40
+                return luticateAuthUsers.del({user_id: id}, promise);
83 41
             };
84 42
 
85
-            $scope.toggleSelectAll = function()
43
+            $scope.getEditController = function()
86 44
             {
87
-                if ($scope.selectedUsers.length == $scope.users.Data.length) {
88
-                    $scope.selectedUsers = [];
89
-                }
90
-                else {
91
-                    $scope.selectedUsers = [];
92
-                    for (var i = 0; i < $scope.users.Data.length; ++i) {
93
-                        $scope.selectedUsers.push($scope.users.Data[i].Id);
94
-                    }
95
-                }
45
+                return "UserEdit";
96 46
             };
97 47
 
98
-            $scope.loadPage($scope.page);
48
+
99 49
     }]);

+ 2
- 0
luticate/index.html Parādīt failu

@@ -27,11 +27,13 @@
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/lutable.js"></script>
30 31
     <script src="../bower_components/luticate-utils/src/modals/dialogerror.js"></script>
31 32
     <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
32 33
     <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>
33 34
     <script src="../bower_components/luticate-auth/src/luticateauth.js"></script>
34 35
     <script src="../bower_components/luticate-auth/src/users.js"></script>
36
+    <script src="../bower_components/luticate-auth/src/groups.js"></script>
35 37
     <script src="../bower_components/luticate-auth/src/cache.js"></script>
36 38
 
37 39
     <!-- scripts -->

+ 2
- 4
luticate/views/groups.html Parādīt failu

@@ -1,7 +1,5 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3
-
4
-    <div class="row">
5
-
6
-    </div>
3
+    <lu-table class="row col-sm-8 col-sm-offset-2" ></lu-table>
7 4
 </div>
5
+

+ 1
- 38
luticate/views/users.html Parādīt failu

@@ -1,41 +1,4 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3
-    <div class="row col-sm-8 col-sm-offset-2" lu-busy="userList">
4
-        <table class="col-sm-12 table table-hover">
5
-            <thead>
6
-                <tr>
7
-                    <th class="col-sm-3">
8
-                        <input type="checkbox" ng-click="toggleSelectAll()"
9
-                               ng-checked="selectedUsers.length == users.Data.length && users.Data.length != 0">
10
-                        Username
11
-                    </th>
12
-                    <th class="col-sm-3">Email</th>
13
-                    <th class="col-sm-3">Firstname</th>
14
-                    <th class="col-sm-3">Lastname</th>
15
-                </tr>
16
-            </thead>
17
-            <tbody>
18
-                <tr ng-repeat="user in users.Data" style="cursor: pointer" ng-click="displayUser(user)">
19
-                    <td><input name="selectedUsers[]" type="checkbox" ng-checked="selectedUsers.indexOf(user.Id) > -1"
20
-                               ng-click="$event.stopPropagation();toggleSelectedUser(user.Id)" >&nbsp;{{ user.Username }}</td>
21
-                    <td>{{ user.Email }}</td>
22
-                    <td>{{ user.Firstname }}</td>
23
-                    <td>{{ user.Lastname }}</td>
24
-                </tr>
25
-            </tbody>
26
-        </table>
27
-
28
-        <div class="col-sm-12 text-center">
29
-            <a class="{{ p == page ? 'pagination-current' : 'pagination-not-current'}}" href="" ng-repeat="p in pages" ng-click="loadPage(p)">{{ p + 1 }}&nbsp;</a>
30
-        </div>
31
-
32
-        <div class="col-sm-12">
33
-            <button class="btn btn-default" type="button" ng-click="removeUsers()" ng-disabled="selectedUsers.length == 0">
34
-                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Remove
35
-            </button>
36
-            <button class="btn btn-default" type="button" ng-click="addUser()">
37
-                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add
38
-            </button>
39
-        </div>
40
-    </div>
3
+    <lu-table class="row col-sm-8 col-sm-offset-2" ></lu-table>
41 4
 </div>

Notiek ielāde…
Atcelt
Saglabāt