mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
remove /rest/fetchLog
This commit is contained in:
@@ -15,7 +15,6 @@ export const readLogSettings = () =>
|
|||||||
alovaInstance.Get<LogSettings>(`/rest/logSettings`);
|
alovaInstance.Get<LogSettings>(`/rest/logSettings`);
|
||||||
export const updateLogSettings = (data: LogSettings) =>
|
export const updateLogSettings = (data: LogSettings) =>
|
||||||
alovaInstance.Post('/rest/logSettings', data);
|
alovaInstance.Post('/rest/logSettings', data);
|
||||||
export const fetchLog = () => alovaInstance.Post('/rest/fetchLog');
|
|
||||||
export const fetchLogES = () => alovaInstance.Get('/es/log');
|
export const fetchLogES = () => alovaInstance.Get('/es/log');
|
||||||
|
|
||||||
// Get versions from github
|
// Get versions from github
|
||||||
|
|||||||
@@ -6,12 +6,7 @@ import WarningIcon from '@mui/icons-material/Warning';
|
|||||||
import { Box, Button, Checkbox, MenuItem, TextField, styled } from '@mui/material';
|
import { Box, Button, Checkbox, MenuItem, TextField, styled } from '@mui/material';
|
||||||
import Grid from '@mui/material/Grid2';
|
import Grid from '@mui/material/Grid2';
|
||||||
|
|
||||||
import {
|
import { fetchLogES, readLogSettings, updateLogSettings } from 'api/system';
|
||||||
fetchLog,
|
|
||||||
fetchLogES,
|
|
||||||
readLogSettings,
|
|
||||||
updateLogSettings
|
|
||||||
} from 'api/system';
|
|
||||||
|
|
||||||
import { useRequest, useSSE } from 'alova/client';
|
import { useRequest, useSSE } from 'alova/client';
|
||||||
import {
|
import {
|
||||||
@@ -98,17 +93,16 @@ const SystemLog = () => {
|
|||||||
useSSE(fetchLogES, {
|
useSSE(fetchLogES, {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
interceptByGlobalResponded: false
|
interceptByGlobalResponded: false
|
||||||
}).onMessage((message: { id: number; data: string }) => {
|
})
|
||||||
|
.onMessage((message: { id: number; data: string }) => {
|
||||||
const rawData = message.data;
|
const rawData = message.data;
|
||||||
const logentry = JSON.parse(rawData) as LogEntry;
|
const logentry = JSON.parse(rawData) as LogEntry;
|
||||||
setLogEntries((log) => [...log, logentry]);
|
setLogEntries((log) => [...log, logentry]);
|
||||||
}).onError(() => {
|
})
|
||||||
|
.onError(() => {
|
||||||
toast.error('No connection to Log service');
|
toast.error('No connection to Log service');
|
||||||
});
|
});
|
||||||
|
|
||||||
// called on page load to reset pointer and fetch all log entries
|
|
||||||
useRequest(fetchLog());
|
|
||||||
|
|
||||||
const paddedLevelLabel = (level: LogLevel) => {
|
const paddedLevelLabel = (level: LogLevel) => {
|
||||||
const label = levelLabel(level);
|
const label = levelLabel(level);
|
||||||
return data?.compact ? ' ' + label[0] : label.padStart(8, '\xa0');
|
return data?.compact ? ' ' + label[0] : label.padStart(8, '\xa0');
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ let log_settings = {
|
|||||||
compact: true,
|
compact: true,
|
||||||
psram: true
|
psram: true
|
||||||
};
|
};
|
||||||
const FETCH_LOG_ENDPOINT = REST_ENDPOINT_ROOT + 'fetchLog';
|
|
||||||
|
|
||||||
// NTP
|
// NTP
|
||||||
const NTP_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'ntpStatus';
|
const NTP_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'ntpStatus';
|
||||||
@@ -4097,9 +4096,6 @@ const emsesp_deviceentities_none = [
|
|||||||
|
|
||||||
// LOG
|
// LOG
|
||||||
router
|
router
|
||||||
.post(FETCH_LOG_ENDPOINT, () => {
|
|
||||||
return status(200);
|
|
||||||
})
|
|
||||||
.get(LOG_SETTINGS_ENDPOINT, () => log_settings)
|
.get(LOG_SETTINGS_ENDPOINT, () => log_settings)
|
||||||
.post(LOG_SETTINGS_ENDPOINT, async (request: any) => {
|
.post(LOG_SETTINGS_ENDPOINT, async (request: any) => {
|
||||||
log_settings = await request.json();
|
log_settings = await request.json();
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ WebLogService::WebLogService(AsyncWebServer * server, SecurityManager * security
|
|||||||
// get & set settings
|
// get & set settings
|
||||||
server->on(EMSESP_LOG_SETTINGS_PATH, [this](AsyncWebServerRequest * request, JsonVariant json) { getSetValues(request, json); });
|
server->on(EMSESP_LOG_SETTINGS_PATH, [this](AsyncWebServerRequest * request, JsonVariant json) { getSetValues(request, json); });
|
||||||
|
|
||||||
// for bring back the whole log - is a command, hence a POST
|
|
||||||
server->on(EMSESP_FETCH_LOG_PATH, HTTP_POST, [this](AsyncWebServerRequest * request) { fetchLog(request); });
|
|
||||||
|
|
||||||
// events_.setFilter(securityManager->filterRequest(AuthenticationPredicates::IS_ADMIN));
|
// events_.setFilter(securityManager->filterRequest(AuthenticationPredicates::IS_ADMIN));
|
||||||
server->addHandler(&events_);
|
server->addHandler(&events_);
|
||||||
}
|
}
|
||||||
@@ -236,13 +233,6 @@ void WebLogService::transmit(const QueuedLogMessage & message) {
|
|||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the complete log buffer to the API, not filtering on log level
|
|
||||||
// done by resetting the pointer
|
|
||||||
void WebLogService::fetchLog(AsyncWebServerRequest * request) {
|
|
||||||
log_message_id_tail_ = 0;
|
|
||||||
request->send(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the values after a POST
|
// sets the values after a POST
|
||||||
void WebLogService::getSetValues(AsyncWebServerRequest * request, JsonVariant json) {
|
void WebLogService::getSetValues(AsyncWebServerRequest * request, JsonVariant json) {
|
||||||
if ((request->method() == HTTP_GET) || (!json.is<JsonObject>())) {
|
if ((request->method() == HTTP_GET) || (!json.is<JsonObject>())) {
|
||||||
@@ -256,9 +246,14 @@ void WebLogService::getSetValues(AsyncWebServerRequest * request, JsonVariant js
|
|||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|
||||||
|
// reset the tail pointer so complete log is sent
|
||||||
|
log_message_id_tail_ = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST - set the values
|
||||||
auto && body = json.as<JsonObject>();
|
auto && body = json.as<JsonObject>();
|
||||||
|
|
||||||
uuid::log::Level level = body["level"];
|
uuid::log::Level level = body["level"];
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#define WebLogService_h
|
#define WebLogService_h
|
||||||
|
|
||||||
#define EMSESP_EVENT_SOURCE_LOG_PATH "/es/log"
|
#define EMSESP_EVENT_SOURCE_LOG_PATH "/es/log"
|
||||||
#define EMSESP_FETCH_LOG_PATH "/rest/fetchLog"
|
|
||||||
#define EMSESP_LOG_SETTINGS_PATH "/rest/logSettings"
|
#define EMSESP_LOG_SETTINGS_PATH "/rest/logSettings"
|
||||||
|
|
||||||
using ::uuid::console::Shell;
|
using ::uuid::console::Shell;
|
||||||
@@ -62,7 +61,6 @@ class WebLogService : public uuid::log::Handler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void transmit(const QueuedLogMessage & message);
|
void transmit(const QueuedLogMessage & message);
|
||||||
void fetchLog(AsyncWebServerRequest * request);
|
|
||||||
void getSetValues(AsyncWebServerRequest * request, JsonVariant json);
|
void getSetValues(AsyncWebServerRequest * request, JsonVariant json);
|
||||||
|
|
||||||
char * messagetime(char * out, const uint64_t t, const size_t bufsize);
|
char * messagetime(char * out, const uint64_t t, const size_t bufsize);
|
||||||
|
|||||||
Reference in New Issue
Block a user