mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-11 01:10:11 +01:00
Clearing of events does not reload anymore
updating workspace name does not result in reload anymore set event log page size to 10 fix css issues with charts
This commit is contained in:
parent
894f727903
commit
b69bf7cc27
@ -107,7 +107,7 @@ export function Chartable({ props, workspace }) {
|
|||||||
);
|
);
|
||||||
case "line":
|
case "line":
|
||||||
return (
|
return (
|
||||||
<div className="bg-zinc-900 p-8 pb-12 rounded-xl text-white h-[500px]">
|
<div className="bg-zinc-900 p-8 pb-12 rounded-xl text-white h-[500px] w-full">
|
||||||
<h3 className="text-lg font-medium">{title}</h3>
|
<h3 className="text-lg font-medium">{title}</h3>
|
||||||
<LineChart
|
<LineChart
|
||||||
className="h-[400px]"
|
className="h-[400px]"
|
||||||
@ -371,7 +371,7 @@ export function Chartable({ props, workspace }) {
|
|||||||
<div className="py-2 px-4 w-full flex gap-x-5 md:max-w-[800px] flex-col">
|
<div className="py-2 px-4 w-full flex gap-x-5 md:max-w-[800px] flex-col">
|
||||||
<div className="flex gap-x-5">
|
<div className="flex gap-x-5">
|
||||||
<WorkspaceProfileImage workspace={workspace} />
|
<WorkspaceProfileImage workspace={workspace} />
|
||||||
<div className="relative">
|
<div className="relative w-full">
|
||||||
<DownloadGraph onClick={handleDownload} />
|
<DownloadGraph onClick={handleDownload} />
|
||||||
<div ref={ref}>{renderChart()}</div>
|
<div ref={ref}>{renderChart()}</div>
|
||||||
<span
|
<span
|
||||||
@ -390,7 +390,7 @@ export function Chartable({ props, workspace }) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-end w-full">
|
<div className="flex justify-center items-end w-full">
|
||||||
<div className="py-2 px-4 w-full flex gap-x-5 md:max-w-[800px] flex-col">
|
<div className="py-2 px-4 w-full flex gap-x-5 md:max-w-[800px] flex-col">
|
||||||
<div className="relative">
|
<div className="relative w-full">
|
||||||
<DownloadGraph onClick={handleDownload} />
|
<DownloadGraph onClick={handleDownload} />
|
||||||
<div ref={ref}>{renderChart()}</div>
|
<div ref={ref}>{renderChart()}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,6 +9,22 @@ import showToast from "@/utils/toast";
|
|||||||
import CTAButton from "@/components/lib/CTAButton";
|
import CTAButton from "@/components/lib/CTAButton";
|
||||||
|
|
||||||
export default function AdminLogs() {
|
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 () => {
|
const handleResetLogs = async () => {
|
||||||
if (
|
if (
|
||||||
!window.confirm(
|
!window.confirm(
|
||||||
@ -19,13 +35,22 @@ export default function AdminLogs() {
|
|||||||
const { success, error } = await System.clearEventLogs();
|
const { success, error } = await System.clearEventLogs();
|
||||||
if (success) {
|
if (success) {
|
||||||
showToast("Event logs cleared successfully.", "success");
|
showToast("Event logs cleared successfully.", "success");
|
||||||
setTimeout(() => {
|
setLogs([]);
|
||||||
window.location.reload();
|
setCanNext(false);
|
||||||
}, 1000);
|
setOffset(0);
|
||||||
} else {
|
} else {
|
||||||
showToast(`Failed to clear logs: ${error}`, "error");
|
showToast(`Failed to clear logs: ${error}`, "error");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePrevious = () => {
|
||||||
|
setOffset(Math.max(offset - 1, 0));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNext = () => {
|
||||||
|
setOffset(offset + 1);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-screen h-screen overflow-hidden bg-sidebar flex">
|
<div className="w-screen h-screen overflow-hidden bg-sidebar flex">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
@ -53,37 +78,28 @@ export default function AdminLogs() {
|
|||||||
Clear Event Logs
|
Clear Event Logs
|
||||||
</CTAButton>
|
</CTAButton>
|
||||||
</div>
|
</div>
|
||||||
<LogsContainer />
|
<LogsContainer
|
||||||
|
loading={loading}
|
||||||
|
logs={logs}
|
||||||
|
offset={offset}
|
||||||
|
canNext={canNext}
|
||||||
|
handleNext={handleNext}
|
||||||
|
handlePrevious={handlePrevious}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogsContainer() {
|
function LogsContainer({
|
||||||
const query = useQuery();
|
loading,
|
||||||
const [loading, setLoading] = useState(true);
|
logs,
|
||||||
const [logs, setLogs] = useState([]);
|
offset,
|
||||||
const [offset, setOffset] = useState(Number(query.get("offset") || 0));
|
canNext,
|
||||||
const [canNext, setCanNext] = useState(false);
|
handleNext,
|
||||||
|
handlePrevious,
|
||||||
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]);
|
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<Skeleton.default
|
<Skeleton.default
|
||||||
|
@ -36,7 +36,6 @@ export default function GeneralInfo({ slug }) {
|
|||||||
);
|
);
|
||||||
if (!!updatedWorkspace) {
|
if (!!updatedWorkspace) {
|
||||||
showToast("Workspace updated!", "success", { clear: true });
|
showToast("Workspace updated!", "success", { clear: true });
|
||||||
setTimeout(() => window.location.reload(), 1_500);
|
|
||||||
} else {
|
} else {
|
||||||
showToast(`Error: ${message}`, "error", { clear: true });
|
showToast(`Error: ${message}`, "error", { clear: true });
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ function systemEndpoints(app) {
|
|||||||
[validatedRequest, flexUserRoleValid([ROLES.admin])],
|
[validatedRequest, flexUserRoleValid([ROLES.admin])],
|
||||||
async (request, response) => {
|
async (request, response) => {
|
||||||
try {
|
try {
|
||||||
const { offset = 0, limit = 20 } = reqBody(request);
|
const { offset = 0, limit = 10 } = reqBody(request);
|
||||||
const logs = await EventLogs.whereWithData({}, limit, offset * limit, {
|
const logs = await EventLogs.whereWithData({}, limit, offset * limit, {
|
||||||
id: "desc",
|
id: "desc",
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user