1 import { Component, OnInit } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { UserSubscriptionService } from '@app/shared/user-subscription'
6 import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
9 selector: 'my-account-subscriptions',
10 templateUrl: './my-account-subscriptions.component.html',
11 styleUrls: [ './my-account-subscriptions.component.scss' ]
13 export class MyAccountSubscriptionsComponent implements OnInit {
14 videoChannels: VideoChannel[] = []
16 pagination: ComponentPagination = {
23 private userSubscriptionService: UserSubscriptionService,
24 private notificationsService: NotificationsService,
29 this.loadSubscriptions()
32 loadSubscriptions () {
33 this.userSubscriptionService.listSubscriptions(this.pagination)
36 this.videoChannels = this.videoChannels.concat(res.data)
37 this.pagination.totalItems = res.total
40 error => this.notificationsService.error(this.i18n('Error'), error.message)
46 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
48 this.pagination.currentPage += 1
49 this.loadSubscriptions()