From bfded9bbccec51b9ecfc923b0007661fe0a6149a Mon Sep 17 00:00:00 2001
From: btsimonh
Date: Sun, 2 Jul 2023 19:11:49 +0100
Subject: [PATCH 1/3] Remove recursion into folders on Manage Files. May be
enabled with UFILESYS_RECURSEFOLDERS_GUI. On Edit of a file, Save and Magane
btuttons return to the folder containgint the file being edited. On delete
file, UI returns to the folder that the deleted file was in.
---
.../xdrv_50_filesystem.ino | 33 +++++++++++++++----
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
index d3d0acbd72cc..775fa533e5bf 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
@@ -608,7 +608,7 @@ void UFSRun(void) {
#ifdef USE_WEBSERVER
const char UFS_WEB_DIR[] PROGMEM =
- "
";
+ ""
@@ -655,7 +655,7 @@ const char UFS_FORM_SDC_HREF[] PROGMEM =
#ifdef GUI_TRASH_FILE
const char UFS_FORM_SDC_HREFdel[] PROGMEM =
//"
🗑"; // 🗑️
- "
🔥"; // 🔥
+ "
🔥"; // 🔥
#endif // GUI_TRASH_FILE
#ifdef GUI_EDIT_FILE
@@ -823,6 +823,7 @@ void UfsListDir(char *path, uint8_t depth) {
if (entry.isDirectory()) {
ext_snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, ppe, epe);
WSContentSend_P(UFS_FORM_SDC_DIRd, npath, ep, name);
+#ifdef UFILESYS_RECURSEFOLDERS_GUI
uint8_t plen = strlen(path);
if (plen > 1) {
strcat(path, "/");
@@ -830,10 +831,11 @@ void UfsListDir(char *path, uint8_t depth) {
strcat(path, ep);
UfsListDir(path, depth + 4);
path[plen] = 0;
+#endif
} else {
#ifdef GUI_TRASH_FILE
- char delpath[128];
- ext_snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, ppe, epe);
+ char delpath[128+UFS_FILENAME_SIZE];
+ ext_snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, ppe, epe, ppe);
#else
char delpath[2];
delpath[0]=0;
@@ -1065,7 +1067,14 @@ void UfsEditor(void) {
}
WSContentSend_P(HTTP_EDITOR_FORM_END);
- WSContentSend_P(UFS_WEB_DIR, PSTR(D_MANAGE_FILE_SYSTEM));
+ for (int i = strlen(fname)-1; i >= 0; i--){
+ if (fname[i] == '/'){
+ fname[i] = 0;
+ break;
+ }
+ }
+
+ WSContentSend_P(UFS_WEB_DIR, fname, PSTR(D_MANAGE_FILE_SYSTEM));
WSContentStop();
}
@@ -1119,7 +1128,17 @@ void UfsEditorUpload(void) {
fp.close();
- Webserver->sendHeader(F("Location"),F("/ufsu"));
+ for (int i = strlen(fname)-1; i >= 0; i--){
+ if (fname[i] == '/'){
+ fname[i] = 0;
+ break;
+ }
+ }
+
+ char t[20+UFS_FILENAME_SIZE] = "/ufsu?download=";
+ strcat(t, fname);
+ Webserver->sendHeader(F("Location"), t);
+
Webserver->send(303);
}
@@ -1160,7 +1179,7 @@ bool Xdrv50(uint32_t function) {
if (XdrvMailbox.index) {
XdrvMailbox.index++;
} else {
- WSContentSend_PD(UFS_WEB_DIR, PSTR(D_MANAGE_FILE_SYSTEM));
+ WSContentSend_PD(UFS_WEB_DIR, "/", PSTR(D_MANAGE_FILE_SYSTEM));
}
}
break;
From 7986deb17b71a9bf214d5e3019138fe7161be4a9 Mon Sep 17 00:00:00 2001
From: btsimonh
Date: Mon, 3 Jul 2023 08:22:15 +0100
Subject: [PATCH 2/3] Make newfile put in in the current folder, and return to
current folder on save of manage button.
---
tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
index 775fa533e5bf..62f03ab45883 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
@@ -632,7 +632,7 @@ const char UFS_FORM_SDC_DIRa[] PROGMEM =
const char UFS_FORM_SDC_DIRc[] PROGMEM =
" ";
const char UFS_FORM_FILE_UPGb[] PROGMEM =
- "