]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts
Use HTML config when possible
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / edit-custom-config / edit-basic-configuration.component.ts
index 34d05f9f3446b60ac6e2d81f5aae55491361d575..bac1015fc4e3b37174895f2a227209f0dc104716 100644 (file)
@@ -1,8 +1,9 @@
-
 import { pairwise } from 'rxjs/operators'
-import { Component, Input, OnInit } from '@angular/core'
+import { SelectOptionsItem } from 'src/types/select-options-item.model'
+import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
 import { FormGroup } from '@angular/forms'
-import { ServerConfig } from '@shared/models'
+import { MenuService } from '@app/core'
+import { HTMLServerConfig } from '@shared/models'
 import { ConfigService } from '../shared/config.service'
 
 @Component({
@@ -10,22 +11,31 @@ import { ConfigService } from '../shared/config.service'
   templateUrl: './edit-basic-configuration.component.html',
   styleUrls: [ './edit-custom-config.component.scss' ]
 })
-export class EditBasicConfigurationComponent implements OnInit {
+export class EditBasicConfigurationComponent implements OnInit, OnChanges {
   @Input() form: FormGroup
   @Input() formErrors: any
 
-  @Input() serverConfig: ServerConfig
+  @Input() serverConfig: HTMLServerConfig
 
   signupAlertMessage: string
+  defaultLandingPageOptions: SelectOptionsItem[] = []
 
   constructor (
-    private configService: ConfigService
+    private configService: ConfigService,
+    private menuService: MenuService
   ) { }
 
   ngOnInit () {
+    this.buildLandingPageOptions()
     this.checkSignupField()
   }
 
+  ngOnChanges (changes: SimpleChanges) {
+    if (changes['serverConfig']) {
+      this.buildLandingPageOptions()
+    }
+  }
+
   getVideoQuotaOptions () {
     return this.configService.videoQuotaOptions
   }
@@ -70,6 +80,15 @@ export class EditBasicConfigurationComponent implements OnInit {
     return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
   }
 
+  buildLandingPageOptions () {
+    this.defaultLandingPageOptions = this.menuService.buildCommonLinks(this.serverConfig)
+      .map(o => ({
+        id: o.path,
+        label: o.label,
+        description: o.path
+      }))
+  }
+
   private checkSignupField () {
     const signupControl = this.form.get('signup.enabled')