From b643ae531e174601876f6757dcacf7817c662843 Mon Sep 17 00:00:00 2001 From: chark1es Date: Fri, 7 Mar 2025 18:30:53 -0800 Subject: [PATCH] updated admindashboard --- src/components/dashboard/AdminDashboard.astro | 1362 +++++++++++++++-- .../AdminDashboard/AdminSystemActivity.tsx | 54 +- .../dashboard/Officer_UserManagement.astro | 3 + 3 files changed, 1282 insertions(+), 137 deletions(-) create mode 100644 src/components/dashboard/Officer_UserManagement.astro diff --git a/src/components/dashboard/AdminDashboard.astro b/src/components/dashboard/AdminDashboard.astro index 5eced37..edd5784 100644 --- a/src/components/dashboard/AdminDashboard.astro +++ b/src/components/dashboard/AdminDashboard.astro @@ -360,6 +360,44 @@ const getUserName = (reimbursement: ExpandedReimbursement) => { + +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + { users.map((user) => ( @@ -424,6 +462,48 @@ const getUserName = (reimbursement: ExpandedReimbursement) => { + +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + { events.map((event) => ( @@ -504,6 +584,40 @@ const getUserName = (reimbursement: ExpandedReimbursement) => { + +
+
+
+
+
+
+
+
+ +
+
+
+
+ + { reimbursements.map((reimbursement) => ( @@ -576,32 +690,85 @@ const getUserName = (reimbursement: ExpandedReimbursement) => { - - -
-

- - Recent System Activity -
- Live updates -
-

-
-
- -
-
-
diff --git a/src/components/dashboard/AdminDashboard/AdminSystemActivity.tsx b/src/components/dashboard/AdminDashboard/AdminSystemActivity.tsx index 944c855..4892f77 100644 --- a/src/components/dashboard/AdminDashboard/AdminSystemActivity.tsx +++ b/src/components/dashboard/AdminDashboard/AdminSystemActivity.tsx @@ -2,17 +2,13 @@ import { useEffect, useState } from "react"; import { Authentication } from "../../../scripts/pocketbase/Authentication"; import { Get } from "../../../scripts/pocketbase/Get"; import { Collections } from "../../../schemas/pocketbase"; -import type { Log } from "../../../schemas/pocketbase"; +import type { Log, User } from "../../../schemas/pocketbase"; import { Icon } from "@iconify/react"; // Extend the Log type to include expand property interface ExtendedLog extends Log { expand?: { - user?: { - name: string; - email: string; - id: string; - }; + user?: User; }; } @@ -43,6 +39,8 @@ export default function AdminSystemActivity({ return; } + console.log(`Fetching logs from collection: ${Collections.LOGS} with limit: ${limit}`); + // Fetch logs with user expansion const logsResponse = await get.getList( Collections.LOGS, @@ -53,18 +51,40 @@ export default function AdminSystemActivity({ { expand: "user" } ); + console.log(`Logs fetched: ${logsResponse.items.length} of ${logsResponse.totalItems} total`); + + if (logsResponse.items.length === 0) { + console.log("No logs found in the response"); + } else { + console.log("First log:", JSON.stringify(logsResponse.items[0], null, 2)); + } + setLogs(logsResponse.items); setError(null); } catch (err) { console.error("Error fetching logs:", err); - setError("Failed to load system logs"); + setError(`Failed to load system logs: ${err instanceof Error ? err.message : String(err)}`); } finally { setLoading(false); } }; + // Expose the refresh function to the window object + useEffect(() => { + if (typeof window !== 'undefined') { + (window as any).refreshAdminSystemActivity = fetchLogs; + } + + return () => { + if (typeof window !== 'undefined') { + delete (window as any).refreshAdminSystemActivity; + } + }; + }, []); + useEffect(() => { // Initial fetch + console.log("AdminSystemActivity mounted, fetching logs..."); fetchLogs(); // Set up auto-refresh if enabled @@ -165,7 +185,14 @@ export default function AdminSystemActivity({ return (
- No system logs found + No system logs found. This could be because no logs have been created yet or because you don't have permission to view logs. +
); } @@ -211,6 +238,17 @@ export default function AdminSystemActivity({ Refreshing... )} + +
+ +
); } \ No newline at end of file diff --git a/src/components/dashboard/Officer_UserManagement.astro b/src/components/dashboard/Officer_UserManagement.astro new file mode 100644 index 0000000..853d812 --- /dev/null +++ b/src/components/dashboard/Officer_UserManagement.astro @@ -0,0 +1,3 @@ +--- + +---