Skip to content

Commit

Permalink
Restored SD file deletion functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMueller2003 committed Aug 22, 2023
1 parent 634215c commit 0816257
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
19 changes: 18 additions & 1 deletion ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ void c_WebMgr::init ()
}
});

// ping handler
webServer.on ("/files", HTTP_GET | HTTP_OPTIONS, [](AsyncWebServerRequest* request)
{
// DEBUG_V("files");
Expand All @@ -259,6 +258,24 @@ void c_WebMgr::init ()
}
});

webServer.on ("/file/delete", HTTP_POST | HTTP_OPTIONS, [](AsyncWebServerRequest* request)
{
// DEBUG_V("/file/delete");
// DEBUG_V(String("URL: ") + request->url());
if(HTTP_OPTIONS == request->method())
{
request->send (200);
}
else
{
// DEBUG_V (String ("url: ") + String (request->url ()));
String filename = request->url ().substring (String ("/file/delete").length ());
// DEBUG_V (String ("filename: ") + String (filename));
FileMgr.DeleteSdFile(filename);
request->send (200);
}
});

// JSON Config Handler
webServer.on ("/conf", HTTP_PUT | HTTP_POST | HTTP_OPTIONS,
[this](AsyncWebServerRequest* request)
Expand Down
9 changes: 4 additions & 5 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,16 @@ function ProcessGetFileListResponse(JsonConfigData) {
} // ProcessGetFileListResponse

function RequestFileDeletion() {
let files = [];

$('#FileManagementTable > tr').each(function (CurRowId) {
if (true === $('#FileSelected_' + CurRowId).prop("checked")) {
let FileEntry = {};
FileEntry["name"] = $('#FileName_' + CurRowId).val().toString();
files.push(FileEntry);
let name = $('#FileName_' + CurRowId).val().toString();
console.info("delete file: " + name);
let Response = SendCommand('file/delete/' + name);
// console.info("delete Response: " + Response);
}
});

// TOBERESTORED wsEnqueue(JSON.stringify({ 'cmd': { 'delete': { 'files': files } } }));
RequestListOfFiles();

} // RequestFileDeletion
Expand Down

0 comments on commit 0816257

Please sign in to comment.