1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { Location } from '@angular/common'
4 import { immutableAssign } from '@app/shared/misc/utils'
5 import { NotificationsService } from 'angular2-notifications'
6 import { AuthService } from '../../core/auth'
7 import { ConfirmService } from '../../core/confirm'
8 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
9 import { VideoService } from '../../shared/video/video.service'
10 import { Account } from '@app/shared/account/account.model'
11 import { AccountService } from '@app/shared/account/account.service'
12 import { tap } from 'rxjs/operators'
13 import { I18n } from '@ngx-translate/i18n-polyfill'
16 selector: 'my-account-videos',
17 templateUrl: '../../shared/video/abstract-video-list.html',
19 '../../shared/video/abstract-video-list.scss',
20 './account-videos.component.scss'
23 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
25 marginContent = false // Disable margin
26 currentRoute = '/account/videos'
29 private account: Account
32 protected router: Router,
33 protected route: ActivatedRoute,
34 protected authService: AuthService,
35 protected notificationsService: NotificationsService,
36 protected confirmService: ConfirmService,
37 protected location: Location,
39 private accountService: AccountService,
40 private videoService: VideoService
44 this.titlePage = this.i18n('Published videos')
50 // Parent get the account for us
51 this.accountService.accountLoaded
52 .subscribe(account => {
53 this.account = account
54 this.currentRoute = '/account/' + this.account.id + '/videos'
56 this.loadMoreVideos(this.pagination.currentPage)
57 this.generateSyndicationList()
65 getVideosObservable (page: number) {
66 const newPagination = immutableAssign(this.pagination, { currentPage: page })
68 return this.videoService
69 .getAccountVideos(this.account, newPagination, this.sort)
71 tap(({ totalVideos }) => {
72 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
77 generateSyndicationList () {
78 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)