diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:31:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:40:59 +0100 |
commit | ba430d7516bc5b1324b60571ba7594460969b7fb (patch) | |
tree | df5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/+admin/config | |
parent | 5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff) | |
download | PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip |
Lazy load static objects
Diffstat (limited to 'client/src/app/+admin/config')
-rw-r--r-- | client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | 23 |
1 files changed, 14 insertions, 9 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 1f6751297..25e06d8a1 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 | |||
@@ -8,7 +8,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' | 9 | import { SelectItem } from 'primeng/api' |
10 | import { forkJoin } from 'rxjs' | 10 | import { forkJoin } from 'rxjs' |
11 | import { first } from 'rxjs/operators' | 11 | import { ServerConfig } from '@shared/models' |
12 | 12 | ||
13 | @Component({ | 13 | @Component({ |
14 | selector: 'my-edit-custom-config', | 14 | selector: 'my-edit-custom-config', |
@@ -24,6 +24,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
24 | languageItems: SelectItem[] = [] | 24 | languageItems: SelectItem[] = [] |
25 | categoryItems: SelectItem[] = [] | 25 | categoryItems: SelectItem[] = [] |
26 | 26 | ||
27 | private serverConfig: ServerConfig | ||
28 | |||
27 | constructor ( | 29 | constructor ( |
28 | protected formValidatorService: FormValidatorService, | 30 | protected formValidatorService: FormValidatorService, |
29 | private customConfigValidatorsService: CustomConfigValidatorsService, | 31 | private customConfigValidatorsService: CustomConfigValidatorsService, |
@@ -84,7 +86,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
84 | } | 86 | } |
85 | 87 | ||
86 | get availableThemes () { | 88 | get availableThemes () { |
87 | return this.serverService.getConfig().theme.registered | 89 | return this.serverConfig.theme.registered |
88 | .map(t => t.name) | 90 | .map(t => t.name) |
89 | } | 91 | } |
90 | 92 | ||
@@ -93,6 +95,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
93 | } | 95 | } |
94 | 96 | ||
95 | ngOnInit () { | 97 | ngOnInit () { |
98 | this.serverConfig = this.serverService.getTmpConfig() | ||
99 | this.serverService.getConfig() | ||
100 | .subscribe(config => this.serverConfig = config) | ||
101 | |||
96 | const formGroupData: { [key in keyof CustomConfig ]: any } = { | 102 | const formGroupData: { [key in keyof CustomConfig ]: any } = { |
97 | instance: { | 103 | instance: { |
98 | name: this.customConfigValidatorsService.INSTANCE_NAME, | 104 | name: this.customConfigValidatorsService.INSTANCE_NAME, |
@@ -218,16 +224,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
218 | 224 | ||
219 | forkJoin([ | 225 | forkJoin([ |
220 | this.configService.getCustomConfig(), | 226 | this.configService.getCustomConfig(), |
221 | this.serverService.videoLanguagesLoaded.pipe(first()), // First so the observable completes | 227 | this.serverService.getVideoLanguages(), |
222 | this.serverService.videoCategoriesLoaded.pipe(first()) | 228 | this.serverService.getVideoCategories() |
223 | ]).subscribe( | 229 | ]).subscribe( |
224 | ([ config ]) => { | 230 | ([ config, languages, categories ]) => { |
225 | this.customConfig = config | 231 | this.customConfig = config |
226 | 232 | ||
227 | const languages = this.serverService.getVideoLanguages() | ||
228 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) | 233 | this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) |
229 | |||
230 | const categories = this.serverService.getVideoCategories() | ||
231 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) | 234 | this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) |
232 | 235 | ||
233 | this.updateForm() | 236 | this.updateForm() |
@@ -249,12 +252,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
249 | 252 | ||
250 | async formValidated () { | 253 | async formValidated () { |
251 | this.configService.updateCustomConfig(this.form.value) | 254 | this.configService.updateCustomConfig(this.form.value) |
255 | .pipe( | ||
256 | ) | ||
252 | .subscribe( | 257 | .subscribe( |
253 | res => { | 258 | res => { |
254 | this.customConfig = res | 259 | this.customConfig = res |
255 | 260 | ||
256 | // Reload general configuration | 261 | // Reload general configuration |
257 | this.serverService.loadConfig() | 262 | this.serverService.resetConfig() |
258 | 263 | ||
259 | this.updateForm() | 264 | this.updateForm() |
260 | 265 | ||