mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
onError/onMessage changes
This commit is contained in:
@@ -86,7 +86,6 @@ const SystemLog = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const [logEntries, setLogEntries] = useState<LogEntry[]>([]);
|
const [logEntries, setLogEntries] = useState<LogEntry[]>([]);
|
||||||
const [lastIndex, setLastIndex] = useState<number>(0);
|
|
||||||
const [autoscroll, setAutoscroll] = useState(true);
|
const [autoscroll, setAutoscroll] = useState(true);
|
||||||
|
|
||||||
const updateFormValue = updateValueDirty(
|
const updateFormValue = updateValueDirty(
|
||||||
@@ -96,23 +95,14 @@ const SystemLog = () => {
|
|||||||
updateDataValue
|
updateDataValue
|
||||||
);
|
);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
useSSE(fetchLogES, {
|
||||||
const { onMessage, onError } = useSSE(fetchLogES, {
|
|
||||||
// withCredentials: true,
|
|
||||||
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;
|
||||||
if (logentry.i > lastIndex) {
|
|
||||||
setLastIndex(logentry.i);
|
|
||||||
setLogEntries((log) => [...log, logentry]);
|
setLogEntries((log) => [...log, logentry]);
|
||||||
}
|
}).onError(() => {
|
||||||
});
|
|
||||||
|
|
||||||
onError(() => {
|
|
||||||
toast.error('No connection to Log service');
|
toast.error('No connection to Log service');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -231,7 +221,7 @@ const SystemLog = () => {
|
|||||||
name="autoscroll"
|
name="autoscroll"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="Auto scroll"
|
label={LL.AUTO_SCROLL()}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user