]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-videos/account-videos.component.ts
Add ability to schedule video publication
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-videos / account-videos.component.ts
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'
15 import { ScreenService } from '@app/shared/misc/screen.service'
16
17 @Component({
18 selector: 'my-account-videos',
19 templateUrl: '../../shared/video/abstract-video-list.html',
20 styleUrls: [
21 '../../shared/video/abstract-video-list.scss',
22 './account-videos.component.scss'
23 ]
24 })
25 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
26 titlePage: string
27 marginContent = false // Disable margin
28 currentRoute = '/account/videos'
29 loadOnInit = false
30
31 private account: Account
32 private accountSub: Subscription
33
34 constructor (
35 protected router: Router,
36 protected route: ActivatedRoute,
37 protected authService: AuthService,
38 protected notificationsService: NotificationsService,
39 protected confirmService: ConfirmService,
40 protected location: Location,
41 protected screenService: ScreenService,
42 protected i18n: I18n,
43 private accountService: AccountService,
44 private videoService: VideoService
45 ) {
46 super()
47
48 this.titlePage = this.i18n('Published videos')
49 }
50
51 ngOnInit () {
52 super.ngOnInit()
53
54 // Parent get the account for us
55 this.accountSub = this.accountService.accountLoaded
56 .subscribe(account => {
57 this.account = account
58 this.currentRoute = '/account/' + this.account.nameWithHost + '/videos'
59
60 this.reloadVideos()
61 this.generateSyndicationList()
62 })
63 }
64
65 ngOnDestroy () {
66 if (this.accountSub) this.accountSub.unsubscribe()
67
68 super.ngOnDestroy()
69 }
70
71 getVideosObservable (page: number) {
72 const newPagination = immutableAssign(this.pagination, { currentPage: page })
73
74 return this.videoService
75 .getAccountVideos(this.account, newPagination, this.sort)
76 .pipe(
77 tap(({ totalVideos }) => {
78 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
79 })
80 )
81 }
82
83 generateSyndicationList () {
84 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
85 }
86 }