From 04572a8e5081b1e4871e273cde9dbaaa44c52fe0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 21:43:44 +0000 Subject: structure: Create apps dir and copy tooling dir from t3-turbo repo --- packages/web/app/dashboard/admin/page.tsx | 203 ------------------------------ 1 file changed, 203 deletions(-) delete mode 100644 packages/web/app/dashboard/admin/page.tsx (limited to 'packages/web/app/dashboard/admin') diff --git a/packages/web/app/dashboard/admin/page.tsx b/packages/web/app/dashboard/admin/page.tsx deleted file mode 100644 index 6babdd79..00000000 --- a/packages/web/app/dashboard/admin/page.tsx +++ /dev/null @@ -1,203 +0,0 @@ -"use client"; - -import { ActionButton } from "@/components/ui/action-button"; -import LoadingSpinner from "@/components/ui/spinner"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { keepPreviousData } from "@tanstack/react-query"; -import { Trash } from "lucide-react"; -import { useSession } from "next-auth/react"; -import { useRouter } from "next/navigation"; - -function ActionsSection() { - const { mutate: recrawlLinks, isPending: isRecrawlPending } = - api.admin.recrawlAllLinks.useMutation({ - onSuccess: () => { - toast({ - description: "Recrawl enqueued", - }); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: e.message, - }); - }, - }); - - const { mutate: reindexBookmarks, isPending: isReindexPending } = - api.admin.reindexAllBookmarks.useMutation({ - onSuccess: () => { - toast({ - description: "Reindex enqueued", - }); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: e.message, - }); - }, - }); - - return ( - <> -

Actions

- recrawlLinks()} - > - Recrawl All Links - - reindexBookmarks()} - > - Reindex All Bookmarks - - - ); -} - -function ServerStatsSection() { - const { data: serverStats } = api.admin.stats.useQuery(undefined, { - refetchInterval: 1000, - placeholderData: keepPreviousData, - }); - - if (!serverStats) { - return ; - } - - return ( - <> -

Server Stats

- - - - Num Users - {serverStats.numUsers} - - - Num Bookmarks - {serverStats.numBookmarks} - - -
-
-

Background Jobs

- - - - Pending Crawling Jobs - {serverStats.pendingCrawls} - - - Pending Indexing Jobs - {serverStats.pendingIndexing} - - - Pending OpenAI Jobs - {serverStats.pendingOpenai} - - -
- - ); -} - -function UsersSection() { - const { data: session } = useSession(); - const invalidateUserList = api.useUtils().users.list.invalidate; - const { data: users } = api.users.list.useQuery(); - const { mutate: deleteUser, isPending: isDeletionPending } = - api.users.delete.useMutation({ - onSuccess: () => { - toast({ - description: "User deleted", - }); - invalidateUserList(); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: `Something went wrong: ${e.message}`, - }); - }, - }); - - if (!users) { - return ; - } - - return ( - <> -

Users

- - - Name - Email - Role - Action - - - {users.users.map((u) => ( - - {u.name} - {u.email} - {u.role} - - deleteUser({ userId: u.id })} - loading={isDeletionPending} - disabled={session!.user.id == u.id} - > - - - - - ))} - -
- - ); -} - -export default function AdminPage() { - const router = useRouter(); - const { data: session, status } = useSession(); - - if (status == "loading") { - return ; - } - - if (!session || session.user.role != "admin") { - router.push("/"); - return; - } - - return ( -
-

Admin

-
- -
- -
- -
- ); -} -- cgit v1.2.3-70-g09d2