mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 13:16:45 +00:00
Show File Editor button in menu, don't allow config.json
This commit is contained in:
parent
fd82582089
commit
d18e58a26f
@ -373,7 +373,12 @@ void webHandleRoot()
|
|||||||
"</button></form></p>");
|
"</button></form></p>");
|
||||||
|
|
||||||
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
||||||
if(HASP_FS.exists(F("/edit.htm.gz")) || HASP_FS.exists(F("/edit.htm"))) {
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
bool flashfile = true;
|
||||||
|
#else
|
||||||
|
bool flashfile = false;
|
||||||
|
#endif
|
||||||
|
if(flashfile || HASP_FS.exists(F("/edit.htm.gz")) || HASP_FS.exists(F("/edit.htm"))) {
|
||||||
httpMessage += F("<p><form method='GET' action='edit.htm?file=/'><button type='submit'>" D_HTTP_FILE_BROWSER
|
httpMessage += F("<p><form method='GET' action='edit.htm?file=/'><button type='submit'>" D_HTTP_FILE_BROWSER
|
||||||
"</button></form></p>");
|
"</button></form></p>");
|
||||||
}
|
}
|
||||||
@ -903,17 +908,23 @@ bool handleFileRead(String path)
|
|||||||
if(HASP_FS.exists(pathWithGz)) path += F(".gz");
|
if(HASP_FS.exists(pathWithGz)) path += F(".gz");
|
||||||
File file = HASP_FS.open(path, "r");
|
File file = HASP_FS.open(path, "r");
|
||||||
|
|
||||||
String contentType;
|
String configFile((char*)0);
|
||||||
if(webServer.hasArg(F("download")))
|
configFile.reserve(32);
|
||||||
contentType = F("application/octet-stream");
|
configFile = String(FPSTR(FP_HASP_CONFIG_FILE));
|
||||||
else
|
|
||||||
contentType = getContentType(path);
|
if(!strncasecmp(file.name(), configFile.c_str(), configFile.length())) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String contentType;
|
||||||
|
if(webServer.hasArg(F("download")))
|
||||||
|
contentType = F("application/octet-stream");
|
||||||
|
else
|
||||||
|
contentType = getContentType(path);
|
||||||
|
|
||||||
|
webServer.streamFile(file, contentType);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
// if(path == F("/edit.htm.gz")) {
|
|
||||||
// contentType = F("text/html");
|
|
||||||
// }
|
|
||||||
webServer.streamFile(file, contentType);
|
|
||||||
file.close();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1052,9 +1063,11 @@ void handleFileList()
|
|||||||
path.clear();
|
path.clear();
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
File root = HASP_FS.open("/", FILE_READ);
|
File root = HASP_FS.open("/", FILE_READ);
|
||||||
File file = root.openNextFile();
|
File file = root.openNextFile();
|
||||||
String output = "[";
|
String output((char*)0);
|
||||||
|
output.reserve(HTTP_PAGE_SIZE);
|
||||||
|
output = "[";
|
||||||
|
|
||||||
while(file) {
|
while(file) {
|
||||||
if(output != "[") {
|
if(output != "[") {
|
||||||
@ -1078,7 +1091,10 @@ void handleFileList()
|
|||||||
webServer.send(200, PSTR("text/json"), output);
|
webServer.send(200, PSTR("text/json"), output);
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
#elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
Dir dir = HASP_FS.openDir(path);
|
Dir dir = HASP_FS.openDir(path);
|
||||||
String output = "[";
|
String output((char*)0);
|
||||||
|
output.reserve(HTTP_PAGE_SIZE);
|
||||||
|
output = "[";
|
||||||
|
|
||||||
while(dir.next()) {
|
while(dir.next()) {
|
||||||
File entry = dir.openFile("r");
|
File entry = dir.openFile("r");
|
||||||
if(output != "[") {
|
if(output != "[") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user