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