浏览代码

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)
tags/v0.14.0
balibabu 11 个月前
父节点
当前提交
01c2712941
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 22 次插入18 次删除
  1. 22
    18
      web/src/pages/user-setting/setting-system/task-bar-chat.tsx

+ 22
- 18
web/src/pages/user-setting/setting-system/task-bar-chat.tsx 查看文件

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 {
{}, {},
); );
return ( return (
<div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
<div className="font-semibold text-lg">
{formatDate(restProps.label)}
<div className="custom-tooltip">
<div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
<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>
); );
} }
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];
<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"
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>

正在加载...
取消
保存