]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add fragment support in admin conf page
authorChocobozzz <me@florianbigard.com>
Wed, 10 Feb 2021 08:19:36 +0000 (09:19 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 10 Feb 2021 10:36:40 +0000 (11:36 +0100)
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts

index 637203b96a0691104f9c6ad234f424d359fd2147..1352761922d7814190e6f07016a39aa7678f2565 100644 (file)
@@ -1,7 +1,7 @@
 <h1 class="sr-only" i18n>Configuration</h1>
 <form role="form" [formGroup]="form">
 
-  <div ngbNav #nav="ngbNav" class="nav-tabs">
+  <div ngbNav #nav="ngbNav" [activeId]="activeNav" (activeIdChange)="onNavChange($event)" class="nav-tabs">
 
     <ng-container ngbNavItem="instance-information">
       <a ngbNavLink i18n>Instance information</a>
index 56be97e844cfecb6988e5bde0a45a158dccc8852..29524fdd8c704e0ec93e9e60df0ebad76cf96829 100644 (file)
@@ -1,7 +1,9 @@
 import { forkJoin } from 'rxjs'
 import { pairwise } from 'rxjs/operators'
+import { SelectOptionsItem } from 'src/types/select-options-item.model'
 import { ViewportScroller } from '@angular/common'
 import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core'
+import { ActivatedRoute, Router } from '@angular/router'
 import { ConfigService } from '@app/+admin/config/shared/config.service'
 import { Notifier } from '@app/core'
 import { ServerService } from '@app/core/server/server.service'
@@ -22,7 +24,6 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@a
 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
 import { CustomConfig, ServerConfig } from '@shared/models'
-import { SelectOptionsItem } from 'src/types/select-options-item.model'
 
 @Component({
   selector: 'my-edit-custom-config',
@@ -30,7 +31,6 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model'
   styleUrls: [ './edit-custom-config.component.scss' ]
 })
 export class EditCustomConfigComponent extends FormReactive implements OnInit, AfterViewChecked {
-  // FIXME: use built-in router
   @ViewChild('nav') nav: NgbNav
 
   initDone = false
@@ -47,9 +47,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
 
   signupAlertMessage: string
 
+  activeNav: string
+
   private serverConfig: ServerConfig
 
   constructor (
+    private router: Router,
+    private route: ActivatedRoute,
     private viewportScroller: ViewportScroller,
     protected formValidatorService: FormValidatorService,
     private notifier: Notifier,
@@ -352,6 +356,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
       formGroupData.live.transcoding.resolutions[resolution.id] = null
     }
 
+    if (this.route.snapshot.fragment) {
+      this.onNavChange(this.route.snapshot.fragment)
+    }
+
     this.buildForm(formGroupData)
     this.loadForm()
 
@@ -440,6 +448,12 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
     return true
   }
 
+  onNavChange (newActiveNav: string) {
+    this.activeNav = newActiveNav
+
+    this.router.navigate([], { fragment: this.activeNav })
+  }
+
   private updateForm () {
     this.form.patchValue(this.customConfig)
   }