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.02: Added pie chart for visualization, tweaked UI.
0.03: Fixed bug with total storage pie chart.

View File

@ -24,7 +24,7 @@
<script>
let globalApps = [];
let storageStats = null;
function onInit(device) {
Util.showModal("Reading Storage...");
Puck.eval(`(()=>{
@ -61,7 +61,9 @@
drawTable();
});
}
function roundDecimal(num){
return Math.round(num * 10) / 10;
}
function drawTable() {
document.getElementById("storageTable").innerHTML = `
<table class="table table-striped">
@ -91,12 +93,12 @@
// App-specific chart
const chartData = [
['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 options = {
title: 'App Storage Breakdown',
title: 'App Storage Breakdown (KBs)',
chartArea: { width: '90%', height: '80%' },
legend: { position: 'bottom' }
};
@ -106,17 +108,19 @@
// Total storage chart
if (storageStats) {
const usedKB = storageStats.usedBytes / 1000;
const freeKB = storageStats.freeBytes / 1000;
const usedKB = roundDecimal(storageStats.fileBytes / 1000);
const freeKB = roundDecimal(storageStats.freeBytes / 1000);
const trashKB = roundDecimal(storageStats.trashBytes / 1000);
const totalData = google.visualization.arrayToDataTable([
['Type', 'KB'],
['Used', usedKB],
['Free', freeKB]
['Free', freeKB],
['Trash', trashKB],
]);
const totalOptions = {
title: 'Total Storage Usage',
pieHole: 0.4,
title: 'Total Storage Usage (KBs)',
chartArea: { width: '90%', height: '80%' },
legend: { position: 'bottom' }
};

View File

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