mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-15 19:45:59 +08:00
Fix launching upload if no file selected
Add moving progress bar when uploading Add meter bar for disk occupation Add better hide parameter
This commit is contained in:
parent
4996066c0f
commit
78ff239f93
@ -39,7 +39,7 @@ $SUCCESS_MSG$
|
||||
<div class="panel-heading">Filesystem</div>
|
||||
<div class="panel-body">
|
||||
<input type="file" id="file-select" name="myfiles[]" multiple />
|
||||
<input class="btn btn-primary" type="button" id="upload-button" onclick="Sendfile();" value="Upload"/><br><br>
|
||||
<input class="btn btn-primary" type="button" id="upload-button" onclick="Sendfile();" value="Upload"/> <progress style="visibility:hidden;" name='prg' id='prg'></progress>
|
||||
<table class="table table-striped" style="border:1px;solid #dddddd;margin-bottom:20px;" ><thead><tr><th>Name</th><th>size</th><th width='0%'></th></tr></thead><tbody id="file_list"><tbody></table>
|
||||
<label class="text-info" id="status"></label>
|
||||
</div>
|
||||
@ -51,7 +51,8 @@ var content ="";
|
||||
content ="Status: "+jsonresponse.status;
|
||||
content +=" Total space: "+jsonresponse.total;
|
||||
content +=" Used space: "+jsonresponse.used;
|
||||
content +=" Occupation: "+jsonresponse.occupation;
|
||||
content +=" Occupation: ";
|
||||
content +="<meter min='0' max='100' high='90' value='"+jsonresponse.occupation +"'></meter>"+jsonresponse.occupation +"%";
|
||||
document.getElementById('status').innerHTML=content;
|
||||
content ="";
|
||||
for (var i=0;i <jsonresponse.files.length;i++){
|
||||
@ -82,8 +83,10 @@ xmlhttp.open("GET", url, true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
function Sendfile(){
|
||||
document.getElementById('upload-button').value = "Uploading...";
|
||||
var files = document.getElementById('file-select').files;
|
||||
if (files.length==0)return;
|
||||
document.getElementById('upload-button').value = "Uploading...";
|
||||
document.getElementById('prg').style.visibility = "visible";
|
||||
var formData = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = files[i];
|
||||
@ -93,6 +96,7 @@ xmlhttp.open('POST', '/FILES', true);
|
||||
xmlhttp.onload = function () {
|
||||
if (xmlhttp.status === 200) {
|
||||
document.getElementById('upload-button').value = 'Upload';
|
||||
document.getElementById('prg').style.visibility = "hidden";
|
||||
document.getElementById('file-select').value="";
|
||||
var jsonresponse = JSON.parse(xmlhttp.responseText);
|
||||
dispatchstatus(jsonresponse);
|
||||
|
@ -63,7 +63,7 @@ const char VALUE_CONNECTION_FAILED2[] PROGMEM = "Connection failed! (Wrong Passw
|
||||
const char VALUE_IDLE[] PROGMEM = "Idle";
|
||||
const char VALUE_DISCONNECTED[] PROGMEM = "Disconnected";
|
||||
const char VALUE_ITEM_VISIBLE[] PROGMEM = "visibility:visible;";
|
||||
const char VALUE_ITEM_HIDDEN[] PROGMEM ="visibility:hidden;height:0px;width:0px;";
|
||||
const char VALUE_ITEM_HIDDEN[] PROGMEM ="visibility:hidden;height:0px;width:0px;padding:0px";
|
||||
const char KEY_IP[] PROGMEM ="$IP$";
|
||||
const char KEY_WEB_ADDRESS[] PROGMEM ="$WEB_ADDRESS$";
|
||||
const char KEY_HOSTNAME[] PROGMEM ="$HOSTNAME$";
|
||||
@ -2402,7 +2402,7 @@ void handleFileList() {
|
||||
jsonfile+="\"used\":\"" + formatBytes(used) + "\",";
|
||||
jsonfile+="\"occupation\":\"" ;
|
||||
jsonfile+= intTostr(100*used/total);
|
||||
jsonfile+="%\"";
|
||||
jsonfile+="\"";
|
||||
jsonfile+="}";
|
||||
path = "";
|
||||
web_interface->WebServer.send(200, "application/json", jsonfile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user