diff options
Diffstat (limited to 'client/src/app/+admin/config')
-rw-r--r-- | client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | 78 |
1 files changed, 24 insertions, 54 deletions
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 73ff4b7bb..f2a3464cb 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 | |||
@@ -17,6 +17,7 @@ import { | |||
17 | import { NotificationsService } from 'angular2-notifications' | 17 | import { NotificationsService } from 'angular2-notifications' |
18 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' | 18 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' |
19 | import { I18n } from '@ngx-translate/i18n-polyfill' | 19 | import { I18n } from '@ngx-translate/i18n-polyfill' |
20 | import { BuildFormDefaultValues, FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
20 | 21 | ||
21 | @Component({ | 22 | @Component({ |
22 | selector: 'my-edit-custom-config', | 23 | selector: 'my-edit-custom-config', |
@@ -44,38 +45,11 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
44 | { value: 8, label: '8' } | 45 | { value: 8, label: '8' } |
45 | ] | 46 | ] |
46 | 47 | ||
47 | form: FormGroup | ||
48 | formErrors = { | ||
49 | instanceName: '', | ||
50 | instanceShortDescription: '', | ||
51 | instanceDescription: '', | ||
52 | instanceTerms: '', | ||
53 | instanceDefaultClientRoute: '', | ||
54 | instanceDefaultNSFWPolicy: '', | ||
55 | servicesTwitterUsername: '', | ||
56 | cachePreviewsSize: '', | ||
57 | signupLimit: '', | ||
58 | adminEmail: '', | ||
59 | userVideoQuota: '', | ||
60 | transcodingThreads: '', | ||
61 | customizationJavascript: '', | ||
62 | customizationCSS: '' | ||
63 | } | ||
64 | validationMessages = { | ||
65 | instanceShortDescription: INSTANCE_SHORT_DESCRIPTION.MESSAGES, | ||
66 | instanceName: INSTANCE_NAME.MESSAGES, | ||
67 | servicesTwitterUsername: SERVICES_TWITTER_USERNAME, | ||
68 | cachePreviewsSize: CACHE_PREVIEWS_SIZE.MESSAGES, | ||
69 | signupLimit: SIGNUP_LIMIT.MESSAGES, | ||
70 | adminEmail: ADMIN_EMAIL.MESSAGES, | ||
71 | userVideoQuota: USER_VIDEO_QUOTA.MESSAGES | ||
72 | } | ||
73 | |||
74 | private oldCustomJavascript: string | 48 | private oldCustomJavascript: string |
75 | private oldCustomCSS: string | 49 | private oldCustomCSS: string |
76 | 50 | ||
77 | constructor ( | 51 | constructor ( |
78 | private formBuilder: FormBuilder, | 52 | protected formValidatorService: FormValidatorService, |
79 | private router: Router, | 53 | private router: Router, |
80 | private notificationsService: NotificationsService, | 54 | private notificationsService: NotificationsService, |
81 | private configService: ConfigService, | 55 | private configService: ConfigService, |
@@ -90,39 +64,35 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
90 | return 'transcodingResolution' + resolution | 64 | return 'transcodingResolution' + resolution |
91 | } | 65 | } |
92 | 66 | ||
93 | buildForm () { | 67 | ngOnInit () { |
94 | const formGroupData = { | 68 | const formGroupData = { |
95 | instanceName: [ '', INSTANCE_NAME.VALIDATORS ], | 69 | instanceName: INSTANCE_NAME, |
96 | instanceShortDescription: [ '', INSTANCE_SHORT_DESCRIPTION.VALIDATORS ], | 70 | instanceShortDescription: INSTANCE_SHORT_DESCRIPTION, |
97 | instanceDescription: [ '' ], | 71 | instanceDescription: null, |
98 | instanceTerms: [ '' ], | 72 | instanceTerms: null, |
99 | instanceDefaultClientRoute: [ '' ], | 73 | instanceDefaultClientRoute: null, |
100 | instanceDefaultNSFWPolicy: [ '' ], | 74 | instanceDefaultNSFWPolicy: null, |
101 | servicesTwitterUsername: [ '', SERVICES_TWITTER_USERNAME.VALIDATORS ], | 75 | servicesTwitterUsername: SERVICES_TWITTER_USERNAME, |
102 | servicesTwitterWhitelisted: [ ], | 76 | servicesTwitterWhitelisted: null, |
103 | cachePreviewsSize: [ '', CACHE_PREVIEWS_SIZE.VALIDATORS ], | 77 | cachePreviewsSize: CACHE_PREVIEWS_SIZE, |
104 | signupEnabled: [ ], | 78 | signupEnabled: null, |
105 | signupLimit: [ '', SIGNUP_LIMIT.VALIDATORS ], | 79 | signupLimit: SIGNUP_LIMIT, |
106 | adminEmail: [ '', ADMIN_EMAIL.VALIDATORS ], | 80 | adminEmail: ADMIN_EMAIL, |
107 | userVideoQuota: [ '', USER_VIDEO_QUOTA.VALIDATORS ], | 81 | userVideoQuota: USER_VIDEO_QUOTA, |
108 | transcodingThreads: [ '', TRANSCODING_THREADS.VALIDATORS ], | 82 | transcodingThreads: TRANSCODING_THREADS, |
109 | transcodingEnabled: [ ], | 83 | transcodingEnabled: null, |
110 | customizationJavascript: [ '' ], | 84 | customizationJavascript: null, |
111 | customizationCSS: [ '' ] | 85 | customizationCSS: null |
112 | } | 86 | } |
113 | 87 | ||
88 | const defaultValues: BuildFormDefaultValues = {} | ||
114 | for (const resolution of this.resolutions) { | 89 | for (const resolution of this.resolutions) { |
115 | const key = this.getResolutionKey(resolution) | 90 | const key = this.getResolutionKey(resolution) |
116 | formGroupData[key] = [ false ] | 91 | defaultValues[key] = 'false' |
92 | formGroupData[key] = null | ||
117 | } | 93 | } |
118 | 94 | ||
119 | this.form = this.formBuilder.group(formGroupData) | 95 | this.buildForm(formGroupData) |
120 | |||
121 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | ||
122 | } | ||
123 | |||
124 | ngOnInit () { | ||
125 | this.buildForm() | ||
126 | 96 | ||
127 | this.configService.getCustomConfig() | 97 | this.configService.getCustomConfig() |
128 | .subscribe( | 98 | .subscribe( |