ActivityPub-federated video streaming platform using P2P directly in your web browser
Improve stats styling
Chocobozzzfd01f26a2555
diff --git a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.htmlindex 40aaaacce8..871afb0289 100644--- a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html@@ -10,16 +10,19 @@<div class="card stats-card"><div class="label">{{ card.label }}+@if (card.help) {- <my-help>- {{ card.help }}- </my-help>+ <my-help>{{ card.help }}</my-help>+ }+ </div>++ <div class="value">+ {{ card.value }}++ @if (card.moreInfo) {+ <div class="more-info">{{ card.moreInfo }}</div>}</div>- <div class="value">{{ card.value }}</div>- @if (card.moreInfo) {- <div class="more-info">{{ card.moreInfo }}</div>- }</div>}</div>@@ -28,7 +31,6 @@</div><div class="stats-with-date">-<div class="overall-stats"><div class="title-container mb-4"><h3 class="mb-0">{{ getViewersStatsTitle() }}</h3>@@ -47,10 +49,13 @@@for (card of overallStatCards; track card) {<div class="card stats-card"><div class="label">{{ card.label }}</div>- <div class="value">{{ card.value }}</div>- @if (card.moreInfo) {- <div class="more-info">{{ card.moreInfo }}</div>- }+ <div class="value">+ {{ card.value }}++ @if (card.moreInfo) {+ <div class="more-info">{{ card.moreInfo }}</div>+ }+ </div></div>}</div>@@ -58,28 +63,31 @@<div class="timeseries"><div ngbNav #nav="ngbNav" [activeId]="activeGraphId" (activeIdChange)="onChartChange($event)" class="nav-tabs">-@for (availableChart of availableCharts; track availableChart) {<ng-container [ngbNavItem]="availableChart.id"><a ngbNavLink><span>{{ availableChart.label }}</span></a>+<ng-template ngbNavContent><div class="chart-container">@if (chartOptions[availableChart.id]) {<p-chart- [height]="chartHeight" [width]="chartWidth"- [type]="chartOptions[availableChart.id].type" [options]="chartOptions[availableChart.id].options" [data]="chartOptions[availableChart.id].data"+ [height]="chartHeight"+ [width]="chartWidth"+ [type]="chartOptions[availableChart.id].type"+ [options]="chartOptions[availableChart.id].options"+ [data]="chartOptions[availableChart.id].data"[plugins]="chartPlugins"></p-chart>}</div>+<div class="zoom-container">- @if (!hasZoom() && availableChart.zoomEnabled) {- <span i18n class="description">You can select a part of the graph to zoom in</span>- }@if (hasZoom()) {<my-button i18n (click)="resetZoom()">Reset zoom</my-button>+ } @else if (availableChart.zoomEnabled) {+ <span i18n class="description">You can select a part of the graph to zoom in</span>}</div></ng-template>diff --git a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scss b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scssindex daac7906c4..7fa7afd842 100644--- a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scss+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scss@@ -39,24 +39,31 @@.stats-card {display: flex;justify-content: center;- align-items: center;+ align-items: flex-start;height: fit-content;min-height: 100px;min-width: 200px;- background-color: pvar(--bg-secondary-400);- margin-bottom: 15px;+ background-color: pvar(--bg-secondary-350);+ margin-bottom: 1rem;+ padding: 1rem;- @include margin-right(15px);+ @include margin-right(1rem);.label,.more-info {- font-size: 1rem;- font-weight: $font-semibold;+ color: pvar(--fg-200);++ @include font-size(14px);+ }++ .more-info {+ display: inline-block;++ @include margin-left(0.5rem);}.value {- font-size: 24px;- font-weight: $font-semibold;+ font-size: 1.5rem;}@media screen and (max-width: $mobile-view) {diff --git a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.tsindex a9c9f7ba13..2355e89bcd 100644--- a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts@@ -17,11 +17,11 @@ import {VideoStatsTimeserieMetric,VideoStatsUserAgent} from '@peertube/peertube-models'+import { SelectOptionsItem } from '@pt-types'import { ChartConfiguration, ChartData, defaults as ChartJSDefaults, ChartOptions, PluginOptionsByType, Scale, TooltipItem } from 'chart.js'import zoomPlugin from 'chartjs-plugin-zoom'import { ChartModule } from 'primeng/chart'import { Observable, of } from 'rxjs'-import { SelectOptionsItem } from '@pt-types'import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'@@ -348,52 +348,52 @@ export class VideoStatsComponent implements OnInit {private buildOverallStatCard (overallStats: VideoStatsOverall) {this.globalStatsCards = [{- label: $localize`Views`,+ label: $localize`VIEWS`,value: this.numberFormatter.transform(this.videoEdit.getVideoAttributes().views),help: $localize`A view means that someone watched the video for several seconds (10 seconds by default)`},{- label: $localize`Downloads`,+ label: $localize`DOWNLOADS`,value: this.numberFormatter.transform(this.videoEdit.getVideoAttributes().downloads)},{- label: $localize`Likes`,+ label: $localize`LIKES`,value: this.numberFormatter.transform(this.videoEdit.getVideoAttributes().likes)}]this.overallStatCards = [{- label: $localize`Average watch time`,+ label: $localize`AVERAGE WATCH TIME`,value: secondsToTime({ seconds: overallStats.averageWatchTime, format: 'locale-string' })},{- label: $localize`Total watch time`,+ label: $localize`TOTAL WATCH TIME`,value: secondsToTime({ seconds: overallStats.totalWatchTime, format: 'locale-string' })},{- label: $localize`Peak viewers`,+ label: $localize`PEAK VIEWERS`,value: this.numberFormatter.transform(overallStats.viewersPeak),moreInfo: overallStats.viewersPeak !== 0? $localize`at ${this.toMediumDate(new Date(overallStats.viewersPeakDate))}`: undefined},{- label: $localize`Unique viewers`,+ label: $localize`UNIQUE VIEWERS`,value: this.numberFormatter.transform(overallStats.totalViewers)}]if (overallStats.countries.length !== 0) {this.overallStatCards.push({- label: $localize`Countries`,+ label: $localize`COUNTRIES`,value: this.numberFormatter.transform(overallStats.countries.length)})}if (overallStats.subdivisions.length !== 0) {this.overallStatCards.push({- label: $localize`Regions`,+ label: $localize`REGIONS`,value: this.numberFormatter.transform(overallStats.subdivisions.length)})}@@ -471,6 +471,11 @@ export class VideoStatsComponent implements OnInit {responsive: true,+ // Avoid cropping the top of the y axis if max is specified: https://github.com/chartjs/Chart.js/issues/9372+ clip: this.activeGraphId === 'retention'+ ? false+ : undefined,+scales: {x: {ticks: {@@ -483,6 +488,10 @@ export class VideoStatsComponent implements OnInit {scale: this})}+ },++ grid: {+ display: false}},@@ -497,6 +506,10 @@ export class VideoStatsComponent implements OnInit {callback: function (value) {return self.formatYTick({ graphId, value, scale: this })}+ },++ grid: {+ color: getComputedStyle(document.documentElement).getPropertyValue('--bg-secondary-350')}}},@@ -541,6 +554,7 @@ export class VideoStatsComponent implements OnInit {datasets: [{data,+ tension: 0.2,borderColor: this.buildChartColor()}]@@ -600,6 +614,7 @@ export class VideoStatsComponent implements OnInit {datasets: [{data,+ tension: 0.2,borderColor: this.buildChartColor()}]