]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-videos/account-videos.component.ts
Implement video channel views
[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 'rxjs/add/observable/from'
7 import 'rxjs/add/operator/concatAll'
8 import { AuthService } from '../../core/auth'
9 import { ConfirmService } from '../../core/confirm'
10 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
11 import { VideoService } from '../../shared/video/video.service'
12 import { Account } from '@app/shared/account/account.model'
13 import { AccountService } from '@app/shared/account/account.service'
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 })
23 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
24 titlePage = 'Published videos'
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,
38 private accountService: AccountService,
39 private videoService: VideoService
40 ) {
41 super()
42 }
43
44 ngOnInit () {
45 super.ngOnInit()
46
47 // Parent get the account for us
48 this.accountService.accountLoaded
49 .subscribe(account => {
50 this.account = account
51 this.currentRoute = '/account/' + this.account.id + '/videos'
52
53 this.loadMoreVideos(this.pagination.currentPage)
54 this.generateSyndicationList()
55 })
56 }
57
58 ngOnDestroy () {
59 super.ngOnDestroy()
60 }
61
62 getVideosObservable (page: number) {
63 const newPagination = immutableAssign(this.pagination, { currentPage: page })
64
65 return this.videoService.getAccountVideos(this.account, newPagination, this.sort)
66 }
67
68 generateSyndicationList () {
69 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
70 }
71 }