From c53bc3b2f426e97e24718977ac20b66e7b428cd4 Mon Sep 17 00:00:00 2001 From: Zain Zafar Date: Sun, 16 Sep 2018 22:58:15 +0500 Subject: [PATCH 01/12] implement pagination and remove markup for inbox, draft, trash --- .../mail-folder/draft/draft.component.ts | 10 ++--- .../generic-folder.component.html | 6 +-- .../generic-folder.component.ts | 38 +++++++++++++++---- .../mail-folder/inbox/inbox.component.ts | 13 ++++--- .../mail-folder/trash/trash.component.ts | 10 ++--- .../mail/mail-list/mail-list.component.html | 12 ++++-- src/app/mail/mail.component.ts | 2 +- src/app/store/services/mail.service.ts | 2 +- 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/app/mail/mail-list/mail-folder/draft/draft.component.ts b/src/app/mail/mail-list/mail-folder/draft/draft.component.ts index 570a4800e..7474c8357 100644 --- a/src/app/mail/mail-list/mail-folder/draft/draft.component.ts +++ b/src/app/mail/mail-list/mail-folder/draft/draft.component.ts @@ -22,12 +22,12 @@ export class DraftComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.DRAFT })); + // this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.DRAFT })); - this.store.select(state => state.mail).takeUntil(this.destroyed$) - .subscribe((mailState: MailState) => { - this.mailState = mailState; - }); + // this.store.select(state => state.mail).takeUntil(this.destroyed$) + // .subscribe((mailState: MailState) => { + // this.mailState = mailState; + // }); } diff --git a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html index ee1f2f3b8..26bcd96ea 100644 --- a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html +++ b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html @@ -140,13 +140,13 @@
- 1-{{mails?.length}} of {{mails?.length}} + {{ OFFSET * LIMIT }}-{{ ( OFFSET * LIMIT ) + LIMIT }} of {{ LIMIT * MAX_EMAIL_PAGE_LIMIT }}
- -
diff --git a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.ts b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.ts index 82b1a0ae8..c2bcb241e 100644 --- a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.ts +++ b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.ts @@ -34,6 +34,10 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { readonly AUTO_REFRESH_DURATION: number = 10000; // duration in milliseconds readonly destroyed$: Observable; + MAX_EMAIL_PAGE_LIMIT: number = 1; + LIMIT: number; + OFFSET: number = 0; + constructor(public store: Store, private router: Router, private sharedService: SharedService, @@ -44,9 +48,7 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { ngOnInit() { this.store.dispatch(new SetCurrentFolder(this.mailFolder)); - if (this.fetchMails) { - this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: this.mailFolder })); - } + this.store.select(state => state.mail).takeUntil(this.destroyed$) .subscribe((mailState: MailState) => { this.showProgress = !mailState.loaded || mailState.inProgress; @@ -58,6 +60,14 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { this.store.select(state => state.user).takeUntil(this.destroyed$) .subscribe((user: UserState) => { this.userState = user; + if (this.fetchMails && this.userState.settings) { + this.LIMIT = user.settings.emails_per_page; + this.MAX_EMAIL_PAGE_LIMIT = user.settings.email_count; + if (this.LIMIT) { + this.store.dispatch(new GetMails({ limit: user.settings.emails_per_page, offset: this.OFFSET, folder: this.mailFolder })); + this.initializeAutoRefresh(); + } + } }); this.store.select(state => state.mailboxes).takeUntil(this.destroyed$) @@ -72,7 +82,6 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { // TODO: apply search }); - this.initializeAutoRefresh(); } ngOnChanges(changes: SimpleChanges) { @@ -96,9 +105,9 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { refresh(forceReload: boolean = false) { if (!forceReload && this.mailFolder === MailFolderType.INBOX) { - this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: this.mailFolder, read: false })); + this.store.dispatch(new GetMails({ limit: this.LIMIT, offset: this.OFFSET, folder: this.mailFolder, read: false })); } else { - this.store.dispatch(new GetMails({ forceReload, limit: 1000, offset: 0, folder: this.mailFolder })); + this.store.dispatch(new GetMails({ forceReload, limit: this.LIMIT, offset: this.OFFSET, folder: this.mailFolder })); } } @@ -164,8 +173,7 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { openMail(mail: Mail) { if (this.mailFolder === MailFolderType.DRAFT) { this.composeMailService.openComposeMailDialog({ draft: mail }); - } - else { + } else { this.store.dispatch(new GetMailDetailSuccess(mail)); this.router.navigate([`/mail/${this.mailFolder}/message/`, mail.id]); } @@ -249,6 +257,20 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges { }); } + prevPage() { + if (this.OFFSET > 0) { + this.OFFSET--; + this.refresh(); + } + } + + nextPage() { + if (this.OFFSET < (this.MAX_EMAIL_PAGE_LIMIT - 1)) { + this.OFFSET++; + this.refresh(); + } + } + /** * @name getMailIDs * @description Get list of comma separated IDs from mail object list diff --git a/src/app/mail/mail-list/mail-folder/inbox/inbox.component.ts b/src/app/mail/mail-list/mail-folder/inbox/inbox.component.ts index fc311e3ff..5f7c2fd8a 100644 --- a/src/app/mail/mail-list/mail-folder/inbox/inbox.component.ts +++ b/src/app/mail/mail-list/mail-folder/inbox/inbox.component.ts @@ -19,15 +19,18 @@ export class InboxComponent implements OnInit, OnDestroy { mailState: MailState; + LIMIT: number; + OFFSET: number = 0; + constructor(public store: Store) { } ngOnInit() { - this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.INBOX })); - this.store.select(state => state.mail).takeUntil(this.destroyed$) - .subscribe((mailState: MailState) => { - this.mailState = mailState; - }); + // this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.INBOX })); + // this.store.select(state => state.mail).takeUntil(this.destroyed$) + // .subscribe((mailState: MailState) => { + // this.mailState = mailState; + // }); } diff --git a/src/app/mail/mail-list/mail-folder/trash/trash.component.ts b/src/app/mail/mail-list/mail-folder/trash/trash.component.ts index 253eb2d54..2d932beca 100644 --- a/src/app/mail/mail-list/mail-folder/trash/trash.component.ts +++ b/src/app/mail/mail-list/mail-folder/trash/trash.component.ts @@ -22,12 +22,12 @@ export class TrashComponent implements OnInit, OnDestroy { } ngOnInit() { - this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.TRASH })); + // this.store.dispatch(new GetMails({ limit: 1000, offset: 0, folder: MailFolderType.TRASH })); - this.store.select(state => state.mail).takeUntil(this.destroyed$) - .subscribe((mailState: MailState) => { - this.mailState = mailState; - }); + // this.store.select(state => state.mail).takeUntil(this.destroyed$) + // .subscribe((mailState: MailState) => { + // this.mailState = mailState; + // }); } diff --git a/src/app/mail/mail-list/mail-list.component.html b/src/app/mail/mail-list/mail-list.component.html index e051a9afd..82472988a 100644 --- a/src/app/mail/mail-list/mail-list.component.html +++ b/src/app/mail/mail-list/mail-list.component.html @@ -1,7 +1,13 @@
- - - + + + diff --git a/src/app/mail/mail.component.ts b/src/app/mail/mail.component.ts index e56ec4dce..047e80822 100644 --- a/src/app/mail/mail.component.ts +++ b/src/app/mail/mail.component.ts @@ -29,7 +29,7 @@ export class MailComponent implements OnDestroy, OnInit, AfterViewInit { ngOnInit() { this.store.dispatch(new AccountDetailsGet()); - this.store.dispatch(new GetMailboxes()); + // this.store.dispatch(new GetMailboxes()); this.store.dispatch(new TimezoneGet()); this.sharedService.hideFooter.emit(true); this.sharedService.hideHeader.emit(true); diff --git a/src/app/store/services/mail.service.ts b/src/app/store/services/mail.service.ts index b08c4c231..e7e66c1af 100644 --- a/src/app/store/services/mail.service.ts +++ b/src/app/store/services/mail.service.ts @@ -39,7 +39,7 @@ export class MailService { }); } - getMailboxes(limit: number = 1000, offset: number = 0): Observable { + getMailboxes(limit: number = 50, offset: number = 0): Observable { const url = `${apiUrl}emails/mailboxes/?limit=${limit}&offset=${offset}`; return this.http.get(url).map(data => { const newData = data['results'].map(mailbox => { From c8fb374f7c3279fdbca777dc5a7a72933cfe022a Mon Sep 17 00:00:00 2001 From: Zain Zafar Date: Sun, 16 Sep 2018 22:58:30 +0500 Subject: [PATCH 02/12] show settings for email pagination --- .../mail-settings.component.html | 91 ++++++++++--------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/src/app/mail/mail-settings/mail-settings.component.html b/src/app/mail/mail-settings/mail-settings.component.html index 49146816e..32016d2ef 100644 --- a/src/app/mail/mail-settings/mail-settings.component.html +++ b/src/app/mail/mail-settings/mail-settings.component.html @@ -319,6 +319,52 @@
Appearance
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
@@ -441,51 +487,6 @@
-
-
- -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
From 579df10645b925d374110553ce9435c717e4f442 Mon Sep 17 00:00:00 2001 From: Zain Zafar Date: Sun, 23 Sep 2018 00:14:59 +0500 Subject: [PATCH 03/12] fix draft getmailboxes error --- src/app/mail/mail.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/mail/mail.component.ts b/src/app/mail/mail.component.ts index 047e80822..e56ec4dce 100644 --- a/src/app/mail/mail.component.ts +++ b/src/app/mail/mail.component.ts @@ -29,7 +29,7 @@ export class MailComponent implements OnDestroy, OnInit, AfterViewInit { ngOnInit() { this.store.dispatch(new AccountDetailsGet()); - // this.store.dispatch(new GetMailboxes()); + this.store.dispatch(new GetMailboxes()); this.store.dispatch(new TimezoneGet()); this.sharedService.hideFooter.emit(true); this.sharedService.hideHeader.emit(true); From b7f850bb97e4b98a2b864f298ef32314a2f536ec Mon Sep 17 00:00:00 2001 From: Zain Zafar Date: Sun, 23 Sep 2018 00:38:40 +0500 Subject: [PATCH 04/12] use email total count --- .../mail-folder/generic-folder/generic-folder.component.html | 2 +- .../mail-folder/generic-folder/generic-folder.component.ts | 2 +- src/app/store/datatypes.ts | 1 + src/app/store/effects/mail.effects.ts | 4 ++-- src/app/store/reducers/mail.reducers.ts | 2 ++ src/app/store/services/mail.service.ts | 4 ++-- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html index 26bcd96ea..6b6808570 100644 --- a/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html +++ b/src/app/mail/mail-list/mail-folder/generic-folder/generic-folder.component.html @@ -140,7 +140,7 @@
- {{ OFFSET * LIMIT }}-{{ ( OFFSET * LIMIT ) + LIMIT }} of {{ LIMIT * MAX_EMAIL_PAGE_LIMIT }} + {{ OFFSET * LIMIT }}-{{ ( OFFSET * LIMIT ) + LIMIT }} of {{ MAX_EMAIL_PAGE_LIMIT }}
- +
diff --git a/src/app/users/users-create-account/users-create-account.component.ts b/src/app/users/users-create-account/users-create-account.component.ts index f076aac4e..4ba0360bc 100644 --- a/src/app/users/users-create-account/users-create-account.component.ts +++ b/src/app/users/users-create-account/users-create-account.component.ts @@ -131,6 +131,9 @@ export class UsersCreateAccountComponent implements OnInit, OnDestroy { const signupFormValue = this.signupForm.value; this.openPgpService.generateUserKeys(signupFormValue.username, signupFormValue.password); + if (this.selectedPlan === 1) { + this.navigateToBillingPage(); + } } private navigateToBillingPage() {