Merge pull request #3940 from RKBoss6/StoragwAnalyser
[Storage Analyser] Fix total storage pie chartmaster
commit
2cc5a9bd21
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<script>
|
<script>
|
||||||
let globalApps = [];
|
let globalApps = [];
|
||||||
let storageStats = null;
|
let storageStats = null;
|
||||||
|
|
||||||
function onInit(device) {
|
function onInit(device) {
|
||||||
Util.showModal("Reading Storage...");
|
Util.showModal("Reading Storage...");
|
||||||
Puck.eval(`(()=>{
|
Puck.eval(`(()=>{
|
||||||
|
|
@ -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' }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue