From e744c6b75a5546b43c9b2610b2ad46efdd649e01 Mon Sep 17 00:00:00 2001 From: Weves Date: Sat, 28 Oct 2023 19:25:50 -0700 Subject: [PATCH] Re-style cc pair status table --- .../feedback/DocumentFeedbackTable.tsx | 5 +- .../status/CCPairIndexingStatusTable.tsx | 146 +++++++++++++++ web/src/app/admin/indexing/status/page.tsx | 168 ++---------------- web/src/components/HoverPopup.tsx | 22 +-- web/src/components/Status.tsx | 27 ++- 5 files changed, 194 insertions(+), 174 deletions(-) create mode 100644 web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx diff --git a/web/src/app/admin/documents/feedback/DocumentFeedbackTable.tsx b/web/src/app/admin/documents/feedback/DocumentFeedbackTable.tsx index 495ded428a34..1822eac78c3b 100644 --- a/web/src/app/admin/documents/feedback/DocumentFeedbackTable.tsx +++ b/web/src/app/admin/documents/feedback/DocumentFeedbackTable.tsx @@ -1,10 +1,9 @@ import { BasicTable } from "@/components/admin/connectors/BasicTable"; -import { PopupSpec, usePopup } from "@/components/admin/connectors/Popup"; +import { usePopup } from "@/components/admin/connectors/Popup"; import { useState } from "react"; import { PageSelector } from "@/components/PageSelector"; import { DocumentBoostStatus } from "@/lib/types"; -import { updateBoost, updateHiddenStatus } from "../lib"; -import { CheckmarkIcon, EditIcon } from "@/components/icons/icons"; +import { updateHiddenStatus } from "../lib"; import { numToDisplay } from "./constants"; import { FiEye, FiEyeOff } from "react-icons/fi"; import { getErrorMsg } from "@/lib/fetchUtils"; diff --git a/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx new file mode 100644 index 000000000000..451e4fd9deed --- /dev/null +++ b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx @@ -0,0 +1,146 @@ +"use client"; + +import { + Table, + TableHead, + TableRow, + TableHeaderCell, + TableBody, + TableCell, +} from "@tremor/react"; +import { CCPairStatus, IndexAttemptStatus } from "@/components/Status"; +import { useState } from "react"; +import { PageSelector } from "@/components/PageSelector"; +import { timeAgo } from "@/lib/time"; +import { ConnectorIndexingStatus } from "@/lib/types"; +import { ConnectorTitle } from "@/components/admin/connectors/ConnectorTitle"; +import { getDocsProcessedPerMinute } from "@/lib/indexAttempt"; +import Link from "next/link"; + +const NUM_IN_PAGE = 20; + +function CCPairIndexingStatusDisplay({ + ccPairsIndexingStatus, +}: { + ccPairsIndexingStatus: ConnectorIndexingStatus; +}) { + if (ccPairsIndexingStatus.connector.disabled) { + return ( + + ); + } + + const docsPerMinute = getDocsProcessedPerMinute( + ccPairsIndexingStatus.latest_index_attempt + )?.toFixed(2); + return ( + <> + + {ccPairsIndexingStatus?.latest_index_attempt?.num_docs_indexed && + ccPairsIndexingStatus?.latest_index_attempt?.status === "in_progress" ? ( +
+
+ Current Run:{" "} + {ccPairsIndexingStatus.latest_index_attempt.num_docs_indexed} docs + indexed +
+
+ Speed:{" "} + {docsPerMinute ? ( + <>{docsPerMinute} docs / min + ) : ( + "calculating rate..." + )} +
+
+ ) : null} + + ); +} + +export function CCPairIndexingStatusTable({ + ccPairsIndexingStatuses, +}: { + ccPairsIndexingStatuses: ConnectorIndexingStatus[]; +}) { + const [page, setPage] = useState(1); + + return ( +
+ + + + Connector + Status + Last Indexed + Docs Indexed + + + + {ccPairsIndexingStatuses + .slice(NUM_IN_PAGE * (page - 1), NUM_IN_PAGE * page) + .map((ccPairsIndexingStatus) => { + return ( + + + + + + + + + {timeAgo(ccPairsIndexingStatus?.last_success) || "-"} + + {ccPairsIndexingStatus.docs_indexed} + {/* Wrapping in + + ); + })} + +
to avoid console warnings */} + + +
+ {ccPairsIndexingStatuses.length > NUM_IN_PAGE && ( +
+
+ { + setPage(newPage); + window.scrollTo({ + top: 0, + left: 0, + behavior: "smooth", + }); + }} + /> +
+
+ )} +
+ ); +} diff --git a/web/src/app/admin/indexing/status/page.tsx b/web/src/app/admin/indexing/status/page.tsx index 4083be4e4f6f..25af76dc4d71 100644 --- a/web/src/app/admin/indexing/status/page.tsx +++ b/web/src/app/admin/indexing/status/page.tsx @@ -2,49 +2,13 @@ import useSWR from "swr"; -import { BasicTable } from "@/components/admin/connectors/BasicTable"; import { LoadingAnimation } from "@/components/Loading"; -import { timeAgo } from "@/lib/time"; -import { - NotebookIcon, - QuestionIcon, - XSquareIcon, -} from "@/components/icons/icons"; +import { NotebookIcon } from "@/components/icons/icons"; import { fetcher } from "@/lib/fetcher"; -import { getSourceMetadata } from "@/components/source"; -import { CheckCircle } from "@phosphor-icons/react"; import { HealthCheckBanner } from "@/components/health/healthcheck"; import { ConnectorIndexingStatus } from "@/lib/types"; -import { useState } from "react"; -import { getDocsProcessedPerMinute } from "@/lib/indexAttempt"; -import { ConnectorTitle } from "@/components/admin/connectors/ConnectorTitle"; - -const ErrorDisplay = ({ message }: { message: string }) => { - const [isHovered, setIsHovered] = useState(false); - return ( -
{ - setIsHovered(true); - }} - onMouseLeave={() => setIsHovered(false)} - className="relative" - > - {isHovered && ( -
-
-
Error Message:
- - {message} -
-
- )} -
- - Error -
-
- ); -}; +import { CCPairIndexingStatusTable } from "./CCPairIndexingStatusTable"; +import { Divider } from "@tremor/react"; function Main() { const { @@ -54,7 +18,7 @@ function Main() { } = useSWR[]>( "/api/manage/admin/connector/indexing-status", fetcher, - { refreshInterval: 30000 } // 30 seconds + { refreshInterval: 10000 } // 10 seconds ); if (indexAttemptIsLoading) { @@ -77,132 +41,20 @@ function Main() { }); return ( - { - const sourceMetadata = getSourceMetadata( - connectorIndexingStatus.connector.source - ); - let statusDisplay = ( -
Initializing...
- ); - if (connectorIndexingStatus.connector.disabled) { - statusDisplay = ( -
- - Disabled -
- ); - } else if (connectorIndexingStatus.last_status === "success") { - statusDisplay = ( -
- - Enabled -
- ); - } else if (connectorIndexingStatus.last_status === "failed") { - statusDisplay = ( - - ); - } else if (connectorIndexingStatus.last_status === "not_started") { - statusDisplay =
Scheduled
; - } else if (connectorIndexingStatus.last_status === "in_progress") { - const docsPerMinute = getDocsProcessedPerMinute( - connectorIndexingStatus.latest_index_attempt - )?.toFixed(2); - statusDisplay = ( -
- In Progress{" "} - {connectorIndexingStatus?.latest_index_attempt - ?.num_docs_indexed ? ( -
-
- Current Run:{" "} - { - connectorIndexingStatus.latest_index_attempt - .num_docs_indexed - }{" "} - docs indexed -
-
- Speed:{" "} - {docsPerMinute ? ( - <>~{docsPerMinute} docs / min - ) : ( - "calculating rate..." - )} -
-
- ) : null} -
- ); - } - return { - indexed_at: timeAgo(connectorIndexingStatus?.last_success) || "-", - docs_indexed: connectorIndexingStatus?.docs_indexed - ? `${connectorIndexingStatus?.docs_indexed} documents` - : "-", - connector: ( - - ), - status: statusDisplay, - // TODO: add the below back in after this is supported in the backend - // reindex: ( - // - // ), - }; - })} - /> + ); } export default function Status() { return ( -
+
-
- -

Indexing Status

-
+

+ Indexing Status +

+
); diff --git a/web/src/components/HoverPopup.tsx b/web/src/components/HoverPopup.tsx index e3a666503493..60ef1ac50faa 100644 --- a/web/src/components/HoverPopup.tsx +++ b/web/src/components/HoverPopup.tsx @@ -21,28 +21,28 @@ export const HoverPopup = ({ popupDirectionClass = "top-0 left-0 transform translate-x-[-110%]"; break; case "bottom": - popupDirectionClass = "top-0 left-0 mt-8"; + popupDirectionClass = "top-0 left-0 mt-6 pt-2"; break; } return (
{ setHovered(true); - console.log("HIII"); }} onMouseLeave={() => setHovered(false)} > {hovered && ( -
- {popupContent} +
+
+ {popupContent} +
)} {mainContent} diff --git a/web/src/components/Status.tsx b/web/src/components/Status.tsx index 761bfa2bd6bd..6d16c848d8a9 100644 --- a/web/src/components/Status.tsx +++ b/web/src/components/Status.tsx @@ -8,34 +8,57 @@ import { FiClock, FiPauseCircle, } from "react-icons/fi"; +import { HoverPopup } from "./HoverPopup"; export function IndexAttemptStatus({ status, + errorMsg, size = "md", }: { status: ValidStatuses; + errorMsg?: string | null; size?: "xs" | "sm" | "md" | "lg"; }) { let badge; if (status === "failed") { - badge = ( + const icon = ( Failed ); + if (errorMsg) { + badge = ( + {icon}
} + popupContent={ +
+ {errorMsg} +
+ } + /> + ); + } else { + badge = icon; + } } else if (status === "success") { badge = ( Succeeded ); - } else if (status === "in_progress" || status === "not_started") { + } else if (status === "in_progress") { badge = ( In Progress ); + } else if (status === "not_started") { + badge = ( + + Scheduled + + ); } else { badge = (