@centreon/ui 23.10.1-MON-21256-handle-range-thresholds.8 → 23.10.1-MON-20799-fe-implement-new-visualization.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Graph/Gauge/AnimatedPie.tsx +20 -31
- package/src/Graph/Gauge/Gauge.stories.tsx +6 -97
- package/src/Graph/Gauge/Gauge.tsx +15 -4
- package/src/Graph/Gauge/PieData.tsx +24 -8
- package/src/Graph/Gauge/ResponsiveGauge.tsx +14 -11
- package/src/Graph/Gauge/Thresholds.tsx +56 -109
- package/src/Graph/Gauge/models.ts +3 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +7 -9
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/index.tsx +4 -2
- package/src/Graph/LineChart/InteractiveComponents/interactionWithGraphAtoms.ts +0 -1
- package/src/Graph/LineChart/Legend/index.tsx +4 -9
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +4 -13
- package/src/Graph/LineChart/Legend/useLegend.ts +13 -10
- package/src/Graph/LineChart/LineChart.tsx +8 -73
- package/src/Graph/LineChart/graphAtoms.ts +3 -0
- package/src/Graph/LineChart/index.stories.tsx +6 -101
- package/src/Graph/LineChart/index.tsx +3 -13
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +8 -10
- package/src/Graph/SingleBar/SingleBar.stories.tsx +6 -119
- package/src/Graph/SingleBar/Thresholds.tsx +82 -28
- package/src/Graph/SingleBar/models.ts +4 -2
- package/src/Graph/Text/Text.tsx +16 -20
- package/src/Graph/common/models.ts +0 -12
- package/src/Graph/common/timeSeries/index.ts +8 -41
- package/src/Graph/common/timeSeries/models.ts +1 -3
- package/src/Graph/common/utils.ts +6 -59
- package/src/Listing/ActionBar/index.tsx +14 -7
- package/src/Listing/Cell/DataCell.tsx +7 -7
- package/src/Listing/Cell/index.tsx +5 -5
- package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +3 -3
- package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
- package/src/Listing/Header/ListingHeader.tsx +4 -4
- package/src/Listing/Listing.styles.ts +1 -1
- package/src/Listing/Row/Row.tsx +3 -3
- package/src/Listing/index.stories.tsx +5 -5
- package/src/Listing/index.tsx +15 -12
- package/src/Listing/tableAtoms.ts +14 -11
- package/src/Listing/useStyleTable.ts +8 -8
- package/src/SortableItems/SortableItem.tsx +2 -1
- package/src/api/useGraphQuery/index.ts +21 -52
- package/src/components/Modal/Modal.styles.ts +2 -1
- package/src/utils/index.ts +0 -1
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +0 -64
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +0 -77
- package/src/Graph/SingleBar/ThresholdLine.tsx +0 -74
- package/src/utils/useRefreshInterval.ts +0 -21
- package/src/utils/useThresholds.ts +0 -0
|
@@ -20,21 +20,8 @@ const Template = (props): JSX.Element => (
|
|
|
20
20
|
export const success: Story = {
|
|
21
21
|
args: {
|
|
22
22
|
data: dataLastWeek,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
label: 'Critical',
|
|
27
|
-
value: 0.6
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
enabled: true,
|
|
31
|
-
warning: [
|
|
32
|
-
{
|
|
33
|
-
label: 'Warning',
|
|
34
|
-
value: 0.5
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
|
23
|
+
thresholdTooltipLabels: ['Warning', 'Critical'],
|
|
24
|
+
thresholds: [0.5, 1.5]
|
|
38
25
|
},
|
|
39
26
|
render: Template
|
|
40
27
|
};
|
|
@@ -42,21 +29,8 @@ export const success: Story = {
|
|
|
42
29
|
export const warning: Story = {
|
|
43
30
|
args: {
|
|
44
31
|
data: dataLastWeek,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
label: 'Critical',
|
|
49
|
-
value: 0.5
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
enabled: true,
|
|
53
|
-
warning: [
|
|
54
|
-
{
|
|
55
|
-
label: 'Warning',
|
|
56
|
-
value: 0.2
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
32
|
+
thresholdTooltipLabels: ['Warning', 'Critical'],
|
|
33
|
+
thresholds: [0.2, 0.5]
|
|
60
34
|
},
|
|
61
35
|
render: Template
|
|
62
36
|
};
|
|
@@ -64,95 +38,8 @@ export const warning: Story = {
|
|
|
64
38
|
export const critical: Story = {
|
|
65
39
|
args: {
|
|
66
40
|
data: dataLastWeek,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
label: 'Critical',
|
|
71
|
-
value: 0.35
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
enabled: true,
|
|
75
|
-
warning: [
|
|
76
|
-
{
|
|
77
|
-
label: 'Warning',
|
|
78
|
-
value: 0.13
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
render: Template
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const disabled: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
data: dataLastWeek,
|
|
89
|
-
thresholds: {
|
|
90
|
-
critical: [
|
|
91
|
-
{
|
|
92
|
-
label: 'Critical',
|
|
93
|
-
value: 0.35
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
enabled: false,
|
|
97
|
-
warning: [
|
|
98
|
-
{
|
|
99
|
-
label: 'Warning',
|
|
100
|
-
value: 0.13
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
render: Template
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const criticalLowerThanWarning: Story = {
|
|
109
|
-
args: {
|
|
110
|
-
data: dataLastWeek,
|
|
111
|
-
thresholds: {
|
|
112
|
-
critical: [
|
|
113
|
-
{
|
|
114
|
-
label: 'Critical',
|
|
115
|
-
value: 0.13
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
enabled: true,
|
|
119
|
-
warning: [
|
|
120
|
-
{
|
|
121
|
-
label: 'Warning',
|
|
122
|
-
value: 0.5
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
render: Template
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const rangeThresholds: Story = {
|
|
131
|
-
args: {
|
|
132
|
-
data: dataLastWeek,
|
|
133
|
-
thresholds: {
|
|
134
|
-
critical: [
|
|
135
|
-
{
|
|
136
|
-
label: 'Critical 1',
|
|
137
|
-
value: 0.5
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
label: 'Critical 2',
|
|
141
|
-
value: 0.6
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
enabled: true,
|
|
145
|
-
warning: [
|
|
146
|
-
{
|
|
147
|
-
label: 'Warning 1',
|
|
148
|
-
value: 0.13
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
label: 'Warning 2',
|
|
152
|
-
value: 0.3
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
41
|
+
thresholdTooltipLabels: ['Warning', 'Critical'],
|
|
42
|
+
thresholds: [0.13, 0.35]
|
|
156
43
|
},
|
|
157
44
|
render: Template
|
|
158
45
|
};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTheme } from '@mui/material';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const margin = 40;
|
|
4
|
+
|
|
5
|
+
export const barHeight = 50;
|
|
4
6
|
|
|
5
7
|
export const groupMargin = 25;
|
|
6
8
|
|
|
9
|
+
const lineMargin = 10;
|
|
10
|
+
|
|
11
|
+
const thresholdLineHeight = 60 + 2 * lineMargin;
|
|
12
|
+
|
|
7
13
|
interface Props {
|
|
8
14
|
hideTooltip: () => void;
|
|
9
15
|
showTooltip: (args) => void;
|
|
10
|
-
|
|
16
|
+
thresholdTooltipLabels: Array<string>;
|
|
17
|
+
thresholds: Array<number>;
|
|
11
18
|
xScale: (value: number) => number;
|
|
12
19
|
}
|
|
13
20
|
|
|
@@ -15,32 +22,79 @@ const Thresholds = ({
|
|
|
15
22
|
xScale,
|
|
16
23
|
thresholds,
|
|
17
24
|
showTooltip,
|
|
18
|
-
hideTooltip
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
hideTooltip,
|
|
26
|
+
thresholdTooltipLabels
|
|
27
|
+
}: Props): JSX.Element => {
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
|
|
30
|
+
const warningValue = thresholds[0];
|
|
31
|
+
const criticalValue = thresholds[1];
|
|
32
|
+
const warningTooltipLabel = thresholdTooltipLabels[0];
|
|
33
|
+
const criticalTooltipLabel = thresholdTooltipLabels[1];
|
|
34
|
+
|
|
35
|
+
const bottom = barHeight + margin * 2;
|
|
36
|
+
|
|
37
|
+
const onMouseEnter =
|
|
38
|
+
({ label, left }) =>
|
|
39
|
+
(): void =>
|
|
40
|
+
showTooltip({
|
|
41
|
+
tooltipData: label,
|
|
42
|
+
tooltipLeft: left,
|
|
43
|
+
tooltipTop: bottom
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<line
|
|
49
|
+
data-testid="warning-line"
|
|
50
|
+
stroke={theme.palette.warning.main}
|
|
51
|
+
strokeDasharray={4}
|
|
52
|
+
strokeWidth={2}
|
|
53
|
+
x1={xScale(warningValue)}
|
|
54
|
+
x2={xScale(warningValue)}
|
|
55
|
+
y1={groupMargin + 3 * lineMargin}
|
|
56
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
57
|
+
/>
|
|
58
|
+
<line
|
|
59
|
+
data-testid="critical-line"
|
|
60
|
+
stroke={theme.palette.error.main}
|
|
61
|
+
strokeDasharray={4}
|
|
62
|
+
strokeWidth={2}
|
|
63
|
+
x1={xScale(criticalValue)}
|
|
64
|
+
x2={xScale(criticalValue)}
|
|
65
|
+
y1={groupMargin + 3 * lineMargin}
|
|
66
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
67
|
+
/>
|
|
68
|
+
<line
|
|
69
|
+
data-testid="warning-line-tooltip"
|
|
70
|
+
stroke="transparent"
|
|
71
|
+
strokeWidth={5}
|
|
72
|
+
x1={xScale(warningValue)}
|
|
73
|
+
x2={xScale(warningValue)}
|
|
74
|
+
y1={groupMargin + 3 * lineMargin}
|
|
75
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
76
|
+
onMouseEnter={onMouseEnter({
|
|
77
|
+
label: warningTooltipLabel,
|
|
78
|
+
left: xScale(warningValue)
|
|
79
|
+
})}
|
|
80
|
+
onMouseLeave={hideTooltip}
|
|
30
81
|
/>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
82
|
+
<line
|
|
83
|
+
data-testid="critical-line-tooltip"
|
|
84
|
+
stroke="transparent"
|
|
85
|
+
strokeWidth={5}
|
|
86
|
+
x1={xScale(criticalValue)}
|
|
87
|
+
x2={xScale(criticalValue)}
|
|
88
|
+
y1={groupMargin + 3 * lineMargin}
|
|
89
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
90
|
+
onMouseEnter={onMouseEnter({
|
|
91
|
+
label: criticalTooltipLabel,
|
|
92
|
+
left: xScale(criticalValue)
|
|
93
|
+
})}
|
|
94
|
+
onMouseLeave={hideTooltip}
|
|
41
95
|
/>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
45
99
|
|
|
46
100
|
export default Thresholds;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { LineChartData
|
|
1
|
+
import { LineChartData } from '../common/models';
|
|
2
2
|
|
|
3
3
|
export interface SingleBarProps {
|
|
4
4
|
data?: LineChartData;
|
|
5
|
-
|
|
5
|
+
disabledThresholds?: boolean;
|
|
6
|
+
thresholdTooltipLabels: Array<string>;
|
|
7
|
+
thresholds: Array<number>;
|
|
6
8
|
}
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { isNil } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { Typography, useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import { LineChartData
|
|
5
|
+
import { LineChartData } from '../common/models';
|
|
6
6
|
import {
|
|
7
7
|
formatMetricValue,
|
|
8
8
|
getMetricWithLatestData
|
|
@@ -13,17 +13,19 @@ import { useTextStyles } from './Text.styles';
|
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
15
|
data?: LineChartData;
|
|
16
|
+
disabledThresholds?: boolean;
|
|
16
17
|
labels: {
|
|
17
18
|
critical: string;
|
|
18
19
|
warning: string;
|
|
19
20
|
};
|
|
20
|
-
thresholds:
|
|
21
|
+
thresholds: Array<number>;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const Text = ({
|
|
24
25
|
thresholds,
|
|
25
26
|
data,
|
|
26
|
-
labels
|
|
27
|
+
labels,
|
|
28
|
+
disabledThresholds
|
|
27
29
|
}: Props): JSX.Element | null => {
|
|
28
30
|
const theme = useTheme();
|
|
29
31
|
const { classes } = useTextStyles();
|
|
@@ -42,20 +44,6 @@ export const Text = ({
|
|
|
42
44
|
thresholds
|
|
43
45
|
});
|
|
44
46
|
|
|
45
|
-
const warningThresholdLabels = thresholds.warning.map(({ value }) =>
|
|
46
|
-
formatMetricValue({
|
|
47
|
-
unit: metricUnit,
|
|
48
|
-
value
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const criticalThresholdLabels = thresholds.critical.map(({ value }) =>
|
|
53
|
-
formatMetricValue({
|
|
54
|
-
unit: metricUnit,
|
|
55
|
-
value
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
|
|
59
47
|
return (
|
|
60
48
|
<div className={classes.graphText}>
|
|
61
49
|
<Typography sx={{ color }} variant="h3">
|
|
@@ -65,17 +53,25 @@ export const Text = ({
|
|
|
65
53
|
})}{' '}
|
|
66
54
|
{metricUnit}
|
|
67
55
|
</Typography>
|
|
68
|
-
{
|
|
56
|
+
{!disabledThresholds && (
|
|
69
57
|
<div className={classes.thresholds}>
|
|
70
58
|
<Typography sx={{ color: 'warning.main' }} variant="h5">
|
|
71
59
|
{labels.warning}
|
|
72
60
|
{': '}
|
|
73
|
-
{
|
|
61
|
+
{formatMetricValue({
|
|
62
|
+
unit: metricUnit,
|
|
63
|
+
value: thresholds[0]
|
|
64
|
+
})}{' '}
|
|
65
|
+
{metricUnit}
|
|
74
66
|
</Typography>
|
|
75
67
|
<Typography sx={{ color: 'error.main' }} variant="h5">
|
|
76
68
|
{labels.critical}
|
|
77
69
|
{': '}
|
|
78
|
-
{
|
|
70
|
+
{formatMetricValue({
|
|
71
|
+
unit: metricUnit,
|
|
72
|
+
value: thresholds[1]
|
|
73
|
+
})}{' '}
|
|
74
|
+
{metricUnit}
|
|
79
75
|
</Typography>
|
|
80
76
|
</div>
|
|
81
77
|
)}
|
|
@@ -5,15 +5,3 @@ export interface LineChartData {
|
|
|
5
5
|
metrics: Array<Metric>;
|
|
6
6
|
times: Array<string>;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
export interface Thresholds {
|
|
10
|
-
critical: Array<{
|
|
11
|
-
label: string;
|
|
12
|
-
value: number;
|
|
13
|
-
}>;
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
warning: Array<{
|
|
16
|
-
label: string;
|
|
17
|
-
value: number;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
@@ -326,19 +326,10 @@ const getYScale = ({
|
|
|
326
326
|
const getScale = ({
|
|
327
327
|
graphValues,
|
|
328
328
|
height,
|
|
329
|
-
stackedValues
|
|
330
|
-
thresholds
|
|
329
|
+
stackedValues
|
|
331
330
|
}): ScaleLinear<number, number> => {
|
|
332
|
-
const minValue =
|
|
333
|
-
|
|
334
|
-
getMin(stackedValues),
|
|
335
|
-
Math.min(...thresholds)
|
|
336
|
-
);
|
|
337
|
-
const maxValue = Math.max(
|
|
338
|
-
getMax(graphValues),
|
|
339
|
-
getMax(stackedValues),
|
|
340
|
-
Math.max(...thresholds)
|
|
341
|
-
);
|
|
331
|
+
const minValue = min(getMin(graphValues), getMin(stackedValues));
|
|
332
|
+
const maxValue = max(getMax(graphValues), getMax(stackedValues));
|
|
342
333
|
|
|
343
334
|
const upperRangeValue = minValue === maxValue && maxValue === 0 ? height : 0;
|
|
344
335
|
|
|
@@ -352,17 +343,10 @@ const getScale = ({
|
|
|
352
343
|
const getLeftScale = ({
|
|
353
344
|
dataLines,
|
|
354
345
|
dataTimeSeries,
|
|
355
|
-
valueGraphHeight
|
|
356
|
-
thresholds,
|
|
357
|
-
thresholdUnit
|
|
346
|
+
valueGraphHeight
|
|
358
347
|
}: AxeScale): ScaleLinear<number, number> => {
|
|
359
348
|
const [firstUnit, , thirdUnit] = getUnits(dataLines);
|
|
360
349
|
|
|
361
|
-
const shouldApplyThresholds =
|
|
362
|
-
equals(thresholdUnit, firstUnit) ||
|
|
363
|
-
equals(thresholdUnit, thirdUnit) ||
|
|
364
|
-
!thresholdUnit;
|
|
365
|
-
|
|
366
350
|
const graphValues = isNil(thirdUnit)
|
|
367
351
|
? getMetricValuesForUnit({
|
|
368
352
|
lines: dataLines,
|
|
@@ -386,12 +370,7 @@ const getLeftScale = ({
|
|
|
386
370
|
})
|
|
387
371
|
: [0];
|
|
388
372
|
|
|
389
|
-
return getScale({
|
|
390
|
-
graphValues,
|
|
391
|
-
height: valueGraphHeight,
|
|
392
|
-
stackedValues,
|
|
393
|
-
thresholds: shouldApplyThresholds ? thresholds : []
|
|
394
|
-
});
|
|
373
|
+
return getScale({ graphValues, height: valueGraphHeight, stackedValues });
|
|
395
374
|
};
|
|
396
375
|
|
|
397
376
|
const getXScale = ({
|
|
@@ -407,9 +386,7 @@ const getXScale = ({
|
|
|
407
386
|
const getRightScale = ({
|
|
408
387
|
dataLines,
|
|
409
388
|
dataTimeSeries,
|
|
410
|
-
valueGraphHeight
|
|
411
|
-
thresholds,
|
|
412
|
-
thresholdUnit
|
|
389
|
+
valueGraphHeight
|
|
413
390
|
}: AxeScale): ScaleLinear<number, number> => {
|
|
414
391
|
const [, secondUnit] = getUnits(dataLines);
|
|
415
392
|
|
|
@@ -419,8 +396,6 @@ const getRightScale = ({
|
|
|
419
396
|
unit: secondUnit
|
|
420
397
|
});
|
|
421
398
|
|
|
422
|
-
const shouldApplyThresholds = equals(thresholdUnit, secondUnit);
|
|
423
|
-
|
|
424
399
|
const secondUnitHasStackedLines = isNil(secondUnit)
|
|
425
400
|
? false
|
|
426
401
|
: hasUnitStackedLines({ lines: dataLines, unit: secondUnit });
|
|
@@ -432,12 +407,7 @@ const getRightScale = ({
|
|
|
432
407
|
})
|
|
433
408
|
: [0];
|
|
434
409
|
|
|
435
|
-
return getScale({
|
|
436
|
-
graphValues,
|
|
437
|
-
height: valueGraphHeight,
|
|
438
|
-
stackedValues,
|
|
439
|
-
thresholds: shouldApplyThresholds ? thresholds : []
|
|
440
|
-
});
|
|
410
|
+
return getScale({ graphValues, height: valueGraphHeight, stackedValues });
|
|
441
411
|
};
|
|
442
412
|
|
|
443
413
|
const formatMetricValue = ({
|
|
@@ -506,10 +476,7 @@ const getTimeValue = ({
|
|
|
506
476
|
xScale,
|
|
507
477
|
timeSeries,
|
|
508
478
|
marginLeft = margin.left
|
|
509
|
-
}: TimeValueProps): TimeValue
|
|
510
|
-
if (isNil(x)) {
|
|
511
|
-
return null;
|
|
512
|
-
}
|
|
479
|
+
}: TimeValueProps): TimeValue => {
|
|
513
480
|
const date = xScale.invert(x - marginLeft);
|
|
514
481
|
const index = bisectDate(getDates(timeSeries), date);
|
|
515
482
|
|
|
@@ -65,8 +65,6 @@ export interface Xscale {
|
|
|
65
65
|
export interface AxeScale {
|
|
66
66
|
dataLines: Array<Line>;
|
|
67
67
|
dataTimeSeries: Array<TimeValue>;
|
|
68
|
-
thresholdUnit?: string;
|
|
69
|
-
thresholds: Array<number>;
|
|
70
68
|
valueGraphHeight: number;
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -119,6 +117,6 @@ export interface YScales {
|
|
|
119
117
|
export interface TimeValueProps {
|
|
120
118
|
marginLeft?: number;
|
|
121
119
|
timeSeries: Array<TimeValue>;
|
|
122
|
-
x
|
|
120
|
+
x: number;
|
|
123
121
|
xScale: ScaleLinear<number, number>;
|
|
124
122
|
}
|
|
@@ -1,73 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
T,
|
|
3
|
-
always,
|
|
4
|
-
cond,
|
|
5
|
-
equals,
|
|
6
|
-
gt,
|
|
7
|
-
gte,
|
|
8
|
-
head,
|
|
9
|
-
length,
|
|
10
|
-
lt,
|
|
11
|
-
lte,
|
|
12
|
-
pluck
|
|
13
|
-
} from 'ramda';
|
|
1
|
+
import { T, always, cond, gt, head } from 'ramda';
|
|
14
2
|
|
|
15
3
|
import { Theme } from '@mui/material';
|
|
16
4
|
|
|
17
|
-
import { Thresholds } from './models';
|
|
18
|
-
|
|
19
5
|
interface GetColorFromDataAndThresholdsProps {
|
|
20
6
|
data: number;
|
|
21
7
|
theme: Theme;
|
|
22
|
-
thresholds:
|
|
8
|
+
thresholds: Array<number>;
|
|
23
9
|
}
|
|
24
10
|
|
|
25
11
|
export const getColorFromDataAndTresholds = ({
|
|
26
12
|
data,
|
|
27
13
|
thresholds,
|
|
28
14
|
theme
|
|
29
|
-
}: GetColorFromDataAndThresholdsProps): string =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const criticalValues = pluck('value', thresholds.critical).sort();
|
|
35
|
-
const warningValues = pluck('value', thresholds.warning).sort();
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
equals(length(criticalValues), 2) &&
|
|
39
|
-
lte(criticalValues[0], data) &&
|
|
40
|
-
gte(criticalValues[1], data)
|
|
41
|
-
) {
|
|
42
|
-
return theme.palette.error.main;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
equals(length(warningValues), 2) &&
|
|
47
|
-
lte(warningValues[0], data) &&
|
|
48
|
-
gte(warningValues[1], data)
|
|
49
|
-
) {
|
|
50
|
-
return theme.palette.warning.main;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (equals(length(warningValues), 2)) {
|
|
54
|
-
return theme.palette.success.main;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const criticalValue = head(criticalValues) as number;
|
|
58
|
-
const warningValue = head(warningValues) as number;
|
|
59
|
-
|
|
60
|
-
if (gt(warningValue, criticalValue)) {
|
|
61
|
-
return cond([
|
|
62
|
-
[lt(warningValue), always(theme.palette.success.main)],
|
|
63
|
-
[lt(criticalValue), always(theme.palette.warning.main)],
|
|
64
|
-
[T, always(theme.palette.error.main)]
|
|
65
|
-
])(data);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return cond([
|
|
69
|
-
[gt(warningValue), always(theme.palette.success.main)],
|
|
70
|
-
[gt(criticalValue), always(theme.palette.warning.main)],
|
|
15
|
+
}: GetColorFromDataAndThresholdsProps): string =>
|
|
16
|
+
cond([
|
|
17
|
+
[gt(head(thresholds) as number), always(theme.palette.success.main)],
|
|
18
|
+
[gt(thresholds[1]), always(theme.palette.warning.main)],
|
|
71
19
|
[T, always(theme.palette.error.main)]
|
|
72
20
|
])(data);
|
|
73
|
-
};
|
|
@@ -86,7 +86,7 @@ type Props = Pick<
|
|
|
86
86
|
| 'moveTablePagination'
|
|
87
87
|
| 'widthToMoveTablePagination'
|
|
88
88
|
| 'customPaginationClassName'
|
|
89
|
-
| '
|
|
89
|
+
| 'listingVariant'
|
|
90
90
|
| 'viewerModeConfiguration'
|
|
91
91
|
>;
|
|
92
92
|
|
|
@@ -107,7 +107,8 @@ const MemoListingActionBar = ({
|
|
|
107
107
|
widthToMoveTablePagination = 550,
|
|
108
108
|
actionsBarMemoProps = [],
|
|
109
109
|
viewerModeConfiguration,
|
|
110
|
-
|
|
110
|
+
listingVariant,
|
|
111
|
+
visualizationActions
|
|
111
112
|
}: Props): JSX.Element => {
|
|
112
113
|
const marginWidthTableListing = 30;
|
|
113
114
|
const { classes, cx } = useStyles({
|
|
@@ -136,6 +137,7 @@ const MemoListingActionBar = ({
|
|
|
136
137
|
<div className={classes.actions}>
|
|
137
138
|
<div>{actions}</div>
|
|
138
139
|
</div>
|
|
140
|
+
{visualizationActions && <div>{visualizationActions}</div>}
|
|
139
141
|
<div className={classes.subContainer}>
|
|
140
142
|
{!isEmpty(viewerModeConfiguration) &&
|
|
141
143
|
!isNil(viewerModeConfiguration) && (
|
|
@@ -159,7 +161,10 @@ const MemoListingActionBar = ({
|
|
|
159
161
|
viewerModeConfiguration?.customStyle
|
|
160
162
|
?.customStyleViewerModeIcon,
|
|
161
163
|
{
|
|
162
|
-
[classes.mode]: equals(
|
|
164
|
+
[classes.mode]: equals(
|
|
165
|
+
listingVariant,
|
|
166
|
+
ListingVariant.extended
|
|
167
|
+
)
|
|
163
168
|
}
|
|
164
169
|
)}
|
|
165
170
|
>
|
|
@@ -210,7 +215,7 @@ const MemoListingActionBar = ({
|
|
|
210
215
|
currentPage,
|
|
211
216
|
moveTablePagination,
|
|
212
217
|
widthToMoveTablePagination,
|
|
213
|
-
|
|
218
|
+
listingVariant,
|
|
214
219
|
themeMode,
|
|
215
220
|
limit,
|
|
216
221
|
pick(
|
|
@@ -240,8 +245,9 @@ const ListingActionBar = ({
|
|
|
240
245
|
moveTablePagination,
|
|
241
246
|
widthToMoveTablePagination,
|
|
242
247
|
customPaginationClassName,
|
|
243
|
-
|
|
244
|
-
viewerModeConfiguration
|
|
248
|
+
listingVariant,
|
|
249
|
+
viewerModeConfiguration,
|
|
250
|
+
visualizationActions
|
|
245
251
|
}: Props): JSX.Element | null => {
|
|
246
252
|
if (
|
|
247
253
|
not(paginated) &&
|
|
@@ -260,11 +266,12 @@ const ListingActionBar = ({
|
|
|
260
266
|
currentPage={currentPage}
|
|
261
267
|
customPaginationClassName={customPaginationClassName}
|
|
262
268
|
limit={limit}
|
|
269
|
+
listingVariant={listingVariant}
|
|
263
270
|
moveTablePagination={moveTablePagination}
|
|
264
271
|
paginated={paginated}
|
|
265
272
|
totalRows={totalRows}
|
|
266
|
-
viewMode={viewMode}
|
|
267
273
|
viewerModeConfiguration={viewerModeConfiguration}
|
|
274
|
+
visualizationActions={visualizationActions}
|
|
268
275
|
widthToMoveTablePagination={widthToMoveTablePagination}
|
|
269
276
|
onLimitChange={onLimitChange}
|
|
270
277
|
onPaginate={onPaginate}
|