From ba8a8367e7fde7915ae6633445bf46ebf4a9fe94 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Feb 2022 16:15:00 +0100 Subject: Better display redundancy pies --- .../video-redundancies-list.component.ts | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index c862cd250..a89603048 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -90,19 +90,31 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit } buildPieData (stats: VideosRedundancyStats) { - const totalSize = stats.totalSize + if (stats.totalSize === 0) return + + const totalAvailable = stats.totalSize ? stats.totalSize - stats.totalUsed - : stats.totalUsed + : null + + const labels = [ $localize`Used (${this.bytesToHuman(stats.totalUsed)})` ] + const data = [ stats.totalUsed ] - if (totalSize === 0) return + // Not in manual strategy + if (totalAvailable) { + labels.push( + $localize`Available (${this.bytesToHuman(totalAvailable)})` + ) + + data.push(totalAvailable) + } this.redundanciesGraphsData.push({ stats, graphData: { - labels: [ $localize`Used`, $localize`Available` ], + labels, datasets: [ { - data: [ stats.totalUsed, totalSize ], + data, backgroundColor: [ '#FF6384', '#36A2EB' @@ -124,12 +136,7 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit tooltip: { callbacks: { label: (tooltip: TooltipItem) => { - let label = tooltip.label || '' - if (label) label += ': ' - - label += this.bytesPipe.transform(tooltip.raw as number, 1) - - return label + return tooltip.label } } } @@ -181,4 +188,8 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit private saveSelectLocalStorage () { peertubeLocalStorage.setItem(VideoRedundanciesListComponent.LOCAL_STORAGE_DISPLAY_TYPE, this.displayType) } + + private bytesToHuman (bytes: number) { + return this.bytesPipe.transform(bytes, 1) + } } -- cgit v1.2.3