@centreon/ui 25.10.29 → 25.10.30
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 -3
- package/public/mockServiceWorker.js +8 -31
- package/src/Dashboard/Item.tsx +142 -149
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +2 -0
- package/src/Form/Inputs/Grid.tsx +2 -3
- package/src/Form/Inputs/models.ts +2 -0
- package/src/Form/Section/navigateToSection.ts +6 -6
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +55 -102
- package/src/Graph/BarChart/BarChart.stories.tsx +1 -51
- package/src/Graph/BarChart/BarChart.tsx +1 -1
- package/src/Graph/BarChart/BarGroup.tsx +32 -22
- package/src/Graph/BarChart/BarStack.tsx +26 -15
- package/src/Graph/BarChart/MemoizedGroup.tsx +18 -14
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +6 -7
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +2 -2
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +5 -4
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +45 -18
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +118 -124
- package/src/Graph/Chart/Chart.cypress.spec.tsx +6 -25
- package/src/Graph/Chart/Chart.stories.tsx +1 -43
- package/src/Graph/Chart/Chart.tsx +13 -9
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +4 -2
- package/src/Graph/Chart/Legend/index.tsx +2 -26
- package/src/Graph/Chart/index.tsx +45 -31
- package/src/Graph/Chart/models.ts +1 -6
- package/src/Graph/Chart/translatedLabels.ts +1 -0
- package/src/Graph/Chart/useChartData.ts +24 -3
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/BaseChart/BaseChart.tsx +1 -6
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +23 -16
- package/src/Graph/common/Error/NoData.tsx +18 -0
- package/src/Graph/common/Grids/index.tsx +4 -4
- package/src/Graph/common/timeSeries/index.test.ts +4 -24
- package/src/Graph/common/timeSeries/index.ts +120 -184
- package/src/Graph/common/timeSeries/models.ts +1 -1
- package/src/Graph/common/utils.ts +4 -10
- package/src/Graph/index.ts +20 -20
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +3 -3
- package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +11 -3
- package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +3 -2
- package/src/InputField/Select/index.tsx +2 -1
- package/src/Listing/ActionBar/Pagination.tsx +2 -1
- package/src/Listing/ActionBar/index.tsx +113 -8
- package/src/Listing/index.tsx +19 -2
- package/src/Listing/translatedLabels.ts +4 -0
- package/src/Module/index.tsx +2 -8
- package/src/ThemeProvider/index.tsx +21 -30
- package/src/ThemeProvider/tailwindcss.css +12 -10
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -5
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -1
- package/src/api/useGraphQuery/index.ts +7 -4
- package/src/components/Layout/PageLayout/PageLayout.tsx +3 -9
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +3 -5
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +3 -5
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +3 -5
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +44 -25
- package/src/components/Layout/PageLayout/translatedLabels.ts +1 -0
- package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
- package/src/components/Menu/Button/MenuButton.tsx +5 -6
- package/src/components/Menu/Menu.styles.ts +68 -0
- package/src/components/Menu/MenuDivider.tsx +5 -1
- package/src/components/Menu/MenuItem.tsx +5 -1
- package/src/components/Menu/MenuItems.tsx +4 -5
- package/src/components/Modal/Modal.styles.ts +2 -1
- package/src/components/Modal/ModalHeader.tsx +1 -5
- package/src/utils/useInfiniteScrollListing.ts +11 -7
- package/src/utils/useViewportIntersection.ts +3 -4
- package/src/Graph/mockedData/dataWithMissingPoint.json +0 -74
- package/src/Graph/mockedData/pingServiceWithStackedKeys.json +0 -205
|
@@ -26,14 +26,14 @@ import {
|
|
|
26
26
|
map,
|
|
27
27
|
negate,
|
|
28
28
|
pipe,
|
|
29
|
-
pluck,
|
|
30
29
|
prop,
|
|
31
30
|
propEq,
|
|
32
31
|
reduce,
|
|
33
32
|
reject,
|
|
34
33
|
sortBy,
|
|
35
34
|
split,
|
|
36
|
-
uniq
|
|
35
|
+
uniq,
|
|
36
|
+
isNotNil
|
|
37
37
|
} from 'ramda';
|
|
38
38
|
|
|
39
39
|
import { margin } from '../../Chart/common';
|
|
@@ -54,6 +54,17 @@ interface TimeTickWithMetrics {
|
|
|
54
54
|
timeTick: string;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
const defaultDsData = {
|
|
58
|
+
ds_color_line: '#000000',
|
|
59
|
+
ds_filled: false,
|
|
60
|
+
ds_invert: false,
|
|
61
|
+
ds_legend: '',
|
|
62
|
+
ds_order: '0',
|
|
63
|
+
ds_stack: '0',
|
|
64
|
+
ds_stack_key: null,
|
|
65
|
+
ds_transparency: 80
|
|
66
|
+
};
|
|
67
|
+
|
|
57
68
|
const toTimeTickWithMetrics = ({
|
|
58
69
|
metrics,
|
|
59
70
|
times
|
|
@@ -73,7 +84,7 @@ const toTimeTickValue = (
|
|
|
73
84
|
const getMetricsForIndex = (): Omit<TimeValue, 'timeTick'> => {
|
|
74
85
|
const addMetricForTimeIndex = (acc, { metric_id, data }): TimeValue => ({
|
|
75
86
|
...acc,
|
|
76
|
-
[metric_id]: data[timeIndex]
|
|
87
|
+
[metric_id]: data[timeIndex]
|
|
77
88
|
});
|
|
78
89
|
|
|
79
90
|
return reduce(addMetricForTimeIndex, {} as TimeValue, metrics);
|
|
@@ -120,30 +131,39 @@ const toLine = ({
|
|
|
120
131
|
maximum_value,
|
|
121
132
|
metric_id,
|
|
122
133
|
displayAs
|
|
123
|
-
}: Metric): Line =>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
}: Metric): Line => {
|
|
135
|
+
const safeDsData = {
|
|
136
|
+
...defaultDsData,
|
|
137
|
+
...(ds_data || {}),
|
|
138
|
+
ds_color_area:
|
|
139
|
+
ds_data?.ds_color_area ?? ds_data?.ds_color_line ?? defaultDsData.ds_color_line
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
areaColor: safeDsData.ds_color_area,
|
|
144
|
+
average_value,
|
|
145
|
+
color: safeDsData.ds_color_line,
|
|
146
|
+
display: true,
|
|
147
|
+
displayAs,
|
|
148
|
+
filled: safeDsData.ds_filled,
|
|
149
|
+
highlight: undefined,
|
|
150
|
+
invert: safeDsData.ds_invert,
|
|
151
|
+
legend: safeDsData.ds_legend,
|
|
152
|
+
lineColor: safeDsData.ds_color_line,
|
|
153
|
+
maximum_value,
|
|
154
|
+
metric,
|
|
155
|
+
metric_id,
|
|
156
|
+
minimum_value,
|
|
157
|
+
name: legend,
|
|
158
|
+
stackKey: safeDsData.ds_stack_key || null,
|
|
159
|
+
stackOrder:
|
|
160
|
+
equals(safeDsData.ds_stack, '1') || equals(safeDsData.ds_stack, true)
|
|
161
|
+
? Number.parseInt(safeDsData.ds_order || '0', 10)
|
|
162
|
+
: null,
|
|
163
|
+
transparency: safeDsData.ds_transparency,
|
|
164
|
+
unit
|
|
165
|
+
};
|
|
166
|
+
};
|
|
147
167
|
|
|
148
168
|
const getLineData = (graphData: LineChartData): Array<Line> =>
|
|
149
169
|
map(toLine, graphData.metrics);
|
|
@@ -160,8 +180,8 @@ const getMetrics = (timeValue: TimeValue): Array<string> =>
|
|
|
160
180
|
|
|
161
181
|
const getValueForMetric =
|
|
162
182
|
(timeValue: TimeValue) =>
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
(metric_id: number): number =>
|
|
184
|
+
prop(metric_id, timeValue) as number;
|
|
165
185
|
|
|
166
186
|
const getUnits = (lines: Array<Line>): Array<string> =>
|
|
167
187
|
pipe(map(prop('unit')), uniq)(lines);
|
|
@@ -242,10 +262,7 @@ const getStackedMetricValues = ({
|
|
|
242
262
|
timeSeries
|
|
243
263
|
}: LinesTimeSeries): Array<number> => {
|
|
244
264
|
const getTimeSeriesValuesForMetric = (metric_id): Array<number> =>
|
|
245
|
-
map(
|
|
246
|
-
(timeValue) => getValueForMetric(timeValue)(metric_id) || 0,
|
|
247
|
-
timeSeries
|
|
248
|
-
);
|
|
265
|
+
map((timeValue) => getValueForMetric(timeValue)(metric_id), timeSeries);
|
|
249
266
|
|
|
250
267
|
const metricsValues = pipe(
|
|
251
268
|
map(prop('metric_id')) as (metric) => Array<number>,
|
|
@@ -308,8 +325,8 @@ const getTimeSeriesForLines = ({
|
|
|
308
325
|
...acc,
|
|
309
326
|
[metric_id]:
|
|
310
327
|
invert &&
|
|
311
|
-
|
|
312
|
-
|
|
328
|
+
metricsValue[metric_id] &&
|
|
329
|
+
gt(metricsValue[metric_id], 0)
|
|
313
330
|
? negate(metricsValue[metric_id])
|
|
314
331
|
: metricsValue[metric_id]
|
|
315
332
|
};
|
|
@@ -342,10 +359,10 @@ const getYScale = ({
|
|
|
342
359
|
|
|
343
360
|
return invert
|
|
344
361
|
? getScaleType(scale)({
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
362
|
+
base: scaleLogarithmicBase,
|
|
363
|
+
domain: yScale.domain().reverse(),
|
|
364
|
+
range: yScale.range().reverse()
|
|
365
|
+
})
|
|
349
366
|
: yScale;
|
|
350
367
|
};
|
|
351
368
|
|
|
@@ -382,6 +399,7 @@ const getScale = ({
|
|
|
382
399
|
invert,
|
|
383
400
|
hasDisplayAsBar,
|
|
384
401
|
hasLineFilled,
|
|
402
|
+
hasStackedLines,
|
|
385
403
|
min,
|
|
386
404
|
max
|
|
387
405
|
}): ScaleLinear<number, number> => {
|
|
@@ -389,30 +407,42 @@ const getScale = ({
|
|
|
389
407
|
const sanitizedValuesForMinimum = min
|
|
390
408
|
? [min]
|
|
391
409
|
: getSanitizedValues([
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
const minValue = Math.min(...sanitizedValuesForMinimum);
|
|
401
|
-
const minValueWithMargin =
|
|
402
|
-
(hasDisplayAsBar || hasLineFilled) && minValue > 0 && !min
|
|
403
|
-
? 0
|
|
404
|
-
: minValue - Math.abs(minValue) * 0.05;
|
|
410
|
+
invert && graphValues.every(lt(0))
|
|
411
|
+
? negate(getMax(graphValues))
|
|
412
|
+
: getMin(graphValues),
|
|
413
|
+
!isEmpty(stackedValues) &&
|
|
414
|
+
!equals(stackedValues, [0]) &&
|
|
415
|
+
getMin(stackedValues),
|
|
416
|
+
Math.min(...thresholds)
|
|
417
|
+
]);
|
|
418
|
+
const minValue = Math.min(...sanitizedValuesForMinimum.filter(isNotNil));
|
|
405
419
|
|
|
406
420
|
const sanitizedValuesForMaximum = max
|
|
407
421
|
? [max]
|
|
408
422
|
: getSanitizedValues([
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const maxValue = Math.max(...sanitizedValuesForMaximum);
|
|
415
|
-
|
|
423
|
+
getMax(graphValues),
|
|
424
|
+
getMax(stackedValues),
|
|
425
|
+
hasOnlyZeroesHasValue(graphValues) ? 1 : null,
|
|
426
|
+
Math.max(...thresholds)
|
|
427
|
+
]);
|
|
428
|
+
const maxValue = Math.max(...sanitizedValuesForMaximum.filter(isNotNil));
|
|
429
|
+
|
|
430
|
+
const minValueWithMargin =
|
|
431
|
+
(hasDisplayAsBar && minValue > 0) ||
|
|
432
|
+
(hasLineFilled &&
|
|
433
|
+
Math.max(maxValue, minValue) > minValue &&
|
|
434
|
+
minValue > 0) ||
|
|
435
|
+
(hasStackedLines && minValue > maxValue)
|
|
436
|
+
? 0
|
|
437
|
+
: minValue - Math.abs(minValue) * 0.05;
|
|
438
|
+
const maxValueWithMargin =
|
|
439
|
+
(hasDisplayAsBar && maxValue < 0) ||
|
|
440
|
+
(hasLineFilled &&
|
|
441
|
+
Math.min(maxValue, minValue) < maxValue &&
|
|
442
|
+
maxValue < 0) ||
|
|
443
|
+
(hasStackedLines && minValue > maxValue)
|
|
444
|
+
? 0
|
|
445
|
+
: maxValue + Math.abs(maxValue) * 0.05;
|
|
416
446
|
|
|
417
447
|
const scaleType = getScaleType(scale);
|
|
418
448
|
|
|
@@ -479,7 +509,8 @@ const getYScaleUnit = ({
|
|
|
479
509
|
min,
|
|
480
510
|
max,
|
|
481
511
|
isBarChart,
|
|
482
|
-
boundariesUnit
|
|
512
|
+
boundariesUnit,
|
|
513
|
+
isFilled
|
|
483
514
|
}: AxeScale & {
|
|
484
515
|
invert?: boolean | string | null;
|
|
485
516
|
unit: string;
|
|
@@ -487,6 +518,7 @@ const getYScaleUnit = ({
|
|
|
487
518
|
min?: number;
|
|
488
519
|
boundariesUnit?: string;
|
|
489
520
|
isBarChart?: boolean;
|
|
521
|
+
isFilled?: boolean;
|
|
490
522
|
}): ScaleLinear<number, number> => {
|
|
491
523
|
const [firstUnit] = getUnits(dataLines);
|
|
492
524
|
const shouldApplyThresholds =
|
|
@@ -505,12 +537,12 @@ const getYScaleUnit = ({
|
|
|
505
537
|
|
|
506
538
|
const stackedValues = hasStackedLines
|
|
507
539
|
? getStackedMetricValues({
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
: [
|
|
540
|
+
lines: getSortedStackedLines(dataLines).filter(
|
|
541
|
+
({ unit: stackedUnit }) => equals(unit, stackedUnit)
|
|
542
|
+
),
|
|
543
|
+
timeSeries: dataTimeSeries
|
|
544
|
+
})
|
|
545
|
+
: [];
|
|
514
546
|
|
|
515
547
|
return getScale({
|
|
516
548
|
graphValues,
|
|
@@ -520,8 +552,14 @@ const getYScaleUnit = ({
|
|
|
520
552
|
({ displayAs, unit: lineUnit }) =>
|
|
521
553
|
equals(unit, lineUnit) && equals(displayAs, 'bar')
|
|
522
554
|
),
|
|
523
|
-
hasLineFilled:
|
|
524
|
-
|
|
555
|
+
hasLineFilled: isNil(isFilled)
|
|
556
|
+
? dataLines.some(
|
|
557
|
+
({ unit: lineUnit, filled }) => equals(unit, lineUnit) && filled
|
|
558
|
+
)
|
|
559
|
+
: isFilled,
|
|
560
|
+
hasStackedLines: dataLines.some(
|
|
561
|
+
({ unit: lineUnit, stackKey, stackOrder }) =>
|
|
562
|
+
equals(unit, lineUnit) && (stackKey || stackOrder)
|
|
525
563
|
),
|
|
526
564
|
height: valueGraphHeight,
|
|
527
565
|
invert,
|
|
@@ -561,12 +599,14 @@ const getYScalePerUnit = ({
|
|
|
561
599
|
isBarChart,
|
|
562
600
|
min,
|
|
563
601
|
max,
|
|
564
|
-
boundariesUnit
|
|
602
|
+
boundariesUnit,
|
|
603
|
+
isFilled
|
|
565
604
|
}: AxeScale & {
|
|
566
605
|
min?: number;
|
|
567
606
|
max?: number;
|
|
568
607
|
isBarChart?: boolean;
|
|
569
608
|
boundariesUnit?: string;
|
|
609
|
+
isFilled?: boolean;
|
|
570
610
|
}): Record<string, ScaleLinear<number, number>> => {
|
|
571
611
|
const units = getUnits(dataLines);
|
|
572
612
|
|
|
@@ -590,7 +630,8 @@ const getYScalePerUnit = ({
|
|
|
590
630
|
min,
|
|
591
631
|
max,
|
|
592
632
|
isBarChart,
|
|
593
|
-
boundariesUnit
|
|
633
|
+
boundariesUnit,
|
|
634
|
+
isFilled
|
|
594
635
|
})
|
|
595
636
|
};
|
|
596
637
|
}, {});
|
|
@@ -598,15 +639,15 @@ const getYScalePerUnit = ({
|
|
|
598
639
|
return scalePerUnit;
|
|
599
640
|
};
|
|
600
641
|
|
|
601
|
-
const formatTime = (
|
|
602
|
-
return `${numeral(value).format('0.[00]a')}
|
|
642
|
+
const formatTime = (value: number): string => {
|
|
643
|
+
return `${numeral(value).format('0.[00]a')} ms`;
|
|
603
644
|
};
|
|
604
645
|
|
|
605
646
|
const registerMsUnitToNumeral = (): null => {
|
|
606
647
|
try {
|
|
607
648
|
numeral.register('format', 'milliseconds', {
|
|
608
649
|
format: (value) => {
|
|
609
|
-
return formatTime(
|
|
650
|
+
return formatTime(value);
|
|
610
651
|
},
|
|
611
652
|
regexps: {
|
|
612
653
|
format: /(ms)/,
|
|
@@ -623,27 +664,6 @@ const registerMsUnitToNumeral = (): null => {
|
|
|
623
664
|
|
|
624
665
|
registerMsUnitToNumeral();
|
|
625
666
|
|
|
626
|
-
const registerSecondsUnitToNumeral = (): null => {
|
|
627
|
-
try {
|
|
628
|
-
numeral.register('format', 'seconds', {
|
|
629
|
-
format: (value) => {
|
|
630
|
-
return formatTime({ value, unit: 's' });
|
|
631
|
-
},
|
|
632
|
-
regexps: {
|
|
633
|
-
format: /(s)/,
|
|
634
|
-
unformat: /(s)/
|
|
635
|
-
},
|
|
636
|
-
unformat: () => ''
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
return null;
|
|
640
|
-
} catch (_) {
|
|
641
|
-
return null;
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
registerSecondsUnitToNumeral();
|
|
646
|
-
|
|
647
667
|
const getBase1024 = ({ unit, base }): boolean => {
|
|
648
668
|
const base2Units = [
|
|
649
669
|
'B',
|
|
@@ -673,13 +693,12 @@ const formatMetricValue = ({
|
|
|
673
693
|
|
|
674
694
|
const formatSuffix = cond([
|
|
675
695
|
[equals('ms'), always(' ms')],
|
|
676
|
-
[equals('s'), always(' s')],
|
|
677
696
|
[T, always(base1024 ? ' ib' : 'a')]
|
|
678
697
|
])(unit);
|
|
679
698
|
|
|
680
699
|
const formattedMetricValue = numeral(Math.abs(value))
|
|
681
700
|
.format(`0.[00]${formatSuffix}`)
|
|
682
|
-
.replace(/
|
|
701
|
+
.replace(/B/, unit);
|
|
683
702
|
|
|
684
703
|
if (lt(value, 0)) {
|
|
685
704
|
return `-${formattedMetricValue}`;
|
|
@@ -698,6 +717,8 @@ const formatMetricValueWithUnit = ({
|
|
|
698
717
|
return null;
|
|
699
718
|
}
|
|
700
719
|
|
|
720
|
+
const base1024 = getBase1024({ base, unit });
|
|
721
|
+
|
|
701
722
|
if (isRaw) {
|
|
702
723
|
const unitText = equals('%', unit) ? unit : ` ${unit}`;
|
|
703
724
|
|
|
@@ -710,7 +731,9 @@ const formatMetricValueWithUnit = ({
|
|
|
710
731
|
|
|
711
732
|
const formattedMetricValue = formatMetricValue({ base, unit, value });
|
|
712
733
|
|
|
713
|
-
return
|
|
734
|
+
return base1024 || !unit || equals(unit, 'ms')
|
|
735
|
+
? formattedMetricValue
|
|
736
|
+
: `${formattedMetricValue} ${unit}`;
|
|
714
737
|
};
|
|
715
738
|
|
|
716
739
|
const bisectDate = bisector(identity).center;
|
|
@@ -760,93 +783,6 @@ export const formatMetricName = ({
|
|
|
760
783
|
return metricName;
|
|
761
784
|
};
|
|
762
785
|
|
|
763
|
-
export const getStackedLinesTimeSeriesPerStackAndUnit = ({
|
|
764
|
-
stackedLines,
|
|
765
|
-
timeSeries,
|
|
766
|
-
invert
|
|
767
|
-
}: {
|
|
768
|
-
stackedLines: Array<Line>;
|
|
769
|
-
timeSeries: Array<TimeValue>;
|
|
770
|
-
invert?: boolean;
|
|
771
|
-
}): {
|
|
772
|
-
stackedLinesTimeSeriesPerStackKeyAndUnit: Record<
|
|
773
|
-
string,
|
|
774
|
-
{ lines: Array<Line>; timeSeries: Array<TimeValue> }
|
|
775
|
-
>;
|
|
776
|
-
stackedKeys: Record<string, null>;
|
|
777
|
-
} => {
|
|
778
|
-
const stackedKeys = stackedLines.reduce(
|
|
779
|
-
(acc, { unit, stackKey }) => ({
|
|
780
|
-
...acc,
|
|
781
|
-
[`stacked-${unit || ''}-${stackKey ? stackKey : ''}`]: null
|
|
782
|
-
}),
|
|
783
|
-
{}
|
|
784
|
-
);
|
|
785
|
-
const stackedKeysWithOnlyStackKey = Object.keys(stackedKeys).filter(
|
|
786
|
-
(stackKey: string) => stackKey.split('-')[2]
|
|
787
|
-
);
|
|
788
|
-
const stackedKeysWithOnlyUnit = Object.keys(stackedKeys).filter(
|
|
789
|
-
(stackKey: string) => !stackKey.split('-')[2]
|
|
790
|
-
);
|
|
791
|
-
|
|
792
|
-
const stackedLinesTimeSeriesPerStackKey = stackedKeysWithOnlyStackKey.reduce(
|
|
793
|
-
(acc, stackedKey: string) => {
|
|
794
|
-
const [, stackUnit, stackKey] = stackedKey.split('-');
|
|
795
|
-
const relatedLines = stackedLines.filter(({ unit, stackKey: key }) => {
|
|
796
|
-
return stackUnit === (unit || '') && stackKey === key;
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
return {
|
|
800
|
-
...acc,
|
|
801
|
-
[stackedKey]: {
|
|
802
|
-
lines: relatedLines,
|
|
803
|
-
timeSeries: getTimeSeriesForLines({
|
|
804
|
-
invert,
|
|
805
|
-
lines: relatedLines,
|
|
806
|
-
timeSeries
|
|
807
|
-
})
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
},
|
|
811
|
-
{}
|
|
812
|
-
);
|
|
813
|
-
const affectedLinesPerStackKey = flatten(
|
|
814
|
-
pluck('lines', Object.values(stackedLinesTimeSeriesPerStackKey))
|
|
815
|
-
);
|
|
816
|
-
const stackedLinesTimeSeriesPerUnit = stackedKeysWithOnlyUnit.reduce(
|
|
817
|
-
(acc, stackedKey: string) => {
|
|
818
|
-
const [, stackUnit] = stackedKey.split('-');
|
|
819
|
-
const relatedLines = stackedLines.filter(
|
|
820
|
-
(line) =>
|
|
821
|
-
!affectedLinesPerStackKey.some(
|
|
822
|
-
(affectedLine) => line.metric_id === affectedLine.metric_id
|
|
823
|
-
) && stackUnit === (line.unit || '')
|
|
824
|
-
);
|
|
825
|
-
|
|
826
|
-
return {
|
|
827
|
-
...acc,
|
|
828
|
-
[stackedKey]: {
|
|
829
|
-
lines: relatedLines,
|
|
830
|
-
timeSeries: getTimeSeriesForLines({
|
|
831
|
-
lines: relatedLines,
|
|
832
|
-
timeSeries,
|
|
833
|
-
invert
|
|
834
|
-
})
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
},
|
|
838
|
-
{}
|
|
839
|
-
);
|
|
840
|
-
|
|
841
|
-
return {
|
|
842
|
-
stackedLinesTimeSeriesPerStackKeyAndUnit: {
|
|
843
|
-
...stackedLinesTimeSeriesPerStackKey,
|
|
844
|
-
...stackedLinesTimeSeriesPerUnit
|
|
845
|
-
},
|
|
846
|
-
stackedKeys
|
|
847
|
-
};
|
|
848
|
-
};
|
|
849
|
-
|
|
850
786
|
export {
|
|
851
787
|
getTimeSeries,
|
|
852
788
|
getLineData,
|
|
@@ -25,7 +25,7 @@ import { BarStyle } from '../BarChart/models';
|
|
|
25
25
|
import { margin } from '../Chart/common';
|
|
26
26
|
import { LineStyle } from '../Chart/models';
|
|
27
27
|
import { Threshold, Thresholds } from './models';
|
|
28
|
-
import {
|
|
28
|
+
import { formatMetricValue } from './timeSeries';
|
|
29
29
|
import { Line, TimeValue } from './timeSeries/models';
|
|
30
30
|
|
|
31
31
|
interface GetColorFromDataAndThresholdsProps {
|
|
@@ -234,7 +234,7 @@ export const getFormattedAxisValues = ({
|
|
|
234
234
|
|
|
235
235
|
const formattedData = metricIds.map((metricId) =>
|
|
236
236
|
timeSeries.map((data) =>
|
|
237
|
-
|
|
237
|
+
formatMetricValue({
|
|
238
238
|
value: data[metricId],
|
|
239
239
|
unit: axisUnit,
|
|
240
240
|
base
|
|
@@ -246,7 +246,7 @@ export const getFormattedAxisValues = ({
|
|
|
246
246
|
|
|
247
247
|
const formattedThresholdValues = equals(thresholdUnit, axisUnit)
|
|
248
248
|
? threshold.map(({ value }) =>
|
|
249
|
-
|
|
249
|
+
formatMetricValue({
|
|
250
250
|
value,
|
|
251
251
|
unit: axisUnit,
|
|
252
252
|
base
|
|
@@ -273,11 +273,5 @@ export const computeGElementMarginLeft = ({
|
|
|
273
273
|
export const computPixelsToShiftMouse = (xScale): number => {
|
|
274
274
|
const domain = xScale.domain();
|
|
275
275
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (!hoursDiffInGraph) {
|
|
279
|
-
return 0;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return Math.round(8 / hoursDiffInGraph);
|
|
276
|
+
return Math.round(8 / dayjs(domain[1]).diff(domain[0], 'h'));
|
|
283
277
|
};
|
package/src/Graph/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export type { ParentSizeProps } from
|
|
2
|
-
export { default as
|
|
3
|
-
export {
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export { default as
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export * from
|
|
1
|
+
export type { ParentSizeProps } from "@visx/responsive/lib/components/ParentSize";
|
|
2
|
+
export { default as BarChart } from "./BarChart/BarChart";
|
|
3
|
+
export { BarStack } from "./BarStack";
|
|
4
|
+
export { default as LineChart } from "./Chart";
|
|
5
|
+
export { default as ThresholdLines } from "./Chart/BasicComponents/Lines/Threshold";
|
|
6
|
+
export * from "./Chart/models";
|
|
7
|
+
export { default as useLineChartData } from "./Chart/useChartData";
|
|
8
|
+
export { default as Header } from "./common/BaseChart/Header";
|
|
9
|
+
export { default as NoData } from "./common/Error/NoData";
|
|
10
|
+
export type { LineChartData, Threshold, Thresholds } from "./common/models";
|
|
11
|
+
export * from "./common/timeSeries";
|
|
12
|
+
export type { Metric } from "./common/timeSeries/models";
|
|
13
|
+
export { Gauge } from "./Gauge";
|
|
14
|
+
export { HeatMap } from "./HeatMap";
|
|
15
|
+
export { PieChart } from "./PieChart";
|
|
16
|
+
export * from "./PieChart/models";
|
|
17
|
+
export { SingleBar } from "./SingleBar";
|
|
18
|
+
export { Text as GraphText } from "./Text";
|
|
19
|
+
export { Timeline } from "./Timeline";
|
|
20
|
+
export * from "./Tree";
|
|
@@ -65,7 +65,7 @@ const ConnectedAutocompleteField = (
|
|
|
65
65
|
open,
|
|
66
66
|
exclusionOptionProperty = 'id',
|
|
67
67
|
searchConditions = [],
|
|
68
|
-
getRenderedOptionText = (option): string => option
|
|
68
|
+
getRenderedOptionText = (option): string => option?.name?.toString(),
|
|
69
69
|
getRequestHeaders,
|
|
70
70
|
displayOptionThumbnail,
|
|
71
71
|
queryKey,
|
|
@@ -340,11 +340,11 @@ const ConnectedAutocompleteField = (
|
|
|
340
340
|
);
|
|
341
341
|
|
|
342
342
|
useEffect(() => {
|
|
343
|
-
if (!autocompleteChangedValue
|
|
343
|
+
if (!autocompleteChangedValue) {
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
346
|
setSearchParameter(undefined);
|
|
347
|
-
}, [autocompleteChangedValue
|
|
347
|
+
}, [autocompleteChangedValue]);
|
|
348
348
|
|
|
349
349
|
useEffect(() => {
|
|
350
350
|
if (!optionsOpen) {
|
|
@@ -38,7 +38,8 @@ const ListboxComponent = ({
|
|
|
38
38
|
options,
|
|
39
39
|
isOptionSelected,
|
|
40
40
|
onChange,
|
|
41
|
-
total
|
|
41
|
+
total,
|
|
42
|
+
value = []
|
|
42
43
|
}) => {
|
|
43
44
|
if (disableSelectAll) {
|
|
44
45
|
return;
|
|
@@ -54,12 +55,19 @@ const ListboxComponent = ({
|
|
|
54
55
|
const syntheticEvent = {} as React.SyntheticEvent;
|
|
55
56
|
|
|
56
57
|
if (allSelected) {
|
|
57
|
-
|
|
58
|
+
const remaining = value.filter(
|
|
59
|
+
(v) => !options.some((opt) => opt.id === v.id)
|
|
60
|
+
);
|
|
61
|
+
onChange?.(syntheticEvent, remaining, 'selectOption');
|
|
58
62
|
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
const merged = [
|
|
67
|
+
...value,
|
|
68
|
+
...options.filter((opt) => !isOptionSelected(opt))
|
|
69
|
+
];
|
|
70
|
+
onChange?.(syntheticEvent, merged, 'selectOption');
|
|
63
71
|
};
|
|
64
72
|
|
|
65
73
|
return (
|
|
@@ -36,7 +36,7 @@ const MultiAutocompleteField = ({
|
|
|
36
36
|
disableSortedOptions = false,
|
|
37
37
|
disableSelectAll = true,
|
|
38
38
|
optionProperty = 'name',
|
|
39
|
-
getOptionLabel = (option): string => option
|
|
39
|
+
getOptionLabel = (option): string => option?.name,
|
|
40
40
|
getTagLabel = (option): string => option[optionProperty],
|
|
41
41
|
getOptionTooltipLabel,
|
|
42
42
|
chipProps,
|
|
@@ -113,7 +113,8 @@ const MultiAutocompleteField = ({
|
|
|
113
113
|
onChange,
|
|
114
114
|
isOptionSelected,
|
|
115
115
|
disableSelectAll,
|
|
116
|
-
options
|
|
116
|
+
options,
|
|
117
|
+
value: values
|
|
117
118
|
})}
|
|
118
119
|
onChange={onChange}
|
|
119
120
|
{...props}
|
|
@@ -96,6 +96,7 @@ const SelectField = ({
|
|
|
96
96
|
fullWidth={fullWidth}
|
|
97
97
|
size="small"
|
|
98
98
|
{...formControlProps}
|
|
99
|
+
|
|
99
100
|
>
|
|
100
101
|
{label && <InputLabel>{label}</InputLabel>}
|
|
101
102
|
<Select
|
|
@@ -150,4 +151,4 @@ const SelectField = ({
|
|
|
150
151
|
);
|
|
151
152
|
};
|
|
152
153
|
|
|
153
|
-
export default SelectField;
|
|
154
|
+
export default SelectField;
|
|
@@ -22,7 +22,8 @@ const MemoizedPagination = memo(
|
|
|
22
22
|
equals(prevProps.page, nextProps.page) &&
|
|
23
23
|
equals(prevProps.count, nextProps.count) &&
|
|
24
24
|
equals(prevProps.labelRowsPerPage, nextProps.labelRowsPerPage) &&
|
|
25
|
-
equals(prevProps.className, nextProps.className)
|
|
25
|
+
equals(prevProps.className, nextProps.className) &&
|
|
26
|
+
prevProps.labelDisplayedRows === nextProps.labelDisplayedRows
|
|
26
27
|
);
|
|
27
28
|
|
|
28
29
|
export default MemoizedPagination;
|