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