@centreon/ui 24.10.12 → 24.10.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 +3 -2
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +3 -1
- package/src/Dashboard/Dashboard.styles.ts +3 -4
- package/src/Dashboard/DashboardLayout.stories.tsx +1 -1
- package/src/Dashboard/Grid.tsx +11 -17
- package/src/Dashboard/Layout.tsx +27 -56
- package/src/Dialog/UnsavedChanges/index.tsx +15 -13
- package/src/Dialog/UnsavedChanges/translatedLabels.ts +15 -13
- package/src/Form/Form.tsx +0 -1
- package/src/Form/Inputs/Autocomplete.tsx +1 -1
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +5 -2
- package/src/Form/Inputs/Grid.tsx +7 -1
- package/src/Form/Inputs/Radio.tsx +1 -1
- package/src/Form/Inputs/Switch.tsx +1 -1
- package/src/Form/Inputs/Text.tsx +1 -1
- package/src/Form/Inputs/index.tsx +25 -24
- package/src/Form/Inputs/models.ts +2 -0
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +3 -3
- package/src/Graph/BarChart/BarChart.tsx +24 -31
- package/src/Graph/BarChart/BarGroup.tsx +32 -59
- package/src/Graph/BarChart/BarStack.tsx +64 -13
- package/src/Graph/BarChart/MemoizedGroup.tsx +123 -0
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +21 -7
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
- package/src/Graph/BarStack/BarStack.stories.tsx +13 -4
- package/src/Graph/BarStack/BarStack.styles.ts +57 -33
- package/src/Graph/BarStack/Graph.tsx +173 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +117 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +61 -168
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/models.ts +0 -1
- package/src/Graph/BarStack/useGraphAndLegend.ts +84 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +73 -97
- package/src/Graph/Chart/Chart.cypress.spec.tsx +14 -26
- package/src/Graph/Chart/Chart.stories.tsx +1 -1
- package/src/Graph/Chart/Chart.tsx +53 -37
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +3 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +19 -6
- package/src/Graph/Chart/Legend/Legend.styles.ts +25 -11
- package/src/Graph/Chart/Legend/index.tsx +6 -24
- package/src/Graph/Chart/index.tsx +34 -43
- package/src/Graph/Chart/models.ts +0 -1
- package/src/Graph/Chart/useChartData.ts +19 -1
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +20 -2
- package/src/Graph/HeatMap/model.ts +6 -2
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +6 -1
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +9 -10
- package/src/Graph/SingleBar/ThresholdLine.tsx +6 -6
- package/src/Graph/Text/Text.styles.ts +2 -2
- package/src/Graph/Text/Text.tsx +23 -10
- package/src/Graph/Timeline/ResponsiveTimeline.tsx +152 -0
- package/src/Graph/Timeline/Timeline.cypress.spec.tsx +148 -0
- package/src/Graph/Timeline/Timeline.stories.tsx +91 -0
- package/src/Graph/Timeline/Timeline.tsx +28 -0
- package/src/Graph/Timeline/index.ts +1 -0
- package/src/Graph/Timeline/models.ts +20 -0
- package/src/Graph/Timeline/timeline.styles.ts +11 -0
- package/src/Graph/Timeline/translatedLabel.ts +6 -0
- package/src/Graph/Timeline/useTimeline.ts +90 -0
- package/src/Graph/Tree/Links.tsx +2 -2
- package/src/Graph/Tree/Tree.tsx +2 -2
- package/src/Graph/Tree/constants.ts +1 -1
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/Axes/useAxisY.ts +8 -4
- package/src/Graph/common/BaseChart/BaseChart.tsx +3 -12
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +12 -4
- package/src/Graph/common/BaseChart/Header/index.tsx +3 -1
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +23 -11
- package/src/Graph/common/BaseChart/useComputeYAxisMaxCharacters.ts +92 -0
- package/src/Graph/common/models.ts +7 -8
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +56 -29
- package/src/Graph/common/timeSeries/models.ts +2 -0
- package/src/Graph/common/utils.ts +51 -3
- package/src/Graph/index.ts +4 -1
- package/src/Graph/mockedData/lastDayWithNullValues.json +6 -6
- package/src/Graph/mockedData/pingServiceLinesBars.json +47 -47
- package/src/Icon/DowntimeIcon.tsx +8 -1
- package/src/Icon/FlappingIcon.tsx +22 -0
- package/src/Icon/index.ts +1 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +52 -15
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/InputField/Select/Autocomplete/index.tsx +79 -54
- package/src/InputField/Text/index.tsx +6 -4
- package/src/InputField/translatedLabels.ts +2 -0
- package/src/Listing/ActionBar/index.tsx +1 -1
- package/src/Listing/Listing.styles.ts +3 -3
- package/src/Listing/index.tsx +40 -37
- package/src/Listing/models.ts +0 -8
- package/src/Listing/useStyleTable.ts +58 -32
- package/src/MultiSelectEntries/index.tsx +2 -0
- package/src/PopoverMenu/index.tsx +2 -9
- package/src/SortableItems/index.tsx +0 -1
- package/src/ThemeProvider/index.tsx +1 -1
- package/src/ThemeProvider/palettes.ts +6 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
- package/src/TimePeriods/DateTimePickerInput.tsx +3 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +1 -0
- package/src/api/customFetch.ts +4 -1
- package/src/api/models.ts +9 -0
- package/src/api/useGraphQuery/index.ts +117 -20
- package/src/api/useGraphQuery/models.ts +1 -0
- package/src/api/useMutationQuery/index.ts +1 -1
- package/src/components/DataTable/DataTable.styles.ts +1 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +2 -1
- package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +4 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +28 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +19 -4
- package/src/components/Form/FormActions.tsx +21 -12
- package/src/components/Layout/AreaIndicator.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +2 -7
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Zoom/Zoom.tsx +9 -2
- package/src/components/Zoom/ZoomContent.tsx +143 -136
- package/src/components/Zoom/models.ts +18 -15
- package/src/components/Zoom/useMinimap.ts +5 -8
- package/src/components/Zoom/useZoom.ts +3 -3
- package/src/index.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/useLocale/index.ts +9 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +38 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +4 -2
- package/src/utils/usePluralizedTranslation.ts +2 -3
- package/src/Graph/common/timeSeries/index.test.ts-E +0 -622
- package/src/components/CrudPage/Actions/Actions.styles.ts +0 -16
- package/src/components/CrudPage/Actions/Actions.tsx +0 -24
- package/src/components/CrudPage/Actions/AddButton.tsx +0 -23
- package/src/components/CrudPage/Actions/Filters.tsx +0 -25
- package/src/components/CrudPage/Actions/Search.tsx +0 -31
- package/src/components/CrudPage/Actions/useSearch.tsx +0 -24
- package/src/components/CrudPage/Columns/Actions.tsx +0 -88
- package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -559
- package/src/components/CrudPage/CrudPage.stories.tsx +0 -278
- package/src/components/CrudPage/CrudPageRoot.tsx +0 -142
- package/src/components/CrudPage/DeleteModal.tsx +0 -77
- package/src/components/CrudPage/Form/AddModal.tsx +0 -35
- package/src/components/CrudPage/Form/Buttons.tsx +0 -98
- package/src/components/CrudPage/Form/UpdateModal.tsx +0 -60
- package/src/components/CrudPage/Listing.tsx +0 -63
- package/src/components/CrudPage/atoms.ts +0 -30
- package/src/components/CrudPage/hooks/useDeleteItem.ts +0 -53
- package/src/components/CrudPage/hooks/useGetItem.ts +0 -36
- package/src/components/CrudPage/hooks/useGetItems.ts +0 -67
- package/src/components/CrudPage/hooks/useListingQueryKey.ts +0 -31
- package/src/components/CrudPage/index.tsx +0 -7
- package/src/components/CrudPage/models.ts +0 -118
- package/src/components/CrudPage/utils.ts +0 -4
|
@@ -5,6 +5,7 @@ import { useAtomValue } from 'jotai';
|
|
|
5
5
|
|
|
6
6
|
import { userAtom } from '@centreon/ui-context';
|
|
7
7
|
|
|
8
|
+
import { useLocale } from '../useLocale';
|
|
8
9
|
import shortLocales from './sortLocales';
|
|
9
10
|
|
|
10
11
|
interface FormatParameters {
|
|
@@ -28,10 +29,11 @@ const timeFormat = 'LT';
|
|
|
28
29
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
29
30
|
|
|
30
31
|
const useLocaleDateTimeFormat = (): LocaleDateTimeFormat => {
|
|
31
|
-
const
|
|
32
|
+
const locale = useLocale();
|
|
33
|
+
const { timezone } = useAtomValue(userAtom);
|
|
32
34
|
|
|
33
35
|
const format = ({ date, formatString }: FormatParameters): string => {
|
|
34
|
-
const normalizedLocale = locale
|
|
36
|
+
const normalizedLocale = locale?.substring(0, 2);
|
|
35
37
|
|
|
36
38
|
const timezoneDate = dayjs(
|
|
37
39
|
new Date(date).toLocaleString('en', { timeZone: timezone })
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
3
|
import pluralize from 'pluralize';
|
|
5
4
|
import { equals, includes } from 'ramda';
|
|
6
5
|
import { useTranslation } from 'react-i18next';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { useLocale } from './useLocale';
|
|
9
8
|
|
|
10
9
|
interface TProps {
|
|
11
10
|
count: number;
|
|
@@ -16,7 +15,7 @@ export const usePluralizedTranslation = (): {
|
|
|
16
15
|
pluralizedT: (props: TProps) => string;
|
|
17
16
|
} => {
|
|
18
17
|
const translation = useTranslation();
|
|
19
|
-
const
|
|
18
|
+
const locale = useLocale();
|
|
20
19
|
|
|
21
20
|
const isNotPartitiveLocale = includes('fr', locale);
|
|
22
21
|
|
|
@@ -1,622 +0,0 @@
|
|
|
1
|
-
import { LineChartData } from '../models';
|
|
2
|
-
|
|
3
|
-
type TestCase = [number | null, string, 1000 | 1024, string | null];
|
|
4
|
-
|
|
5
|
-
describe('timeSeries', () => {
|
|
6
|
-
const graphData: LineChartData = {
|
|
7
|
-
global: {},
|
|
8
|
-
metrics: [
|
|
9
|
-
{
|
|
10
|
-
average_value: 1,
|
|
11
|
-
data: [0, 1],
|
|
12
|
-
ds_data: {
|
|
13
|
-
ds_color_area: 'transparent',
|
|
14
|
-
ds_color_line: 'black',
|
|
15
|
-
ds_filled: false,
|
|
16
|
-
ds_invert: null,
|
|
17
|
-
ds_legend: 'Round-Trip-Time Average',
|
|
18
|
-
ds_order: null,
|
|
19
|
-
ds_stack: null,
|
|
20
|
-
ds_transparency: 80
|
|
21
|
-
},
|
|
22
|
-
legend: 'Round-Trip-Time Average (ms)',
|
|
23
|
-
maximum_value: 1.5,
|
|
24
|
-
metric: 'rta',
|
|
25
|
-
metric_id: 1,
|
|
26
|
-
minimum_value: 0.5,
|
|
27
|
-
unit: 'ms'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
average_value: 1,
|
|
31
|
-
data: [0.5, 3],
|
|
32
|
-
ds_data: {
|
|
33
|
-
ds_color_area: 'blue',
|
|
34
|
-
ds_color_line: 'blue',
|
|
35
|
-
ds_filled: true,
|
|
36
|
-
ds_invert: null,
|
|
37
|
-
ds_legend: 'Time',
|
|
38
|
-
ds_order: null,
|
|
39
|
-
ds_stack: null,
|
|
40
|
-
ds_transparency: 80
|
|
41
|
-
},
|
|
42
|
-
legend: 'Time (ms)',
|
|
43
|
-
maximum_value: 1.5,
|
|
44
|
-
metric: 'time',
|
|
45
|
-
metric_id: 2,
|
|
46
|
-
minimum_value: 0.5,
|
|
47
|
-
unit: 'ms'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
average_value: 1,
|
|
51
|
-
data: [6, 4],
|
|
52
|
-
ds_data: {
|
|
53
|
-
ds_color_area: 'red',
|
|
54
|
-
ds_color_line: 'red',
|
|
55
|
-
ds_filled: true,
|
|
56
|
-
ds_invert: null,
|
|
57
|
-
ds_legend: 'Average duration',
|
|
58
|
-
ds_order: '2',
|
|
59
|
-
ds_stack: '1',
|
|
60
|
-
ds_transparency: 80
|
|
61
|
-
},
|
|
62
|
-
legend: 'Average duration (ms)',
|
|
63
|
-
maximum_value: 1.5,
|
|
64
|
-
metric: 'avgDuration',
|
|
65
|
-
metric_id: 3,
|
|
66
|
-
minimum_value: 0.5,
|
|
67
|
-
unit: 'ms'
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
average_value: 1,
|
|
71
|
-
data: [12, 25],
|
|
72
|
-
ds_data: {
|
|
73
|
-
ds_color_area: 'yellow',
|
|
74
|
-
ds_color_line: 'yellow',
|
|
75
|
-
ds_filled: true,
|
|
76
|
-
ds_invert: '1',
|
|
77
|
-
ds_legend: 'Duration',
|
|
78
|
-
ds_order: '1',
|
|
79
|
-
ds_stack: '1',
|
|
80
|
-
ds_transparency: 80
|
|
81
|
-
},
|
|
82
|
-
legend: 'Duration (ms)',
|
|
83
|
-
maximum_value: 1.5,
|
|
84
|
-
metric: 'duration',
|
|
85
|
-
metric_id: 4,
|
|
86
|
-
minimum_value: 0.5,
|
|
87
|
-
unit: 'ms'
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
average_value: 1,
|
|
91
|
-
data: [0, 1],
|
|
92
|
-
ds_data: {
|
|
93
|
-
ds_color_area: 'yellow',
|
|
94
|
-
ds_color_line: 'yellow',
|
|
95
|
-
ds_filled: true,
|
|
96
|
-
ds_invert: null,
|
|
97
|
-
ds_legend: 'Packet Loss',
|
|
98
|
-
ds_order: null,
|
|
99
|
-
ds_stack: null,
|
|
100
|
-
ds_transparency: 80
|
|
101
|
-
},
|
|
102
|
-
legend: 'Packet Loss (%)',
|
|
103
|
-
maximum_value: 1.5,
|
|
104
|
-
metric: 'packet_loss',
|
|
105
|
-
metric_id: 5,
|
|
106
|
-
minimum_value: 0.5,
|
|
107
|
-
unit: '%'
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
times: ['2020-11-05T10:35:00Z', '2020-11-05T10:40:00Z']
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
describe('getTimeSeries', () => {
|
|
114
|
-
it('returns the time series for the given graph data', () => {
|
|
115
|
-
expect(getTimeSeries(graphData)).toEqual([
|
|
116
|
-
{
|
|
117
|
-
1: 0,
|
|
118
|
-
2: 0.5,
|
|
119
|
-
3: 6,
|
|
120
|
-
4: 12,
|
|
121
|
-
5: 0,
|
|
122
|
-
timeTick: '2020-11-05T10:35:00Z'
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
1: 1,
|
|
126
|
-
2: 3,
|
|
127
|
-
3: 4,
|
|
128
|
-
4: 25,
|
|
129
|
-
5: 1,
|
|
130
|
-
timeTick: '2020-11-05T10:40:00Z'
|
|
131
|
-
}
|
|
132
|
-
]);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('filters metric values below the given lower-limit value', () => {
|
|
136
|
-
const graphDataWithLowerLimit = {
|
|
137
|
-
...graphData,
|
|
138
|
-
global: {
|
|
139
|
-
'lower-limit': 0.4
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
expect(getTimeSeries(graphDataWithLowerLimit)).toEqual([
|
|
144
|
-
{
|
|
145
|
-
2: 0.5,
|
|
146
|
-
3: 6,
|
|
147
|
-
4: 12,
|
|
148
|
-
timeTick: '2020-11-05T10:35:00Z'
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
1: 1,
|
|
152
|
-
2: 3,
|
|
153
|
-
3: 4,
|
|
154
|
-
4: 25,
|
|
155
|
-
5: 1,
|
|
156
|
-
timeTick: '2020-11-05T10:40:00Z'
|
|
157
|
-
}
|
|
158
|
-
]);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe('getLineData', () => {
|
|
163
|
-
it('returns the line information for the given graph data', () => {
|
|
164
|
-
expect(getLineData(graphData)).toEqual([
|
|
165
|
-
{
|
|
166
|
-
areaColor: 'transparent',
|
|
167
|
-
average_value: 1,
|
|
168
|
-
color: 'black',
|
|
169
|
-
display: true,
|
|
170
|
-
filled: false,
|
|
171
|
-
highlight: undefined,
|
|
172
|
-
invert: null,
|
|
173
|
-
legend: 'Round-Trip-Time Average',
|
|
174
|
-
lineColor: 'black',
|
|
175
|
-
maximum_value: 1.5,
|
|
176
|
-
metric: 'rta',
|
|
177
|
-
metric_id: 1,
|
|
178
|
-
minimum_value: 0.5,
|
|
179
|
-
name: 'Round-Trip-Time Average (ms)',
|
|
180
|
-
stackOrder: null,
|
|
181
|
-
transparency: 80,
|
|
182
|
-
unit: 'ms'
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
areaColor: 'blue',
|
|
186
|
-
average_value: 1,
|
|
187
|
-
color: 'blue',
|
|
188
|
-
display: true,
|
|
189
|
-
filled: true,
|
|
190
|
-
highlight: undefined,
|
|
191
|
-
invert: null,
|
|
192
|
-
legend: 'Time',
|
|
193
|
-
lineColor: 'blue',
|
|
194
|
-
maximum_value: 1.5,
|
|
195
|
-
metric: 'time',
|
|
196
|
-
metric_id: 2,
|
|
197
|
-
minimum_value: 0.5,
|
|
198
|
-
name: 'Time (ms)',
|
|
199
|
-
stackOrder: null,
|
|
200
|
-
transparency: 80,
|
|
201
|
-
unit: 'ms'
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
areaColor: 'red',
|
|
205
|
-
average_value: 1,
|
|
206
|
-
color: 'red',
|
|
207
|
-
display: true,
|
|
208
|
-
filled: true,
|
|
209
|
-
highlight: undefined,
|
|
210
|
-
invert: null,
|
|
211
|
-
legend: 'Average duration',
|
|
212
|
-
lineColor: 'red',
|
|
213
|
-
maximum_value: 1.5,
|
|
214
|
-
metric: 'avgDuration',
|
|
215
|
-
metric_id: 3,
|
|
216
|
-
minimum_value: 0.5,
|
|
217
|
-
name: 'Average duration (ms)',
|
|
218
|
-
stackOrder: 2,
|
|
219
|
-
transparency: 80,
|
|
220
|
-
unit: 'ms'
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
areaColor: 'yellow',
|
|
224
|
-
average_value: 1,
|
|
225
|
-
color: 'yellow',
|
|
226
|
-
display: true,
|
|
227
|
-
filled: true,
|
|
228
|
-
highlight: undefined,
|
|
229
|
-
invert: '1',
|
|
230
|
-
legend: 'Duration',
|
|
231
|
-
lineColor: 'yellow',
|
|
232
|
-
maximum_value: 1.5,
|
|
233
|
-
metric: 'duration',
|
|
234
|
-
metric_id: 4,
|
|
235
|
-
minimum_value: 0.5,
|
|
236
|
-
name: 'Duration (ms)',
|
|
237
|
-
stackOrder: 1,
|
|
238
|
-
transparency: 80,
|
|
239
|
-
unit: 'ms'
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
areaColor: 'yellow',
|
|
243
|
-
average_value: 1,
|
|
244
|
-
color: 'yellow',
|
|
245
|
-
display: true,
|
|
246
|
-
filled: true,
|
|
247
|
-
highlight: undefined,
|
|
248
|
-
invert: null,
|
|
249
|
-
legend: 'Packet Loss',
|
|
250
|
-
lineColor: 'yellow',
|
|
251
|
-
maximum_value: 1.5,
|
|
252
|
-
metric: 'packet_loss',
|
|
253
|
-
metric_id: 5,
|
|
254
|
-
minimum_value: 0.5,
|
|
255
|
-
name: 'Packet Loss (%)',
|
|
256
|
-
stackOrder: null,
|
|
257
|
-
transparency: 80,
|
|
258
|
-
unit: '%'
|
|
259
|
-
}
|
|
260
|
-
]);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
describe('getMetrics', () => {
|
|
265
|
-
it('returns the metrics for the given time value', () => {
|
|
266
|
-
expect(
|
|
267
|
-
getMetrics({
|
|
268
|
-
rta: 1,
|
|
269
|
-
time: 0,
|
|
270
|
-
timeTick: '2020-11-05T10:40:00Z'
|
|
271
|
-
})
|
|
272
|
-
).toEqual(['rta', 'time']);
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
describe('getMetricValuesForUnit', () => {
|
|
277
|
-
it('returns the values in the given time series corresponding to the given line unit', () => {
|
|
278
|
-
const series = getTimeSeries(graphData);
|
|
279
|
-
const lines = getLineData(graphData);
|
|
280
|
-
const unit = 'ms';
|
|
281
|
-
|
|
282
|
-
expect(
|
|
283
|
-
getMetricValuesForUnit({ lines, timeSeries: series, unit })
|
|
284
|
-
).toEqual([0, 1, 0.5, 3, 6, 4, 12, 25]);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe('getUnits', () => {
|
|
289
|
-
it('returns the units for the given lines', () => {
|
|
290
|
-
const lines = getLineData(graphData);
|
|
291
|
-
|
|
292
|
-
expect(getUnits(lines)).toEqual(['ms', '%']);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe('getDates', () => {
|
|
297
|
-
it('teruns the dates for the given time series', () => {
|
|
298
|
-
const series = getTimeSeries(graphData);
|
|
299
|
-
|
|
300
|
-
expect(getDates(series)).toEqual([
|
|
301
|
-
new Date('2020-11-05T10:35:00.000Z'),
|
|
302
|
-
new Date('2020-11-05T10:40:00.000Z')
|
|
303
|
-
]);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe('getLineForMetric', () => {
|
|
308
|
-
it('returns the line corresponding to the given metrics', () => {
|
|
309
|
-
const lines = getLineData(graphData);
|
|
310
|
-
|
|
311
|
-
expect(getLineForMetric({ lines, metric_id: 1 })).toEqual({
|
|
312
|
-
areaColor: 'transparent',
|
|
313
|
-
average_value: 1,
|
|
314
|
-
color: 'black',
|
|
315
|
-
display: true,
|
|
316
|
-
filled: false,
|
|
317
|
-
highlight: undefined,
|
|
318
|
-
invert: null,
|
|
319
|
-
legend: 'Round-Trip-Time Average',
|
|
320
|
-
lineColor: 'black',
|
|
321
|
-
maximum_value: 1.5,
|
|
322
|
-
metric: 'rta',
|
|
323
|
-
metric_id: 1,
|
|
324
|
-
minimum_value: 0.5,
|
|
325
|
-
name: 'Round-Trip-Time Average (ms)',
|
|
326
|
-
stackOrder: null,
|
|
327
|
-
transparency: 80,
|
|
328
|
-
unit: 'ms'
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
describe('getMetricValuesForLines', () => {
|
|
334
|
-
it('returns the metric values for the given lines within the given time series', () => {
|
|
335
|
-
const lines = getLineData(graphData);
|
|
336
|
-
const series = getTimeSeries(graphData);
|
|
337
|
-
|
|
338
|
-
expect(
|
|
339
|
-
getMetricValuesForLines({ lines, timeSeries: series })
|
|
340
|
-
).toEqual([0, 1, 0.5, 3, 6, 4, 12, 25, 0, 1]);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
describe(formatMetricValue, () => {
|
|
345
|
-
const cases: Array<TestCase> = [
|
|
346
|
-
[218857269, '', 1000, '218.86m'],
|
|
347
|
-
[218857269, '', 1024, '208.72 M'],
|
|
348
|
-
[0.12232323445, '', 1000, '0.12'],
|
|
349
|
-
[1024, 'B', 1000, '1 KB'],
|
|
350
|
-
[1024, 'B', 1024, '1 KB'],
|
|
351
|
-
[null, 'B', 1024, null]
|
|
352
|
-
];
|
|
353
|
-
|
|
354
|
-
it.each(cases)(
|
|
355
|
-
'formats the given value to a human readable form according to the given unit and base',
|
|
356
|
-
(value, unit, base, formattedResult) => {
|
|
357
|
-
expect(formatMetricValue({ base, unit, value })).toEqual(
|
|
358
|
-
formattedResult
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
describe('getSortedStackedLines', () => {
|
|
365
|
-
it('returns stacked lines sorted by their own order for the given lines', () => {
|
|
366
|
-
const lines = getLineData(graphData);
|
|
367
|
-
|
|
368
|
-
expect(getSortedStackedLines(lines)).toEqual([
|
|
369
|
-
{
|
|
370
|
-
areaColor: 'yellow',
|
|
371
|
-
average_value: 1,
|
|
372
|
-
color: 'yellow',
|
|
373
|
-
display: true,
|
|
374
|
-
filled: true,
|
|
375
|
-
highlight: undefined,
|
|
376
|
-
invert: '1',
|
|
377
|
-
legend: 'Duration',
|
|
378
|
-
lineColor: 'yellow',
|
|
379
|
-
maximum_value: 1.5,
|
|
380
|
-
metric: 'duration',
|
|
381
|
-
metric_id: 4,
|
|
382
|
-
minimum_value: 0.5,
|
|
383
|
-
name: 'Duration (ms)',
|
|
384
|
-
stackOrder: 1,
|
|
385
|
-
transparency: 80,
|
|
386
|
-
unit: 'ms'
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
areaColor: 'red',
|
|
390
|
-
average_value: 1,
|
|
391
|
-
color: 'red',
|
|
392
|
-
display: true,
|
|
393
|
-
filled: true,
|
|
394
|
-
highlight: undefined,
|
|
395
|
-
invert: null,
|
|
396
|
-
legend: 'Average duration',
|
|
397
|
-
lineColor: 'red',
|
|
398
|
-
maximum_value: 1.5,
|
|
399
|
-
metric: 'avgDuration',
|
|
400
|
-
metric_id: 3,
|
|
401
|
-
minimum_value: 0.5,
|
|
402
|
-
name: 'Average duration (ms)',
|
|
403
|
-
stackOrder: 2,
|
|
404
|
-
transparency: 80,
|
|
405
|
-
unit: 'ms'
|
|
406
|
-
}
|
|
407
|
-
]);
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
describe('getStackedMetricValues', () => {
|
|
412
|
-
it('returns stacked metrics values for the given lines and the given time series', () => {
|
|
413
|
-
const lines = getLineData(graphData);
|
|
414
|
-
const series = getTimeSeries(graphData);
|
|
415
|
-
|
|
416
|
-
expect(
|
|
417
|
-
getStackedMetricValues({
|
|
418
|
-
lines: getSortedStackedLines(lines),
|
|
419
|
-
timeSeries: series
|
|
420
|
-
})
|
|
421
|
-
).toEqual([18, 29]);
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
describe('getTimeSeriesForLines', () => {
|
|
426
|
-
it('returns the specific time series for the given lines and the fiven time series', () => {
|
|
427
|
-
const lines = getLineData(graphData);
|
|
428
|
-
const series = getTimeSeries(graphData);
|
|
429
|
-
|
|
430
|
-
expect(
|
|
431
|
-
getTimeSeriesForLines({
|
|
432
|
-
lines: getSortedStackedLines(lines),
|
|
433
|
-
timeSeries: series
|
|
434
|
-
})
|
|
435
|
-
).toEqual([
|
|
436
|
-
{
|
|
437
|
-
3: 6,
|
|
438
|
-
4: 12,
|
|
439
|
-
timeTick: '2020-11-05T10:35:00Z'
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
3: 4,
|
|
443
|
-
4: 25,
|
|
444
|
-
timeTick: '2020-11-05T10:40:00Z'
|
|
445
|
-
}
|
|
446
|
-
]);
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
describe('getInvertedStackedLines', () => {
|
|
451
|
-
it('returns inverted and stacked lines for the given lines', () => {
|
|
452
|
-
const lines = getLineData(graphData);
|
|
453
|
-
|
|
454
|
-
expect(getInvertedStackedLines(lines)).toEqual([
|
|
455
|
-
{
|
|
456
|
-
areaColor: 'yellow',
|
|
457
|
-
average_value: 1,
|
|
458
|
-
color: 'yellow',
|
|
459
|
-
display: true,
|
|
460
|
-
filled: true,
|
|
461
|
-
highlight: undefined,
|
|
462
|
-
invert: '1',
|
|
463
|
-
legend: 'Duration',
|
|
464
|
-
lineColor: 'yellow',
|
|
465
|
-
maximum_value: 1.5,
|
|
466
|
-
metric: 'duration',
|
|
467
|
-
metric_id: 4,
|
|
468
|
-
minimum_value: 0.5,
|
|
469
|
-
name: 'Duration (ms)',
|
|
470
|
-
stackOrder: 1,
|
|
471
|
-
transparency: 80,
|
|
472
|
-
unit: 'ms'
|
|
473
|
-
}
|
|
474
|
-
]);
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
describe('getNotInvertedStackedLines', () => {
|
|
479
|
-
it('returns not inverted and stacked lines for the given lines', () => {
|
|
480
|
-
const lines = getLineData(graphData);
|
|
481
|
-
|
|
482
|
-
expect(getNotInvertedStackedLines(lines)).toEqual([
|
|
483
|
-
{
|
|
484
|
-
areaColor: 'red',
|
|
485
|
-
average_value: 1,
|
|
486
|
-
color: 'red',
|
|
487
|
-
display: true,
|
|
488
|
-
filled: true,
|
|
489
|
-
highlight: undefined,
|
|
490
|
-
invert: null,
|
|
491
|
-
legend: 'Average duration',
|
|
492
|
-
lineColor: 'red',
|
|
493
|
-
maximum_value: 1.5,
|
|
494
|
-
metric: 'avgDuration',
|
|
495
|
-
metric_id: 3,
|
|
496
|
-
minimum_value: 0.5,
|
|
497
|
-
name: 'Average duration (ms)',
|
|
498
|
-
stackOrder: 2,
|
|
499
|
-
transparency: 80,
|
|
500
|
-
unit: 'ms'
|
|
501
|
-
}
|
|
502
|
-
]);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
describe('hasUnitStackedLines', () => {
|
|
507
|
-
it('returns true if the given unit contains stacked lines following the given lines, false otherwise', () => {
|
|
508
|
-
const lines = getLineData(graphData);
|
|
509
|
-
|
|
510
|
-
expect(hasUnitStackedLines({ lines, unit: 'ms' })).toEqual(
|
|
511
|
-
true
|
|
512
|
-
);
|
|
513
|
-
|
|
514
|
-
expect(hasUnitStackedLines({ lines, unit: '%' })).toEqual(
|
|
515
|
-
false
|
|
516
|
-
);
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
describe('Format value with unit', () => {
|
|
522
|
-
const units = [
|
|
523
|
-
'B',
|
|
524
|
-
'bytes',
|
|
525
|
-
'bytespersecond',
|
|
526
|
-
'B/s',
|
|
527
|
-
'B/sec',
|
|
528
|
-
'o',
|
|
529
|
-
'octets',
|
|
530
|
-
'b/s',
|
|
531
|
-
'b',
|
|
532
|
-
'ms',
|
|
533
|
-
'%',
|
|
534
|
-
''
|
|
535
|
-
];
|
|
536
|
-
|
|
537
|
-
const getExpectedResult = (unit): string => {
|
|
538
|
-
if (unit === '') {
|
|
539
|
-
return '324.23m';
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return `309.21 M${unit}`;
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
const humanReadableTestCases = units.map((unit) => {
|
|
546
|
-
if (unit === '%') {
|
|
547
|
-
return {
|
|
548
|
-
expectedResult: '45.56%',
|
|
549
|
-
unit,
|
|
550
|
-
value: 45.55678
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (unit === 'ms') {
|
|
555
|
-
return {
|
|
556
|
-
expectedResult: '34.23 seconds',
|
|
557
|
-
unit,
|
|
558
|
-
value: 34232
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return {
|
|
563
|
-
expectedResult: getExpectedResult(unit),
|
|
564
|
-
unit,
|
|
565
|
-
value: 324234232.34233
|
|
566
|
-
};
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
const rawTestCases = units.map((unit) => {
|
|
570
|
-
if (unit === '%') {
|
|
571
|
-
return {
|
|
572
|
-
expectedResult: '45.55678%',
|
|
573
|
-
unit,
|
|
574
|
-
value: 45.55678
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (unit === 'ms') {
|
|
579
|
-
return {
|
|
580
|
-
expectedResult: '34232 ms',
|
|
581
|
-
unit,
|
|
582
|
-
value: 34232
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
return {
|
|
587
|
-
expectedResult:
|
|
588
|
-
unit === '' ? '324234232.34233 ' : `324234232.34233 ${unit}`,
|
|
589
|
-
unit,
|
|
590
|
-
value: 324234232.34233
|
|
591
|
-
};
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
describe('Format the value as human readable', () => {
|
|
595
|
-
it.each(humanReadableTestCases)(
|
|
596
|
-
'formats the value with $unit',
|
|
597
|
-
({ value, unit, expectedResult }) => {
|
|
598
|
-
expect(
|
|
599
|
-
formatMetricValueWithUnit({
|
|
600
|
-
unit,
|
|
601
|
-
value
|
|
602
|
-
})
|
|
603
|
-
).toEqual(expectedResult);
|
|
604
|
-
}
|
|
605
|
-
);
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
describe('Format the value as raw', () => {
|
|
609
|
-
it.each(rawTestCases)(
|
|
610
|
-
'formats the value with $unit',
|
|
611
|
-
({ value, unit, expectedResult }) => {
|
|
612
|
-
expect(
|
|
613
|
-
timeSeries.formatMetricValueWithUnit({
|
|
614
|
-
isRaw: true,
|
|
615
|
-
unit,
|
|
616
|
-
value
|
|
617
|
-
})
|
|
618
|
-
).toEqual(expectedResult);
|
|
619
|
-
}
|
|
620
|
-
);
|
|
621
|
-
});
|
|
622
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
|
-
export const useActionsStyles = makeStyles()((theme) => ({
|
|
4
|
-
search: {
|
|
5
|
-
maxWidth: theme.spacing(50)
|
|
6
|
-
},
|
|
7
|
-
clearButton: {
|
|
8
|
-
alignSelf: 'flex-start'
|
|
9
|
-
},
|
|
10
|
-
tooltipFilters: {
|
|
11
|
-
padding: theme.spacing(2, 3),
|
|
12
|
-
display: 'flex',
|
|
13
|
-
flexDirection: 'column',
|
|
14
|
-
gap: theme.spacing(2)
|
|
15
|
-
}
|
|
16
|
-
}));
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Box } from '@mui/material';
|
|
2
|
-
import AddButton from './AddButton';
|
|
3
|
-
import Search from './Search';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
labels: {
|
|
7
|
-
search: string;
|
|
8
|
-
add: string;
|
|
9
|
-
};
|
|
10
|
-
filters: JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Actions = ({ labels, filters }: Props): JSX.Element => {
|
|
14
|
-
return (
|
|
15
|
-
<Box
|
|
16
|
-
sx={{ display: 'grid', gridTemplateColumns: 'min-content auto', gap: 2 }}
|
|
17
|
-
>
|
|
18
|
-
<AddButton label={labels.add} />
|
|
19
|
-
<Search label={labels.search} filters={filters} />
|
|
20
|
-
</Box>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default Actions;
|