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'
14 import { Subscription } from 'rxjs'
17 selector: 'my-account-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
20 '../../shared/video/abstract-video-list.scss',
21 './account-videos.component.scss'
24 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
26 marginContent = false // Disable margin
27 currentRoute = '/account/videos'
30 private account: Account
31 private accountSub: Subscription
34 protected router: Router,
35 protected route: ActivatedRoute,
36 protected authService: AuthService,
37 protected notificationsService: NotificationsService,
38 protected confirmService: ConfirmService,
39 protected location: Location,
41 private accountService: AccountService,
42 private videoService: VideoService
46 this.titlePage = this.i18n('Published videos')
52 // Parent get the account for us
53 this.accountSub = this.accountService.accountLoaded
54 .subscribe(account => {
55 this.account = account
56 this.currentRoute = '/account/' + this.account.nameWithHost + '/videos'
59 this.generateSyndicationList()
64 if (this.accountSub) this.accountSub.unsubscribe()
69 getVideosObservable (page: number) {
70 const newPagination = immutableAssign(this.pagination, { currentPage: page })
72 return this.videoService
73 .getAccountVideos(this.account, newPagination, this.sort)
75 tap(({ totalVideos }) => {
76 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
81 generateSyndicationList () {
82 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)