kopia lustrzana https://github.com/Aircoookie/WLED
Have json/cfg return live config
Rather than reading the file off disk, have the json/cfg endpoint return the live config from system state data. This can improve UI behaviour as it can never be out of date or include values that do not apply to the current firmware install.pull/4609/head
rodzic
9c8f8c645e
commit
22e2b6f3c5
|
@ -1028,7 +1028,7 @@ class LockedJsonResponse: public AsyncJsonResponse {
|
|||
void serveJson(AsyncWebServerRequest* request)
|
||||
{
|
||||
enum class json_target {
|
||||
all, state, info, state_info, nodes, effects, palettes, fxdata, networks
|
||||
all, state, info, state_info, nodes, effects, palettes, fxdata, networks, config
|
||||
};
|
||||
json_target subJson = json_target::all;
|
||||
|
||||
|
@ -1041,6 +1041,7 @@ void serveJson(AsyncWebServerRequest* request)
|
|||
else if (url.indexOf(F("palx")) > 0) subJson = json_target::palettes;
|
||||
else if (url.indexOf(F("fxda")) > 0) subJson = json_target::fxdata;
|
||||
else if (url.indexOf(F("net")) > 0) subJson = json_target::networks;
|
||||
else if (url.indexOf(F("cfg")) > 0) subJson = json_target::config;
|
||||
#ifdef WLED_ENABLE_JSONLIVE
|
||||
else if (url.indexOf("live") > 0) {
|
||||
serveLiveLeds(request);
|
||||
|
@ -1051,9 +1052,6 @@ void serveJson(AsyncWebServerRequest* request)
|
|||
request->send_P(200, FPSTR(CONTENT_TYPE_JSON), JSON_palette_names);
|
||||
return;
|
||||
}
|
||||
else if (url.indexOf(F("cfg")) > 0 && handleFileRead(request, F("/cfg.json"))) {
|
||||
return;
|
||||
}
|
||||
else if (url.length() > 6) { //not just /json
|
||||
serveJsonError(request, 501, ERR_NOT_IMPL);
|
||||
return;
|
||||
|
@ -1085,6 +1083,8 @@ void serveJson(AsyncWebServerRequest* request)
|
|||
serializeModeData(lDoc); break;
|
||||
case json_target::networks:
|
||||
serializeNetworks(lDoc); break;
|
||||
case json_target::config:
|
||||
serializeConfig(lDoc); break;
|
||||
case json_target::state_info:
|
||||
case json_target::all:
|
||||
JsonObject state = lDoc.createNestedObject("state");
|
||||
|
|
Ładowanie…
Reference in New Issue