From 04cda1d7a5f27429acde3ecd9c3c6e18a2b44aed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 6 Jan 2020 16:43:15 +0100 Subject: Add warning if admin disables webtorrent --- .../edit-custom-config.component.html | 4 ++ .../edit-custom-config.component.ts | 73 +++++++++++++++------- 2 files changed, 55 insertions(+), 22 deletions(-) (limited to 'client/src/app') 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 @@ Experimental, we suggest you to not disable webtorrent support for now

If you also enabled HLS support, it will multiply videos storage by 2

+ +
+ + If disabled, breaks federation with PeerTube instances < 2.1 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 { } this.buildForm(formGroupData) - - forkJoin([ - this.configService.getCustomConfig(), - this.serverService.getVideoLanguages(), - this.serverService.getVideoCategories() - ]).subscribe( - ([ config, languages, categories ]) => { - this.customConfig = config - - this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) - this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) - - this.updateForm() - // Force form validation - this.forceCheck() - }, - - err => this.notifier.error(err.message) - ) + this.loadForm() + this.checkTranscodingFields() } isTranscodingEnabled () { @@ -252,9 +235,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } async formValidated () { - this.configService.updateCustomConfig(this.form.value) - .pipe( - ) + this.configService.updateCustomConfig(this.form.getRawValue()) .subscribe( res => { this.customConfig = res @@ -290,4 +271,52 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { private updateForm () { this.form.patchValue(this.customConfig) } + + private loadForm () { + forkJoin([ + this.configService.getCustomConfig(), + this.serverService.getVideoLanguages(), + this.serverService.getVideoCategories() + ]).subscribe( + ([ config, languages, categories ]) => { + this.customConfig = config + + this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) + this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) + + this.updateForm() + // Force form validation + this.forceCheck() + }, + + err => this.notifier.error(err.message) + ) + } + + private checkTranscodingFields () { + const hlsControl = this.form.get('transcoding.hls.enabled') + const webtorrentControl = this.form.get('transcoding.webtorrent.enabled') + + webtorrentControl.valueChanges + .subscribe(newValue => { + if (newValue === false && !hlsControl.disabled) { + hlsControl.disable() + } + + if (newValue === true && !hlsControl.enabled) { + hlsControl.enable() + } + }) + + hlsControl.valueChanges + .subscribe(newValue => { + if (newValue === false && !webtorrentControl.disabled) { + webtorrentControl.disable() + } + + if (newValue === true && !webtorrentControl.enabled) { + webtorrentControl.enable() + } + }) + } } -- cgit v1.2.3