]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
Fix misplaced i18n tag in admin system config
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / edit-custom-config / edit-custom-config.component.ts
index 0a69f34819fc970f7132a83f40fb00cbc2096174..3fda0851efa9da12e0807788f120251cf6e8427d 100644 (file)
@@ -8,7 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
 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',
@@ -18,12 +18,14 @@ import { first } from 'rxjs/operators'
 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,
@@ -36,6 +38,11 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
     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')
@@ -80,7 +87,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   }
 
   get availableThemes () {
-    return this.serverService.getConfig().theme.registered
+    return this.serverConfig.theme.registered
       .map(t => t.name)
   }
 
@@ -89,6 +96,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   }
 
   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,
@@ -166,7 +177,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
         threads: this.customConfigValidatorsService.TRANSCODING_THREADS,
         allowAdditionalExtensions: null,
         allowAudioFiles: null,
-        resolutions: {}
+        resolutions: {},
+        hls: {
+          enabled: null
+        },
+        webtorrent: {
+          enabled: null
+        }
       },
       autoBlacklist: {
         videos: {
@@ -208,16 +225,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
 
     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()
@@ -239,12 +253,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
 
   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()