diff --git a/src/components/ui/Badge.tsx b/src/components/ui/Badge.tsx new file mode 100644 index 0000000..d94cbb2 --- /dev/null +++ b/src/components/ui/Badge.tsx @@ -0,0 +1,20 @@ +import { capitalize } from "../../utils/utils"; + +type BadgeProps = { + text: string; +}; + +const Badge = ({ text }: BadgeProps) => { + const lowerCaseWord = text.toLowerCase(); + return ( + + {capitalize(lowerCaseWord)} + + ); +}; + +export default Badge; diff --git a/src/components/ui/StatusIndicator.tsx b/src/components/ui/StatusIndicator.tsx new file mode 100644 index 0000000..a0a6bc4 --- /dev/null +++ b/src/components/ui/StatusIndicator.tsx @@ -0,0 +1,9 @@ +import clsx from "clsx"; + +type StatusIndicatorProps = { status: string }; + +const StatusIndicator = ({ status }: StatusIndicatorProps) => { + return ; +}; + +export default StatusIndicator; diff --git a/src/features/dashboard/Dashboard.tsx b/src/features/dashboard/Dashboard.tsx index 8a1de53..843a8dc 100644 --- a/src/features/dashboard/Dashboard.tsx +++ b/src/features/dashboard/Dashboard.tsx @@ -3,6 +3,7 @@ import SightingStack from "./components/sightingStack/SightingStack"; import VideoFeed from "./components/videoFeed/VideoFeed"; import { useSightingList } from "./hooks/useSightingList"; import { useCameraSettingsContext } from "../../app/context/CameraSettingsContext"; +import SystemOverview from "./SystemOverview/SystemOverview"; const Dashboard = () => { const { sightingList, isLoading } = useSightingList(); @@ -13,13 +14,15 @@ const Dashboard = () => { return (
Some systems are experiencing issues.
+ ) : ( + <> + {isAllCamerasOperational ? ( +All systems are operational.
+ ) : ( +Some systems have issues.
+ )} + {!isError && !isAllCamerasOperational && ( + + Click to view more details. + + )} + > + )} +{camera.id}
+No sighting data available.
- )} + ) : null} ); }; diff --git a/src/features/dashboard/components/videoFeed/VideoFeed.tsx b/src/features/dashboard/components/videoFeed/VideoFeed.tsx index dadc359..aaa44b7 100644 --- a/src/features/dashboard/components/videoFeed/VideoFeed.tsx +++ b/src/features/dashboard/components/videoFeed/VideoFeed.tsx @@ -33,7 +33,7 @@ const VideoFeed = ({ mostRecentSighting, isLoading, size, modeSetting, isModal = useEffect(() => { const updateSize = () => { - const width = window.innerWidth * 0.48; + const width = window.innerWidth * 0.57; const height = (width * 2) / 3; dispatch({ type: "SET_IMAGE_SIZE", payload: { width, height } }); }; diff --git a/src/features/dashboard/hooks/useGetStore.ts b/src/features/dashboard/hooks/useGetStore.ts new file mode 100644 index 0000000..496bcd5 --- /dev/null +++ b/src/features/dashboard/hooks/useGetStore.ts @@ -0,0 +1,16 @@ +import { useQuery } from "@tanstack/react-query"; +import { cambase } from "../../../app/config"; +const fetchStore = async () => { + const response = await fetch(`${cambase}/Store0/diagnostics-json`); + if (!response.ok) throw new Error("Network response was not ok"); + return response.json(); +}; + +export const useGetStore = () => { + const storeQuery = useQuery({ + queryKey: ["storeData"], + queryFn: fetchStore, + refetchInterval: 5000, + }); + return { storeQuery }; +}; diff --git a/src/features/dashboard/hooks/useGetSystemHealth.ts b/src/features/dashboard/hooks/useGetSystemHealth.ts new file mode 100644 index 0000000..fb9c475 --- /dev/null +++ b/src/features/dashboard/hooks/useGetSystemHealth.ts @@ -0,0 +1,21 @@ +import { useQuery } from "@tanstack/react-query"; +import { cambase } from "../../../app/config"; + +const fetchSystemHealth = async () => { + const response = await fetch(`${cambase}/api/system-health`); + if (!response.ok) throw new Error("Network response was not ok"); + return response.json(); +}; + +export const useGetSystemHealth = () => { + const systemHealthQuery = useQuery({ + queryKey: ["systemHealth"], + queryFn: fetchSystemHealth, + refetchInterval: 60000, + refetchOnWindowFocus: false, + retry: false, + staleTime: 30000, + }); + + return { systemHealthQuery }; +}; diff --git a/src/utils/types.ts b/src/utils/types.ts index 7b6ed6f..9e5c09f 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -65,3 +65,25 @@ export type CameraSettingsAction = type: "SET_IMAGE_SIZE"; payload: { width: number; height: number }; }; + +export type CameraStatus = { + id: string; + groupID: string; + tags: string[]; +}; + +export type SystemHealth = { + UptimeHumane: string; + StartTimeHumane: string; + Status: CameraStatus[]; +}; + +export type StoreData = { + totalPending: number; + totalActive: number; + totalSent: number; + totalReceived: number; + totalLost: number; + sanityCheck: boolean; + sanityCheckFormula: string; +}; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 6fa3103..8c14d9a 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -22,3 +22,7 @@ export const timeAgo = (timestampmili: number | null) => { return `${diffHours === 1 ? "1 hour" : diffHours + " hours"} ago`; } }; + +export function capitalize(s?: string) { + return s ? s.charAt(0).toUpperCase() + s.slice(1) : ""; +}