fix up/download scheduler files

This commit is contained in:
MichaelDvP
2023-03-22 17:33:34 +01:00
parent a5d2beb3e7
commit aea2277e26
4 changed files with 20 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ WebAPIService::WebAPIService(AsyncWebServer * server, SecurityManager * security
server->on(GET_CUSTOMIZATIONS_PATH,
HTTP_GET,
securityManager->wrapRequest(std::bind(&WebAPIService::getCustomizations, this, _1), AuthenticationPredicates::IS_ADMIN));
server->on(GET_SCHEDULE_PATH, HTTP_GET, securityManager->wrapRequest(std::bind(&WebAPIService::getSchedule, this, _1), AuthenticationPredicates::IS_ADMIN));
}
// HTTP GET
@@ -196,4 +197,16 @@ void WebAPIService::getCustomizations(AsyncWebServerRequest * request) {
request->send(response);
}
void WebAPIService::getSchedule(AsyncWebServerRequest * request) {
auto * response = new AsyncJsonResponse(false, FS_BUFFER_SIZE);
JsonObject root = response->getRoot();
root["type"] = "schedule";
System::extractSettings(EMSESP_SCHEDULER_FILE, "Schedule", root, FS_BUFFER_SIZE);
response->setLength();
request->send(response);
}
} // namespace emsesp

View File

@@ -22,6 +22,7 @@
#define EMSESP_API_SERVICE_PATH "/api"
#define GET_SETTINGS_PATH "/rest/getSettings"
#define GET_CUSTOMIZATIONS_PATH "/rest/getCustomizations"
#define GET_SCHEDULE_PATH "/rest/getSchedule"
namespace emsesp {
@@ -51,6 +52,7 @@ class WebAPIService {
void getSettings(AsyncWebServerRequest * request);
void getCustomizations(AsyncWebServerRequest * request);
void getSchedule(AsyncWebServerRequest * request);
};
} // namespace emsesp