diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-04 13:31:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-04 15:45:44 +0200 |
commit | 2989628b7913383b39ac34c7db8666a21f8e5037 (patch) | |
tree | ac7759177c04e524e7845143fd685aefb49e810e /client/src/app/+about/about-instance | |
parent | 8e08d415f9473b6b72fef698729453e726da16e7 (diff) | |
download | PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.gz PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.zst PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.zip |
Use HTML config when possible
Diffstat (limited to 'client/src/app/+about/about-instance')
3 files changed, 17 insertions, 21 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index 5627aaa5a..f02048f39 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts | |||
@@ -2,10 +2,10 @@ import { ViewportScroller } from '@angular/common' | |||
2 | import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 2 | import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute } from '@angular/router' | 3 | import { ActivatedRoute } from '@angular/router' |
4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | 4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
5 | import { Notifier } from '@app/core' | 5 | import { Notifier, ServerService } from '@app/core' |
6 | import { CustomMarkupService } from '@app/shared/shared-custom-markup' | 6 | import { CustomMarkupService } from '@app/shared/shared-custom-markup' |
7 | import { InstanceService } from '@app/shared/shared-instance' | 7 | import { InstanceService } from '@app/shared/shared-instance' |
8 | import { About, ServerConfig } from '@shared/models' | 8 | import { About, HTMLServerConfig, ServerConfig } from '@shared/models' |
9 | import { copyToClipboard } from '../../../root-helpers/utils' | 9 | import { copyToClipboard } from '../../../root-helpers/utils' |
10 | import { ResolverData } from './about-instance.resolver' | 10 | import { ResolverData } from './about-instance.resolver' |
11 | 11 | ||
@@ -35,16 +35,17 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
35 | languages: string[] = [] | 35 | languages: string[] = [] |
36 | categories: string[] = [] | 36 | categories: string[] = [] |
37 | 37 | ||
38 | serverConfig: ServerConfig | ||
39 | |||
40 | initialized = false | 38 | initialized = false |
41 | 39 | ||
40 | private serverConfig: HTMLServerConfig | ||
41 | |||
42 | private lastScrollHash: string | 42 | private lastScrollHash: string |
43 | 43 | ||
44 | constructor ( | 44 | constructor ( |
45 | private viewportScroller: ViewportScroller, | 45 | private viewportScroller: ViewportScroller, |
46 | private route: ActivatedRoute, | 46 | private route: ActivatedRoute, |
47 | private notifier: Notifier, | 47 | private notifier: Notifier, |
48 | private serverService: ServerService, | ||
48 | private instanceService: InstanceService | 49 | private instanceService: InstanceService |
49 | ) {} | 50 | ) {} |
50 | 51 | ||
@@ -61,9 +62,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
61 | } | 62 | } |
62 | 63 | ||
63 | async ngOnInit () { | 64 | async ngOnInit () { |
64 | const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData | 65 | const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData |
65 | 66 | ||
66 | this.serverConfig = serverConfig | 67 | this.serverConfig = this.serverService.getHTMLConfig() |
67 | 68 | ||
68 | this.languages = languages | 69 | this.languages = languages |
69 | this.categories = categories | 70 | this.categories = categories |
diff --git a/client/src/app/+about/about-instance/about-instance.resolver.ts b/client/src/app/+about/about-instance/about-instance.resolver.ts index 9a5924ebb..ee0219df0 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts | |||
@@ -1,30 +1,27 @@ | |||
1 | import { forkJoin } from 'rxjs' | 1 | import { forkJoin } from 'rxjs' |
2 | import { map, switchMap } from 'rxjs/operators' | 2 | import { map, switchMap } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' | 4 | import { Resolve } from '@angular/router' |
5 | import { ServerService } from '@app/core' | ||
6 | import { InstanceService } from '@app/shared/shared-instance' | 5 | import { InstanceService } from '@app/shared/shared-instance' |
7 | import { About, ServerConfig } from '@shared/models/server' | 6 | import { About } from '@shared/models/server' |
8 | 7 | ||
9 | export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig } | 8 | export type ResolverData = { about: About, languages: string[], categories: string[] } |
10 | 9 | ||
11 | @Injectable() | 10 | @Injectable() |
12 | export class AboutInstanceResolver implements Resolve<any> { | 11 | export class AboutInstanceResolver implements Resolve<any> { |
13 | 12 | ||
14 | constructor ( | 13 | constructor ( |
15 | private instanceService: InstanceService, | 14 | private instanceService: InstanceService |
16 | private serverService: ServerService | ||
17 | ) {} | 15 | ) {} |
18 | 16 | ||
19 | resolve (route: ActivatedRouteSnapshot) { | 17 | resolve () { |
20 | return this.instanceService.getAbout() | 18 | return this.instanceService.getAbout() |
21 | .pipe( | 19 | .pipe( |
22 | switchMap(about => { | 20 | switchMap(about => { |
23 | return forkJoin([ | 21 | return forkJoin([ |
24 | this.instanceService.buildTranslatedLanguages(about), | 22 | this.instanceService.buildTranslatedLanguages(about), |
25 | this.instanceService.buildTranslatedCategories(about), | 23 | this.instanceService.buildTranslatedCategories(about) |
26 | this.serverService.getConfig() | 24 | ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }) as ResolverData)) |
27 | ]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig }))) | ||
28 | }) | 25 | }) |
29 | ) | 26 | ) |
30 | } | 27 | } |
diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts index ac2a6c980..adbe7fe9a 100644 --- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts +++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts | |||
@@ -11,7 +11,7 @@ import { InstanceService } from '@app/shared/shared-instance' | |||
11 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 11 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
12 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 12 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
13 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
14 | import { ServerConfig } from '@shared/models' | 14 | import { HTMLServerConfig } from '@shared/models' |
15 | 15 | ||
16 | @Component({ | 16 | @Component({ |
17 | selector: 'my-contact-admin-modal', | 17 | selector: 'my-contact-admin-modal', |
@@ -24,7 +24,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { | |||
24 | error: string | 24 | error: string |
25 | 25 | ||
26 | private openedModal: NgbModalRef | 26 | private openedModal: NgbModalRef |
27 | private serverConfig: ServerConfig | 27 | private serverConfig: HTMLServerConfig |
28 | 28 | ||
29 | constructor ( | 29 | constructor ( |
30 | protected formValidatorService: FormValidatorService, | 30 | protected formValidatorService: FormValidatorService, |
@@ -41,9 +41,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | ngOnInit () { | 43 | ngOnInit () { |
44 | this.serverConfig = this.serverService.getTmpConfig() | 44 | this.serverConfig = this.serverService.getHTMLConfig() |
45 | this.serverService.getConfig() | ||
46 | .subscribe(config => this.serverConfig = config) | ||
47 | 45 | ||
48 | this.buildForm({ | 46 | this.buildForm({ |
49 | fromName: FROM_NAME_VALIDATOR, | 47 | fromName: FROM_NAME_VALIDATOR, |