mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### 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:
@ -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="custom-tooltip">
|
||||||
<div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
|
<div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
|
||||||
<div className="font-semibold text-lg">
|
<div className="font-semibold text-lg">
|
||||||
{formatDate(restProps.label)}
|
{formatDate(restProps.label)}
|
||||||
</div>
|
</div>
|
||||||
{Object.entries(taskExecutorHeartbeatItem).map(([key, val], index) => {
|
|
||||||
return (
|
<JsonView
|
||||||
<div key={index} className="flex gap-1">
|
src={taskExecutorHeartbeatItem}
|
||||||
<span className="font-semibold">{`${key}: `}</span>
|
displaySize={30}
|
||||||
<span>
|
className="w-full max-h-[300px] break-words overflow-auto"
|
||||||
{key === 'now' || key === 'boot_at' ? formatDate(val) : val}
|
/>
|
||||||
</span>
|
|
||||||
</div>
|
</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user