5050 font-size : 12px ;
5151 margin-top : 6px ;
5252 }
53+ # db-size {
54+ color : # 9ca3af ;
55+ font-size : 12px ;
56+ }
5357 # vehicle-detail {
5458 margin-top : 10px ;
5559 padding-top : 10px ;
@@ -164,6 +168,7 @@ <h3>Where the Plow</h3>
164168 < button id ="btn-coverage "> Coverage</ button >
165169 </ div >
166170 < div id ="vehicle-count "> Loading vehicles...</ div >
171+ < div id ="db-size "> </ div >
167172 < div id ="vehicle-detail ">
168173 < span class ="detail-close " id ="detail-close "> ×</ span >
169174 < div class ="detail-name " id ="detail-name "> </ div >
@@ -214,10 +219,24 @@ <h3>Where the Plow</h3>
214219 return VEHICLE_COLORS [ type ] || DEFAULT_COLOR ;
215220 }
216221
222+ function formatBytes ( bytes ) {
223+ if ( bytes === null || bytes === undefined ) return '' ;
224+ if ( bytes < 1024 ) return bytes + ' B' ;
225+ if ( bytes < 1024 * 1024 ) return ( bytes / 1024 ) . toFixed ( 1 ) + ' KB' ;
226+ if ( bytes < 1024 * 1024 * 1024 ) return ( bytes / ( 1024 * 1024 ) ) . toFixed ( 1 ) + ' MB' ;
227+ return ( bytes / ( 1024 * 1024 * 1024 ) ) . toFixed ( 1 ) + ' GB' ;
228+ }
229+
217230 function updateVehicleCount ( data ) {
218231 const count = data . features ? data . features . length : 0 ;
219232 document . getElementById ( 'vehicle-count' ) . textContent =
220233 count + ' vehicle' + ( count !== 1 ? 's' : '' ) + ' tracked' ;
234+ fetch ( '/stats' ) . then ( r => r . json ( ) ) . then ( stats => {
235+ if ( stats . db_size_bytes ) {
236+ document . getElementById ( 'db-size' ) . textContent =
237+ formatBytes ( stats . db_size_bytes ) + ' of data' ;
238+ }
239+ } ) . catch ( ( ) => { } ) ;
221240 }
222241
223242 async function fetchVehicles ( ) {
@@ -464,6 +483,7 @@ <h3>Where the Plow</h3>
464483 map . setLayoutProperty ( 'vehicle-circles' , 'visibility' , 'visible' ) ;
465484 }
466485 document . getElementById ( 'vehicle-count' ) . style . display = '' ;
486+ document . getElementById ( 'db-size' ) . style . display = '' ;
467487 startAutoRefresh ( ) ;
468488 }
469489
@@ -477,6 +497,7 @@ <h3>Where the Plow</h3>
477497 map . setLayoutProperty ( 'vehicle-circles' , 'visibility' , 'none' ) ;
478498 }
479499 document . getElementById ( 'vehicle-count' ) . style . display = 'none' ;
500+ document . getElementById ( 'db-size' ) . style . display = 'none' ;
480501 coveragePanelEl . style . display = 'block' ;
481502 coverageLoading . style . display = 'block' ;
482503 timeSlider . value = 1000 ;
0 commit comments