diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-24 10:31:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | aa55a4da422330fe2816f1764b64f6607a0ca4aa (patch) | |
tree | 39933a835cc13a685696178e374fe3ac8ba9003b /client/src/app/+my-account | |
parent | f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9 (diff) | |
download | PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.gz PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.zst PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.zip |
Infinite scroll to list our subscriptions
Diffstat (limited to 'client/src/app/+my-account')
3 files changed, 32 insertions, 10 deletions
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 @@ | |||
1 | <div class="video-channels"> | 1 | <div class="video-channels" myInfiniteScroller [autoInit]="true" (nearOfBottom)="onNearOfBottom()"> |
2 | <div *ngFor="let videoChannel of videoChannels" class="video-channel"> | 2 | <div *ngFor="let videoChannel of videoChannels" class="video-channel"> |
3 | <a [routerLink]="[ '/video-channels', videoChannel.name ]"> | 3 | <a [routerLink]="[ '/video-channels', videoChannel.name ]"> |
4 | <img [src]="videoChannel.avatarUrl" alt="Avatar" /> | 4 | <img [src]="videoChannel.avatarUrl" alt="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' | |||
3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | 4 | import { I18n } from '@ngx-translate/i18n-polyfill' |
5 | import { UserSubscriptionService } from '@app/shared/user-subscription' | 5 | import { UserSubscriptionService } from '@app/shared/user-subscription' |
6 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-account-subscriptions', | 9 | selector: 'my-account-subscriptions', |
@@ -12,6 +13,12 @@ import { UserSubscriptionService } from '@app/shared/user-subscription' | |||
12 | export class MyAccountSubscriptionsComponent implements OnInit { | 13 | export class MyAccountSubscriptionsComponent implements OnInit { |
13 | videoChannels: VideoChannel[] = [] | 14 | videoChannels: VideoChannel[] = [] |
14 | 15 | ||
16 | pagination: ComponentPagination = { | ||
17 | currentPage: 1, | ||
18 | itemsPerPage: 10, | ||
19 | totalItems: null | ||
20 | } | ||
21 | |||
15 | constructor ( | 22 | constructor ( |
16 | private userSubscriptionService: UserSubscriptionService, | 23 | private userSubscriptionService: UserSubscriptionService, |
17 | private notificationsService: NotificationsService, | 24 | private notificationsService: NotificationsService, |
@@ -19,12 +26,27 @@ export class MyAccountSubscriptionsComponent implements OnInit { | |||
19 | ) {} | 26 | ) {} |
20 | 27 | ||
21 | ngOnInit () { | 28 | ngOnInit () { |
22 | this.userSubscriptionService.listSubscriptions() | 29 | this.loadSubscriptions() |
23 | .subscribe( | 30 | } |
24 | res => this.videoChannels = res.data, | 31 | |
32 | loadSubscriptions () { | ||
33 | this.userSubscriptionService.listSubscriptions(this.pagination) | ||
34 | .subscribe( | ||
35 | res => { | ||
36 | this.videoChannels = this.videoChannels.concat(res.data) | ||
37 | this.pagination.totalItems = res.total | ||
38 | }, | ||
39 | |||
40 | error => this.notificationsService.error(this.i18n('Error'), error.message) | ||
41 | ) | ||
42 | } | ||
43 | |||
44 | onNearOfBottom () { | ||
45 | // Last page | ||
46 | if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return | ||
25 | 47 | ||
26 | error => this.notificationsService.error(this.i18n('Error'), error.message) | 48 | this.pagination.currentPage += 1 |
27 | ) | 49 | this.loadSubscriptions() |
28 | } | 50 | } |
29 | 51 | ||
30 | } | 52 | } |
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 @@ | |||
29 | </td> | 29 | </td> |
30 | 30 | ||
31 | <td *ngIf="isVideoImportPending(videoImport)"> | 31 | <td *ngIf="isVideoImportPending(videoImport)"> |
32 | {{ videoImport.video.name }} | 32 | {{ videoImport.video?.name }} |
33 | </td> | 33 | </td> |
34 | <td *ngIf="isVideoImportSuccess(videoImport)"> | 34 | <td *ngIf="isVideoImportSuccess(videoImport) && videoImport.video"> |
35 | <a [href]="getVideoUrl(videoImport.video)" target="_blank" rel="noopener noreferrer">{{ videoImport.video.name }}</a> | 35 | <a [href]="getVideoUrl(videoImport.video)" target="_blank" rel="noopener noreferrer">{{ videoImport.video?.name }}</a> |
36 | </td> | 36 | </td> |
37 | <td *ngIf="isVideoImportFailed(videoImport)"></td> | 37 | <td *ngIf="isVideoImportFailed(videoImport)"></td> |
38 | 38 | ||
@@ -40,7 +40,7 @@ | |||
40 | <td>{{ videoImport.createdAt }}</td> | 40 | <td>{{ videoImport.createdAt }}</td> |
41 | 41 | ||
42 | <td class="action-cell"> | 42 | <td class="action-cell"> |
43 | <my-edit-button *ngIf="isVideoImportSuccess(videoImport)" [routerLink]="getEditVideoUrl(videoImport.video)"></my-edit-button> | 43 | <my-edit-button *ngIf="isVideoImportSuccess(videoImport) && videoImport.video" [routerLink]="getEditVideoUrl(videoImport.video)"></my-edit-button> |
44 | </td> | 44 | </td> |
45 | </tr> | 45 | </tr> |
46 | </ng-template> | 46 | </ng-template> |