@centreon/ui 24.4.46 → 24.4.48
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 +14 -23
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +5 -9
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/index.tsx +1 -1
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +1 -3
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -9
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +13 -16
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +2 -4
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +4 -60
- package/src/Graph/Text/Text.tsx +1 -1
- package/src/Graph/common/timeSeries/index.ts +14 -22
- package/src/Graph/common/utils.ts +0 -19
- package/src/Graph/index.ts +0 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +115 -121
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/ActionBar/index.tsx +8 -9
- package/src/Listing/Cell/DataCell.styles.ts +0 -3
- package/src/Listing/Cell/DataCell.tsx +5 -23
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +4 -80
- package/src/Listing/Listing.styles.ts +7 -4
- package/src/Listing/index.stories.tsx +3 -37
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +3 -4
- package/src/Listing/models.ts +0 -1
- package/src/Module/index.tsx +4 -2
- package/src/RichTextEditor/RichTextEditor.tsx +1 -12
- package/src/SortableItems/index.tsx +7 -2
- package/src/ThemeProvider/index.tsx +0 -24
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +4 -12
- package/src/TimePeriods/index.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +23 -27
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +25 -60
- package/src/components/Button/Icon/IconButton.tsx +2 -6
- package/src/components/DataTable/DataTable.stories.tsx +0 -40
- package/src/components/DataTable/DataTable.styles.ts +0 -3
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +1 -3
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
- package/src/components/Layout/PageLayout/index.ts +1 -3
- package/src/components/Modal/Modal.styles.ts +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +1 -5
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/useFullscreen/useFullscreenListener.ts +7 -10
- package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/Form/Form.cypress.spec.tsx +0 -133
- package/src/Form/Inputs/List/Content.tsx +0 -62
- package/src/Form/Inputs/List/List.styles.ts +0 -29
- package/src/Form/Inputs/List/List.tsx +0 -58
- package/src/Form/Inputs/List/useList.ts +0 -81
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +0 -154
- package/src/Graph/BarStack/BarStack.stories.tsx +0 -123
- package/src/Graph/BarStack/BarStack.styles.ts +0 -36
- package/src/Graph/BarStack/BarStack.tsx +0 -14
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +0 -208
- package/src/Graph/BarStack/index.ts +0 -1
- package/src/Graph/BarStack/models.ts +0 -19
- package/src/Graph/BarStack/useResponsiveBarStack.ts +0 -139
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
- package/src/Graph/Legend/Legend.tsx +0 -21
- package/src/Graph/Legend/index.ts +0 -1
- package/src/Graph/Legend/models.ts +0 -11
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -169
- package/src/Graph/PieChart/PieChart.stories.tsx +0 -194
- package/src/Graph/PieChart/PieChart.styles.ts +0 -39
- package/src/Graph/PieChart/PieChart.tsx +0 -14
- package/src/Graph/PieChart/ResponsivePie.tsx +0 -251
- package/src/Graph/PieChart/index.ts +0 -1
- package/src/Graph/PieChart/models.ts +0 -19
- package/src/Graph/PieChart/useResponsivePie.ts +0 -86
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
- package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
- package/src/Graph/common/testUtils.ts +0 -71
- package/src/Graph/translatedLabels.ts +0 -1
- package/src/Module/Module.cypress.spec.tsx +0 -129
- package/src/components/DataTable/DataListing.tsx +0 -6
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
- package/src/utils/usePluralizedTranslation.ts +0 -21
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Pie } from '@visx/shape';
|
|
4
|
-
import { Group } from '@visx/group';
|
|
5
|
-
import { Text } from '@visx/text';
|
|
6
|
-
import numeral from 'numeral';
|
|
7
|
-
import { always, equals, gt, ifElse, lt } from 'ramda';
|
|
8
|
-
import { useTranslation } from 'react-i18next';
|
|
9
|
-
|
|
10
|
-
import { Typography, useTheme } from '@mui/material';
|
|
11
|
-
|
|
12
|
-
import { Tooltip } from '../../components';
|
|
13
|
-
import { Legend as LegendComponent } from '../Legend';
|
|
14
|
-
import { LegendProps } from '../Legend/models';
|
|
15
|
-
import { getValueByUnit } from '../common/utils';
|
|
16
|
-
import { labelNoDataFound } from '../translatedLabels';
|
|
17
|
-
|
|
18
|
-
import { PieProps } from './models';
|
|
19
|
-
import { usePieStyles } from './PieChart.styles';
|
|
20
|
-
import { useResponsivePie } from './useResponsivePie';
|
|
21
|
-
|
|
22
|
-
const DefaultLengd = ({ scale, direction }: LegendProps): JSX.Element => (
|
|
23
|
-
<LegendComponent direction={direction} scale={scale} />
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
type Placement = 'left' | 'right' | 'top' | 'bottom';
|
|
27
|
-
|
|
28
|
-
const getTooltipPlacement = ({ radianX, radianY }): Placement => {
|
|
29
|
-
if (gt(Math.abs(radianX), Math.abs(radianY))) {
|
|
30
|
-
return ifElse<[b: number], Placement, Placement>(
|
|
31
|
-
lt(0),
|
|
32
|
-
always<Placement>('right'),
|
|
33
|
-
always<Placement>('left')
|
|
34
|
-
)(radianX);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return ifElse<[b: number], Placement, Placement>(
|
|
38
|
-
lt(0),
|
|
39
|
-
always<Placement>('bottom'),
|
|
40
|
-
always<Placement>('top')
|
|
41
|
-
)(radianY);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const ResponsivePie = ({
|
|
45
|
-
title,
|
|
46
|
-
variant = 'pie',
|
|
47
|
-
width,
|
|
48
|
-
height,
|
|
49
|
-
data,
|
|
50
|
-
unit = 'number',
|
|
51
|
-
Legend = DefaultLengd,
|
|
52
|
-
displayLegend = true,
|
|
53
|
-
innerRadius: defaultInnerRadius = 40,
|
|
54
|
-
onArcClick,
|
|
55
|
-
displayValues,
|
|
56
|
-
TooltipContent,
|
|
57
|
-
legendDirection = 'column'
|
|
58
|
-
}: PieProps & { height: number; width: number }): JSX.Element => {
|
|
59
|
-
const { t } = useTranslation();
|
|
60
|
-
const theme = useTheme();
|
|
61
|
-
|
|
62
|
-
const legendRef = useRef(null);
|
|
63
|
-
const titleRef = useRef(null);
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
half,
|
|
67
|
-
legendScale,
|
|
68
|
-
svgContainerSize,
|
|
69
|
-
svgSize,
|
|
70
|
-
svgWrapperWidth,
|
|
71
|
-
total,
|
|
72
|
-
innerRadius,
|
|
73
|
-
isContainsExactlyOneNonZeroValue,
|
|
74
|
-
areAllValuesNull
|
|
75
|
-
} = useResponsivePie({
|
|
76
|
-
data,
|
|
77
|
-
defaultInnerRadius,
|
|
78
|
-
height,
|
|
79
|
-
legendRef,
|
|
80
|
-
titleRef,
|
|
81
|
-
unit,
|
|
82
|
-
width
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const { classes } = usePieStyles({ svgSize });
|
|
86
|
-
|
|
87
|
-
if (areAllValuesNull) {
|
|
88
|
-
return (
|
|
89
|
-
<div className={classes.container} style={{ height, width }}>
|
|
90
|
-
<Typography variant="h3">{t(labelNoDataFound)}</Typography>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div
|
|
97
|
-
className={classes.container}
|
|
98
|
-
style={{
|
|
99
|
-
height,
|
|
100
|
-
width
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
<div
|
|
104
|
-
className={classes.svgWrapper}
|
|
105
|
-
style={{
|
|
106
|
-
height,
|
|
107
|
-
width: svgWrapperWidth
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
{equals(variant, 'pie') && title && (
|
|
111
|
-
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
112
|
-
{`${numeral(total).format('0a').toUpperCase()} `} {title}
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
<div
|
|
116
|
-
className={classes.svgContainer}
|
|
117
|
-
data-testid="pieChart"
|
|
118
|
-
style={{
|
|
119
|
-
height: svgContainerSize,
|
|
120
|
-
width: svgContainerSize
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<svg data-variant={variant} height={svgSize} width={svgSize}>
|
|
124
|
-
<Group left={half} top={half}>
|
|
125
|
-
<Pie
|
|
126
|
-
cornerRadius={4}
|
|
127
|
-
data={data}
|
|
128
|
-
innerRadius={() => {
|
|
129
|
-
return equals(variant, 'pie') ? 0 : half - innerRadius;
|
|
130
|
-
}}
|
|
131
|
-
outerRadius={half}
|
|
132
|
-
pieValue={(items) => items.value}
|
|
133
|
-
>
|
|
134
|
-
{(pie) => {
|
|
135
|
-
return pie.arcs.map((arc) => {
|
|
136
|
-
const [centroidX, centroidY] = pie.path.centroid(arc);
|
|
137
|
-
const midAngle = Math.atan2(centroidY, centroidX);
|
|
138
|
-
|
|
139
|
-
const labelRadius = half * 0.8;
|
|
140
|
-
|
|
141
|
-
const labelX = Math.cos(midAngle) * labelRadius;
|
|
142
|
-
const labelY = Math.sin(midAngle) * labelRadius;
|
|
143
|
-
|
|
144
|
-
const angle = arc.endAngle - arc.startAngle;
|
|
145
|
-
const minAngle = 0.2;
|
|
146
|
-
|
|
147
|
-
const x = equals(variant, 'donut') ? centroidX : labelX;
|
|
148
|
-
const y = equals(variant, 'donut') ? centroidY : labelY;
|
|
149
|
-
|
|
150
|
-
const onClick = (): void => {
|
|
151
|
-
onArcClick?.(arc.data);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<Tooltip
|
|
156
|
-
hasCaret
|
|
157
|
-
classes={{
|
|
158
|
-
tooltip: classes.pieChartTooltip
|
|
159
|
-
}}
|
|
160
|
-
followCursor={false}
|
|
161
|
-
key={arc.data.label}
|
|
162
|
-
label={
|
|
163
|
-
TooltipContent && (
|
|
164
|
-
<TooltipContent
|
|
165
|
-
color={arc.data.color}
|
|
166
|
-
label={arc.data.label}
|
|
167
|
-
title={title}
|
|
168
|
-
total={total}
|
|
169
|
-
value={arc.data.value}
|
|
170
|
-
/>
|
|
171
|
-
)
|
|
172
|
-
}
|
|
173
|
-
leaveDelay={200}
|
|
174
|
-
placement={getTooltipPlacement({
|
|
175
|
-
radianX: Math.cos(midAngle),
|
|
176
|
-
radianY: Math.sin(midAngle)
|
|
177
|
-
})}
|
|
178
|
-
>
|
|
179
|
-
<g data-testid={arc.data.label} onClick={onClick}>
|
|
180
|
-
<path
|
|
181
|
-
d={pie.path(arc) as string}
|
|
182
|
-
fill={arc.data.color}
|
|
183
|
-
/>
|
|
184
|
-
{displayValues &&
|
|
185
|
-
!isContainsExactlyOneNonZeroValue &&
|
|
186
|
-
angle > minAngle && (
|
|
187
|
-
<Text
|
|
188
|
-
data-testid="value"
|
|
189
|
-
dy=".33em"
|
|
190
|
-
fill="#000"
|
|
191
|
-
fontSize={12}
|
|
192
|
-
pointerEvents="none"
|
|
193
|
-
textAnchor="middle"
|
|
194
|
-
x={x}
|
|
195
|
-
y={y}
|
|
196
|
-
>
|
|
197
|
-
{getValueByUnit({
|
|
198
|
-
total,
|
|
199
|
-
unit,
|
|
200
|
-
value: arc.data.value
|
|
201
|
-
})}
|
|
202
|
-
</Text>
|
|
203
|
-
)}
|
|
204
|
-
</g>
|
|
205
|
-
</Tooltip>
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
}}
|
|
209
|
-
</Pie>
|
|
210
|
-
{equals(variant, 'donut') && title && (
|
|
211
|
-
<>
|
|
212
|
-
<Text
|
|
213
|
-
className={classes.title}
|
|
214
|
-
dy={lt(svgSize, 150) ? -10 : -15}
|
|
215
|
-
fill={theme.palette.text.primary}
|
|
216
|
-
textAnchor="middle"
|
|
217
|
-
>
|
|
218
|
-
{numeral(total).format('0a').toUpperCase()}
|
|
219
|
-
</Text>
|
|
220
|
-
<Text
|
|
221
|
-
className={classes.title}
|
|
222
|
-
data-testid="Title"
|
|
223
|
-
dy={lt(svgSize, 150) ? 10 : 15}
|
|
224
|
-
fill={theme.palette.text.primary}
|
|
225
|
-
textAnchor="middle"
|
|
226
|
-
>
|
|
227
|
-
{title}
|
|
228
|
-
</Text>
|
|
229
|
-
</>
|
|
230
|
-
)}
|
|
231
|
-
</Group>
|
|
232
|
-
</svg>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
{displayLegend && (
|
|
236
|
-
<div data-testid="Legend" ref={legendRef}>
|
|
237
|
-
<Legend
|
|
238
|
-
data={data}
|
|
239
|
-
direction={legendDirection}
|
|
240
|
-
scale={legendScale}
|
|
241
|
-
title={title}
|
|
242
|
-
total={total}
|
|
243
|
-
unit={unit}
|
|
244
|
-
/>
|
|
245
|
-
</div>
|
|
246
|
-
)}
|
|
247
|
-
</div>
|
|
248
|
-
);
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
export default ResponsivePie;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as PieChart } from './PieChart';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface ArcType {
|
|
2
|
-
color: string;
|
|
3
|
-
label: string;
|
|
4
|
-
value: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface PieProps {
|
|
8
|
-
Legend?: ({ scale, direction, data, title, total, unit }) => JSX.Element;
|
|
9
|
-
TooltipContent?: (arcData) => JSX.Element | boolean | null;
|
|
10
|
-
data: Array<ArcType>;
|
|
11
|
-
displayLegend?: boolean;
|
|
12
|
-
displayValues?: boolean;
|
|
13
|
-
innerRadius?: number;
|
|
14
|
-
legendDirection?: 'row' | 'column';
|
|
15
|
-
onArcClick?: (ardata) => void;
|
|
16
|
-
title?: string;
|
|
17
|
-
unit?: 'percentage' | 'number';
|
|
18
|
-
variant?: 'pie' | 'donut';
|
|
19
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { equals, isEmpty, pluck, reject } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import { LegendScale } from '../Legend/models';
|
|
4
|
-
import { getValueByUnit } from '../common/utils';
|
|
5
|
-
|
|
6
|
-
import { ArcType } from './models';
|
|
7
|
-
|
|
8
|
-
interface ResponsivePieProps {
|
|
9
|
-
data: Array<ArcType>;
|
|
10
|
-
defaultInnerRadius: number;
|
|
11
|
-
height: number;
|
|
12
|
-
legendRef;
|
|
13
|
-
titleRef;
|
|
14
|
-
unit: 'percentage' | 'number';
|
|
15
|
-
width: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ResponsivePieState {
|
|
19
|
-
areAllValuesNull: boolean;
|
|
20
|
-
half: number;
|
|
21
|
-
innerRadius: number;
|
|
22
|
-
isContainsExactlyOneNonZeroValue: boolean;
|
|
23
|
-
legendScale: LegendScale;
|
|
24
|
-
svgContainerSize: number;
|
|
25
|
-
svgSize: number;
|
|
26
|
-
svgWrapperWidth: number;
|
|
27
|
-
total: number;
|
|
28
|
-
}
|
|
29
|
-
export const useResponsivePie = ({
|
|
30
|
-
titleRef,
|
|
31
|
-
legendRef,
|
|
32
|
-
height,
|
|
33
|
-
width,
|
|
34
|
-
data,
|
|
35
|
-
unit,
|
|
36
|
-
defaultInnerRadius
|
|
37
|
-
}: ResponsivePieProps): ResponsivePieState => {
|
|
38
|
-
const heightOfTitle = titleRef.current?.offsetHeight || 0;
|
|
39
|
-
const widthOfLegend = legendRef.current?.offsetWidth || 0;
|
|
40
|
-
|
|
41
|
-
const horizontalGap = widthOfLegend > 0 ? 16 : 0;
|
|
42
|
-
const verticalGap = heightOfTitle > 0 ? 8 : 0;
|
|
43
|
-
|
|
44
|
-
const svgWrapperWidth = width - widthOfLegend - horizontalGap;
|
|
45
|
-
|
|
46
|
-
const svgContainerSize = Math.min(
|
|
47
|
-
height - heightOfTitle - verticalGap,
|
|
48
|
-
width - widthOfLegend - horizontalGap
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const outerRadius = Math.min(32, svgContainerSize / 6);
|
|
52
|
-
|
|
53
|
-
const svgSize = svgContainerSize - outerRadius;
|
|
54
|
-
|
|
55
|
-
const half = svgSize / 2;
|
|
56
|
-
|
|
57
|
-
const total = Math.floor(data.reduce((acc, { value }) => acc + value, 0));
|
|
58
|
-
|
|
59
|
-
const innerRadius = Math.min(defaultInnerRadius, svgSize / 5);
|
|
60
|
-
|
|
61
|
-
const legendScale = {
|
|
62
|
-
domain: data.map(({ value }) => getValueByUnit({ total, unit, value })),
|
|
63
|
-
range: pluck('color', data)
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const values = pluck('value', data);
|
|
67
|
-
|
|
68
|
-
const isContainsExactlyOneNonZeroValue = equals(
|
|
69
|
-
reject((value) => equals(value, 0), values).length,
|
|
70
|
-
1
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const areAllValuesNull = isEmpty(reject((value) => equals(value, 0), values));
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
areAllValuesNull,
|
|
77
|
-
half,
|
|
78
|
-
innerRadius,
|
|
79
|
-
isContainsExactlyOneNonZeroValue,
|
|
80
|
-
legendScale,
|
|
81
|
-
svgContainerSize,
|
|
82
|
-
svgSize,
|
|
83
|
-
svgWrapperWidth,
|
|
84
|
-
total
|
|
85
|
-
};
|
|
86
|
-
};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
|
|
2
|
-
import {
|
|
3
|
-
criticalThresholds,
|
|
4
|
-
rangedThresholds,
|
|
5
|
-
successThresholds,
|
|
6
|
-
warningThresholds
|
|
7
|
-
} from '../common/testUtils';
|
|
8
|
-
|
|
9
|
-
import SingleBar from './SingleBar';
|
|
10
|
-
import { SingleBarProps } from './models';
|
|
11
|
-
|
|
12
|
-
const initialize = (
|
|
13
|
-
args: Omit<SingleBarProps, 'data' | 'labels' | 'baseColor'>
|
|
14
|
-
): void => {
|
|
15
|
-
cy.mount({
|
|
16
|
-
Component: (
|
|
17
|
-
<div style={{ height: '100vh', width: '100vw' }}>
|
|
18
|
-
<SingleBar
|
|
19
|
-
baseColor="#000"
|
|
20
|
-
data={dataLastWeek}
|
|
21
|
-
labels={{
|
|
22
|
-
critical: 'Critical',
|
|
23
|
-
warning: 'Warning'
|
|
24
|
-
}}
|
|
25
|
-
{...args}
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
)
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
describe('Single bar', () => {
|
|
33
|
-
it('displays the single bar as success when corresponding thresholds are set', () => {
|
|
34
|
-
initialize({ thresholds: successThresholds });
|
|
35
|
-
|
|
36
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
|
|
37
|
-
cy.findByTestId('warning-line-0.5').should('be.visible');
|
|
38
|
-
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
39
|
-
cy.findByTestId('critical-line-1.5').should('be.visible');
|
|
40
|
-
cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
|
|
41
|
-
|
|
42
|
-
cy.makeSnapshot();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('displays the single bar as warning when corresponding thresholds are set', () => {
|
|
46
|
-
initialize({ thresholds: warningThresholds });
|
|
47
|
-
|
|
48
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
|
|
49
|
-
cy.findByTestId('warning-line-0.4').should('be.visible');
|
|
50
|
-
cy.findByTestId('warning-line-0.4-tooltip').should('be.visible');
|
|
51
|
-
cy.findByTestId('critical-line-1.5').should('be.visible');
|
|
52
|
-
cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
|
|
53
|
-
|
|
54
|
-
cy.makeSnapshot();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('displays the single bar as critical when corresponding thresholds are set', () => {
|
|
58
|
-
initialize({ thresholds: criticalThresholds });
|
|
59
|
-
|
|
60
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
|
|
61
|
-
cy.findByTestId('warning-line-0.2').should('be.visible');
|
|
62
|
-
cy.findByTestId('warning-line-0.2-tooltip').should('be.visible');
|
|
63
|
-
cy.findByTestId('critical-line-0.3').should('be.visible');
|
|
64
|
-
cy.findByTestId('critical-line-0.3-tooltip').should('be.visible');
|
|
65
|
-
|
|
66
|
-
cy.makeSnapshot();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('displays ranged thresholds', () => {
|
|
70
|
-
initialize({ thresholds: rangedThresholds });
|
|
71
|
-
|
|
72
|
-
cy.findByTestId('warning-line-0.13').should('be.visible');
|
|
73
|
-
cy.findByTestId('warning-line-0.13-tooltip').should('be.visible');
|
|
74
|
-
cy.findByTestId('warning-line-0.5').should('be.visible');
|
|
75
|
-
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
76
|
-
cy.findByTestId('critical-line-0.55').should('be.visible');
|
|
77
|
-
cy.findByTestId('critical-line-0.55-tooltip').should('be.visible');
|
|
78
|
-
cy.findByTestId('critical-line-0.65').should('be.visible');
|
|
79
|
-
cy.findByTestId('critical-line-0.65-tooltip').should('be.visible');
|
|
80
|
-
|
|
81
|
-
cy.makeSnapshot();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('displays the threshold tooltip when a threshold is hovered', () => {
|
|
85
|
-
initialize({ thresholds: successThresholds });
|
|
86
|
-
|
|
87
|
-
cy.findByTestId('warning-line-0.5-tooltip').trigger('mouseover');
|
|
88
|
-
|
|
89
|
-
cy.contains('Warning').should('be.visible');
|
|
90
|
-
|
|
91
|
-
cy.findByTestId('critical-line-1.5-tooltip').trigger('mouseover');
|
|
92
|
-
|
|
93
|
-
cy.contains('Critical').should('be.visible');
|
|
94
|
-
|
|
95
|
-
cy.makeSnapshot();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('displays single bar as small when the props is set', () => {
|
|
99
|
-
initialize({ size: 'small', thresholds: successThresholds });
|
|
100
|
-
|
|
101
|
-
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
102
|
-
|
|
103
|
-
cy.makeSnapshot();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('displays the value as raw when the prop is set', () => {
|
|
107
|
-
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
108
|
-
|
|
109
|
-
cy.contains('0.40663333333 s').should('be.visible');
|
|
110
|
-
|
|
111
|
-
cy.makeSnapshot();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('does not display the value when the prop is set', () => {
|
|
115
|
-
initialize({ showLabels: false, thresholds: successThresholds });
|
|
116
|
-
|
|
117
|
-
cy.contains('0.41 s').should('not.exist');
|
|
118
|
-
|
|
119
|
-
cy.makeSnapshot();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
|
|
2
|
-
import {
|
|
3
|
-
criticalThresholds,
|
|
4
|
-
rangedThresholds,
|
|
5
|
-
successThresholds,
|
|
6
|
-
warningThresholds
|
|
7
|
-
} from '../common/testUtils';
|
|
8
|
-
|
|
9
|
-
import { Text, Props } from './Text';
|
|
10
|
-
|
|
11
|
-
const initialize = (
|
|
12
|
-
args: Omit<Props, 'data' | 'labels' | 'baseColor'>
|
|
13
|
-
): void => {
|
|
14
|
-
cy.mount({
|
|
15
|
-
Component: (
|
|
16
|
-
<div style={{ height: '100vh', width: '100vw' }}>
|
|
17
|
-
<Text
|
|
18
|
-
baseColor="#000"
|
|
19
|
-
data={dataLastWeek}
|
|
20
|
-
labels={{
|
|
21
|
-
critical: 'Critical',
|
|
22
|
-
warning: 'Warning'
|
|
23
|
-
}}
|
|
24
|
-
{...args}
|
|
25
|
-
/>
|
|
26
|
-
</div>
|
|
27
|
-
)
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
describe('Text', () => {
|
|
32
|
-
it('displays the text as success when corresponding thresholds are set', () => {
|
|
33
|
-
initialize({ thresholds: successThresholds });
|
|
34
|
-
|
|
35
|
-
cy.contains('0.41 s').should('have.css', 'color', 'rgb(136, 185, 34)');
|
|
36
|
-
cy.contains('Warning: 0.5 s').should('be.visible');
|
|
37
|
-
cy.contains('Critical: 1.5 s').should('be.visible');
|
|
38
|
-
|
|
39
|
-
cy.makeSnapshot();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('displays the text as warning when corresponding thresholds are set', () => {
|
|
43
|
-
initialize({ thresholds: warningThresholds });
|
|
44
|
-
|
|
45
|
-
cy.contains('0.41 s').should('have.css', 'color', 'rgb(253, 155, 39)');
|
|
46
|
-
cy.contains('Warning: 0.4 s').should('be.visible');
|
|
47
|
-
cy.contains('Critical: 1.5 s').should('be.visible');
|
|
48
|
-
|
|
49
|
-
cy.makeSnapshot();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('displays the text as critical when corresponding thresholds are set', () => {
|
|
53
|
-
initialize({ thresholds: criticalThresholds });
|
|
54
|
-
|
|
55
|
-
cy.contains('0.41 s').should('have.css', 'color', 'rgb(255, 74, 74)');
|
|
56
|
-
cy.contains('Warning: 0.2 s').should('be.visible');
|
|
57
|
-
cy.contains('Critical: 0.3 s').should('be.visible');
|
|
58
|
-
|
|
59
|
-
cy.makeSnapshot();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('displays ranged thresholds', () => {
|
|
63
|
-
initialize({ thresholds: rangedThresholds });
|
|
64
|
-
|
|
65
|
-
cy.contains('Warning: 0.13 s - 0.5 s').should('be.visible');
|
|
66
|
-
cy.contains('Critical: 0.55 s - 0.65 s').should('be.visible');
|
|
67
|
-
|
|
68
|
-
cy.makeSnapshot();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('displays the value as raw when the prop is set', () => {
|
|
72
|
-
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
73
|
-
|
|
74
|
-
cy.contains('0.40663333333 s').should('be.visible');
|
|
75
|
-
|
|
76
|
-
cy.makeSnapshot();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('does not display the text', () => {
|
|
80
|
-
initialize({ data: undefined, thresholds: successThresholds });
|
|
81
|
-
|
|
82
|
-
cy.contains('0.41 s').should('not.exist');
|
|
83
|
-
|
|
84
|
-
cy.makeSnapshot();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('displays text with default values when the data is empty', () => {
|
|
88
|
-
initialize({
|
|
89
|
-
data: {
|
|
90
|
-
global: {},
|
|
91
|
-
metrics: [],
|
|
92
|
-
times: []
|
|
93
|
-
},
|
|
94
|
-
thresholds: successThresholds
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
cy.contains('0').should('be.visible');
|
|
98
|
-
|
|
99
|
-
cy.makeSnapshot();
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export const successThresholds = {
|
|
2
|
-
critical: [
|
|
3
|
-
{
|
|
4
|
-
label: 'Critical',
|
|
5
|
-
value: 1.5
|
|
6
|
-
}
|
|
7
|
-
],
|
|
8
|
-
enabled: true,
|
|
9
|
-
warning: [
|
|
10
|
-
{
|
|
11
|
-
label: 'Warning',
|
|
12
|
-
value: 0.5
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const warningThresholds = {
|
|
18
|
-
critical: [
|
|
19
|
-
{
|
|
20
|
-
label: 'Critical',
|
|
21
|
-
value: 1.5
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
enabled: true,
|
|
25
|
-
warning: [
|
|
26
|
-
{
|
|
27
|
-
label: 'Warning',
|
|
28
|
-
value: 0.4
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const criticalThresholds = {
|
|
34
|
-
critical: [
|
|
35
|
-
{
|
|
36
|
-
label: 'Critical',
|
|
37
|
-
value: 0.3
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
enabled: true,
|
|
41
|
-
warning: [
|
|
42
|
-
{
|
|
43
|
-
label: 'Warning',
|
|
44
|
-
value: 0.2
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const rangedThresholds = {
|
|
50
|
-
critical: [
|
|
51
|
-
{
|
|
52
|
-
label: 'Critical',
|
|
53
|
-
value: 0.55
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
label: 'Critical',
|
|
57
|
-
value: 0.65
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
enabled: true,
|
|
61
|
-
warning: [
|
|
62
|
-
{
|
|
63
|
-
label: 'Warning',
|
|
64
|
-
value: 0.13
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
label: 'Warning',
|
|
68
|
-
value: 0.5
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const labelNoDataFound = 'No Data Available';
|