diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-23 15:23:27 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-09-05 10:17:02 +0200 |
commit | ccc00cb2aac1360921b957f3ecb3be7eb55dfa1b (patch) | |
tree | 364e1beecb1db90af60f23bbb5219ff2f964cc0d /client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | |
parent | 2ba613a5438f993c3874376dd79be9d460ea81d1 (diff) | |
download | PeerTube-ccc00cb2aac1360921b957f3ecb3be7eb55dfa1b.tar.gz PeerTube-ccc00cb2aac1360921b957f3ecb3be7eb55dfa1b.tar.zst PeerTube-ccc00cb2aac1360921b957f3ecb3be7eb55dfa1b.zip |
Add more attributes to about page
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts')
-rw-r--r-- | client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | 68 |
1 files changed, 55 insertions, 13 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 d51104569..3119ab040 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' | |||
6 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' | 6 | import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 7 | import { I18n } from '@ngx-translate/i18n-polyfill' |
8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
9 | import { SelectItem } from 'primeng/api' | ||
10 | import { forkJoin } from 'rxjs' | ||
11 | import { first } from 'rxjs/operators' | ||
9 | 12 | ||
10 | @Component({ | 13 | @Component({ |
11 | selector: 'my-edit-custom-config', | 14 | selector: 'my-edit-custom-config', |
@@ -18,6 +21,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
18 | resolutions: { id: string, label: string }[] = [] | 21 | resolutions: { id: string, label: string }[] = [] |
19 | transcodingThreadOptions: { label: string, value: number }[] = [] | 22 | transcodingThreadOptions: { label: string, value: number }[] = [] |
20 | 23 | ||
24 | languageItems: SelectItem[] = [] | ||
25 | categoryItems: SelectItem[] = [] | ||
26 | |||
21 | constructor ( | 27 | constructor ( |
22 | protected formValidatorService: FormValidatorService, | 28 | protected formValidatorService: FormValidatorService, |
23 | private customConfigValidatorsService: CustomConfigValidatorsService, | 29 | private customConfigValidatorsService: CustomConfigValidatorsService, |
@@ -88,10 +94,22 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
88 | name: this.customConfigValidatorsService.INSTANCE_NAME, | 94 | name: this.customConfigValidatorsService.INSTANCE_NAME, |
89 | shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION, | 95 | shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION, |
90 | description: null, | 96 | description: null, |
91 | terms: null, | 97 | |
92 | defaultClientRoute: null, | ||
93 | isNSFW: false, | 98 | isNSFW: false, |
94 | defaultNSFWPolicy: null, | 99 | defaultNSFWPolicy: null, |
100 | |||
101 | terms: null, | ||
102 | codeOfConduct: null, | ||
103 | moderationInformation: null, | ||
104 | administrator: null, | ||
105 | maintenanceLifetime: null, | ||
106 | businessModel: null, | ||
107 | |||
108 | categories: null, | ||
109 | languages: null, | ||
110 | |||
111 | defaultClientRoute: null, | ||
112 | |||
95 | customizations: { | 113 | customizations: { |
96 | javascript: null, | 114 | javascript: null, |
97 | css: null | 115 | css: null |
@@ -184,18 +202,27 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
184 | 202 | ||
185 | this.buildForm(formGroupData) | 203 | this.buildForm(formGroupData) |
186 | 204 | ||
187 | this.configService.getCustomConfig() | 205 | forkJoin([ |
188 | .subscribe( | 206 | this.configService.getCustomConfig(), |
189 | res => { | 207 | this.serverService.videoLanguagesLoaded.pipe(first()), // First so the observable completes |
190 | this.customConfig = res | 208 | this.serverService.videoCategoriesLoaded.pipe(first()) |
209 | ]).subscribe( | ||
210 | ([ config ]) => { | ||
211 | this.customConfig = config | ||
191 | 212 | ||
192 | this.updateForm() | 213 | const languages = this.serverService.getVideoLanguages() |
193 | // Force form validation | 214 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) |
194 | this.forceCheck() | ||
195 | }, | ||
196 | 215 | ||
197 | err => this.notifier.error(err.message) | 216 | const categories = this.serverService.getVideoCategories() |
198 | ) | 217 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) |
218 | |||
219 | this.updateForm() | ||
220 | // Force form validation | ||
221 | this.forceCheck() | ||
222 | }, | ||
223 | |||
224 | err => this.notifier.error(err.message) | ||
225 | ) | ||
199 | } | 226 | } |
200 | 227 | ||
201 | isTranscodingEnabled () { | 228 | isTranscodingEnabled () { |
@@ -224,8 +251,23 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
224 | ) | 251 | ) |
225 | } | 252 | } |
226 | 253 | ||
254 | getSelectedLanguageLabel () { | ||
255 | return this.i18n('{{\'{0} languages selected') | ||
256 | } | ||
257 | |||
258 | getDefaultLanguageLabel () { | ||
259 | return this.i18n('No language') | ||
260 | } | ||
261 | |||
262 | getSelectedCategoryLabel () { | ||
263 | return this.i18n('{{\'{0} categories selected') | ||
264 | } | ||
265 | |||
266 | getDefaultCategoryLabel () { | ||
267 | return this.i18n('No category') | ||
268 | } | ||
269 | |||
227 | private updateForm () { | 270 | private updateForm () { |
228 | this.form.patchValue(this.customConfig) | 271 | this.form.patchValue(this.customConfig) |
229 | } | 272 | } |
230 | |||
231 | } | 273 | } |