X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fconfig%2Fedit-custom-config%2Fedit-custom-config.component.ts;h=3fda0851efa9da12e0807788f120251cf6e8427d;hb=6a07a058616b3fb70e56cd4e50b8deb02a2468d0;hp=8bd7f7cf6e3ad12254c7af568067d97f24a71bd9;hpb=ffb321bedca46d6987c7b31dd58e5dea96ea2ea2;p=github%2FChocobozzz%2FPeerTube.git 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 8bd7f7cf6..3fda0851e 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 @@ -6,6 +6,9 @@ import { Notifier } from '@app/core' import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { SelectItem } from 'primeng/api' +import { forkJoin } from 'rxjs' +import { ServerConfig } from '@shared/models' @Component({ selector: 'my-edit-custom-config', @@ -15,9 +18,14 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val export class EditCustomConfigComponent extends FormReactive implements OnInit { customConfig: CustomConfig - resolutions: { id: string, label: string }[] = [] + resolutions: { id: string, label: string, description?: string }[] = [] transcodingThreadOptions: { label: string, value: number }[] = [] + languageItems: SelectItem[] = [] + categoryItems: SelectItem[] = [] + + private serverConfig: ServerConfig + constructor ( protected formValidatorService: FormValidatorService, private customConfigValidatorsService: CustomConfigValidatorsService, @@ -30,6 +38,11 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { super() this.resolutions = [ + { + id: '0p', + label: this.i18n('Audio-only'), + description: this.i18n('A .mp4 that keeps the original audio track, with no video') + }, { id: '240p', label: this.i18n('240p') @@ -74,7 +87,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } get availableThemes () { - return this.serverService.getConfig().theme.registered + return this.serverConfig.theme.registered .map(t => t.name) } @@ -83,15 +96,35 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } ngOnInit () { + this.serverConfig = this.serverService.getTmpConfig() + this.serverService.getConfig() + .subscribe(config => this.serverConfig = config) + const formGroupData: { [key in keyof CustomConfig ]: any } = { instance: { name: this.customConfigValidatorsService.INSTANCE_NAME, shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION, description: null, - terms: null, - defaultClientRoute: null, + isNSFW: false, defaultNSFWPolicy: null, + + terms: null, + codeOfConduct: null, + + creationReason: null, + moderationInformation: null, + administrator: null, + maintenanceLifetime: null, + businessModel: null, + + hardwareInformation: null, + + categories: null, + languages: null, + + defaultClientRoute: null, + customizations: { javascript: null, css: null @@ -144,7 +177,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { threads: this.customConfigValidatorsService.TRANSCODING_THREADS, allowAdditionalExtensions: null, allowAudioFiles: null, - resolutions: {} + resolutions: {}, + hls: { + enabled: null + }, + webtorrent: { + enabled: null + } }, autoBlacklist: { videos: { @@ -158,6 +197,17 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { enabled: null, manualApproval: null } + }, + followings: { + instance: { + autoFollowBack: { + enabled: null + }, + autoFollowIndex: { + enabled: null, + indexUrl: this.customConfigValidatorsService.INDEX_URL + } + } } } @@ -173,18 +223,24 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { this.buildForm(formGroupData) - this.configService.getCustomConfig() - .subscribe( - res => { - this.customConfig = res + forkJoin([ + this.configService.getCustomConfig(), + this.serverService.getVideoLanguages(), + this.serverService.getVideoCategories() + ]).subscribe( + ([ config, languages, categories ]) => { + this.customConfig = config - this.updateForm() - // Force form validation - this.forceCheck() - }, + this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) + this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) - err => this.notifier.error(err.message) - ) + this.updateForm() + // Force form validation + this.forceCheck() + }, + + err => this.notifier.error(err.message) + ) } isTranscodingEnabled () { @@ -197,12 +253,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { async formValidated () { this.configService.updateCustomConfig(this.form.value) + .pipe( + ) .subscribe( res => { this.customConfig = res // Reload general configuration - this.serverService.loadConfig() + this.serverService.resetConfig() this.updateForm() @@ -213,8 +271,23 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { ) } + getSelectedLanguageLabel () { + return this.i18n('{{\'{0} languages selected') + } + + getDefaultLanguageLabel () { + return this.i18n('No language') + } + + getSelectedCategoryLabel () { + return this.i18n('{{\'{0} categories selected') + } + + getDefaultCategoryLabel () { + return this.i18n('No category') + } + private updateForm () { this.form.patchValue(this.customConfig) } - }