diff --git a/src/client/components/dashboard/AddButton.tsx b/src/client/components/dashboard/AddButton.tsx
index c8bf7ae..f0efbca 100644
--- a/src/client/components/dashboard/AddButton.tsx
+++ b/src/client/components/dashboard/AddButton.tsx
@@ -40,10 +40,14 @@ export const DashboardItemAddButton: React.FC = React.memo(() => {
},
},
{
- key: `website#${website.id}#event`,
+ key: `website#${website.id}#events`,
label: 'Events',
onClick: () => {
- addItem('websiteEvent', website.id, `${website.name}'s Event`);
+ addItem(
+ 'websiteEvents',
+ website.id,
+ `${website.name}'s Events`
+ );
},
},
],
@@ -67,6 +71,35 @@ export const DashboardItemAddButton: React.FC = React.memo(() => {
);
},
},
+ {
+ key: `monitor#${monitor.id}#metrics`,
+ label: 'Metrics',
+ onClick: () => {
+ addItem(
+ 'monitorMetrics',
+ monitor.id,
+ `${monitor.name}'s Metrics`
+ );
+ },
+ },
+ {
+ key: `monitor#${monitor.id}#chart`,
+ label: 'Chart',
+ onClick: () => {
+ addItem('monitorChart', monitor.id, `${monitor.name}'s Chart`);
+ },
+ },
+ {
+ key: `monitor#${monitor.id}#events`,
+ label: 'Events',
+ onClick: () => {
+ addItem(
+ 'monitorEvents',
+ monitor.id,
+ `${monitor.name}'s Events`
+ );
+ },
+ },
],
})),
},
diff --git a/src/client/components/dashboard/items/MonitorChartItem.tsx b/src/client/components/dashboard/items/MonitorChartItem.tsx
new file mode 100644
index 0000000..81940fe
--- /dev/null
+++ b/src/client/components/dashboard/items/MonitorChartItem.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { MonitorDataChart } from '../../monitor/MonitorDataChart';
+
+export const MonitorChartItem: React.FC<{
+ monitorId: string;
+}> = React.memo((props) => {
+ return ;
+});
+MonitorChartItem.displayName = 'MonitorChartItem';
diff --git a/src/client/components/dashboard/items/MonitorEventsItem.tsx b/src/client/components/dashboard/items/MonitorEventsItem.tsx
new file mode 100644
index 0000000..5485084
--- /dev/null
+++ b/src/client/components/dashboard/items/MonitorEventsItem.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { MonitorEventList } from '../../monitor/MonitorEventList';
+
+export const MonitorEventsItem: React.FC<{
+ monitorId: string;
+}> = React.memo((props) => {
+ return ;
+});
+MonitorEventsItem.displayName = 'MonitorEventsItem';
diff --git a/src/client/components/dashboard/items/MonitorMetricsItem.tsx b/src/client/components/dashboard/items/MonitorMetricsItem.tsx
new file mode 100644
index 0000000..f6ba242
--- /dev/null
+++ b/src/client/components/dashboard/items/MonitorMetricsItem.tsx
@@ -0,0 +1,33 @@
+import React from 'react';
+import { trpc } from '../../../api/trpc';
+import { NotFoundTip } from '../../NotFoundTip';
+import { useCurrentWorkspaceId } from '../../../store/user';
+import { Loading } from '../../Loading';
+import { MonitorDataMetrics } from '../../monitor/MonitorDataMetrics';
+
+export const MonitorMetricsItem: React.FC<{
+ monitorId: string;
+}> = React.memo((props) => {
+ const workspaceId = useCurrentWorkspaceId();
+
+ const { data: monitorInfo, isLoading } = trpc.monitor.get.useQuery({
+ workspaceId,
+ monitorId: props.monitorId,
+ });
+
+ if (isLoading) {
+ return ;
+ }
+
+ if (!monitorInfo) {
+ return ;
+ }
+
+ return (
+
+ );
+});
+MonitorMetricsItem.displayName = 'MonitorMetricsItem';
diff --git a/src/client/components/dashboard/items/index.tsx b/src/client/components/dashboard/items/index.tsx
index 8b15288..0a21daa 100644
--- a/src/client/components/dashboard/items/index.tsx
+++ b/src/client/components/dashboard/items/index.tsx
@@ -8,6 +8,9 @@ import { DeleteOutlined } from '@ant-design/icons';
import { useEvent } from '../../../hooks/useEvent';
import { WebsiteEventItem } from './WebsiteEventItem';
import { MonitorHealthBarItem } from './MonitorHealthBarItem';
+import { MonitorMetricsItem } from './MonitorMetricsItem';
+import { MonitorChartItem } from './MonitorChartItem';
+import { MonitorEventsItem } from './MonitorEventsItem';
interface DashboardGridItemProps {
item: DashboardItem;
@@ -20,10 +23,16 @@ export const DashboardGridItem: React.FC = React.memo(
const inner = useMemo(() => {
if (type === 'websiteOverview') {
return ;
- } else if (type === 'websiteEvent') {
+ } else if (type === 'websiteEvents') {
return ;
} else if (type === 'monitorHealthBar') {
return ;
+ } else if (type === 'monitorMetrics') {
+ return ;
+ } else if (type === 'monitorChart') {
+ return ;
+ } else if (type === 'monitorEvents') {
+ return ;
} else {
return ;
}
diff --git a/src/client/store/dashboard.ts b/src/client/store/dashboard.ts
index ccc3997..5183cc1 100644
--- a/src/client/store/dashboard.ts
+++ b/src/client/store/dashboard.ts
@@ -5,12 +5,11 @@ import { v1 as uuid } from 'uuid';
export type DashboardItemType =
| 'websiteOverview'
- | 'websiteEvent'
+ | 'websiteEvents'
| 'monitorHealthBar'
- | 'monitorStatus'
+ | 'monitorMetrics'
| 'monitorChart'
- | 'monitorEvent'
- | 'serverStatus';
+ | 'monitorEvents';
export interface DashboardItem {
key: string; // match with layout, not equal
@@ -73,11 +72,10 @@ export const useDashboardStore = create((set, get) => ({
}));
export const defaultItemLayout: Record> = {
- websiteOverview: { x: Infinity, y: Infinity, w: 4, h: 12 },
- websiteEvent: { x: Infinity, y: Infinity, w: 2, h: 5 },
- monitorHealthBar: { x: Infinity, y: Infinity, w: 2, h: 2 },
- monitorStatus: { x: Infinity, y: Infinity, w: 4, h: 2 },
- monitorChart: { x: Infinity, y: Infinity, w: 4, h: 2 },
- monitorEvent: { x: Infinity, y: Infinity, w: 4, h: 2 },
- serverStatus: { x: Infinity, y: Infinity, w: 4, h: 2 },
+ websiteOverview: { x: 0, y: Infinity, w: 4, h: 12 },
+ websiteEvents: { x: 0, y: Infinity, w: 2, h: 5 },
+ monitorHealthBar: { x: 0, y: Infinity, w: 2, h: 2 },
+ monitorMetrics: { x: 0, y: Infinity, w: 2, h: 3 },
+ monitorChart: { x: 0, y: Infinity, w: 2, h: 6 },
+ monitorEvents: { x: 0, y: Infinity, w: 2, h: 10 },
};