Display total space, used space and % occuped

in file manager for SPIFFS
This commit is contained in:
luc 2015-10-23 11:58:07 +08:00
parent 94232ca720
commit eae00a3648
2 changed files with 15 additions and 2 deletions

View File

@ -35,7 +35,12 @@ $SUCCESS_MSG$
function dispatchstatus(jsonresponse) function dispatchstatus(jsonresponse)
{ {
var content =""; var content ="";
document.getElementById('status').innerHTML=jsonresponse.status; content ="Status: "+jsonresponse.status;
content +="  Total space: "+jsonresponse.total;
content +="  Used space: "+jsonresponse.used;
content +="  Occupation: "+jsonresponse.occupation;
document.getElementById('status').innerHTML=content;
content ="";
for (var i=0;i <jsonresponse.files.length;i++){ for (var i=0;i <jsonresponse.files.length;i++){
content +="<TR><TD style=\"cursor:hand;\" onclick=\"window.open('"+jsonresponse.files[i].name+"');\">"; content +="<TR><TD style=\"cursor:hand;\" onclick=\"window.open('"+jsonresponse.files[i].name+"');\">";
content +=jsonresponse.files[i].name; content +=jsonresponse.files[i].name;

View File

@ -2394,7 +2394,15 @@ void handleFileList() {
f.close(); f.close();
} }
jsonfile+="],"; jsonfile+="],";
jsonfile+="\"status\":\"" + status + "\""; jsonfile+="\"status\":\"" + status + "\",";
uint32_t total;
uint32_t used;
SPIFFS.info(&total,&used);
jsonfile+="\"total\":\"" + formatBytes(total) + "\",";
jsonfile+="\"used\":\"" + formatBytes(used) + "\",";
jsonfile+="\"occupation\":\"" ;
jsonfile+= intTostr(100*used/total);
jsonfile+="%\"";
jsonfile+="}"; jsonfile+="}";
path = ""; path = "";
web_interface->WebServer.send(200, "application/json", jsonfile); web_interface->WebServer.send(200, "application/json", jsonfile);