mirror of https://github.com/Chocobozzz/PeerTube
Fix stats anchor link
parent
343d1395df
commit
f6cf8e8d8e
|
@ -210,6 +210,7 @@
|
||||||
|
|
||||||
<div class="col" myPluginSelector pluginSelectorId="about-instance-statistics">
|
<div class="col" myPluginSelector pluginSelectorId="about-instance-statistics">
|
||||||
<div class="anchor" id="statistics"></div>
|
<div class="anchor" id="statistics"></div>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="anchor-link"
|
class="anchor-link"
|
||||||
routerLink="/about/instance"
|
routerLink="/about/instance"
|
||||||
|
@ -218,7 +219,8 @@
|
||||||
(click)="onClickCopyLink(anchorLink)">
|
(click)="onClickCopyLink(anchorLink)">
|
||||||
<h2 i18n class="middle-title">STATISTICS</h2>
|
<h2 i18n class="middle-title">STATISTICS</h2>
|
||||||
</a>
|
</a>
|
||||||
<my-instance-statistics></my-instance-statistics>
|
|
||||||
|
<my-instance-statistics [serverStats]="serverStats"></my-instance-statistics>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router'
|
||||||
import { Notifier, ServerService } from '@app/core'
|
import { Notifier, ServerService } from '@app/core'
|
||||||
import { AboutHTML } from '@app/shared/shared-instance'
|
import { AboutHTML } from '@app/shared/shared-instance'
|
||||||
import { copyToClipboard } from '@root-helpers/utils'
|
import { copyToClipboard } from '@root-helpers/utils'
|
||||||
import { HTMLServerConfig } from '@shared/models/server'
|
import { HTMLServerConfig, ServerStats } from '@shared/models/server'
|
||||||
import { ResolverData } from './about-instance.resolver'
|
import { ResolverData } from './about-instance.resolver'
|
||||||
import { ContactAdminModalComponent } from './contact-admin-modal.component'
|
import { ContactAdminModalComponent } from './contact-admin-modal.component'
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
|
||||||
|
|
||||||
initialized = false
|
initialized = false
|
||||||
|
|
||||||
|
serverStats: ServerStats
|
||||||
|
|
||||||
private serverConfig: HTMLServerConfig
|
private serverConfig: HTMLServerConfig
|
||||||
|
|
||||||
private lastScrollHash: string
|
private lastScrollHash: string
|
||||||
|
@ -50,7 +52,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
const { about, languages, categories, aboutHTML, descriptionElement }: ResolverData = this.route.snapshot.data.instanceData
|
const { about, languages, categories, aboutHTML, descriptionElement, serverStats }: ResolverData = this.route.snapshot.data.instanceData
|
||||||
|
|
||||||
|
this.serverStats = serverStats
|
||||||
|
|
||||||
this.aboutHTML = aboutHTML
|
this.aboutHTML = aboutHTML
|
||||||
this.descriptionElement = descriptionElement
|
this.descriptionElement = descriptionElement
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { forkJoin } from 'rxjs'
|
import { forkJoin, Observable } from 'rxjs'
|
||||||
import { map, switchMap } from 'rxjs/operators'
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Resolve } from '@angular/router'
|
import { Resolve } from '@angular/router'
|
||||||
|
import { ServerService } from '@app/core'
|
||||||
import { CustomMarkupService } from '@app/shared/shared-custom-markup'
|
import { CustomMarkupService } from '@app/shared/shared-custom-markup'
|
||||||
import { AboutHTML, InstanceService } from '@app/shared/shared-instance'
|
import { AboutHTML, InstanceService } from '@app/shared/shared-instance'
|
||||||
import { About } from '@shared/models/server'
|
import { About, ServerStats } from '@shared/models/server'
|
||||||
|
|
||||||
export type ResolverData = {
|
export type ResolverData = {
|
||||||
|
serverStats: ServerStats
|
||||||
about: About
|
about: About
|
||||||
languages: string[]
|
languages: string[]
|
||||||
categories: string[]
|
categories: string[]
|
||||||
|
@ -19,11 +21,32 @@ export class AboutInstanceResolver implements Resolve<any> {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private instanceService: InstanceService,
|
private instanceService: InstanceService,
|
||||||
private customMarkupService: CustomMarkupService
|
private customMarkupService: CustomMarkupService,
|
||||||
|
private serverService: ServerService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
resolve () {
|
resolve (): Observable<ResolverData> {
|
||||||
|
return forkJoin([
|
||||||
|
this.buildInstanceAboutObservable(),
|
||||||
|
this.buildInstanceStatsObservable()
|
||||||
|
]).pipe(
|
||||||
|
map(([
|
||||||
|
[ about, languages, categories, aboutHTML, { rootElement } ],
|
||||||
|
serverStats
|
||||||
|
]) => {
|
||||||
|
return {
|
||||||
|
serverStats,
|
||||||
|
about,
|
||||||
|
languages,
|
||||||
|
categories,
|
||||||
|
aboutHTML,
|
||||||
|
descriptionElement: rootElement
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildInstanceAboutObservable () {
|
||||||
return this.instanceService.getAbout()
|
return this.instanceService.getAbout()
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(about => {
|
switchMap(about => {
|
||||||
|
@ -34,10 +57,11 @@ export class AboutInstanceResolver implements Resolve<any> {
|
||||||
this.instanceService.buildHtml(about),
|
this.instanceService.buildHtml(about),
|
||||||
this.customMarkupService.buildElement(about.instance.description)
|
this.customMarkupService.buildElement(about.instance.description)
|
||||||
])
|
])
|
||||||
}),
|
|
||||||
map(([ about, languages, categories, aboutHTML, { rootElement } ]) => {
|
|
||||||
return { about, languages, categories, aboutHTML, descriptionElement: rootElement } as ResolverData
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildInstanceStatsObservable () {
|
||||||
|
return this.serverService.getServerStats()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { Component, Input } from '@angular/core'
|
||||||
|
import { ServerStats } from '@shared/models/server'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-instance-statistics',
|
||||||
|
templateUrl: './instance-statistics.component.html',
|
||||||
|
styleUrls: [ './instance-statistics.component.scss' ]
|
||||||
|
})
|
||||||
|
export class InstanceStatisticsComponent {
|
||||||
|
@Input() serverStats: ServerStats
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { AboutFollowsComponent } from '@app/+about/about-follows/about-follows.c
|
||||||
import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component'
|
import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component'
|
||||||
import { AboutInstanceResolver } from '@app/+about/about-instance/about-instance.resolver'
|
import { AboutInstanceResolver } from '@app/+about/about-instance/about-instance.resolver'
|
||||||
import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
|
import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
|
||||||
|
import { InstanceStatisticsComponent } from '@app/+about/about-instance/instance-statistics.component'
|
||||||
import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component'
|
import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component'
|
||||||
import { SharedCustomMarkupModule } from '@app/shared/shared-custom-markup'
|
import { SharedCustomMarkupModule } from '@app/shared/shared-custom-markup'
|
||||||
import { SharedFormModule } from '@app/shared/shared-forms'
|
import { SharedFormModule } from '@app/shared/shared-forms'
|
||||||
|
@ -25,10 +26,13 @@ import { AboutComponent } from './about.component'
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
AboutComponent,
|
AboutComponent,
|
||||||
|
|
||||||
AboutInstanceComponent,
|
AboutInstanceComponent,
|
||||||
|
ContactAdminModalComponent,
|
||||||
|
InstanceStatisticsComponent,
|
||||||
|
|
||||||
AboutPeertubeComponent,
|
AboutPeertubeComponent,
|
||||||
AboutFollowsComponent,
|
AboutFollowsComponent
|
||||||
ContactAdminModalComponent
|
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
|
|
|
@ -2,6 +2,5 @@ export * from './feature-boolean.component'
|
||||||
export * from './instance-about-accordion.component'
|
export * from './instance-about-accordion.component'
|
||||||
export * from './instance-features-table.component'
|
export * from './instance-features-table.component'
|
||||||
export * from './instance-follow.service'
|
export * from './instance-follow.service'
|
||||||
export * from './instance-statistics.component'
|
|
||||||
export * from './instance.service'
|
export * from './instance.service'
|
||||||
export * from './shared-instance.module'
|
export * from './shared-instance.module'
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core'
|
|
||||||
import { ServerStats } from '@shared/models/server'
|
|
||||||
import { ServerService } from '@app/core'
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'my-instance-statistics',
|
|
||||||
templateUrl: './instance-statistics.component.html',
|
|
||||||
styleUrls: [ './instance-statistics.component.scss' ]
|
|
||||||
})
|
|
||||||
export class InstanceStatisticsComponent implements OnInit {
|
|
||||||
serverStats: ServerStats = null
|
|
||||||
|
|
||||||
constructor (
|
|
||||||
private serverService: ServerService
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit () {
|
|
||||||
this.serverService.getServerStats()
|
|
||||||
.subscribe(res => {
|
|
||||||
this.serverStats = res
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { SharedGlobalIconModule } from '../shared-icons'
|
import { SharedGlobalIconModule } from '../shared-icons'
|
||||||
|
@ -7,7 +6,6 @@ import { FeatureBooleanComponent } from './feature-boolean.component'
|
||||||
import { InstanceAboutAccordionComponent } from './instance-about-accordion.component'
|
import { InstanceAboutAccordionComponent } from './instance-about-accordion.component'
|
||||||
import { InstanceFeaturesTableComponent } from './instance-features-table.component'
|
import { InstanceFeaturesTableComponent } from './instance-features-table.component'
|
||||||
import { InstanceFollowService } from './instance-follow.service'
|
import { InstanceFollowService } from './instance-follow.service'
|
||||||
import { InstanceStatisticsComponent } from './instance-statistics.component'
|
|
||||||
import { InstanceService } from './instance.service'
|
import { InstanceService } from './instance.service'
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -20,15 +18,13 @@ import { InstanceService } from './instance.service'
|
||||||
declarations: [
|
declarations: [
|
||||||
FeatureBooleanComponent,
|
FeatureBooleanComponent,
|
||||||
InstanceAboutAccordionComponent,
|
InstanceAboutAccordionComponent,
|
||||||
InstanceFeaturesTableComponent,
|
InstanceFeaturesTableComponent
|
||||||
InstanceStatisticsComponent
|
|
||||||
],
|
],
|
||||||
|
|
||||||
exports: [
|
exports: [
|
||||||
FeatureBooleanComponent,
|
FeatureBooleanComponent,
|
||||||
InstanceAboutAccordionComponent,
|
InstanceAboutAccordionComponent,
|
||||||
InstanceFeaturesTableComponent,
|
InstanceFeaturesTableComponent
|
||||||
InstanceStatisticsComponent
|
|
||||||
],
|
],
|
||||||
|
|
||||||
providers: [
|
providers: [
|
||||||
|
|
Loading…
Reference in New Issue