diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-15 15:53:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-15 16:08:32 +0100 |
commit | f6cf8e8d8e9bc61dac266886c873613bb715936d (patch) | |
tree | e5fb73f19ff933f8d816faf0755a8085b085605c /client/src/app/+about/about-instance/about-instance.resolver.ts | |
parent | 343d1395df2e07ea9eb3540724c9fd689e617cb8 (diff) | |
download | PeerTube-f6cf8e8d8e9bc61dac266886c873613bb715936d.tar.gz PeerTube-f6cf8e8d8e9bc61dac266886c873613bb715936d.tar.zst PeerTube-f6cf8e8d8e9bc61dac266886c873613bb715936d.zip |
Fix stats anchor link
Diffstat (limited to 'client/src/app/+about/about-instance/about-instance.resolver.ts')
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.resolver.ts | 62 |
1 files changed, 43 insertions, 19 deletions
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 8818fc582..94388e71d 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts | |||
@@ -1,12 +1,14 @@ | |||
1 | import { forkJoin } from 'rxjs' | 1 | import { forkJoin, Observable } 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 { Resolve } from '@angular/router' | 4 | import { Resolve } from '@angular/router' |
5 | import { ServerService } from '@app/core' | ||
5 | import { CustomMarkupService } from '@app/shared/shared-custom-markup' | 6 | import { CustomMarkupService } from '@app/shared/shared-custom-markup' |
6 | import { AboutHTML, InstanceService } from '@app/shared/shared-instance' | 7 | import { AboutHTML, InstanceService } from '@app/shared/shared-instance' |
7 | import { About } from '@shared/models/server' | 8 | import { About, ServerStats } from '@shared/models/server' |
8 | 9 | ||
9 | export type ResolverData = { | 10 | export type ResolverData = { |
11 | serverStats: ServerStats | ||
10 | about: About | 12 | about: About |
11 | languages: string[] | 13 | languages: string[] |
12 | categories: string[] | 14 | categories: string[] |
@@ -19,25 +21,47 @@ export class AboutInstanceResolver implements Resolve<any> { | |||
19 | 21 | ||
20 | constructor ( | 22 | constructor ( |
21 | private instanceService: InstanceService, | 23 | private instanceService: InstanceService, |
22 | private customMarkupService: CustomMarkupService | 24 | private customMarkupService: CustomMarkupService, |
23 | 25 | private serverService: ServerService | |
24 | ) {} | 26 | ) {} |
25 | 27 | ||
26 | resolve () { | 28 | resolve (): Observable<ResolverData> { |
29 | return forkJoin([ | ||
30 | this.buildInstanceAboutObservable(), | ||
31 | this.buildInstanceStatsObservable() | ||
32 | ]).pipe( | ||
33 | map(([ | ||
34 | [ about, languages, categories, aboutHTML, { rootElement } ], | ||
35 | serverStats | ||
36 | ]) => { | ||
37 | return { | ||
38 | serverStats, | ||
39 | about, | ||
40 | languages, | ||
41 | categories, | ||
42 | aboutHTML, | ||
43 | descriptionElement: rootElement | ||
44 | } | ||
45 | }) | ||
46 | ) | ||
47 | } | ||
48 | |||
49 | private buildInstanceAboutObservable () { | ||
27 | return this.instanceService.getAbout() | 50 | return this.instanceService.getAbout() |
28 | .pipe( | 51 | .pipe( |
29 | switchMap(about => { | 52 | switchMap(about => { |
30 | return forkJoin([ | 53 | return forkJoin([ |
31 | Promise.resolve(about), | 54 | Promise.resolve(about), |
32 | this.instanceService.buildTranslatedLanguages(about), | 55 | this.instanceService.buildTranslatedLanguages(about), |
33 | this.instanceService.buildTranslatedCategories(about), | 56 | this.instanceService.buildTranslatedCategories(about), |
34 | this.instanceService.buildHtml(about), | 57 | this.instanceService.buildHtml(about), |
35 | this.customMarkupService.buildElement(about.instance.description) | 58 | this.customMarkupService.buildElement(about.instance.description) |
36 | ]) | 59 | ]) |
37 | }), | 60 | }) |
38 | map(([ about, languages, categories, aboutHTML, { rootElement } ]) => { | 61 | ) |
39 | return { about, languages, categories, aboutHTML, descriptionElement: rootElement } as ResolverData | 62 | } |
40 | }) | 63 | |
41 | ) | 64 | private buildInstanceStatsObservable () { |
65 | return this.serverService.getServerStats() | ||
42 | } | 66 | } |
43 | } | 67 | } |