import { Component, OnInit } from '@angular/core'
import { ConfigService } from '@app/+admin/config/shared/config.service'
-import { ConfirmService } from '@app/core'
import { ServerService } from '@app/core/server/server.service'
import { CustomConfigValidatorsService, FormReactive, UserValidatorsService } from '@app/shared'
import { NotificationsService } from 'angular2-notifications'
private notificationsService: NotificationsService,
private configService: ConfigService,
private serverService: ServerService,
- private confirmService: ConfirmService,
private i18n: I18n
) {
super()
}
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 = {
instance: {
name: this.form.value['instanceName'],