From: Julien Maulny Date: Wed, 2 Oct 2019 20:37:01 +0000 (+0200) Subject: Add statistics section in about page X-Git-Tag: v2.0.0-rc.1~50 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3d05209c9a9f1e229f8c704ee5fe06a5c97c9840;p=oweals%2Fpeertube.git Add statistics section in about page --- diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.html index 25d416740..f05f33d36 100644 --- a/client/src/app/+about/about-instance/about-instance.component.html +++ b/client/src/app/+about/about-instance/about-instance.component.html @@ -94,6 +94,13 @@ + +
+
+ Statistics +
+ +
diff --git a/client/src/app/shared/instance/instance-statistics.component.html b/client/src/app/shared/instance/instance-statistics.component.html new file mode 100644 index 000000000..181c57b57 --- /dev/null +++ b/client/src/app/shared/instance/instance-statistics.component.html @@ -0,0 +1,101 @@ +

Loading instance statistics...

+ +
+
Local
+ +
+
+
+
+

{{ serverStats.totalUsers }}

+

users

+
+ +
+
+ +
+
+
+

{{ serverStats.totalLocalVideos }}

+

videos

+
+ +
+
+ +
+
+
+

{{ serverStats.totalLocalVideoViews }}

+

videos views

+
+ +
+
+ +
+
+
+

{{ serverStats.totalLocalVideoComments }}

+

videos comments

+
+ +
+
+ +
+
+
+

{{ serverStats.totalLocalVideoFilesSize | bytes:1 }}

+

of hosted video

+
+ +
+
+
+ +
Federation
+ +
+
+
+
+

{{ serverStats.totalVideos }}

+

videos

+
+ +
+
+ +
+
+
+

{{ serverStats.totalVideoComments }}

+

videos comments

+
+ +
+
+ +
+
+
+

{{ serverStats.totalInstanceFollowers }}

+

followers

+
+ +
+
+ +
+
+
+

{{ serverStats.totalInstanceFollowing }}

+

following

+
+ +
+
+
+
diff --git a/client/src/app/shared/instance/instance-statistics.component.scss b/client/src/app/shared/instance/instance-statistics.component.scss new file mode 100644 index 000000000..63f8911f6 --- /dev/null +++ b/client/src/app/shared/instance/instance-statistics.component.scss @@ -0,0 +1,35 @@ +.stat { + text-align: center; + margin-bottom: 1em; + overflow: hidden; + + .stat-value { + font-size: 2.25em; + line-height: 1em; + margin: 0; + } + + .stat-label { + font-size: 1.15em; + margin: 0; + } + + .glyphicon { + opacity: 0.12; + position: absolute; + left: 16px; + top: -24px; + + &.icon-bottom { + top: 4px; + } + + &::before { + font-size: 8em; + } + } + + .card-body { + z-index: 2; + } +} diff --git a/client/src/app/shared/instance/instance-statistics.component.ts b/client/src/app/shared/instance/instance-statistics.component.ts new file mode 100644 index 000000000..8ec728f05 --- /dev/null +++ b/client/src/app/shared/instance/instance-statistics.component.ts @@ -0,0 +1,37 @@ +import { map } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Component, OnInit } from '@angular/core' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { ServerStats } from '@shared/models/server' +import { environment } from '../../../environments/environment' + +@Component({ + selector: 'my-instance-statistics', + templateUrl: './instance-statistics.component.html', + styleUrls: [ './instance-statistics.component.scss' ] +}) +export class InstanceStatisticsComponent implements OnInit { + private static BASE_STATS_URL = environment.apiUrl + '/api/v1/server/stats' + + serverStats: ServerStats = null + + constructor ( + private http: HttpClient, + private i18n: I18n + ) { + } + + ngOnInit () { + this.getStats() + .subscribe( + res => { + this.serverStats = res + } + ) + } + + getStats () { + return this.http + .get(InstanceStatisticsComponent.BASE_STATS_URL) + } +} diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 65e0f21a4..f6991a66d 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -61,6 +61,7 @@ import { } from '@ng-bootstrap/ng-bootstrap' import { RemoteSubscribeComponent, SubscribeButtonComponent, UserSubscriptionService } from '@app/shared/user-subscription' import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-features-table.component' +import { InstanceStatisticsComponent } from '@app/shared/instance/instance-statistics.component' import { OverviewService } from '@app/shared/overview' import { UserBanModalComponent } from '@app/shared/moderation' import { UserModerationDropdownComponent } from '@app/shared/moderation/user-moderation-dropdown.component' @@ -157,6 +158,7 @@ import { FeatureBooleanComponent } from '@app/shared/instance/feature-boolean.co SubscribeButtonComponent, RemoteSubscribeComponent, InstanceFeaturesTableComponent, + InstanceStatisticsComponent, FeatureBooleanComponent, UserBanModalComponent, UserModerationDropdownComponent, @@ -224,6 +226,7 @@ import { FeatureBooleanComponent } from '@app/shared/instance/feature-boolean.co SubscribeButtonComponent, RemoteSubscribeComponent, InstanceFeaturesTableComponent, + InstanceStatisticsComponent, UserBanModalComponent, UserModerationDropdownComponent, TopMenuDropdownComponent,