feat: Display task executor tooltip with json-view #3409 (#3467)

### What problem does this PR solve?

feat: Display task executor  tooltip with json-view #3409

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-11-18 18:36:18 +08:00
committed by GitHub
parent 4413683898
commit 01c2712941

View File

@ -14,6 +14,9 @@ import {
import { formatDate, formatTime } from '@/utils/date'; import { formatDate, formatTime } from '@/utils/date';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { get } from 'lodash'; import { get } from 'lodash';
import JsonView from 'react18-json-view';
import 'react18-json-view/src/style.css';
import styles from './index.less'; import styles from './index.less';
interface IProps { interface IProps {
@ -28,20 +31,18 @@ const CustomTooltip = ({ active, payload, ...restProps }: any) => {
{}, {},
); );
return ( return (
<div className="bg-slate-50 p-2 rounded-md border border-indigo-100"> <div className="custom-tooltip">
<div className="font-semibold text-lg"> <div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
{formatDate(restProps.label)} <div className="font-semibold text-lg">
{formatDate(restProps.label)}
</div>
<JsonView
src={taskExecutorHeartbeatItem}
displaySize={30}
className="w-full max-h-[300px] break-words overflow-auto"
/>
</div> </div>
{Object.entries(taskExecutorHeartbeatItem).map(([key, val], index) => {
return (
<div key={index} className="flex gap-1">
<span className="font-semibold">{`${key}: `}</span>
<span>
{key === 'now' || key === 'boot_at' ? formatDate(val) : val}
</span>
</div>
);
})}
</div> </div>
); );
} }
@ -54,7 +55,6 @@ const TaskBarChat = ({ data }: IProps) => {
const data = val.map((x) => ({ const data = val.map((x) => ({
...x, ...x,
now: dayjs(x.now).valueOf(), now: dayjs(x.now).valueOf(),
failed: 5,
})); }));
const firstItem = data[0]; const firstItem = data[0];
const lastItem = data[data.length - 1]; const lastItem = data[data.length - 1];
@ -69,7 +69,7 @@ const TaskBarChat = ({ data }: IProps) => {
<b className={styles.taskBarTitle}>Pending: {lastItem.pending}</b> <b className={styles.taskBarTitle}>Pending: {lastItem.pending}</b>
</div> </div>
<ResponsiveContainer> <ResponsiveContainer>
<BarChart data={data} barSize={20}> <BarChart data={data}>
<XAxis <XAxis
dataKey="now" dataKey="now"
type="number" type="number"
@ -82,16 +82,20 @@ const TaskBarChat = ({ data }: IProps) => {
tickMargin={20} tickMargin={20}
/> />
<CartesianGrid strokeDasharray="3 3" /> <CartesianGrid strokeDasharray="3 3" />
<Tooltip content={<CustomTooltip></CustomTooltip>} /> <Tooltip
wrapperStyle={{ pointerEvents: 'auto' }}
content={<CustomTooltip></CustomTooltip>}
trigger="click"
/>
<Legend wrapperStyle={{ bottom: -22 }} /> <Legend wrapperStyle={{ bottom: -22 }} />
<Bar <Bar
dataKey="done" dataKey="done"
fill="#8884d8" fill="#2fe235"
activeBar={<Rectangle fill="pink" stroke="blue" />} activeBar={<Rectangle fill="pink" stroke="blue" />}
/> />
<Bar <Bar
dataKey="failed" dataKey="failed"
fill="#82ca9d" fill="#ef3b74"
activeBar={<Rectangle fill="gold" stroke="purple" />} activeBar={<Rectangle fill="gold" stroke="purple" />}
/> />
</BarChart> </BarChart>