balibabu commited on
Commit
9efd53f
·
1 Parent(s): eae0334

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

Browse files

### 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)

web/src/pages/user-setting/setting-system/task-bar-chat.tsx CHANGED
@@ -14,6 +14,9 @@ import {
14
  import { formatDate, formatTime } from '@/utils/date';
15
  import dayjs from 'dayjs';
16
  import { get } from 'lodash';
 
 
 
17
  import styles from './index.less';
18
 
19
  interface IProps {
@@ -28,20 +31,18 @@ const CustomTooltip = ({ active, payload, ...restProps }: any) => {
28
  {},
29
  );
30
  return (
31
- <div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
32
- <div className="font-semibold text-lg">
33
- {formatDate(restProps.label)}
 
 
 
 
 
 
 
 
34
  </div>
35
- {Object.entries(taskExecutorHeartbeatItem).map(([key, val], index) => {
36
- return (
37
- <div key={index} className="flex gap-1">
38
- <span className="font-semibold">{`${key}: `}</span>
39
- <span>
40
- {key === 'now' || key === 'boot_at' ? formatDate(val) : val}
41
- </span>
42
- </div>
43
- );
44
- })}
45
  </div>
46
  );
47
  }
@@ -54,7 +55,6 @@ const TaskBarChat = ({ data }: IProps) => {
54
  const data = val.map((x) => ({
55
  ...x,
56
  now: dayjs(x.now).valueOf(),
57
- failed: 5,
58
  }));
59
  const firstItem = data[0];
60
  const lastItem = data[data.length - 1];
@@ -69,7 +69,7 @@ const TaskBarChat = ({ data }: IProps) => {
69
  <b className={styles.taskBarTitle}>Pending: {lastItem.pending}</b>
70
  </div>
71
  <ResponsiveContainer>
72
- <BarChart data={data} barSize={20}>
73
  <XAxis
74
  dataKey="now"
75
  type="number"
@@ -82,16 +82,20 @@ const TaskBarChat = ({ data }: IProps) => {
82
  tickMargin={20}
83
  />
84
  <CartesianGrid strokeDasharray="3 3" />
85
- <Tooltip content={<CustomTooltip></CustomTooltip>} />
 
 
 
 
86
  <Legend wrapperStyle={{ bottom: -22 }} />
87
  <Bar
88
  dataKey="done"
89
- fill="#8884d8"
90
  activeBar={<Rectangle fill="pink" stroke="blue" />}
91
  />
92
  <Bar
93
  dataKey="failed"
94
- fill="#82ca9d"
95
  activeBar={<Rectangle fill="gold" stroke="purple" />}
96
  />
97
  </BarChart>
 
14
  import { formatDate, formatTime } from '@/utils/date';
15
  import dayjs from 'dayjs';
16
  import { get } from 'lodash';
17
+ import JsonView from 'react18-json-view';
18
+ import 'react18-json-view/src/style.css';
19
+
20
  import styles from './index.less';
21
 
22
  interface IProps {
 
31
  {},
32
  );
33
  return (
34
+ <div className="custom-tooltip">
35
+ <div className="bg-slate-50 p-2 rounded-md border border-indigo-100">
36
+ <div className="font-semibold text-lg">
37
+ {formatDate(restProps.label)}
38
+ </div>
39
+
40
+ <JsonView
41
+ src={taskExecutorHeartbeatItem}
42
+ displaySize={30}
43
+ className="w-full max-h-[300px] break-words overflow-auto"
44
+ />
45
  </div>
 
 
 
 
 
 
 
 
 
 
46
  </div>
47
  );
48
  }
 
55
  const data = val.map((x) => ({
56
  ...x,
57
  now: dayjs(x.now).valueOf(),
 
58
  }));
59
  const firstItem = data[0];
60
  const lastItem = data[data.length - 1];
 
69
  <b className={styles.taskBarTitle}>Pending: {lastItem.pending}</b>
70
  </div>
71
  <ResponsiveContainer>
72
+ <BarChart data={data}>
73
  <XAxis
74
  dataKey="now"
75
  type="number"
 
82
  tickMargin={20}
83
  />
84
  <CartesianGrid strokeDasharray="3 3" />
85
+ <Tooltip
86
+ wrapperStyle={{ pointerEvents: 'auto' }}
87
+ content={<CustomTooltip></CustomTooltip>}
88
+ trigger="click"
89
+ />
90
  <Legend wrapperStyle={{ bottom: -22 }} />
91
  <Bar
92
  dataKey="done"
93
+ fill="#2fe235"
94
  activeBar={<Rectangle fill="pink" stroke="blue" />}
95
  />
96
  <Bar
97
  dataKey="failed"
98
+ fill="#ef3b74"
99
  activeBar={<Rectangle fill="gold" stroke="purple" />}
100
  />
101
  </BarChart>