From 081625728cd4f6e9c3996d028b96c2c900ba7926 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 22 Aug 2023 15:39:43 -0400 Subject: [PATCH] Restored SD file deletion functionality --- ESPixelStick/src/WebMgr.cpp | 19 ++++++++++++++++++- html/script.js | 9 ++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ESPixelStick/src/WebMgr.cpp b/ESPixelStick/src/WebMgr.cpp index 682049f31..7feb0c512 100644 --- a/ESPixelStick/src/WebMgr.cpp +++ b/ESPixelStick/src/WebMgr.cpp @@ -242,7 +242,6 @@ void c_WebMgr::init () } }); - // ping handler webServer.on ("/files", HTTP_GET | HTTP_OPTIONS, [](AsyncWebServerRequest* request) { // DEBUG_V("files"); @@ -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) diff --git a/html/script.js b/html/script.js index d351e63bf..f96a19d05 100644 --- a/html/script.js +++ b/html/script.js @@ -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