]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+accounts/account-videos/account-videos.component.ts
Prepare i18n files
[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'
0626e7af
C
13
14@Component({
15 selector: 'my-account-videos',
16 templateUrl: '../../shared/video/abstract-video-list.html',
17 styleUrls: [
18 '../../shared/video/abstract-video-list.scss',
19 './account-videos.component.scss'
20 ]
21})
22export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
23 titlePage = 'Published videos'
24 marginContent = false // Disable margin
25 currentRoute = '/account/videos'
26 loadOnInit = false
27
28 private account: Account
29
30 constructor (
31 protected router: Router,
32 protected route: ActivatedRoute,
33 protected authService: AuthService,
34 protected notificationsService: NotificationsService,
35 protected confirmService: ConfirmService,
36 protected location: Location,
37 private accountService: AccountService,
38 private videoService: VideoService
39 ) {
40 super()
41 }
42
43 ngOnInit () {
44 super.ngOnInit()
45
46 // Parent get the account for us
47 this.accountService.accountLoaded
48 .subscribe(account => {
49 this.account = account
50 this.currentRoute = '/account/' + this.account.id + '/videos'
51
52 this.loadMoreVideos(this.pagination.currentPage)
53 this.generateSyndicationList()
54 })
55 }
56
57 ngOnDestroy () {
58 super.ngOnDestroy()
59 }
60
61 getVideosObservable (page: number) {
62 const newPagination = immutableAssign(this.pagination, { currentPage: page })
63
0bf1f265
C
64 return this.videoService
65 .getAccountVideos(this.account, newPagination, this.sort)
66 .pipe(tap(({ totalVideos }) => this.titlePage = `Published ${totalVideos} videos`))
0626e7af
C
67 }
68
69 generateSyndicationList () {
70 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
71 }
72}