Skip to content

Commit

Permalink
complete topic page style
Browse files Browse the repository at this point in the history
  • Loading branch information
SUN committed Mar 9, 2024
1 parent da3fc68 commit a5339c4
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 34 deletions.
59 changes: 59 additions & 0 deletions eventmesh-dashboard-view/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions eventmesh-dashboard-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.12",
"@mui/material": "^5.15.12",
"@mui/x-data-grid": "^6.19.6",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.86",
"@types/react": "^18.2.63",
"@types/react-dom": "^18.2.20",
"echarts": "^5.5.0",
"localforage": "^1.10.0",
"match-sorter": "^6.3.4",
"react": "^18.2.0",
Expand Down
Empty file.
5 changes: 3 additions & 2 deletions eventmesh-dashboard-view/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from 'react'
import { createTheme, ThemeProvider, CssBaseline } from '@mui/material'
import './App.css'
import AppRoutes from './routes/Routes'

function App() {
const theme = React.useMemo(
() =>
createTheme({
palette: {
// mode: prefersDarkMode ? 'dark' : 'light',
primary: {
main: '#1f95fc'
}
},
typography: {
fontSize: 14
}
}),
[]
Expand Down
3 changes: 2 additions & 1 deletion eventmesh-dashboard-view/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HomeOutlinedIcon from '@mui/icons-material/HomeOutlined';
import AddCircleOutlineOutlinedIcon from '@mui/icons-material/AddCircleOutlineOutlined';
import FoundationIcon from '@mui/icons-material/Foundation';
import RefreshIcon from '@mui/icons-material/Refresh';

import { ReactComponent as EventMeshLogoIcon } from './eventmesh-logo.svg';
import { ReactComponent as EventMeshTopicIcon } from './eventmesh-topic.svg';
Expand All @@ -20,7 +21,7 @@ export const Icons = {
HomeOutlined: HomeOutlinedIcon,
AddCircleOutlineOutlined: AddCircleOutlineOutlinedIcon,
Foundation: FoundationIcon,

Refresh: RefreshIcon,

EventMeshLogo: EventMeshLogoIcon,
EventMeshTopic: EventMeshTopicIcon,
Expand Down
35 changes: 5 additions & 30 deletions eventmesh-dashboard-view/src/routes/topic/Topic.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
import React, { forwardRef } from 'react'
import React, { forwardRef, useState } from 'react'
import { Box, BoxProps, Paper, Stack } from '@mui/material'
import Page from '../../components/Page'
import TopicCount from './TopicCount'
import AbnormalTopicCount from './AbnormalTopicCount'
import Stats from './stats/Stats'
import TopicList from './topic-list/TopicList'

interface TopicProps extends BoxProps {}

const Topic = forwardRef<typeof Box, TopicProps>(({ ...props }, ref) => {
return (
<Page>
<Stack sx={{ width: 1, height: 1, p: 2 }} spacing={1}>
<Stack direction="row" spacing={1}>
<Stack sx={{ width: { sm: 180, md: 240, lg: 360 } }} spacing={1}>
<TopicCount />
<AbnormalTopicCount />
</Stack>
<Stack>
<Stack direction="row">
<Box>Filter</Box>
<Box>Refresh</Box>
</Stack>
<Stack direction="row">
<Box sx={{ flexFlow: 1 }}>Topic Stats</Box>
<Box>Message Stats</Box>
<Box>Average Message Stats</Box>
</Stack>
</Stack>
</Stack>
<Stack sx={{ flexGrow: 1 }}>
<Stack
direction="row"
justifyContent="space-between"
alignItems="center">
<Box> Search</Box>
<Box> Add</Box>
</Stack>
<Paper sx={{ flexGrow: 1 }}>List</Paper>
</Stack>
<Stats />
<TopicList />
</Stack>
</Page>
)
Expand Down
110 changes: 110 additions & 0 deletions eventmesh-dashboard-view/src/routes/topic/stats/Stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React, { forwardRef, useState } from 'react'
import {
Stack,
StackProps,
Box,
Select,
MenuItem,
Paper,
Grid
} from '@mui/material'
import TopicCount from './TopicCount'
import AbnormalTopicCount from './AbnormalTopicCount'
import { Icons } from '../../../assets/icons'
import StatsChart from './StatsChart'

enum TimeOptionEnum {
LatestHour = 'LATEST_HOUR'
}
type StatsParams = {
time?: TimeOptionEnum
runtimeId?: string
}

const TimeOptions = [{ value: TimeOptionEnum.LatestHour, label: '最新一小时' }]

interface StatsProps extends StackProps {}

const Stats = forwardRef<typeof Stack, StatsProps>(({ ...props }, ref) => {
const [statsParams, setStatsParams] = useState<StatsParams>({
runtimeId: ''
})

return (
<Stack direction="row" spacing={1}>
<Stack sx={{ width: { sm: 180, md: 240, lg: 360 } }} spacing={1}>
<TopicCount />
<AbnormalTopicCount />
</Stack>

<Paper sx={{ flexGrow: 1, p: 1 }}>
<Stack sx={{ width: 1, height: 1 }} spacing={2}>
<Stack
direction="row"
justifyContent="space-between"
alignItems="center">
<Stack direction="row" spacing={2}>
<Select
sx={{
fontSize: 14
}}
disableUnderline
displayEmpty
size="small"
variant="standard"
value={statsParams.time ?? ''}>
<MenuItem value={''}>所有时间段</MenuItem>
{TimeOptions.map((opt) => {
return (
<MenuItem
key={opt.value}
value={opt.value}
sx={{ fontSize: 'inherit' }}>
{opt.label}
</MenuItem>
)
})}
</Select>

<Select
sx={{ fontSize: 14 }}
displayEmpty
disableUnderline
size="small"
variant="standard"
value={statsParams.time ?? ''}>
<MenuItem value={''}>所有 Runtime</MenuItem>
{TimeOptions.map((opt) => {
return (
<MenuItem
key={opt.value}
value={opt.value}
sx={{ fontSize: 'inherit' }}>
{opt.label}
</MenuItem>
)
})}
</Select>
</Stack>

<Icons.Refresh fontSize="inherit" />
</Stack>
<Grid container sx={{ flexGrow: 1 }}>
<Grid item sm={4}>
<StatsChart />
</Grid>
<Grid item sm={4}>
<StatsChart />
</Grid>
<Grid item sm={4}>
<StatsChart />
</Grid>
</Grid>
</Stack>
</Paper>
</Stack>
)
})

Stats.displayName = 'Stats'
export default Stats
79 changes: 79 additions & 0 deletions eventmesh-dashboard-view/src/routes/topic/stats/StatsChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { forwardRef, useRef, useEffect } from 'react'
import { Box, BoxProps } from '@mui/material'
import echarts from '../../../utils/chart'

interface StatsChartProps extends BoxProps {}

const StatsChart = forwardRef<typeof Box, StatsChartProps>(
({ ...props }, ref) => {
const chartElemRef = useRef(null)
const chartInsRef = useRef<echarts.ECharts | null>(null)

useEffect(() => {
if (!chartInsRef.current) {
const chartIns = echarts.init(chartElemRef.current)
const chartOptions = getChartOptions()
chartIns.setOption(chartOptions)
chartInsRef.current = chartIns
}
}, [])

return <Box ref={chartElemRef} sx={{ width: 1, height: 1 }}></Box>
}
)

StatsChart.displayName = 'StatsChart'
export default StatsChart

const getChartOptions = () => {
return {
grid: {
top: 10,
left: 40,
right: 10,
bottom: 20
},
xAxis: {
type: 'category',
splitLine: {
show: true,
lineStyle: {
type: 'dashed'
}
},
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value',
splitLine: {
show: true,
lineStyle: {
type: 'dashed'
}
}
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true,
showSymbol: false,
lineStyle: {
width: 0
},
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgb(92, 216, 244)'
},
{
offset: 1,
color: 'rgb(115, 189, 255)'
}
])
}
}
]
}
}
Loading

0 comments on commit a5339c4

Please sign in to comment.