]>
Commit | Line | Data |
---|---|---|
0626e7af C |
1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
0626e7af | 3 | import { immutableAssign } from '@app/shared/misc/utils' |
0626e7af C |
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' | |
0bf1f265 | 10 | import { tap } from 'rxjs/operators' |
b1d40cff | 11 | import { I18n } from '@ngx-translate/i18n-polyfill' |
734a5ceb | 12 | import { Subscription } from 'rxjs' |
bbe0f064 | 13 | import { ScreenService } from '@app/shared/misc/screen.service' |
489290b8 | 14 | import { Notifier, ServerService } from '@app/core' |
0626e7af C |
15 | |
16 | @Component({ | |
17 | selector: 'my-account-videos', | |
18 | templateUrl: '../../shared/video/abstract-video-list.html', | |
19 | styleUrls: [ | |
20 | '../../shared/video/abstract-video-list.scss', | |
21 | './account-videos.component.scss' | |
22 | ] | |
23 | }) | |
24 | export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
b1d40cff | 25 | titlePage: string |
0626e7af | 26 | marginContent = false // Disable margin |
0626e7af C |
27 | loadOnInit = false |
28 | ||
29 | private account: Account | |
734a5ceb | 30 | private accountSub: Subscription |
0626e7af C |
31 | |
32 | constructor ( | |
33 | protected router: Router, | |
489290b8 | 34 | protected serverService: ServerService, |
0626e7af C |
35 | protected route: ActivatedRoute, |
36 | protected authService: AuthService, | |
f8b2c1b4 | 37 | protected notifier: Notifier, |
0626e7af | 38 | protected confirmService: ConfirmService, |
bbe0f064 | 39 | protected screenService: ScreenService, |
489290b8 | 40 | private i18n: I18n, |
0626e7af C |
41 | private accountService: AccountService, |
42 | private videoService: VideoService | |
43 | ) { | |
44 | super() | |
b1d40cff C |
45 | |
46 | this.titlePage = this.i18n('Published videos') | |
0626e7af C |
47 | } |
48 | ||
49 | ngOnInit () { | |
50 | super.ngOnInit() | |
51 | ||
52 | // Parent get the account for us | |
734a5ceb | 53 | this.accountSub = this.accountService.accountLoaded |
0626e7af C |
54 | .subscribe(account => { |
55 | this.account = account | |
0626e7af | 56 | |
734a5ceb | 57 | this.reloadVideos() |
0626e7af C |
58 | this.generateSyndicationList() |
59 | }) | |
60 | } | |
61 | ||
62 | ngOnDestroy () { | |
734a5ceb C |
63 | if (this.accountSub) this.accountSub.unsubscribe() |
64 | ||
0626e7af C |
65 | super.ngOnDestroy() |
66 | } | |
67 | ||
68 | getVideosObservable (page: number) { | |
69 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
70 | ||
0bf1f265 C |
71 | return this.videoService |
72 | .getAccountVideos(this.account, newPagination, this.sort) | |
b1d40cff C |
73 | .pipe( |
74 | tap(({ totalVideos }) => { | |
25acef90 | 75 | this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos }) |
b1d40cff C |
76 | }) |
77 | ) | |
0626e7af C |
78 | } |
79 | ||
80 | generateSyndicationList () { | |
81 | this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id) | |
82 | } | |
83 | } |