- const formGroupData = {
- instanceName: this.customConfigValidatorsService.INSTANCE_NAME,
- instanceShortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION,
- instanceDescription: null,
- instanceTerms: null,
- instanceDefaultClientRoute: null,
- instanceDefaultNSFWPolicy: null,
- servicesTwitterUsername: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME,
- servicesTwitterWhitelisted: null,
- cachePreviewsSize: this.customConfigValidatorsService.CACHE_PREVIEWS_SIZE,
- cacheCaptionsSize: this.customConfigValidatorsService.CACHE_CAPTIONS_SIZE,
- signupEnabled: null,
- signupLimit: this.customConfigValidatorsService.SIGNUP_LIMIT,
- signupRequiresEmailVerification: null,
- importVideosHttpEnabled: null,
- importVideosTorrentEnabled: null,
- adminEmail: this.customConfigValidatorsService.ADMIN_EMAIL,
- userVideoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
- userVideoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
- transcodingThreads: this.customConfigValidatorsService.TRANSCODING_THREADS,
- transcodingEnabled: null,
- customizationJavascript: null,
- customizationCSS: null
- }
-
- const defaultValues: BuildFormDefaultValues = {}
- for (const resolution of this.resolutions) {
- const key = this.getResolutionKey(resolution)
- defaultValues[key] = 'false'
- formGroupData[key] = null
- }
-
- this.buildForm(formGroupData)
-
- this.configService.getCustomConfig()
- .subscribe(
- res => {
- this.customConfig = res
-
- this.oldCustomCSS = this.customConfig.instance.customizations.css
- this.oldCustomJavascript = this.customConfig.instance.customizations.javascript
-
- this.updateForm()
- // Force form validation
- this.forceCheck()
- },
-
- err => this.notificationsService.error(this.i18n('Error'), err.message)
- )
- }
-
- isTranscodingEnabled () {
- return this.form.value['transcodingEnabled'] === true
- }
-
- isSignupEnabled () {
- return this.form.value['signupEnabled'] === true
- }
-
- async formValidated () {
- const newCustomizationJavascript = this.form.value['customizationJavascript']
- const newCustomizationCSS = this.form.value['customizationCSS']
-
- const customizations = []
- if (newCustomizationJavascript && newCustomizationJavascript !== this.oldCustomJavascript) customizations.push('JavaScript')
- if (newCustomizationCSS && newCustomizationCSS !== this.oldCustomCSS) customizations.push('CSS')
-
- if (customizations.length !== 0) {
- const customizationsText = customizations.join('/')
-
- // FIXME: i18n service does not support string concatenation
- const message = this.i18n('You set custom {{customizationsText}}. ', { customizationsText }) +
- this.i18n('This could lead to security issues or bugs if you do not understand it. ') +
- this.i18n('Are you sure you want to update the configuration?')
-
- const label = this.i18n('Please type') + ` "I understand the ${customizationsText} I set" ` + this.i18n('to confirm.')
- const expectedInputValue = `I understand the ${customizationsText} I set`
-
- const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue)
- if (confirmRes === false) return
- }
-
- const data: CustomConfig = {