import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
import { SelectItem } from 'primeng/api'
import { forkJoin } from 'rxjs'
-import { first } from 'rxjs/operators'
+import { ServerConfig } from '@shared/models'
@Component({
selector: 'my-edit-custom-config',
export class EditCustomConfigComponent extends FormReactive implements OnInit {
customConfig: CustomConfig
- resolutions: { id: string, label: string }[] = []
+ resolutions: { id: string, label: string, description?: string }[] = []
transcodingThreadOptions: { label: string, value: number }[] = []
languageItems: SelectItem[] = []
categoryItems: SelectItem[] = []
+ private serverConfig: ServerConfig
+
constructor (
protected formValidatorService: FormValidatorService,
private customConfigValidatorsService: CustomConfigValidatorsService,
super()
this.resolutions = [
+ {
+ id: '0p',
+ label: this.i18n('Audio-only'),
+ description: this.i18n('A <code>.mp4</code> that keeps the original audio track, with no video')
+ },
{
id: '240p',
label: this.i18n('240p')
}
get availableThemes () {
- return this.serverService.getConfig().theme.registered
+ return this.serverConfig.theme.registered
.map(t => t.name)
}
}
ngOnInit () {
+ this.serverConfig = this.serverService.getTmpConfig()
+ this.serverService.getConfig()
+ .subscribe(config => this.serverConfig = config)
+
const formGroupData: { [key in keyof CustomConfig ]: any } = {
instance: {
name: this.customConfigValidatorsService.INSTANCE_NAME,
forkJoin([
this.configService.getCustomConfig(),
- this.serverService.videoLanguagesLoaded.pipe(first()), // First so the observable completes
- this.serverService.videoCategoriesLoaded.pipe(first())
+ this.serverService.getVideoLanguages(),
+ this.serverService.getVideoCategories()
]).subscribe(
- ([ config ]) => {
+ ([ config, languages, categories ]) => {
this.customConfig = config
- const languages = this.serverService.getVideoLanguages()
this.languageItems = languages.map(l => ({ label: l.label, value: l.id }))
-
- const categories = this.serverService.getVideoCategories()
this.categoryItems = categories.map(l => ({ label: l.label, value: l.id }))
this.updateForm()
async formValidated () {
this.configService.updateCustomConfig(this.form.value)
+ .pipe(
+ )
.subscribe(
res => {
this.customConfig = res
// Reload general configuration
- this.serverService.loadConfig()
+ this.serverService.resetConfig()
this.updateForm()