From 0d8b501cf71a676b08bc56903688ffaaec1039a4 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 10 Sep 2023 15:55:04 +0800 Subject: [PATCH] refactor: change layout of website overview and add websites data --- src/client/components/WebsiteOverview.tsx | 40 ++++++++++++++++++++--- src/client/pages/Dashboard.tsx | 10 +++++- src/client/pages/Layout.tsx | 6 ++-- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/client/components/WebsiteOverview.tsx b/src/client/components/WebsiteOverview.tsx index 092f2ca..6b22e33 100644 --- a/src/client/components/WebsiteOverview.tsx +++ b/src/client/components/WebsiteOverview.tsx @@ -4,16 +4,46 @@ import { Column } from '@ant-design/charts'; import { ArrowRightOutlined, SyncOutlined } from '@ant-design/icons'; import { DateFilter } from './DateFilter'; import { HealthBar } from './HealthBar'; +import { useWorspaceWebsites, WebsiteInfo } from '../api/model/website'; +import { Loading } from './Loading'; -export const WebsiteOverview: React.FC = React.memo(() => { +interface WebsiteOverviewProps { + workspaceId: string; +} +export const WebsiteOverview: React.FC = React.memo( + (props) => { + const { isLoading, websites } = useWorspaceWebsites(props.workspaceId); + + if (isLoading) { + return ; + } + + return ( +
+ {websites.map((website) => ( + + ))} +
+ ); + } +); +WebsiteOverview.displayName = 'WebsiteOverview'; + +const WebsiteOverviewItem: React.FC<{ + website: WebsiteInfo; +}> = React.memo((props) => { return ( -
+
- Tianji + + {props.website.name} + ({ status: 'health' }))} + beats={Array.from({ length: 13 }).map(() => ({ + status: 'health', + }))} />
@@ -50,7 +80,7 @@ export const WebsiteOverview: React.FC = React.memo(() => {
); }); -WebsiteOverview.displayName = 'WebsiteOverview'; +WebsiteOverviewItem.displayName = 'WebsiteOverviewItem'; const MetricCard: React.FC<{ label: string; diff --git a/src/client/pages/Dashboard.tsx b/src/client/pages/Dashboard.tsx index 8802181..3ba9511 100644 --- a/src/client/pages/Dashboard.tsx +++ b/src/client/pages/Dashboard.tsx @@ -2,8 +2,16 @@ import React from 'react'; import { EditOutlined } from '@ant-design/icons'; import { Button } from 'antd'; import { WebsiteOverview } from '../components/WebsiteOverview'; +import { useCurrentWorkspaceId } from '../store/user'; +import { Loading } from '../components/Loading'; export const Dashboard: React.FC = React.memo(() => { + const workspaceId = useCurrentWorkspaceId(); + + if (!workspaceId) { + return ; + } + return (
@@ -15,7 +23,7 @@ export const Dashboard: React.FC = React.memo(() => {
- +
); diff --git a/src/client/pages/Layout.tsx b/src/client/pages/Layout.tsx index 3ada306..d8cc97b 100644 --- a/src/client/pages/Layout.tsx +++ b/src/client/pages/Layout.tsx @@ -59,8 +59,10 @@ export const Layout: React.FC = React.memo(() => {
-
- +
+
+ +
);