]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
Add debug component to help admins to fix IP issues
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
CommitLineData
0626e7af
C
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
0626e7af 3import { immutableAssign } from '@app/shared/misc/utils'
0626e7af
C
4import { AuthService } from '../../core/auth'
5import { ConfirmService } from '../../core/confirm'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { VideoService } from '../../shared/video/video.service'
8import { Account } from '@app/shared/account/account.model'
9import { AccountService } from '@app/shared/account/account.service'
0bf1f265 10import { tap } from 'rxjs/operators'
b1d40cff 11import { I18n } from '@ngx-translate/i18n-polyfill'
734a5ceb 12import { Subscription } from 'rxjs'
bbe0f064 13import { ScreenService } from '@app/shared/misc/screen.service'
489290b8 14import { Notifier, ServerService } from '@app/core'
0626e7af
C
15
16@Component({
17 selector: 'my-account-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
19 styleUrls: [
20 '../../shared/video/abstract-video-list.scss',
21 './account-videos.component.scss'
22 ]
23})
24export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 25 titlePage: string
0626e7af
C
26 loadOnInit = false
27
28 private account: Account
734a5ceb 29 private accountSub: Subscription
0626e7af
C
30
31 constructor (
32 protected router: Router,
489290b8 33 protected serverService: ServerService,
0626e7af
C
34 protected route: ActivatedRoute,
35 protected authService: AuthService,
f8b2c1b4 36 protected notifier: Notifier,
0626e7af 37 protected confirmService: ConfirmService,
bbe0f064 38 protected screenService: ScreenService,
489290b8 39 private i18n: I18n,
0626e7af
C
40 private accountService: AccountService,
41 private videoService: VideoService
42 ) {
43 super()
b1d40cff
C
44
45 this.titlePage = this.i18n('Published videos')
0626e7af
C
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
50
51 // Parent get the account for us
734a5ceb 52 this.accountSub = this.accountService.accountLoaded
0626e7af
C
53 .subscribe(account => {
54 this.account = account
0626e7af 55
734a5ceb 56 this.reloadVideos()
0626e7af
C
57 this.generateSyndicationList()
58 })
59 }
60
61 ngOnDestroy () {
734a5ceb
C
62 if (this.accountSub) this.accountSub.unsubscribe()
63
0626e7af
C
64 super.ngOnDestroy()
65 }
66
67 getVideosObservable (page: number) {
68 const newPagination = immutableAssign(this.pagination, { currentPage: page })
69
0bf1f265
C
70 return this.videoService
71 .getAccountVideos(this.account, newPagination, this.sort)
b1d40cff
C
72 .pipe(
73 tap(({ totalVideos }) => {
25acef90 74 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
b1d40cff
C
75 })
76 )
0626e7af
C
77 }
78
79 generateSyndicationList () {
80 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
81 }
82}