|
24 | 24 | <script> |
25 | 25 | let globalApps = []; |
26 | 26 | let storageStats = null; |
27 | | - |
| 27 | + |
28 | 28 | function onInit(device) { |
29 | 29 | Util.showModal("Reading Storage..."); |
30 | 30 | Puck.eval(`(()=>{ |
|
61 | 61 | drawTable(); |
62 | 62 | }); |
63 | 63 | } |
64 | | - |
| 64 | + function roundDecimal(num){ |
| 65 | + return Math.round(num * 10) / 10; |
| 66 | + } |
65 | 67 | function drawTable() { |
66 | 68 | document.getElementById("storageTable").innerHTML = ` |
67 | 69 | <table class="table table-striped"> |
|
91 | 93 | // App-specific chart |
92 | 94 | const chartData = [ |
93 | 95 | ['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)])); |
95 | 97 |
|
96 | 98 | const data = google.visualization.arrayToDataTable(chartData); |
97 | 99 |
|
98 | 100 | const options = { |
99 | | - title: 'App Storage Breakdown', |
| 101 | + title: 'App Storage Breakdown (KBs)', |
100 | 102 | chartArea: { width: '90%', height: '80%' }, |
101 | 103 | legend: { position: 'bottom' } |
102 | 104 | }; |
|
106 | 108 |
|
107 | 109 | // Total storage chart |
108 | 110 | 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); |
111 | 114 | const totalData = google.visualization.arrayToDataTable([ |
112 | 115 | ['Type', 'KB'], |
113 | 116 | ['Used', usedKB], |
114 | | - ['Free', freeKB] |
| 117 | + ['Free', freeKB], |
| 118 | + ['Trash', trashKB], |
115 | 119 | ]); |
116 | 120 |
|
117 | 121 | const totalOptions = { |
118 | | - title: 'Total Storage Usage', |
119 | | - pieHole: 0.4, |
| 122 | + title: 'Total Storage Usage (KBs)', |
| 123 | + |
120 | 124 | chartArea: { width: '90%', height: '80%' }, |
121 | 125 | legend: { position: 'bottom' } |
122 | 126 | }; |
|
0 commit comments