From aa55a4da422330fe2816f1764b64f6607a0ca4aa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Aug 2018 10:31:56 +0200 Subject: Infinite scroll to list our subscriptions --- .../my-account-subscriptions.component.html | 2 +- .../my-account-subscriptions.component.ts | 32 ++++++++++++++++++---- .../my-account-video-imports.component.html | 8 +++--- 3 files changed, 32 insertions(+), 10 deletions(-) (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html index 4c68cd1a5..3752de49f 100644 --- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html +++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html @@ -1,4 +1,4 @@ -
+
Avatar diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts index 9434b196f..9517a3705 100644 --- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts +++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts @@ -3,6 +3,7 @@ import { NotificationsService } from 'angular2-notifications' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { I18n } from '@ngx-translate/i18n-polyfill' import { UserSubscriptionService } from '@app/shared/user-subscription' +import { ComponentPagination } from '@app/shared/rest/component-pagination.model' @Component({ selector: 'my-account-subscriptions', @@ -12,6 +13,12 @@ import { UserSubscriptionService } from '@app/shared/user-subscription' export class MyAccountSubscriptionsComponent implements OnInit { videoChannels: VideoChannel[] = [] + pagination: ComponentPagination = { + currentPage: 1, + itemsPerPage: 10, + totalItems: null + } + constructor ( private userSubscriptionService: UserSubscriptionService, private notificationsService: NotificationsService, @@ -19,12 +26,27 @@ export class MyAccountSubscriptionsComponent implements OnInit { ) {} ngOnInit () { - this.userSubscriptionService.listSubscriptions() - .subscribe( - res => this.videoChannels = res.data, + this.loadSubscriptions() + } + + loadSubscriptions () { + this.userSubscriptionService.listSubscriptions(this.pagination) + .subscribe( + res => { + this.videoChannels = this.videoChannels.concat(res.data) + this.pagination.totalItems = res.total + }, + + error => this.notificationsService.error(this.i18n('Error'), error.message) + ) + } + + onNearOfBottom () { + // Last page + if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return - error => this.notificationsService.error(this.i18n('Error'), error.message) - ) + this.pagination.currentPage += 1 + this.loadSubscriptions() } } diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html index b2b6c3d60..329948cb5 100644 --- a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html @@ -29,10 +29,10 @@ - {{ videoImport.video.name }} + {{ videoImport.video?.name }} - - {{ videoImport.video.name }} + + {{ videoImport.video?.name }} @@ -40,7 +40,7 @@ {{ videoImport.createdAt }} - + -- cgit v1.2.3