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=e64750713a26efe9fdc93503fc257a1b559da237;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;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 e64750713..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: 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,11 +38,35 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { super() this.resolutions = [ - this.i18n('240p'), - this.i18n('360p'), - this.i18n('480p'), - this.i18n('720p'), - this.i18n('1080p') + { + 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') + }, + { + id: '360p', + label: this.i18n('360p') + }, + { + id: '480p', + label: this.i18n('480p') + }, + { + id: '720p', + label: this.i18n('720p') + }, + { + id: '1080p', + label: this.i18n('1080p') + }, + { + id: '2160p', + label: this.i18n('2160p') + } ] this.transcodingThreadOptions = [ @@ -54,25 +86,53 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { return this.configService.videoQuotaDailyOptions } + get availableThemes () { + return this.serverConfig.theme.registered + .map(t => t.name) + } + getResolutionKey (resolution: string) { return 'transcoding.resolutions.' + resolution } 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 } }, + theme: { + default: null + }, services: { twitter: { username: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME, @@ -116,7 +176,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { enabled: null, threads: this.customConfigValidatorsService.TRANSCODING_THREADS, allowAdditionalExtensions: null, - resolutions: {} + allowAudioFiles: null, + resolutions: {}, + hls: { + enabled: null + }, + webtorrent: { + enabled: null + } }, autoBlacklist: { videos: { @@ -130,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 + } + } } } @@ -139,24 +217,30 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } } for (const resolution of this.resolutions) { - defaultValues.transcoding.resolutions[resolution] = 'false' - formGroupData.transcoding.resolutions[resolution] = null + defaultValues.transcoding.resolutions[resolution.id] = 'false' + formGroupData.transcoding.resolutions[resolution.id] = null } 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 () { @@ -169,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() @@ -185,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) } - }