]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-videos/account-videos.component.ts
First implem global search
[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 { immutableAssign } from '@app/shared/misc/utils'
4 import { AuthService } from '../../core/auth'
5 import { ConfirmService } from '../../core/confirm'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { VideoService } from '../../shared/video/video.service'
8 import { Account } from '@app/shared/account/account.model'
9 import { AccountService } from '@app/shared/account/account.service'
10 import { first, tap } from 'rxjs/operators'
11 import { I18n } from '@ngx-translate/i18n-polyfill'
12 import { Subscription } from 'rxjs'
13 import { ScreenService } from '@app/shared/misc/screen.service'
14 import { Notifier, ServerService } from '@app/core'
15 import { UserService } from '@app/shared'
16 import { LocalStorageService } from '@app/shared/misc/storage.service'
17
18 @Component({
19 selector: 'my-account-videos',
20 templateUrl: '../../shared/video/abstract-video-list.html',
21 styleUrls: [
22 '../../shared/video/abstract-video-list.scss',
23 './account-videos.component.scss'
24 ]
25 })
26 export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
27 titlePage: string
28 loadOnInit = false
29
30 private account: Account
31 private accountSub: Subscription
32
33 constructor (
34 protected i18n: I18n,
35 protected router: Router,
36 protected serverService: ServerService,
37 protected route: ActivatedRoute,
38 protected authService: AuthService,
39 protected userService: UserService,
40 protected notifier: Notifier,
41 protected confirmService: ConfirmService,
42 protected screenService: ScreenService,
43 protected storageService: LocalStorageService,
44 private accountService: AccountService,
45 private videoService: VideoService
46 ) {
47 super()
48 }
49
50 ngOnInit () {
51 super.ngOnInit()
52
53 // Parent get the account for us
54 this.accountSub = this.accountService.accountLoaded
55 .pipe(first())
56 .subscribe(account => {
57 this.account = account
58
59 this.reloadVideos()
60 this.generateSyndicationList()
61 })
62 }
63
64 ngOnDestroy () {
65 if (this.accountSub) this.accountSub.unsubscribe()
66
67 super.ngOnDestroy()
68 }
69
70 getVideosObservable (page: number) {
71 const newPagination = immutableAssign(this.pagination, { currentPage: page })
72
73 return this.videoService
74 .getAccountVideos(this.account, newPagination, this.sort)
75 .pipe(
76 tap(({ total }) => {
77 this.titlePage = this.i18n('Published {{total}} videos', { total })
78 })
79 )
80 }
81
82 generateSyndicationList () {
83 this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id)
84 }
85 }