Merge pull request #3940 from RKBoss6/StoragwAnalyser

[Storage Analyser] Fix total storage pie chart
master
Rob Pilling 2025-07-23 08:29:10 +01:00 committed by GitHub
commit 2cc5a9bd21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 10 deletions

View File

@ -1,2 +1,3 @@
0.01: New App! 0.01: New App!
0.02: Added pie chart for visualization, tweaked UI. 0.02: Added pie chart for visualization, tweaked UI.
0.03: Fixed bug with total storage pie chart.

View File

@ -61,7 +61,9 @@
drawTable(); drawTable();
}); });
} }
function roundDecimal(num){
return Math.round(num * 10) / 10;
}
function drawTable() { function drawTable() {
document.getElementById("storageTable").innerHTML = ` document.getElementById("storageTable").innerHTML = `
<table class="table table-striped"> <table class="table table-striped">
@ -91,12 +93,12 @@
// App-specific chart // App-specific chart
const chartData = [ const chartData = [
['App', 'Total Size (KB)'] ['App', 'Total Size (KB)']
].concat(globalApps.map(app => [app[0], (app[1] + app[2])/1000])); ].concat(globalApps.map(app => [app[0], roundDecimal((app[1] + app[2])/1000)]));
const data = google.visualization.arrayToDataTable(chartData); const data = google.visualization.arrayToDataTable(chartData);
const options = { const options = {
title: 'App Storage Breakdown', title: 'App Storage Breakdown (KBs)',
chartArea: { width: '90%', height: '80%' }, chartArea: { width: '90%', height: '80%' },
legend: { position: 'bottom' } legend: { position: 'bottom' }
}; };
@ -106,17 +108,19 @@
// Total storage chart // Total storage chart
if (storageStats) { if (storageStats) {
const usedKB = storageStats.usedBytes / 1000; const usedKB = roundDecimal(storageStats.fileBytes / 1000);
const freeKB = storageStats.freeBytes / 1000; const freeKB = roundDecimal(storageStats.freeBytes / 1000);
const trashKB = roundDecimal(storageStats.trashBytes / 1000);
const totalData = google.visualization.arrayToDataTable([ const totalData = google.visualization.arrayToDataTable([
['Type', 'KB'], ['Type', 'KB'],
['Used', usedKB], ['Used', usedKB],
['Free', freeKB] ['Free', freeKB],
['Trash', trashKB],
]); ]);
const totalOptions = { const totalOptions = {
title: 'Total Storage Usage', title: 'Total Storage Usage (KBs)',
pieHole: 0.4,
chartArea: { width: '90%', height: '80%' }, chartArea: { width: '90%', height: '80%' },
legend: { position: 'bottom' } legend: { position: 'bottom' }
}; };

View File

@ -1,7 +1,7 @@
{ {
"id": "storageanalyzer", "id": "storageanalyzer",
"name": "Storage Analyzer", "name": "Storage Analyzer",
"version": "0.02", "version": "0.03",
"description": "Analyzes Bangle.js storage and shows which apps are using storage space", "description": "Analyzes Bangle.js storage and shows which apps are using storage space",
"icon": "icon.png", "icon": "icon.png",
"type": "RAM", "type": "RAM",