diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-04 13:31:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-04 15:45:44 +0200 |
commit | 2989628b7913383b39ac34c7db8666a21f8e5037 (patch) | |
tree | ac7759177c04e524e7845143fd685aefb49e810e /client/src/app/+videos | |
parent | 8e08d415f9473b6b72fef698729453e726da16e7 (diff) | |
download | PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.gz PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.zst PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.zip |
Use HTML config when possible
Diffstat (limited to 'client/src/app/+videos')
7 files changed, 49 insertions, 56 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts index e48d16527..875911b91 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts | |||
@@ -4,7 +4,7 @@ import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from ' | |||
4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
5 | import { VideoCaptionEdit } from '@app/shared/shared-main' | 5 | import { VideoCaptionEdit } from '@app/shared/shared-main' |
6 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' |
7 | import { ServerConfig, VideoConstant } from '@shared/models' | 7 | import { HTMLServerConfig, VideoConstant } from '@shared/models' |
8 | 8 | ||
9 | @Component({ | 9 | @Component({ |
10 | selector: 'my-video-caption-add-modal', | 10 | selector: 'my-video-caption-add-modal', |
@@ -14,7 +14,7 @@ import { ServerConfig, VideoConstant } from '@shared/models' | |||
14 | 14 | ||
15 | export class VideoCaptionAddModalComponent extends FormReactive implements OnInit { | 15 | export class VideoCaptionAddModalComponent extends FormReactive implements OnInit { |
16 | @Input() existingCaptions: string[] | 16 | @Input() existingCaptions: string[] |
17 | @Input() serverConfig: ServerConfig | 17 | @Input() serverConfig: HTMLServerConfig |
18 | 18 | ||
19 | @Output() captionAdded = new EventEmitter<VideoCaptionEdit>() | 19 | @Output() captionAdded = new EventEmitter<VideoCaptionEdit>() |
20 | 20 | ||
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 3d916dbce..52801802b 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts | |||
@@ -22,10 +22,10 @@ import { FormReactiveValidationMessages, FormValidatorService } from '@app/share | |||
22 | import { InstanceService } from '@app/shared/shared-instance' | 22 | import { InstanceService } from '@app/shared/shared-instance' |
23 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' | 23 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' |
24 | import { | 24 | import { |
25 | HTMLServerConfig, | ||
25 | LiveVideo, | 26 | LiveVideo, |
26 | RegisterClientFormFieldOptions, | 27 | RegisterClientFormFieldOptions, |
27 | RegisterClientVideoFieldOptions, | 28 | RegisterClientVideoFieldOptions, |
28 | ServerConfig, | ||
29 | VideoConstant, | 29 | VideoConstant, |
30 | VideoDetails, | 30 | VideoDetails, |
31 | VideoPrivacy | 31 | VideoPrivacy |
@@ -84,7 +84,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
84 | calendarTimezone: string | 84 | calendarTimezone: string |
85 | calendarDateFormat: string | 85 | calendarDateFormat: string |
86 | 86 | ||
87 | serverConfig: ServerConfig | 87 | serverConfig: HTMLServerConfig |
88 | 88 | ||
89 | pluginFields: PluginField[] = [] | 89 | pluginFields: PluginField[] = [] |
90 | 90 | ||
@@ -194,9 +194,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
194 | } | 194 | } |
195 | }) | 195 | }) |
196 | 196 | ||
197 | this.serverConfig = this.serverService.getTmpConfig() | 197 | |
198 | this.serverService.getConfig() | 198 | this.serverConfig = this.serverService.getHTMLConfig() |
199 | .subscribe(config => this.serverConfig = config) | ||
200 | 199 | ||
201 | this.initialVideoCaptions = this.videoCaptions.map(c => c.language.id) | 200 | this.initialVideoCaptions = this.videoCaptions.map(c => c.language.id) |
202 | 201 | ||
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index 3614499cd..a185892fe 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts | |||
@@ -6,7 +6,7 @@ import { listUserChannels } from '@app/helpers' | |||
6 | import { FormReactive } from '@app/shared/shared-forms' | 6 | import { FormReactive } from '@app/shared/shared-forms' |
7 | import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 7 | import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
8 | import { LoadingBarService } from '@ngx-loading-bar/core' | 8 | import { LoadingBarService } from '@ngx-loading-bar/core' |
9 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' | 9 | import { HTMLServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' |
10 | 10 | ||
11 | @Directive() | 11 | @Directive() |
12 | // tslint:disable-next-line: directive-class-suffix | 12 | // tslint:disable-next-line: directive-class-suffix |
@@ -28,7 +28,7 @@ export abstract class VideoSend extends FormReactive implements OnInit { | |||
28 | protected serverService: ServerService | 28 | protected serverService: ServerService |
29 | protected videoService: VideoService | 29 | protected videoService: VideoService |
30 | protected videoCaptionService: VideoCaptionService | 30 | protected videoCaptionService: VideoCaptionService |
31 | protected serverConfig: ServerConfig | 31 | protected serverConfig: HTMLServerConfig |
32 | 32 | ||
33 | abstract canDeactivate (): CanComponentDeactivateResult | 33 | abstract canDeactivate (): CanComponentDeactivateResult |
34 | 34 | ||
@@ -41,9 +41,7 @@ export abstract class VideoSend extends FormReactive implements OnInit { | |||
41 | this.firstStepChannelId = this.userVideoChannels[0].id | 41 | this.firstStepChannelId = this.userVideoChannels[0].id |
42 | }) | 42 | }) |
43 | 43 | ||
44 | this.serverConfig = this.serverService.getTmpConfig() | 44 | this.serverConfig = this.serverService.getHTMLConfig() |
45 | this.serverService.getConfig() | ||
46 | .subscribe(config => this.serverConfig = config) | ||
47 | 45 | ||
48 | this.serverService.getVideoPrivacies() | 46 | this.serverService.getVideoPrivacies() |
49 | .subscribe( | 47 | .subscribe( |
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index d735c936c..8606b8222 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { AuthService, AuthUser, CanComponentDeactivate, ServerService } from '@app/core' | 3 | import { AuthService, AuthUser, CanComponentDeactivate, ServerService } from '@app/core' |
4 | import { ServerConfig } from '@shared/models' | 4 | import { HTMLServerConfig } from '@shared/models' |
5 | import { VideoEditType } from './shared/video-edit.type' | 5 | import { VideoEditType } from './shared/video-edit.type' |
6 | import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' | 6 | import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' |
7 | import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' | 7 | import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' |
@@ -26,7 +26,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
26 | 26 | ||
27 | activeNav: string | 27 | activeNav: string |
28 | 28 | ||
29 | private serverConfig: ServerConfig | 29 | private serverConfig: HTMLServerConfig |
30 | 30 | ||
31 | constructor ( | 31 | constructor ( |
32 | private auth: AuthService, | 32 | private auth: AuthService, |
@@ -42,10 +42,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
42 | ngOnInit () { | 42 | ngOnInit () { |
43 | this.user = this.auth.getUser() | 43 | this.user = this.auth.getUser() |
44 | 44 | ||
45 | this.serverConfig = this.serverService.getTmpConfig() | 45 | this.serverConfig = this.serverService.getHTMLConfig() |
46 | |||
47 | this.serverService.getConfig() | ||
48 | .subscribe(config => this.serverConfig = config) | ||
49 | 46 | ||
50 | this.user = this.auth.getUser() | 47 | this.user = this.auth.getUser() |
51 | 48 | ||
diff --git a/client/src/app/+videos/+video-watch/recommendations/recent-videos-recommendation.service.ts b/client/src/app/+videos/+video-watch/recommendations/recent-videos-recommendation.service.ts index 2a851f13a..4654da847 100644 --- a/client/src/app/+videos/+video-watch/recommendations/recent-videos-recommendation.service.ts +++ b/client/src/app/+videos/+video-watch/recommendations/recent-videos-recommendation.service.ts | |||
@@ -4,7 +4,7 @@ import { Injectable } from '@angular/core' | |||
4 | import { ServerService, UserService } from '@app/core' | 4 | import { ServerService, UserService } from '@app/core' |
5 | import { Video, VideoService } from '@app/shared/shared-main' | 5 | import { Video, VideoService } from '@app/shared/shared-main' |
6 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' | 6 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' |
7 | import { ServerConfig } from '@shared/models' | 7 | import { HTMLServerConfig } from '@shared/models' |
8 | import { RecommendationInfo } from './recommendation-info.model' | 8 | import { RecommendationInfo } from './recommendation-info.model' |
9 | import { RecommendationService } from './recommendations.service' | 9 | import { RecommendationService } from './recommendations.service' |
10 | 10 | ||
@@ -15,7 +15,7 @@ import { RecommendationService } from './recommendations.service' | |||
15 | export class RecentVideosRecommendationService implements RecommendationService { | 15 | export class RecentVideosRecommendationService implements RecommendationService { |
16 | readonly pageSize = 5 | 16 | readonly pageSize = 5 |
17 | 17 | ||
18 | private config: ServerConfig | 18 | private config: HTMLServerConfig |
19 | 19 | ||
20 | constructor ( | 20 | constructor ( |
21 | private videos: VideoService, | 21 | private videos: VideoService, |
@@ -23,13 +23,11 @@ export class RecentVideosRecommendationService implements RecommendationService | |||
23 | private userService: UserService, | 23 | private userService: UserService, |
24 | private serverService: ServerService | 24 | private serverService: ServerService |
25 | ) { | 25 | ) { |
26 | this.config = this.serverService.getTmpConfig() | 26 | this.config = this.serverService.getHTMLConfig() |
27 | |||
28 | this.serverService.getConfig() | ||
29 | .subscribe(config => this.config = config) | ||
30 | } | 27 | } |
31 | 28 | ||
32 | getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> { | 29 | getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> { |
30 | |||
33 | return this.fetchPage(1, recommendation) | 31 | return this.fetchPage(1, recommendation) |
34 | .pipe( | 32 | .pipe( |
35 | map(videos => { | 33 | map(videos => { |
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 540b568ed..51d486ea5 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts | |||
@@ -28,7 +28,15 @@ import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/sha | |||
28 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' | 28 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' |
29 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 29 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
30 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 30 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
31 | import { PeerTubeProblemDocument, ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' | 31 | import { |
32 | HTMLServerConfig, | ||
33 | PeerTubeProblemDocument, | ||
34 | ServerErrorCode, | ||
35 | UserVideoRateType, | ||
36 | VideoCaption, | ||
37 | VideoPrivacy, | ||
38 | VideoState | ||
39 | } from '@shared/models' | ||
32 | import { | 40 | import { |
33 | cleanupVideoWatch, | 41 | cleanupVideoWatch, |
34 | getStoredP2PEnabled, | 42 | getStoredP2PEnabled, |
@@ -116,7 +124,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
116 | private configSub: Subscription | 124 | private configSub: Subscription |
117 | private liveVideosSub: Subscription | 125 | private liveVideosSub: Subscription |
118 | 126 | ||
119 | private serverConfig: ServerConfig | 127 | private serverConfig: HTMLServerConfig |
120 | 128 | ||
121 | constructor ( | 129 | constructor ( |
122 | private elementRef: ElementRef, | 130 | private elementRef: ElementRef, |
@@ -163,21 +171,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
163 | 171 | ||
164 | PeertubePlayerManager.initState() | 172 | PeertubePlayerManager.initState() |
165 | 173 | ||
166 | this.serverConfig = this.serverService.getTmpConfig() | 174 | this.serverConfig = this.serverService.getHTMLConfig() |
167 | 175 | if ( | |
168 | this.configSub = this.serverService.getConfig() | 176 | isWebRTCDisabled() || |
169 | .subscribe(config => { | 177 | this.serverConfig.tracker.enabled === false || |
170 | this.serverConfig = config | 178 | getStoredP2PEnabled() === false || |
179 | peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true' | ||
180 | ) { | ||
181 | this.hasAlreadyAcceptedPrivacyConcern = true | ||
182 | } | ||
171 | 183 | ||
172 | if ( | ||
173 | isWebRTCDisabled() || | ||
174 | this.serverConfig.tracker.enabled === false || | ||
175 | getStoredP2PEnabled() === false || | ||
176 | peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true' | ||
177 | ) { | ||
178 | this.hasAlreadyAcceptedPrivacyConcern = true | ||
179 | } | ||
180 | }) | ||
181 | 184 | ||
182 | this.paramsSub = this.route.params.subscribe(routeParams => { | 185 | this.paramsSub = this.route.params.subscribe(routeParams => { |
183 | const videoId = routeParams[ 'videoId' ] | 186 | const videoId = routeParams[ 'videoId' ] |
diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts index bbb02a236..6c2b32a4f 100644 --- a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts +++ b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { Subscription } from 'rxjs' | ||
1 | import { Component, HostBinding, Inject, OnDestroy, OnInit } from '@angular/core' | 2 | import { Component, HostBinding, Inject, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' | ||
4 | import { GlobalIconName } from '@app/shared/shared-icons' | ||
5 | import { ServerService } from '@app/core/server/server.service' | ||
6 | import { Subscription } from 'rxjs' | ||
7 | import { AuthService, RedirectService } from '@app/core' | 4 | import { AuthService, RedirectService } from '@app/core' |
5 | import { ServerService } from '@app/core/server/server.service' | ||
6 | import { GlobalIconName } from '@app/shared/shared-icons' | ||
7 | import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' | ||
8 | 8 | ||
9 | interface VideoTrendingHeaderItem { | 9 | interface VideoTrendingHeaderItem { |
10 | label: string | 10 | label: string |
@@ -67,21 +67,19 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent imple | |||
67 | } | 67 | } |
68 | 68 | ||
69 | ngOnInit () { | 69 | ngOnInit () { |
70 | this.serverService.getConfig() | 70 | const serverConfig = this.serverService.getHTMLConfig() |
71 | .subscribe(config => { | 71 | const algEnabled = serverConfig.trending.videos.algorithms.enabled |
72 | const algEnabled = config.trending.videos.algorithms.enabled | ||
73 | 72 | ||
74 | this.buttons = this.buttons.map(b => { | 73 | this.buttons = this.buttons.map(b => { |
75 | b.hidden = !algEnabled.includes(b.value) | 74 | b.hidden = !algEnabled.includes(b.value) |
76 | 75 | ||
77 | // Best is adapted by the user history so | 76 | // Best is adapted by the user history so |
78 | if (b.value === 'best' && !this.auth.isLoggedIn()) { | 77 | if (b.value === 'best' && !this.auth.isLoggedIn()) { |
79 | b.hidden = true | 78 | b.hidden = true |
80 | } | 79 | } |
81 | 80 | ||
82 | return b | 81 | return b |
83 | }) | 82 | }) |
84 | }) | ||
85 | 83 | ||
86 | this.algorithmChangeSub = this.route.queryParams.subscribe( | 84 | this.algorithmChangeSub = this.route.queryParams.subscribe( |
87 | queryParams => { | 85 | queryParams => { |