summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-08 11:27:59 +0700
committerThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-08 11:27:59 +0700
commit3bead1bf78758e81a97150053c5df8e6be2d6fe1 (patch)
tree3df98870627a747994c8c5ff7aea73432cd7b3b1
parent1f6545e411fbe98fc1a0b1d5361c7a2bcc74056a (diff)
downloadwekan-3bead1bf78758e81a97150053c5df8e6be2d6fe1.tar.gz
wekan-3bead1bf78758e81a97150053c5df8e6be2d6fe1.tar.bz2
wekan-3bead1bf78758e81a97150053c5df8e6be2d6fe1.zip
Added pagination to people management in admin panel
-rw-r--r--client/components/settings/peopleBody.jade13
-rw-r--r--client/components/settings/peopleBody.js38
-rw-r--r--client/components/settings/peopleBody.styl3
-rw-r--r--server/publications/people.js8
4 files changed, 55 insertions, 7 deletions
diff --git a/client/components/settings/peopleBody.jade b/client/components/settings/peopleBody.jade
index 3ed2e4c8..34004d31 100644
--- a/client/components/settings/peopleBody.jade
+++ b/client/components/settings/peopleBody.jade
@@ -46,12 +46,12 @@ template(name="peopleRow")
| true
else
| false
- td {{ userData.createdAt }}
+ td {{ moment userData.createdAt 'LLL' }}
td
- if userData.active
- | true
- else
+ if userData.loginDisabled
| false
+ else
+ | true
td
a.edit-user
| edit
@@ -80,5 +80,10 @@ template(name="editUserPopup")
select.select-role.js-profile-isadmin
option(value="false") No
option(value="true" selected="{{user.isAdmin}}") Yes
+ label
+ | {{_ 'isActive'}}
+ select.select-active.js-profile-isactive
+ option(value="false") Yes
+ option(value="true" selected="{{user.loginDisabled}}") No
input.primary.wide(type="submit" value="{{_ 'save'}}")
diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js
index 85376ebb..d59dc38b 100644
--- a/client/components/settings/peopleBody.js
+++ b/client/components/settings/peopleBody.js
@@ -1,10 +1,46 @@
-Meteor.subscribe('people');
+const usersPerPage = 25;
BlazeComponent.extendComponent({
+ mixins() {
+ return [Mixins.InfiniteScrolling];
+ },
onCreated() {
this.error = new ReactiveVar('');
this.loading = new ReactiveVar(false);
this.people = new ReactiveVar(true);
+
+ this.page = new ReactiveVar(1);
+ this.loadNextPageLocked = false;
+ this.callFirstWith(null, 'resetNextPeak');
+ this.autorun(() => {
+ const limit = this.page.get() * usersPerPage;
+
+ this.subscribe('people', limit, () => {
+ this.loadNextPageLocked = false;
+ const nextPeakBefore = this.callFirstWith(null, 'getNextPeak');
+ this.calculateNextPeak();
+ const nextPeakAfter = this.callFirstWith(null, 'getNextPeak');
+ if (nextPeakBefore === nextPeakAfter) {
+ this.callFirstWith(null, 'resetNextPeak');
+ }
+ });
+ });
+ },
+ loadNextPage() {
+ if (this.loadNextPageLocked === false) {
+ this.page.set(this.page.get() + 1);
+ this.loadNextPageLocked = true;
+ }
+ },
+ calculateNextPeak() {
+ const element = this.find('.main-body');
+ if (element) {
+ const altitude = element.scrollHeight;
+ this.callFirstWith(this, 'setNextPeak', altitude);
+ }
+ },
+ reachNextPeak() {
+ this.loadNextPage();
},
setError(error) {
this.error.set(error);
diff --git a/client/components/settings/peopleBody.styl b/client/components/settings/peopleBody.styl
index dc3210ad..2e89ea3b 100644
--- a/client/components/settings/peopleBody.styl
+++ b/client/components/settings/peopleBody.styl
@@ -1,3 +1,6 @@
+.main-body
+ overflow: scroll;
+
table
font-family: arial, sans-serif;
border-collapse: collapse;
diff --git a/server/publications/people.js b/server/publications/people.js
index 3beeec6a..f3c2bdfe 100644
--- a/server/publications/people.js
+++ b/server/publications/people.js
@@ -1,3 +1,7 @@
-Meteor.publish('people', function () {
- return Meteor.users.find({}, {fields:{}});
+Meteor.publish('people', (limit) => {
+ check(limit, Number);
+ return Users.find({}, {
+ limit,
+ sort: {createdAt: -1},
+ });
});