From 7a4c8f5bacb74cf66faf7c842b5cc1943dda7831 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 17 Oct 2023 20:34:26 +0800 Subject: [PATCH] feat: webview overview support click healthbar can jump to monitor --- .../components/website/WebsiteOverview.tsx | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/client/components/website/WebsiteOverview.tsx b/src/client/components/website/WebsiteOverview.tsx index f7cf92a..7bbce67 100644 --- a/src/client/components/website/WebsiteOverview.tsx +++ b/src/client/components/website/WebsiteOverview.tsx @@ -3,15 +3,12 @@ import React, { useMemo } from 'react'; import { Column, ColumnConfig } from '@ant-design/charts'; import { SyncOutlined } from '@ant-design/icons'; import { DateFilter } from '../DateFilter'; -import { HealthBar } from '../HealthBar'; import { StatsItemType, useWorkspaceWebsitePageview, useWorkspaceWebsiteStats, WebsiteInfo, } from '../../api/model/website'; -import { Loading } from '../Loading'; -import dayjs from 'dayjs'; import { DateUnit, formatDate, @@ -25,12 +22,15 @@ import { useTheme } from '../../hooks/useTheme'; import { WebsiteOnlineCount } from '../WebsiteOnlineCount'; import { useGlobalRangeDate } from '../../hooks/useGlobalRangeDate'; import { MonitorHealthBar } from '../monitor/MonitorHealthBar'; +import { useNavigate } from 'react-router'; export const WebsiteOverview: React.FC<{ website: WebsiteInfo; actions?: React.ReactNode; }> = React.memo((props) => { + const { website, actions } = props; const { startDate, endDate, unit } = useGlobalRangeDate(); + const navigate = useNavigate(); const { pageviews, @@ -38,8 +38,8 @@ export const WebsiteOverview: React.FC<{ isLoading: isLoadingPageview, refetch: refetchPageview, } = useWorkspaceWebsitePageview( - props.website.workspaceId, - props.website.id, + website.workspaceId, + website.id, startDate.unix() * 1000, endDate.unix() * 1000, unit @@ -50,8 +50,8 @@ export const WebsiteOverview: React.FC<{ isLoading: isLoadingStats, refetch: refetchStats, } = useWorkspaceWebsiteStats( - props.website.workspaceId, - props.website.id, + website.workspaceId, + website.id, startDate.unix() * 1000, endDate.unix() * 1000, unit @@ -78,23 +78,28 @@ export const WebsiteOverview: React.FC<{
- - {props.website.name} + + {website.name} - {props.website.monitorId && ( - + {website.monitorId && ( +
navigate(`/monitor/${website.monitorId}`)} + > + +
)}
-
{props.actions}
+
{actions}