diff --git a/web/src/app/admin/connector/[ccPairId]/page.tsx b/web/src/app/admin/connector/[ccPairId]/page.tsx index 697cd5e23a27..f04ec6995ad5 100644 --- a/web/src/app/admin/connector/[ccPairId]/page.tsx +++ b/web/src/app/admin/connector/[ccPairId]/page.tsx @@ -1,6 +1,6 @@ -import { getCCPairSS } from "@/lib/ss/ccPair"; +"use client"; + import { CCPairFullInfo } from "./types"; -import { getErrorMsg } from "@/lib/fetchUtils"; import { HealthCheckBanner } from "@/components/health/healthcheck"; import { CCPairStatus } from "@/components/Status"; import { BackButton } from "@/components/BackButton"; @@ -10,36 +10,42 @@ import { Text } from "@tremor/react"; import { ConfigDisplay } from "./ConfigDisplay"; import { ModifyStatusButtonCluster } from "./ModifyStatusButtonCluster"; import { DeletionButton } from "./DeletionButton"; -import { SSRAutoRefresh } from "@/components/SSRAutoRefresh"; import { ErrorCallout } from "@/components/ErrorCallout"; import { ReIndexButton } from "./ReIndexButton"; import { isCurrentlyDeleting } from "@/lib/documentDeletion"; import { ValidSources } from "@/lib/types"; +import useSWR from "swr"; +import { errorHandlingFetcher } from "@/lib/fetcher"; +import { ThreeDotsLoader } from "@/components/Loading"; // since the uploaded files are cleaned up after some period of time // re-indexing will not work for the file connector. Also, it would not // make sense to re-index, since the files will not have changed. const CONNECTOR_TYPES_THAT_CANT_REINDEX: ValidSources[] = ["file"]; -export default async function Page({ - params, -}: { - params: { ccPairId: string }; -}) { - const ccPairId = parseInt(params.ccPairId); +function Main({ ccPairId }: { ccPairId: number }) { + const { + data: ccPair, + isLoading, + error, + } = useSWR( + `/api/manage/admin/cc-pair/${ccPairId}`, + errorHandlingFetcher + ); - const ccPairResponse = await getCCPairSS(ccPairId); - if (!ccPairResponse.ok) { - const errorMsg = await getErrorMsg(ccPairResponse); + if (isLoading) { + return ; + } + + if (error || !ccPair) { return ( -
- - -
+ ); } - const ccPair = (await ccPairResponse.json()) as CCPairFullInfo; const lastIndexAttempt = ccPair.index_attempts[0]; const isDeleting = isCurrentlyDeleting(ccPair.latest_deletion_attempt); @@ -55,76 +61,83 @@ export default async function Page({ return ( <> - -
-
- + +
+

{ccPair.name}

+ +
+
+
- -
-

{ccPair.name}

+ -
- -
-
+
+ Total Documents Indexed:{" "} + {totalDocsIndexed} +
- + -
- Total Documents Indexed:{" "} - {totalDocsIndexed} -
- - - - - {/* NOTE: no divider / title here for `ConfigDisplay` since it is optional and we need + + {/* NOTE: no divider / title here for `ConfigDisplay` since it is optional and we need to render these conditionally.*/} -
-
- Indexing Attempts +
+
+ Indexing Attempts - {!CONNECTOR_TYPES_THAT_CANT_REINDEX.includes( - ccPair.connector.source - ) && ( - - )} -
- - + {!CONNECTOR_TYPES_THAT_CANT_REINDEX.includes( + ccPair.connector.source + ) && ( + + )}
- - -
- Delete Connector - - Deleting the connector will also delete all associated documents. - - -
-
- -
-
-
- - {/* TODO: add document search*/} +
+ + + +
+ Delete Connector + + Deleting the connector will also delete all associated documents. + + +
+
+ +
+
+
+ + {/* TODO: add document search*/} ); } + +export default function Page({ params }: { params: { ccPairId: string } }) { + const ccPairId = parseInt(params.ccPairId); + + return ( +
+
+ +
+ +
+
+ ); +} diff --git a/web/src/components/ErrorCallout.tsx b/web/src/components/ErrorCallout.tsx index 71f1563834ce..6c236762a399 100644 --- a/web/src/components/ErrorCallout.tsx +++ b/web/src/components/ErrorCallout.tsx @@ -8,7 +8,6 @@ export function ErrorCallout({ errorTitle?: string; errorMsg?: string; }) { - console.log(errorMsg); return (
{ - const interval = setInterval(() => { - router.refresh(); - }, refreshFreq * 1000); +// useEffect(() => { +// const interval = setInterval(() => { +// router.refresh(); +// }, refreshFreq * 1000); - return () => clearInterval(interval); - }, []); +// return () => clearInterval(interval); +// }, []); - return <>; -} +// return <>; +// } export function InstantSSRAutoRefresh() { const router = useRouter();