Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restored sending system config when device config is requested. #393

Merged
merged 4 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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