feat: add monitor event list into monitor info page

This commit is contained in:
moonrailgun 2023-10-25 00:29:47 +08:00
parent 111cf2f0eb
commit 7f014b539e
5 changed files with 61 additions and 56 deletions

View File

@ -15,6 +15,7 @@ import { ErrorTip } from '../ErrorTip';
import { ColorTag } from '../ColorTag'; import { ColorTag } from '../ColorTag';
import { useNavigate } from 'react-router'; import { useNavigate } from 'react-router';
import { MonitorStatsBlock } from './MonitorStatsBlock'; import { MonitorStatsBlock } from './MonitorStatsBlock';
import { MonitorEventList } from './MonitorEventList';
interface MonitorInfoProps { interface MonitorInfoProps {
monitorId: string; monitorId: string;
@ -43,8 +44,9 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
} }
return ( return (
<div className="w-full h-full overflow-auto">
<Spin spinning={isLoading}> <Spin spinning={isLoading}>
<Space className="w-full" direction="vertical"> <Space direction="vertical">
<div className="flex justify-between"> <div className="flex justify-between">
<Space direction="vertical"> <Space direction="vertical">
<div className="text-2xl">{monitorInfo.name}</div> <div className="text-2xl">{monitorInfo.name}</div>
@ -97,8 +99,11 @@ export const MonitorInfo: React.FC<MonitorInfoProps> = React.memo((props) => {
<Card> <Card>
<MonitorDataChart monitorId={monitorId} /> <MonitorDataChart monitorId={monitorId} />
</Card> </Card>
<MonitorEventList monitorId={monitorId} />
</Space> </Space>
</Spin> </Spin>
</div>
); );
}); });
MonitorInfo.displayName = 'MonitorInfo'; MonitorInfo.displayName = 'MonitorInfo';

View File

@ -71,8 +71,8 @@ export const Layout: React.FC = React.memo(() => {
</div> </div>
</div> </div>
)} )}
<div className="flex-1 w-full px-4"> <div className="flex-1 w-full px-4 overflow-hidden">
<div className="max-w-7xl m-auto h-full"> <div className="max-w-7xl m-auto h-full overflow-auto">
<Outlet /> <Outlet />
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@ export const MonitorDetail: React.FC = React.memo(() => {
} }
return ( return (
<div className="px-2"> <div className="px-2 h-full">
<MonitorInfo monitorId={monitorId} /> <MonitorInfo monitorId={monitorId} />
</div> </div>
); );

View File

@ -11,7 +11,7 @@ export const MonitorPage: React.FC = React.memo(() => {
return ( return (
<div className="h-full flex flex-col"> <div className="h-full flex flex-col">
<div className="flex-1"> <div>
<div className="px-4 pt-4"> <div className="px-4 pt-4">
<div <div
className="px-3 py-2 rounded-full bg-green-400 hover:bg-green-500 text-white inline-block cursor-pointer" className="px-3 py-2 rounded-full bg-green-400 hover:bg-green-500 text-white inline-block cursor-pointer"
@ -21,7 +21,7 @@ export const MonitorPage: React.FC = React.memo(() => {
</div> </div>
</div> </div>
</div> </div>
<div className="py-5 flex h-full"> <div className="py-5 flex flex-1 overflow-hidden">
<div className="w-5/12 bg-gray-50"> <div className="w-5/12 bg-gray-50">
<MonitorList /> <MonitorList />
</div> </div>

View File

@ -156,7 +156,7 @@ class MonitorRunner {
if (value < 0 && currentStatus === 'UP') { if (value < 0 && currentStatus === 'UP') {
await prisma.monitorEvent.create({ await prisma.monitorEvent.create({
data: { data: {
message: `Monitor ${monitor.name} has been down`, message: `Monitor [${monitor.name}] has been down`,
monitorId: monitor.id, monitorId: monitor.id,
type: 'DOWN', type: 'DOWN',
}, },
@ -170,7 +170,7 @@ class MonitorRunner {
} else if (value > 0 && currentStatus === 'DOWN') { } else if (value > 0 && currentStatus === 'DOWN') {
await prisma.monitorEvent.create({ await prisma.monitorEvent.create({
data: { data: {
message: `Monitor ${monitor.name} has been up`, message: `Monitor [${monitor.name}] has been up`,
monitorId: monitor.id, monitorId: monitor.id,
type: 'UP', type: 'UP',
}, },