diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx index 8217fe95..6a6e6b13 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Chartable/index.jsx @@ -107,7 +107,7 @@ export function Chartable({ props, workspace }) { ); case "line": return ( -
+

{title}

-
+
{renderChart()}
-
+
{renderChart()}
diff --git a/frontend/src/pages/Admin/Logging/index.jsx b/frontend/src/pages/Admin/Logging/index.jsx index 69a81ab5..49824784 100644 --- a/frontend/src/pages/Admin/Logging/index.jsx +++ b/frontend/src/pages/Admin/Logging/index.jsx @@ -9,6 +9,22 @@ import showToast from "@/utils/toast"; import CTAButton from "@/components/lib/CTAButton"; export default function AdminLogs() { + const query = useQuery(); + const [loading, setLoading] = useState(true); + const [logs, setLogs] = useState([]); + const [offset, setOffset] = useState(Number(query.get("offset") || 0)); + const [canNext, setCanNext] = useState(false); + + useEffect(() => { + async function fetchLogs() { + const { logs: _logs, hasPages = false } = await System.eventLogs(offset); + setLogs(_logs); + setCanNext(hasPages); + setLoading(false); + } + fetchLogs(); + }, [offset]); + const handleResetLogs = async () => { if ( !window.confirm( @@ -19,13 +35,22 @@ export default function AdminLogs() { const { success, error } = await System.clearEventLogs(); if (success) { showToast("Event logs cleared successfully.", "success"); - setTimeout(() => { - window.location.reload(); - }, 1000); + setLogs([]); + setCanNext(false); + setOffset(0); } else { showToast(`Failed to clear logs: ${error}`, "error"); } }; + + const handlePrevious = () => { + setOffset(Math.max(offset - 1, 0)); + }; + + const handleNext = () => { + setOffset(offset + 1); + }; + return (
@@ -53,37 +78,28 @@ export default function AdminLogs() { Clear Event Logs
- +
); } -function LogsContainer() { - const query = useQuery(); - const [loading, setLoading] = useState(true); - const [logs, setLogs] = useState([]); - const [offset, setOffset] = useState(Number(query.get("offset") || 0)); - const [canNext, setCanNext] = useState(false); - - const handlePrevious = () => { - setOffset(Math.max(offset - 1, 0)); - }; - const handleNext = () => { - setOffset(offset + 1); - }; - - useEffect(() => { - async function fetchLogs() { - const { logs: _logs, hasPages = false } = await System.eventLogs(offset); - setLogs(_logs); - setCanNext(hasPages); - setLoading(false); - } - fetchLogs(); - }, [offset]); - +function LogsContainer({ + loading, + logs, + offset, + canNext, + handleNext, + handlePrevious, +}) { if (loading) { return ( window.location.reload(), 1_500); } else { showToast(`Error: ${message}`, "error", { clear: true }); } diff --git a/server/endpoints/system.js b/server/endpoints/system.js index 3ea7fb24..60d51e35 100644 --- a/server/endpoints/system.js +++ b/server/endpoints/system.js @@ -913,7 +913,7 @@ function systemEndpoints(app) { [validatedRequest, flexUserRoleValid([ROLES.admin])], async (request, response) => { try { - const { offset = 0, limit = 20 } = reqBody(request); + const { offset = 0, limit = 10 } = reqBody(request); const logs = await EventLogs.whereWithData({}, limit, offset * limit, { id: "desc", });