diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-06 16:43:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-06 17:10:02 +0100 |
commit | 04cda1d7a5f27429acde3ecd9c3c6e18a2b44aed (patch) | |
tree | f552ccf360f610f0c8dafe204f8a35022b1a00b4 | |
parent | c10b638c4b52e9766ef68b58849ee0728647988f (diff) | |
download | PeerTube-04cda1d7a5f27429acde3ecd9c3c6e18a2b44aed.tar.gz PeerTube-04cda1d7a5f27429acde3ecd9c3c6e18a2b44aed.tar.zst PeerTube-04cda1d7a5f27429acde3ecd9c3c6e18a2b44aed.zip |
Add warning if admin disables webtorrent
5 files changed, 58 insertions, 23 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 27f5ef722..ac0447d25 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html | |||
@@ -502,6 +502,10 @@ | |||
502 | <strong>Experimental, we suggest you to not disable webtorrent support for now</strong> | 502 | <strong>Experimental, we suggest you to not disable webtorrent support for now</strong> |
503 | 503 | ||
504 | <p>If you also enabled HLS support, it will multiply videos storage by 2</p> | 504 | <p>If you also enabled HLS support, it will multiply videos storage by 2</p> |
505 | |||
506 | <br /> | ||
507 | |||
508 | <strong>If disabled, breaks federation with PeerTube instances < 2.1</strong> | ||
505 | </ng-container> | 509 | </ng-container> |
506 | </ng-template> | 510 | </ng-template> |
507 | </my-peertube-checkbox> | 511 | </my-peertube-checkbox> |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 3fda0851e..49bb4db0e 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | |||
@@ -222,25 +222,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
222 | } | 222 | } |
223 | 223 | ||
224 | this.buildForm(formGroupData) | 224 | this.buildForm(formGroupData) |
225 | 225 | this.loadForm() | |
226 | forkJoin([ | 226 | this.checkTranscodingFields() |
227 | this.configService.getCustomConfig(), | ||
228 | this.serverService.getVideoLanguages(), | ||
229 | this.serverService.getVideoCategories() | ||
230 | ]).subscribe( | ||
231 | ([ config, languages, categories ]) => { | ||
232 | this.customConfig = config | ||
233 | |||
234 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) | ||
235 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) | ||
236 | |||
237 | this.updateForm() | ||
238 | // Force form validation | ||
239 | this.forceCheck() | ||
240 | }, | ||
241 | |||
242 | err => this.notifier.error(err.message) | ||
243 | ) | ||
244 | } | 227 | } |
245 | 228 | ||
246 | isTranscodingEnabled () { | 229 | isTranscodingEnabled () { |
@@ -252,9 +235,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
252 | } | 235 | } |
253 | 236 | ||
254 | async formValidated () { | 237 | async formValidated () { |
255 | this.configService.updateCustomConfig(this.form.value) | 238 | this.configService.updateCustomConfig(this.form.getRawValue()) |
256 | .pipe( | ||
257 | ) | ||
258 | .subscribe( | 239 | .subscribe( |
259 | res => { | 240 | res => { |
260 | this.customConfig = res | 241 | this.customConfig = res |
@@ -290,4 +271,52 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
290 | private updateForm () { | 271 | private updateForm () { |
291 | this.form.patchValue(this.customConfig) | 272 | this.form.patchValue(this.customConfig) |
292 | } | 273 | } |
274 | |||
275 | private loadForm () { | ||
276 | forkJoin([ | ||
277 | this.configService.getCustomConfig(), | ||
278 | this.serverService.getVideoLanguages(), | ||
279 | this.serverService.getVideoCategories() | ||
280 | ]).subscribe( | ||
281 | ([ config, languages, categories ]) => { | ||
282 | this.customConfig = config | ||
283 | |||
284 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) | ||
285 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) | ||
286 | |||
287 | this.updateForm() | ||
288 | // Force form validation | ||
289 | this.forceCheck() | ||
290 | }, | ||
291 | |||
292 | err => this.notifier.error(err.message) | ||
293 | ) | ||
294 | } | ||
295 | |||
296 | private checkTranscodingFields () { | ||
297 | const hlsControl = this.form.get('transcoding.hls.enabled') | ||
298 | const webtorrentControl = this.form.get('transcoding.webtorrent.enabled') | ||
299 | |||
300 | webtorrentControl.valueChanges | ||
301 | .subscribe(newValue => { | ||
302 | if (newValue === false && !hlsControl.disabled) { | ||
303 | hlsControl.disable() | ||
304 | } | ||
305 | |||
306 | if (newValue === true && !hlsControl.enabled) { | ||
307 | hlsControl.enable() | ||
308 | } | ||
309 | }) | ||
310 | |||
311 | hlsControl.valueChanges | ||
312 | .subscribe(newValue => { | ||
313 | if (newValue === false && !webtorrentControl.disabled) { | ||
314 | webtorrentControl.disable() | ||
315 | } | ||
316 | |||
317 | if (newValue === true && !webtorrentControl.enabled) { | ||
318 | webtorrentControl.enable() | ||
319 | } | ||
320 | }) | ||
321 | } | ||
293 | } | 322 | } |
diff --git a/config/default.yaml b/config/default.yaml index 7fe817aa0..8e866c126 100644 --- a/config/default.yaml +++ b/config/default.yaml | |||
@@ -216,6 +216,7 @@ transcoding: | |||
216 | 216 | ||
217 | # Generate videos in a WebTorrent format (what we do since the first PeerTube release) | 217 | # Generate videos in a WebTorrent format (what we do since the first PeerTube release) |
218 | # If you also enabled the hls format, it will multiply videos storage by 2 | 218 | # If you also enabled the hls format, it will multiply videos storage by 2 |
219 | # If disabled, breaks federation with PeerTube instances < 2.1 | ||
219 | webtorrent: | 220 | webtorrent: |
220 | enabled: true | 221 | enabled: true |
221 | 222 | ||
diff --git a/config/production.yaml.example b/config/production.yaml.example index 629d0c4b6..68d29d26f 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example | |||
@@ -230,6 +230,7 @@ transcoding: | |||
230 | 230 | ||
231 | # Generate videos in a WebTorrent format (what we do since the first PeerTube release) | 231 | # Generate videos in a WebTorrent format (what we do since the first PeerTube release) |
232 | # If you also enabled the hls format, it will multiply videos storage by 2 | 232 | # If you also enabled the hls format, it will multiply videos storage by 2 |
233 | # If disabled, breaks federation with PeerTube instances < 2.1 | ||
233 | webtorrent: | 234 | webtorrent: |
234 | enabled: true | 235 | enabled: true |
235 | 236 | ||
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index d86fa700b..2d1f61947 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -45,7 +45,7 @@ const customConfigUpdateValidator = [ | |||
45 | body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), | 45 | body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), |
46 | 46 | ||
47 | body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), | 47 | body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), |
48 | body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), | 48 | body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'), |
49 | 49 | ||
50 | body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), | 50 | body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), |
51 | body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), | 51 | body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), |