|
| 1 | +import React from 'react'; |
| 2 | +import styles from './Dashboard.module.css'; |
| 3 | +import Quicklinks from './Quicklinks'; |
| 4 | +import JobStatus from './Jobstatus'; |
| 5 | +import { Table, Tag } from 'antd'; |
| 6 | +import { useGetLiveSystemStatus } from '../../../_hooks/src/systems/useGetLiveSystemStatus'; |
| 7 | + |
| 8 | +export interface DashboardProps {} |
| 9 | + |
| 10 | +export function Dashboard(props: DashboardProps) { |
| 11 | + const { data: liveSystems, isLoading } = useGetLiveSystemStatus(); |
| 12 | + |
| 13 | + const columns = [ |
| 14 | + { |
| 15 | + title: 'System Name', |
| 16 | + dataIndex: 'display_name', |
| 17 | + key: 'name', |
| 18 | + }, |
| 19 | + { |
| 20 | + title: 'Status', |
| 21 | + dataIndex: 'online', |
| 22 | + key: 'status', |
| 23 | + render: (online: boolean) => ( |
| 24 | + <Tag color={online ? 'green' : 'red'}>{online ? 'UP' : 'DOWN'}</Tag> |
| 25 | + ), |
| 26 | + }, |
| 27 | + { |
| 28 | + title: 'Load', |
| 29 | + dataIndex: 'load', |
| 30 | + key: 'load', |
| 31 | + render: (load: number) => `${Math.round(load * 100)}%`, |
| 32 | + }, |
| 33 | + { |
| 34 | + title: 'Running Jobs', |
| 35 | + dataIndex: 'running', |
| 36 | + key: 'running', |
| 37 | + }, |
| 38 | + { |
| 39 | + title: 'Waiting Jobs', |
| 40 | + dataIndex: 'waiting', |
| 41 | + key: 'waiting', |
| 42 | + }, |
| 43 | + ]; |
| 44 | + |
| 45 | + return ( |
| 46 | + <div style={{ display: 'flex', gap: '2rem' }}> |
| 47 | + {/* Sidebar on the left */} |
| 48 | + <Quicklinks /> |
| 49 | + |
| 50 | + {/* Middle section */} |
| 51 | + <div style={{ flex: 2 }}> |
| 52 | + <h1>DASHBOARD</h1> |
| 53 | + <JobStatus /> |
| 54 | + </div> |
| 55 | + {/* Vertical separator */} |
| 56 | + <div |
| 57 | + style={{ |
| 58 | + width: '1px', |
| 59 | + backgroundColor: '#ccc', |
| 60 | + marginTop: '2.5rem', |
| 61 | + marginBottom: '2rem', |
| 62 | + height: 'auto', |
| 63 | + minHeight: '300px', |
| 64 | + }} |
| 65 | + ></div> |
| 66 | + |
| 67 | + {/* System Status on the right */} |
| 68 | + <div style={{ flex: 1.3, paddingRight: '1.5rem' }}> |
| 69 | + <div |
| 70 | + style={{ |
| 71 | + backgroundColor: '#fff', |
| 72 | + padding: '1.5rem', |
| 73 | + borderRadius: '8px', |
| 74 | + border: '1px solid #e0e0e0', |
| 75 | + boxShadow: '0 2px 4px rgba(0, 0, 0, 0.05)', |
| 76 | + }} |
| 77 | + > |
| 78 | + <h3 style={{ marginBottom: '1rem' }}>System Status</h3> |
| 79 | + <Table |
| 80 | + columns={columns} |
| 81 | + dataSource={liveSystems?.map((sys) => ({ |
| 82 | + key: sys.hostname, |
| 83 | + ...sys, |
| 84 | + }))} |
| 85 | + loading={isLoading} |
| 86 | + size="small" |
| 87 | + pagination={false} |
| 88 | + /> |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + ); |
| 93 | +} |
| 94 | + |
| 95 | +export default Dashboard; |
0 commit comments