mirror of https://github.com/Chocobozzz/PeerTube
Better display redundancy pies
parent
15a0e5f3b3
commit
ba8a8367e7
|
@ -90,19 +90,31 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPieData (stats: VideosRedundancyStats) {
|
buildPieData (stats: VideosRedundancyStats) {
|
||||||
const totalSize = stats.totalSize
|
if (stats.totalSize === 0) return
|
||||||
? stats.totalSize - stats.totalUsed
|
|
||||||
: stats.totalUsed
|
|
||||||
|
|
||||||
if (totalSize === 0) return
|
const totalAvailable = stats.totalSize
|
||||||
|
? stats.totalSize - stats.totalUsed
|
||||||
|
: null
|
||||||
|
|
||||||
|
const labels = [ $localize`Used (${this.bytesToHuman(stats.totalUsed)})` ]
|
||||||
|
const data = [ stats.totalUsed ]
|
||||||
|
|
||||||
|
// Not in manual strategy
|
||||||
|
if (totalAvailable) {
|
||||||
|
labels.push(
|
||||||
|
$localize`Available (${this.bytesToHuman(totalAvailable)})`
|
||||||
|
)
|
||||||
|
|
||||||
|
data.push(totalAvailable)
|
||||||
|
}
|
||||||
|
|
||||||
this.redundanciesGraphsData.push({
|
this.redundanciesGraphsData.push({
|
||||||
stats,
|
stats,
|
||||||
graphData: {
|
graphData: {
|
||||||
labels: [ $localize`Used`, $localize`Available` ],
|
labels,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
data: [ stats.totalUsed, totalSize ],
|
data,
|
||||||
backgroundColor: [
|
backgroundColor: [
|
||||||
'#FF6384',
|
'#FF6384',
|
||||||
'#36A2EB'
|
'#36A2EB'
|
||||||
|
@ -124,12 +136,7 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: (tooltip: TooltipItem<any>) => {
|
label: (tooltip: TooltipItem<any>) => {
|
||||||
let label = tooltip.label || ''
|
return tooltip.label
|
||||||
if (label) label += ': '
|
|
||||||
|
|
||||||
label += this.bytesPipe.transform(tooltip.raw as number, 1)
|
|
||||||
|
|
||||||
return label
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,4 +188,8 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
|
||||||
private saveSelectLocalStorage () {
|
private saveSelectLocalStorage () {
|
||||||
peertubeLocalStorage.setItem(VideoRedundanciesListComponent.LOCAL_STORAGE_DISPLAY_TYPE, this.displayType)
|
peertubeLocalStorage.setItem(VideoRedundanciesListComponent.LOCAL_STORAGE_DISPLAY_TYPE, this.displayType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bytesToHuman (bytes: number) {
|
||||||
|
return this.bytesPipe.transform(bytes, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue