Skip to content

Commit

Permalink
Merge pull request #393 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Restored sending system config when device config is requested.
  • Loading branch information
forkineye committed Oct 15, 2021
2 parents 5f9262f + c039cbe commit 9c35ad0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ void c_WebMgr::processCmdGet (JsonObject & jsonCmd)
size_t bufferoffset = strlen(WebSocketFrameCollectionBuffer);
size_t BufferFreeSize = sizeof (WebSocketFrameCollectionBuffer) - bufferoffset;

if (jsonCmd[CN_get] == CN_system)
if ((jsonCmd[CN_get] == CN_system) || (jsonCmd[CN_get] == CN_device))
{
// DEBUG_V ("system");
FileMgr.ReadConfigFile (ConfigFileName,
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
<legend class="esps-legend">File Management</legend>
<div>
<a id="FileDeleteButton" class="button">Remove Selected File(s)</a>
<!-- <a id="FileUploadButton" class="button">Upload Selected File(s)</a> -->
</div>
<div>
<fieldset>
Expand Down
88 changes: 84 additions & 4 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ $(function ()
{
RequestFileDeletion();
});

/*
$('#FileUploadButton').click(function () {
RequestFileUpload();
});
*/
// Autoload tab based on URL hash
let hash = window.location.hash;
hash && $('ul.navbar-nav li a[href="' + hash + '"]').click();
Expand Down Expand Up @@ -410,9 +414,18 @@ function ProcessGetFileListResponse(JsonConfigData)
let rowPattern = '<tr>' + SelectedPattern + NamePattern + DatePattern + SizePattern + '</tr>';
$('#FileManagementTable tr:last').after(rowPattern);

$('#FileName_' + (CurrentRowId)).val(file.name);
$('#FileDate_' + (CurrentRowId)).val(new Date(file.date * 1000).toISOString());
$('#FileSize_' + (CurrentRowId)).val(file.length);
try
{
$('#FileName_' + (CurrentRowId)).val(file.name);
$('#FileDate_' + (CurrentRowId)).val(new Date(file.date * 1000).toISOString());
$('#FileSize_' + (CurrentRowId)).val(file.length);
}
catch
{
$('#FileName_' + (CurrentRowId)).val("InvalidFile");
$('#FileDate_' + (CurrentRowId)).val(new Date(0).toISOString());
$('#FileSize_' + (CurrentRowId)).val(0);
}

CurrentRowId++;
});
Expand All @@ -437,6 +450,73 @@ function RequestFileDeletion()

} // RequestFileDeletion

/*
function RequestFileUpload()
{
$('#FileManagementTable > tr').each(function (CurRowId)
{
if (true === $('#FileSelected_' + CurRowId).prop("checked"))
{
let FileName = $('#FileName_' + CurRowId).val().toString().replace(" - ", "/");
let FileLength = parseInt($('#Length_' + CurRowId).val());
let uri = "data:application/octet-stream";
console.info(" uri: " + uri);
console.info(" FileName: " + FileName);
console.info("FileLength: " + FileName);
downloadURI(uri, FileName, FileLength);
$('#FileSelected_' + CurRowId).prop("checked", false);
}
});
} // RequestFileUpload
*/
/*
async function downloadURI(uri, name, totalLength)
{
const response = await fetch('http://' + target + '/download/' + name);
.then(resp => resp.blob())
let length = response.headers.get('Content-Length');
console.info("length: " + length);
if (!length)
{
length = totalLength; // handle the error
console.info("Adjusted length: " + length);
}
console.info("response.status: " + response.status);
if (response.status >= 200 && response.status < 300)
{
let results = await response.json();
}
else
{
alert("Download '" + name + "' request was rejected by server");
}
/*
window.status = "Download '" + name + "' Started";
fetch('http://' + target + '/download/' + name)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// the filename you want
a.download = name;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
window.status = "Download '" + name + "' Complete";
})
.catch(() => alert("Download '" + name + "' Failed"));
* /
} // downloadURI
*/

function ParseParameter(name)
{
return (location.search.split(name + '=')[1] || '').split('&')[0];
Expand Down

0 comments on commit 9c35ad0

Please sign in to comment.