mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix up/download scheduler files
This commit is contained in:
@@ -69,7 +69,7 @@ const GeneralFileUpload: FC<UploadFileProps> = ({ uploadGeneralFile }) => {
|
||||
|
||||
const downloadSchedule = async () => {
|
||||
try {
|
||||
const response = await EMSESP.readSchedule();
|
||||
const response = await EMSESP.getSchedule();
|
||||
if (response.status !== 200) {
|
||||
toast.error(LL.PROBLEM_LOADING());
|
||||
} else {
|
||||
|
||||
@@ -96,6 +96,10 @@ export function getCustomizations(): AxiosPromise<void> {
|
||||
return AXIOS.get('/getCustomizations');
|
||||
}
|
||||
|
||||
export function getSchedule(): AxiosPromise<Schedule> {
|
||||
return AXIOS.get('/getSchedule');
|
||||
}
|
||||
|
||||
export function readSchedule(): AxiosPromise<Schedule> {
|
||||
return AXIOS.get('/schedule');
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user