@@ -1455,6 +1455,14 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
14551455 class ="label d-flex position-absolute flex-column align-self-center text-center w-100 text-nowrap text-light ">
14561456 </ div >
14571457 </ div >
1458+ < div id ="sdCapacity " class ="mt-3 " data-visible ="false ">
1459+ < small > < span data-i18n ="files.storage.title "> </ span > : < span
1460+ id ="sdCapacityText "> </ span > </ small >
1461+ < div class ="progress progress-sm ">
1462+ < div id ="sdCapacityBar " class ="progress-bar " role ="progressbar " aria-valuemin ="0 "
1463+ aria-valuemax ="100 "> </ div >
1464+ </ div >
1465+ </ div >
14581466 </ div >
14591467 </ div >
14601468 </ fieldset >
@@ -2388,6 +2396,7 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
23882396 } ) ;
23892397 i18next . on ( 'languageChanged' , ( lng ) => {
23902398 document . querySelector ( '#langSel' ) . value = lng ;
2399+ refreshSdCapacity ( ) ;
23912400 if ( localize ) {
23922401 localize ( 'body' ) ;
23932402 // (re)initialize all popover buttons to get correct translations in the popovers
@@ -2771,6 +2780,7 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
27712780 addFileDirectory ( sel , data ) ;
27722781 ref . open_node ( sel ) ;
27732782 } ) ;
2783+ refreshSdCapacity ( ) ;
27742784 } ,
27752785 error : function ( request , status , error ) {
27762786 console . log ( "Upload ERROR!" , request ) ;
@@ -4250,6 +4260,28 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
42504260 }
42514261 return dDisplay + hDisplay + mDisplay ;
42524262 }
4263+ async function refreshSdCapacity ( ) {
4264+ try {
4265+ const info = await ( await fetch ( "http://" + host + "/info?section=sdcard" ) ) . json ( ) ;
4266+ const sd = info . sdcard ;
4267+ if ( ! sd || ! sd . size ) {
4268+ return ;
4269+ }
4270+ const usedPercent = Math . round ( ( sd . size - sd . free ) * 100 / sd . size ) ;
4271+ const bar = document . getElementById ( 'sdCapacityBar' ) ;
4272+ bar . style . width = usedPercent + "%" ;
4273+ bar . setAttribute ( 'aria-valuenow' , usedPercent ) ;
4274+ document . getElementById ( 'sdCapacityText' ) . textContent = i18next . t ( "files.storage.info" , {
4275+ free : ( sd . free / 1024 ) . toFixed ( 1 ) ,
4276+ total : ( sd . size / 1024 ) . toFixed ( 1 ) ,
4277+ percent : usedPercent
4278+ } ) ;
4279+ document . getElementById ( 'sdCapacity' ) . setAttribute ( 'data-visible' , true ) ;
4280+ } catch ( e ) {
4281+ console . log ( "failed to fetch sd capacity" , e ) ;
4282+ }
4283+ }
4284+
42534285 async function fetchInfo ( ) {
42544286 let info = await ( await fetch ( "http://" + host + "/info" ) ) . json ( ) ;
42554287 console . log ( info ) ;
@@ -4297,6 +4329,12 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
42974329 audiotimesincestart : timestampToDuration ( info . audio . playtimeSinceStart , true )
42984330 } ) + "<br>" ;
42994331 }
4332+ if ( info . sdcard && info . sdcard . size ) {
4333+ content += i18next . t ( "systeminfo.sdcard" , {
4334+ free : ( info . sdcard . free / 1024 ) . toFixed ( 1 ) ,
4335+ total : ( info . sdcard . size / 1024 ) . toFixed ( 1 )
4336+ } ) + "<br>" ;
4337+ }
43004338 if ( info . battery ) {
43014339 content += i18next . t ( "systeminfo.currvoltage" , {
43024340 currvoltage : info . battery . currVoltage . toFixed ( 2 )
0 commit comments