Skip to content

Commit 2cc5a9b

Browse files
authored
Merge pull request #3940 from RKBoss6/StoragwAnalyser
[Storage Analyser] Fix total storage pie chart
2 parents 169519a + 43fd2cb commit 2cc5a9b

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

apps/storageanalyzer/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
0.01: New App!
22
0.02: Added pie chart for visualization, tweaked UI.
3+
0.03: Fixed bug with total storage pie chart.

apps/storageanalyzer/custom.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<script>
2525
let globalApps = [];
2626
let storageStats = null;
27-
27+
2828
function onInit(device) {
2929
Util.showModal("Reading Storage...");
3030
Puck.eval(`(()=>{
@@ -61,7 +61,9 @@
6161
drawTable();
6262
});
6363
}
64-
64+
function roundDecimal(num){
65+
return Math.round(num * 10) / 10;
66+
}
6567
function drawTable() {
6668
document.getElementById("storageTable").innerHTML = `
6769
<table class="table table-striped">
@@ -91,12 +93,12 @@
9193
// App-specific chart
9294
const chartData = [
9395
['App', 'Total Size (KB)']
94-
].concat(globalApps.map(app => [app[0], (app[1] + app[2])/1000]));
96+
].concat(globalApps.map(app => [app[0], roundDecimal((app[1] + app[2])/1000)]));
9597

9698
const data = google.visualization.arrayToDataTable(chartData);
9799

98100
const options = {
99-
title: 'App Storage Breakdown',
101+
title: 'App Storage Breakdown (KBs)',
100102
chartArea: { width: '90%', height: '80%' },
101103
legend: { position: 'bottom' }
102104
};
@@ -106,17 +108,19 @@
106108

107109
// Total storage chart
108110
if (storageStats) {
109-
const usedKB = storageStats.usedBytes / 1000;
110-
const freeKB = storageStats.freeBytes / 1000;
111+
const usedKB = roundDecimal(storageStats.fileBytes / 1000);
112+
const freeKB = roundDecimal(storageStats.freeBytes / 1000);
113+
const trashKB = roundDecimal(storageStats.trashBytes / 1000);
111114
const totalData = google.visualization.arrayToDataTable([
112115
['Type', 'KB'],
113116
['Used', usedKB],
114-
['Free', freeKB]
117+
['Free', freeKB],
118+
['Trash', trashKB],
115119
]);
116120

117121
const totalOptions = {
118-
title: 'Total Storage Usage',
119-
pieHole: 0.4,
122+
title: 'Total Storage Usage (KBs)',
123+
120124
chartArea: { width: '90%', height: '80%' },
121125
legend: { position: 'bottom' }
122126
};

apps/storageanalyzer/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "storageanalyzer",
33
"name": "Storage Analyzer",
4-
"version": "0.02",
4+
"version": "0.03",
55
"description": "Analyzes Bangle.js storage and shows which apps are using storage space",
66
"icon": "icon.png",
77
"type": "RAM",

0 commit comments

Comments
 (0)