import {
ADMIN_EMAIL,
CACHE_PREVIEWS_SIZE,
- INSTANCE_NAME, INSTANCE_SHORT_DESCRIPTION,
+ INSTANCE_NAME,
+ INSTANCE_SHORT_DESCRIPTION,
+ SERVICES_TWITTER_USERNAME,
SIGNUP_LIMIT,
TRANSCODING_THREADS
} from '@app/shared/forms/form-validators/custom-config'
import { NotificationsService } from 'angular2-notifications'
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
+import { I18n } from '@ngx-translate/i18n-polyfill'
@Component({
selector: 'my-edit-custom-config',
instanceDescription: '',
instanceTerms: '',
instanceDefaultClientRoute: '',
+ instanceDefaultNSFWPolicy: '',
+ servicesTwitterUsername: '',
cachePreviewsSize: '',
signupLimit: '',
adminEmail: '',
validationMessages = {
instanceShortDescription: INSTANCE_SHORT_DESCRIPTION.MESSAGES,
instanceName: INSTANCE_NAME.MESSAGES,
+ servicesTwitterUsername: SERVICES_TWITTER_USERNAME,
cachePreviewsSize: CACHE_PREVIEWS_SIZE.MESSAGES,
signupLimit: SIGNUP_LIMIT.MESSAGES,
adminEmail: ADMIN_EMAIL.MESSAGES,
private notificationsService: NotificationsService,
private configService: ConfigService,
private serverService: ServerService,
- private confirmService: ConfirmService
+ private confirmService: ConfirmService,
+ private i18n: I18n
) {
super()
}
instanceDescription: [ '' ],
instanceTerms: [ '' ],
instanceDefaultClientRoute: [ '' ],
+ instanceDefaultNSFWPolicy: [ '' ],
+ servicesTwitterUsername: [ '', SERVICES_TWITTER_USERNAME.VALIDATORS ],
+ servicesTwitterWhitelisted: [ ],
cachePreviewsSize: [ '', CACHE_PREVIEWS_SIZE.VALIDATORS ],
signupEnabled: [ ],
signupLimit: [ '', SIGNUP_LIMIT.VALIDATORS ],
this.forceCheck()
},
- err => this.notificationsService.error('Error', err.message)
+ err => this.notificationsService.error(this.i18n('Error'), err.message)
)
}
if (customizations.length !== 0) {
const customizationsText = customizations.join('/')
- const message = `You set custom ${customizationsText}. ` +
- 'This could lead to security issues or bugs if you do not understand it. ' +
- 'Are you sure you want to update the configuration?'
- const label = `Please type "I understand the ${customizationsText} I set" to confirm.`
- const expectedInputValue = `I understand the ${customizationsText} I set`
+ // 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" to confirm.',
+ { customizationsText }
+ )
+ const expectedInputValue = this.i18n('I understand the {{customizationsText}} I set', { customizationsText })
const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue)
if (confirmRes === false) return
description: this.form.value['instanceDescription'],
terms: this.form.value['instanceTerms'],
defaultClientRoute: this.form.value['instanceDefaultClientRoute'],
+ defaultNSFWPolicy: this.form.value['instanceDefaultNSFWPolicy'],
customizations: {
javascript: this.form.value['customizationJavascript'],
css: this.form.value['customizationCSS']
}
},
+ services: {
+ twitter: {
+ username: this.form.value['servicesTwitterUsername'],
+ whitelisted: this.form.value['servicesTwitterWhitelisted']
+ }
+ },
cache: {
previews: {
size: this.form.value['cachePreviewsSize']
this.updateForm()
- this.notificationsService.success('Success', 'Configuration updated.')
+ this.notificationsService.success(this.i18n('Success'), this.i18n('Configuration updated.'))
},
- err => this.notificationsService.error('Error', err.message)
+ err => this.notificationsService.error(this.i18n('Error'), err.message)
)
}
instanceDescription: this.customConfig.instance.description,
instanceTerms: this.customConfig.instance.terms,
instanceDefaultClientRoute: this.customConfig.instance.defaultClientRoute,
+ instanceDefaultNSFWPolicy: this.customConfig.instance.defaultNSFWPolicy,
+ servicesTwitterUsername: this.customConfig.services.twitter.username,
+ servicesTwitterWhitelisted: this.customConfig.services.twitter.whitelisted,
cachePreviewsSize: this.customConfig.cache.previews.size,
signupEnabled: this.customConfig.signup.enabled,
signupLimit: this.customConfig.signup.limit,