]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
Fix i18n in components
[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'
3import { Location } from '@angular/common'
4import { immutableAssign } from '@app/shared/misc/utils'
5import { NotificationsService } from 'angular2-notifications'
0626e7af
C
6import { AuthService } from '../../core/auth'
7import { ConfirmService } from '../../core/confirm'
8import { AbstractVideoList } from '../../shared/video/abstract-video-list'
9import { VideoService } from '../../shared/video/video.service'
10import { Account } from '@app/shared/account/account.model'
11import { AccountService } from '@app/shared/account/account.service'
0bf1f265 12import { tap } from 'rxjs/operators'
b1d40cff 13import { I18n } from '@ngx-translate/i18n-polyfill'
0626e7af
C
14
15@Component({
16 selector: 'my-account-videos',
17 templateUrl: '../../shared/video/abstract-video-list.html',
18 styleUrls: [
19 '../../shared/video/abstract-video-list.scss',
20 './account-videos.component.scss'
21 ]
22})
23export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 24 titlePage: string
0626e7af
C
25 marginContent = false // Disable margin
26 currentRoute = '/account/videos'
27 loadOnInit = false
28
29 private account: Account
30
31 constructor (
32 protected router: Router,
33 protected route: ActivatedRoute,
34 protected authService: AuthService,
35 protected notificationsService: NotificationsService,
36 protected confirmService: ConfirmService,
37 protected location: Location,
b1d40cff 38 protected i18n: I18n,
0626e7af
C
39 private accountService: AccountService,
40 private videoService: VideoService
41 ) {
42 super()
b1d40cff
C
43
44 this.titlePage = this.i18n('Published videos')
0626e7af
C
45 }
46
47 ngOnInit () {
48 super.ngOnInit()
49
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'
55
56 this.loadMoreVideos(this.pagination.currentPage)
57 this.generateSyndicationList()
58 })
59 }
60
61 ngOnDestroy () {
62 super.ngOnDestroy()
63 }
64
65 getVideosObservable (page: number) {
66 const newPagination = immutableAssign(this.pagination, { currentPage: page })
67
0bf1f265
C
68 return this.videoService
69 .getAccountVideos(this.account, newPagination, this.sort)
b1d40cff
C
70 .pipe(
71 tap(({ totalVideos }) => {
25acef90 72 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
b1d40cff
C
73 })
74 )
0626e7af
C
75 }
76
77 generateSyndicationList () {
78 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
79 }
80}