aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-03-11 19:38:17 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-03-11 19:38:17 +0100
commit45e0d6697c107d77dce73d8e354867dc1959741d (patch)
tree6acff1e8fdc59ed396a3da4439461d4a475ee8b5 /client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
parent111fdc267b36201cf1be1fdf91017005102b4a5e (diff)
downloadPeerTube-45e0d6697c107d77dce73d8e354867dc1959741d.tar.gz
PeerTube-45e0d6697c107d77dce73d8e354867dc1959741d.tar.zst
PeerTube-45e0d6697c107d77dce73d8e354867dc1959741d.zip
Properly scroll to anchors in links, especially in admin config
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts29
1 files changed, 27 insertions, 2 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 c88e81c01..c3eac68bb 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
@@ -1,4 +1,4 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit, AfterViewChecked, ViewChild } from '@angular/core'
2import { ConfigService } from '@app/+admin/config/shared/config.service' 2import { ConfigService } from '@app/+admin/config/shared/config.service'
3import { ServerService } from '@app/core/server/server.service' 3import { ServerService } from '@app/core/server/server.service'
4import { CustomConfigValidatorsService, FormReactive, UserValidatorsService } from '@app/shared' 4import { CustomConfigValidatorsService, FormReactive, UserValidatorsService } from '@app/shared'
@@ -9,13 +9,18 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
9import { SelectItem } from 'primeng/api' 9import { SelectItem } from 'primeng/api'
10import { forkJoin } from 'rxjs' 10import { forkJoin } from 'rxjs'
11import { ServerConfig } from '@shared/models' 11import { ServerConfig } from '@shared/models'
12import { ViewportScroller } from '@angular/common'
13import { NgbTabset } from '@ng-bootstrap/ng-bootstrap'
12 14
13@Component({ 15@Component({
14 selector: 'my-edit-custom-config', 16 selector: 'my-edit-custom-config',
15 templateUrl: './edit-custom-config.component.html', 17 templateUrl: './edit-custom-config.component.html',
16 styleUrls: [ './edit-custom-config.component.scss' ] 18 styleUrls: [ './edit-custom-config.component.scss' ]
17}) 19})
18export class EditCustomConfigComponent extends FormReactive implements OnInit { 20export class EditCustomConfigComponent extends FormReactive implements OnInit, AfterViewChecked {
21 @ViewChild('tabs') private tabs: NgbTabset
22
23 initDone = false
19 customConfig: CustomConfig 24 customConfig: CustomConfig
20 25
21 resolutions: { id: string, label: string, description?: string }[] = [] 26 resolutions: { id: string, label: string, description?: string }[] = []
@@ -27,6 +32,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
27 private serverConfig: ServerConfig 32 private serverConfig: ServerConfig
28 33
29 constructor ( 34 constructor (
35 private viewportScroller: ViewportScroller,
30 protected formValidatorService: FormValidatorService, 36 protected formValidatorService: FormValidatorService,
31 private customConfigValidatorsService: CustomConfigValidatorsService, 37 private customConfigValidatorsService: CustomConfigValidatorsService,
32 private userValidatorsService: UserValidatorsService, 38 private userValidatorsService: UserValidatorsService,
@@ -226,6 +232,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
226 this.checkTranscodingFields() 232 this.checkTranscodingFields()
227 } 233 }
228 234
235 ngAfterViewChecked () {
236 if (!this.initDone) {
237 this.initDone = true
238 this.gotoAnchor()
239 }
240 }
241
229 isTranscodingEnabled () { 242 isTranscodingEnabled () {
230 return this.form.value['transcoding']['enabled'] === true 243 return this.form.value['transcoding']['enabled'] === true
231 } 244 }
@@ -272,6 +285,18 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
272 return this.i18n('No category') 285 return this.i18n('No category')
273 } 286 }
274 287
288 gotoAnchor () {
289 const hashToTab = {
290 'customizations': 'advanced-configuration'
291 }
292 const hash = window.location.hash.replace('#', '')
293
294 if (hash && Object.keys(hashToTab).includes(hash)) {
295 this.tabs.select(hashToTab[hash])
296 setTimeout(() => this.viewportScroller.scrollToAnchor(hash), 100)
297 }
298 }
299
275 private updateForm () { 300 private updateForm () {
276 this.form.patchValue(this.customConfig) 301 this.form.patchValue(this.customConfig)
277 } 302 }