@centreon/ui 25.10.9 → 25.10.11
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/public/mockServiceWorker.js +8 -31
- 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 -92
- package/src/Graph/BarChart/BarChart.stories.tsx +1 -42
- package/src/Graph/BarChart/BarChart.tsx +1 -1
- package/src/Graph/BarChart/BarStack.tsx +26 -15
- package/src/Graph/BarChart/MemoizedGroup.tsx +8 -7
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +1 -2
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +5 -4
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +94 -94
- package/src/Graph/Chart/Chart.cypress.spec.tsx +6 -25
- package/src/Graph/Chart/Chart.stories.tsx +1 -34
- package/src/Graph/Chart/Chart.tsx +6 -5
- package/src/Graph/Chart/Legend/index.tsx +2 -26
- package/src/Graph/Chart/index.tsx +28 -24
- package/src/Graph/Chart/models.ts +1 -6
- package/src/Graph/Chart/translatedLabels.ts +1 -0
- package/src/Graph/Chart/useChartData.ts +1 -1
- package/src/Graph/common/BaseChart/BaseChart.tsx +1 -6
- package/src/Graph/common/BaseChart/Header/index.tsx +3 -1
- package/src/Graph/common/Error/NoData.tsx +18 -0
- package/src/Graph/common/timeSeries/index.test.ts +4 -4
- package/src/Graph/common/timeSeries/index.ts +77 -73
- package/src/Graph/common/utils.ts +4 -10
- package/src/Graph/index.ts +20 -19
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -7
- package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +28 -17
- package/src/InputField/Select/Option.tsx +3 -3
- package/src/InputField/Select/index.tsx +2 -1
- package/src/Module/index.tsx +2 -8
- package/src/ThemeProvider/index.tsx +21 -30
- package/src/ThemeProvider/tailwindcss.css +10 -10
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +4 -3
- package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +15 -10
- package/src/components/Menu/Button/MenuButton.tsx +1 -2
- package/src/components/Modal/Modal.styles.ts +2 -1
- package/src/components/Modal/ModalHeader.tsx +1 -5
- package/src/Graph/mockedData/dataWithMissingPoint.json +0 -74
|
@@ -107,7 +107,7 @@ const Lines = ({
|
|
|
107
107
|
key={`stacked-${unit}`}
|
|
108
108
|
lines={lines}
|
|
109
109
|
timeSeries={stackedTimeSeries}
|
|
110
|
-
yScale={yScalesPerUnit[unit]}
|
|
110
|
+
yScale={yScalesPerUnit[unit] ?? undefined}
|
|
111
111
|
{...commonStackedLinesProps}
|
|
112
112
|
/>
|
|
113
113
|
)
|
|
@@ -123,7 +123,7 @@ const Lines = ({
|
|
|
123
123
|
invert: '1',
|
|
124
124
|
scale,
|
|
125
125
|
scaleLogarithmicBase,
|
|
126
|
-
unit,
|
|
126
|
+
unit: unit ?? undefined,
|
|
127
127
|
yScalesPerUnit
|
|
128
128
|
})}
|
|
129
129
|
{...commonStackedLinesProps}
|
|
@@ -146,107 +146,107 @@ const Lines = ({
|
|
|
146
146
|
|
|
147
147
|
{displayAreaRegularLines
|
|
148
148
|
? regularLines.map(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
({
|
|
150
|
+
areaColor,
|
|
151
|
+
transparency,
|
|
152
|
+
lineColor,
|
|
153
|
+
filled,
|
|
154
|
+
unit,
|
|
155
|
+
highlight,
|
|
156
|
+
invert,
|
|
157
|
+
metric_id,
|
|
158
|
+
...rest
|
|
159
|
+
}) => {
|
|
160
|
+
const yScale = getYScale({
|
|
161
|
+
invert,
|
|
162
|
+
scale,
|
|
163
|
+
scaleLogarithmicBase,
|
|
154
164
|
unit,
|
|
155
|
-
|
|
165
|
+
yScalesPerUnit
|
|
166
|
+
});
|
|
167
|
+
const relatedTimeSeries = getTimeSeriesForLines({
|
|
156
168
|
invert,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
timeSeries
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const style = getStyle({
|
|
186
|
-
style: lineStyle,
|
|
187
|
-
metricId: metric_id
|
|
188
|
-
}) as LineStyle;
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<g key={metric_id}>
|
|
192
|
-
{displayGuidingLines && (
|
|
193
|
-
<RegularAnchorPoint
|
|
194
|
-
areaColor={areaColor || lineColor}
|
|
195
|
-
lineColor={lineColor}
|
|
196
|
-
metric_id={metric_id}
|
|
197
|
-
timeSeries={relatedTimeSeries}
|
|
198
|
-
transparency={transparency}
|
|
199
|
-
xScale={xScale}
|
|
200
|
-
yScale={yScale}
|
|
201
|
-
maxLeftAxisCharacters={maxLeftAxisCharacters}
|
|
202
|
-
hasSecondUnit={hasSecondUnit}
|
|
203
|
-
/>
|
|
204
|
-
)}
|
|
205
|
-
{style?.showPoints &&
|
|
206
|
-
getDates(relatedTimeSeries).map((timeTick) => (
|
|
207
|
-
<Point
|
|
208
|
-
key={timeTick.toString()}
|
|
209
|
-
lineColor={lineColor}
|
|
210
|
-
metric_id={metric_id}
|
|
211
|
-
radius={getPointRadius(style?.lineWidth)}
|
|
212
|
-
timeSeries={relatedTimeSeries}
|
|
213
|
-
timeTick={timeTick}
|
|
214
|
-
xScale={xScale}
|
|
215
|
-
yPoint={getYAnchorPoint({
|
|
216
|
-
metric_id,
|
|
217
|
-
timeSeries: relatedTimeSeries,
|
|
218
|
-
timeTick,
|
|
219
|
-
yScale
|
|
220
|
-
})}
|
|
221
|
-
yScale={yScale}
|
|
222
|
-
/>
|
|
223
|
-
))}
|
|
224
|
-
<RegularLine
|
|
169
|
+
lines: [
|
|
170
|
+
{
|
|
171
|
+
areaColor,
|
|
172
|
+
filled,
|
|
173
|
+
highlight,
|
|
174
|
+
invert,
|
|
175
|
+
lineColor,
|
|
176
|
+
metric_id,
|
|
177
|
+
transparency,
|
|
178
|
+
unit,
|
|
179
|
+
...rest
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
timeSeries
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const style = getStyle({
|
|
186
|
+
style: lineStyle,
|
|
187
|
+
metricId: metric_id
|
|
188
|
+
}) as LineStyle;
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<g key={metric_id}>
|
|
192
|
+
{displayGuidingLines && (
|
|
193
|
+
<RegularAnchorPoint
|
|
225
194
|
areaColor={areaColor || lineColor}
|
|
226
|
-
curve={style?.curve || 'linear'}
|
|
227
|
-
dashLength={style?.dashLength}
|
|
228
|
-
dashOffset={style?.dashOffset}
|
|
229
|
-
dotOffset={style?.dotOffset}
|
|
230
|
-
filled={isNil(style?.showArea) ? filled : style.showArea}
|
|
231
|
-
graphHeight={height}
|
|
232
|
-
highlight={highlight}
|
|
233
195
|
lineColor={lineColor}
|
|
234
|
-
lineWidth={style?.lineWidth || 2}
|
|
235
196
|
metric_id={metric_id}
|
|
236
197
|
timeSeries={relatedTimeSeries}
|
|
237
|
-
transparency={
|
|
238
|
-
isNil(style?.areaTransparency)
|
|
239
|
-
? transparency || 80
|
|
240
|
-
: style.areaTransparency
|
|
241
|
-
}
|
|
242
|
-
unit={unit}
|
|
198
|
+
transparency={transparency}
|
|
243
199
|
xScale={xScale}
|
|
244
200
|
yScale={yScale}
|
|
201
|
+
maxLeftAxisCharacters={maxLeftAxisCharacters}
|
|
202
|
+
hasSecondUnit={hasSecondUnit}
|
|
245
203
|
/>
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
204
|
+
)}
|
|
205
|
+
{style?.showPoints &&
|
|
206
|
+
getDates(relatedTimeSeries).map((timeTick) => (
|
|
207
|
+
<Point
|
|
208
|
+
key={timeTick.toString()}
|
|
209
|
+
lineColor={lineColor}
|
|
210
|
+
metric_id={metric_id}
|
|
211
|
+
radius={getPointRadius(style?.lineWidth)}
|
|
212
|
+
timeSeries={relatedTimeSeries}
|
|
213
|
+
timeTick={timeTick}
|
|
214
|
+
xScale={xScale}
|
|
215
|
+
yPoint={getYAnchorPoint({
|
|
216
|
+
metric_id,
|
|
217
|
+
timeSeries: relatedTimeSeries,
|
|
218
|
+
timeTick,
|
|
219
|
+
yScale
|
|
220
|
+
})}
|
|
221
|
+
yScale={yScale}
|
|
222
|
+
/>
|
|
223
|
+
))}
|
|
224
|
+
<RegularLine
|
|
225
|
+
areaColor={areaColor || lineColor}
|
|
226
|
+
curve={style?.curve || 'linear'}
|
|
227
|
+
dashLength={style?.dashLength}
|
|
228
|
+
dashOffset={style?.dashOffset}
|
|
229
|
+
dotOffset={style?.dotOffset}
|
|
230
|
+
filled={isNil(style?.showArea) ? filled : style.showArea}
|
|
231
|
+
graphHeight={height}
|
|
232
|
+
highlight={highlight}
|
|
233
|
+
lineColor={lineColor}
|
|
234
|
+
lineWidth={style?.lineWidth || 2}
|
|
235
|
+
metric_id={metric_id}
|
|
236
|
+
timeSeries={relatedTimeSeries}
|
|
237
|
+
transparency={
|
|
238
|
+
isNil(style?.areaTransparency)
|
|
239
|
+
? transparency || 80
|
|
240
|
+
: style.areaTransparency
|
|
241
|
+
}
|
|
242
|
+
unit={unit}
|
|
243
|
+
xScale={xScale}
|
|
244
|
+
yScale={yScale}
|
|
245
|
+
/>
|
|
246
|
+
</g>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
250
|
: null}
|
|
251
251
|
</g>
|
|
252
252
|
);
|
|
@@ -180,7 +180,7 @@ describe('Line chart', () => {
|
|
|
180
180
|
cy.contains('06/18/2023').should('be.visible');
|
|
181
181
|
|
|
182
182
|
cy.contains('0.4 s').should('be.visible');
|
|
183
|
-
|
|
183
|
+
cy.contains('75.64%').should('be.visible');
|
|
184
184
|
|
|
185
185
|
cy.makeSnapshot();
|
|
186
186
|
});
|
|
@@ -532,7 +532,7 @@ describe('Line chart', () => {
|
|
|
532
532
|
|
|
533
533
|
checkGraphWidth();
|
|
534
534
|
cy.contains(':00 AM').should('be.visible');
|
|
535
|
-
cy.get('circle[cx="
|
|
535
|
+
cy.get('circle[cx="250.83333333333334"]').should('be.visible');
|
|
536
536
|
cy.get('circle[cy="251.79089393069725"]').should('be.visible');
|
|
537
537
|
|
|
538
538
|
cy.makeSnapshot();
|
|
@@ -591,7 +591,7 @@ describe('Line chart', () => {
|
|
|
591
591
|
cy.get('path.visx-area-closed')
|
|
592
592
|
.should('have.attr', 'stroke-dasharray')
|
|
593
593
|
.and('equals', '5 4');
|
|
594
|
-
cy.get('circle[cx="33.
|
|
594
|
+
cy.get('circle[cx="33.44444444444444"]').should('be.visible');
|
|
595
595
|
|
|
596
596
|
cy.makeSnapshot();
|
|
597
597
|
});
|
|
@@ -713,7 +713,7 @@ describe('Lines and bars', () => {
|
|
|
713
713
|
cy.findByLabelText('B').click();
|
|
714
714
|
|
|
715
715
|
cy.findAllByTestId('unit-selector').eq(0).should('have.value', 'B');
|
|
716
|
-
cy.contains('8.79
|
|
716
|
+
cy.contains('8.79 KiB').should('be.visible');
|
|
717
717
|
|
|
718
718
|
cy.findAllByTestId('unit-selector').eq(1).parent().click();
|
|
719
719
|
cy.findByLabelText('%').click();
|
|
@@ -746,11 +746,9 @@ describe('Lines and bars', () => {
|
|
|
746
746
|
|
|
747
747
|
checkGraphWidth();
|
|
748
748
|
|
|
749
|
-
cy.get(
|
|
750
|
-
'path[d="M7.501377410468319,350.5553648585503 h56.51239669421488 h1v1 v23.44463514144968 a1,1 0 0 1 -1,1 h-56.51239669421488 a1,1 0 0 1 -1,-1 v-23.44463514144968 v-1h1z"]'
|
|
749
|
+
cy.get('path[d="M7.501377410468319,350.5553648585503 h56.51239669421488 h1v1 v23.44463514144968 a1,1 0 0 1 -1,1 h-56.51239669421488 a1,1 0 0 1 -1,-1 v-23.44463514144968 v-1h1z"]'
|
|
751
750
|
).should('be.visible');
|
|
752
|
-
cy.get(
|
|
753
|
-
'path[d="M24.05509641873278,201.58170928199803 h23.404958677685954 a17.553719008264462,17.553719008264462 0 0 1 17.553719008264462,17.553719008264462 v113.86621756002336 v17.553719008264462h-17.553719008264462 h-23.404958677685954 h-17.553719008264462v-17.553719008264462 v-113.86621756002336 a17.553719008264462,17.553719008264462 0 0 1 17.553719008264462,-17.553719008264462z"]'
|
|
751
|
+
cy.get('path[d="M24.05509641873278,201.58170928199803 h23.404958677685954 a17.553719008264462,17.553719008264462 0 0 1 17.553719008264462,17.553719008264462 v113.86621756002336 v17.553719008264462h-17.553719008264462 h-23.404958677685954 h-17.553719008264462v-17.553719008264462 v-113.86621756002336 a17.553719008264462,17.553719008264462 0 0 1 17.553719008264462,-17.553719008264462z"]'
|
|
754
752
|
).should('be.visible');
|
|
755
753
|
|
|
756
754
|
cy.makeSnapshot();
|
|
@@ -816,21 +814,4 @@ describe('Lines and bars', () => {
|
|
|
816
814
|
|
|
817
815
|
cy.makeSnapshot();
|
|
818
816
|
});
|
|
819
|
-
|
|
820
|
-
it('calls the secondary function when a metric is clicked in the legend', () => {
|
|
821
|
-
const secondaryClick = cy.stub().as('secondaryClick');
|
|
822
|
-
initialize({
|
|
823
|
-
data: dataPingServiceLines,
|
|
824
|
-
legend: {
|
|
825
|
-
mode: 'grid',
|
|
826
|
-
placement: 'bottom',
|
|
827
|
-
secondaryClick
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
|
|
831
|
-
checkGraphWidth();
|
|
832
|
-
|
|
833
|
-
cy.contains('Packet Loss').rightclick();
|
|
834
|
-
cy.get('@secondaryClick').should('have.been.called');
|
|
835
|
-
});
|
|
836
817
|
});
|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react';
|
|
4
4
|
|
|
5
|
-
import { Button
|
|
5
|
+
import { Button } from '@mui/material';
|
|
6
6
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
7
7
|
import Switch from '@mui/material/Switch';
|
|
8
8
|
import Tooltip from '@mui/material/Tooltip';
|
|
@@ -758,36 +758,3 @@ export const linesAndBarsMinMaxForUnit: Story = {
|
|
|
758
758
|
/>
|
|
759
759
|
)
|
|
760
760
|
};
|
|
761
|
-
|
|
762
|
-
const LegendSecondaryClick = (args) => {
|
|
763
|
-
const [anchor, setAnchor] = useState<EventTarget | null>(null);
|
|
764
|
-
|
|
765
|
-
return (
|
|
766
|
-
<>
|
|
767
|
-
<WrapperChart
|
|
768
|
-
{...args}
|
|
769
|
-
legend={{
|
|
770
|
-
secondaryClick: ({ element }) => setAnchor(element)
|
|
771
|
-
}}
|
|
772
|
-
/>
|
|
773
|
-
<Menu
|
|
774
|
-
anchorEl={anchor}
|
|
775
|
-
open={Boolean(anchor)}
|
|
776
|
-
onClose={() => setAnchor(null)}
|
|
777
|
-
>
|
|
778
|
-
menu
|
|
779
|
-
</Menu>
|
|
780
|
-
</>
|
|
781
|
-
);
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
export const withLegendSecondaryClick: Story = {
|
|
785
|
-
argTypes,
|
|
786
|
-
args: argumentsData,
|
|
787
|
-
render: (args) => (
|
|
788
|
-
<LegendSecondaryClick
|
|
789
|
-
{...args}
|
|
790
|
-
data={dataPingService as unknown as LineChartData}
|
|
791
|
-
/>
|
|
792
|
-
)
|
|
793
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type MutableRefObject,
|
|
3
|
+
ReactElement,
|
|
3
4
|
useEffect,
|
|
4
5
|
useMemo,
|
|
5
6
|
useRef,
|
|
@@ -116,7 +117,7 @@ const Chart = ({
|
|
|
116
117
|
min,
|
|
117
118
|
max,
|
|
118
119
|
boundariesUnit
|
|
119
|
-
}: Props):
|
|
120
|
+
}: Props): ReactElement => {
|
|
120
121
|
const { classes } = useChartStyles();
|
|
121
122
|
|
|
122
123
|
const { title, timeSeries, baseAxis, lines } = graphData;
|
|
@@ -197,7 +198,8 @@ const Chart = ({
|
|
|
197
198
|
valueGraphHeight: graphHeight - margin.bottom,
|
|
198
199
|
min,
|
|
199
200
|
max,
|
|
200
|
-
boundariesUnit
|
|
201
|
+
boundariesUnit,
|
|
202
|
+
isFilled: lineStyle?.showArea
|
|
201
203
|
}),
|
|
202
204
|
[
|
|
203
205
|
linesGraph,
|
|
@@ -277,8 +279,7 @@ const Chart = ({
|
|
|
277
279
|
legendHeight: legend?.height,
|
|
278
280
|
mode: legend?.mode,
|
|
279
281
|
placement: legend?.placement,
|
|
280
|
-
renderExtraComponent: legend?.renderExtraComponent
|
|
281
|
-
secondaryClick: legend?.secondaryClick
|
|
282
|
+
renderExtraComponent: legend?.renderExtraComponent
|
|
282
283
|
}}
|
|
283
284
|
legendRef={legendRef}
|
|
284
285
|
limitLegend={limitLegend}
|
|
@@ -395,4 +396,4 @@ const Chart = ({
|
|
|
395
396
|
);
|
|
396
397
|
};
|
|
397
398
|
|
|
398
|
-
export default Chart;
|
|
399
|
+
export default Chart;
|
|
@@ -26,11 +26,6 @@ interface Props extends Pick<LegendModel, 'placement' | 'mode'> {
|
|
|
26
26
|
setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
|
|
27
27
|
shouldDisplayLegendInCompactMode: boolean;
|
|
28
28
|
toggable?: boolean;
|
|
29
|
-
secondaryClick?: (props: {
|
|
30
|
-
element: EventTarget | null;
|
|
31
|
-
metricId: number | string;
|
|
32
|
-
position: [number, number];
|
|
33
|
-
}) => void;
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
const MainLegend = ({
|
|
@@ -43,8 +38,7 @@ const MainLegend = ({
|
|
|
43
38
|
shouldDisplayLegendInCompactMode,
|
|
44
39
|
placement,
|
|
45
40
|
height,
|
|
46
|
-
mode
|
|
47
|
-
secondaryClick
|
|
41
|
+
mode
|
|
48
42
|
}: Props): JSX.Element => {
|
|
49
43
|
const { classes, cx } = useStyles({
|
|
50
44
|
limitLegendRows: Boolean(limitLegend),
|
|
@@ -71,24 +65,7 @@ const MainLegend = ({
|
|
|
71
65
|
value
|
|
72
66
|
}) || 'N/A';
|
|
73
67
|
|
|
74
|
-
const
|
|
75
|
-
(metricId: number) =>
|
|
76
|
-
(event: MouseEvent): void => {
|
|
77
|
-
if (!secondaryClick) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
secondaryClick({
|
|
82
|
-
element: event.target,
|
|
83
|
-
metricId,
|
|
84
|
-
position: [event.pageX, event.pageY]
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const selectMetric = ({
|
|
89
|
-
event,
|
|
90
|
-
metric_id
|
|
91
|
-
}: { event: MouseEvent; metric_id: number }): void => {
|
|
68
|
+
const selectMetric = ({ event, metric_id }): void => {
|
|
92
69
|
if (!toggable) {
|
|
93
70
|
return;
|
|
94
71
|
}
|
|
@@ -150,7 +127,6 @@ const MainLegend = ({
|
|
|
150
127
|
onClick={(event): void => selectMetric({ event, metric_id })}
|
|
151
128
|
onMouseEnter={(): void => highlightLine(metric_id)}
|
|
152
129
|
onMouseLeave={(): void => clearHighlight()}
|
|
153
|
-
onContextMenu={contextMenuClick(metric_id)}
|
|
154
130
|
>
|
|
155
131
|
<LegendHeader
|
|
156
132
|
color={markerColor}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { memo, type RefCallback, useEffect } from "react";
|
|
3
|
+
import "dayjs/locale/en";
|
|
4
|
+
import "dayjs/locale/es";
|
|
5
|
+
import "dayjs/locale/fr";
|
|
6
|
+
import "dayjs/locale/pt";
|
|
2
7
|
|
|
3
|
-
import
|
|
4
|
-
import 'dayjs/locale/en';
|
|
5
|
-
import 'dayjs/locale/es';
|
|
6
|
-
import 'dayjs/locale/fr';
|
|
7
|
-
import 'dayjs/locale/pt';
|
|
8
|
-
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
9
|
-
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
10
|
-
import utcPlugin from 'dayjs/plugin/utc';
|
|
11
|
-
import Loading from '../../LoadingSkeleton';
|
|
12
|
-
import type { LineChartData, Thresholds } from '../common/models';
|
|
8
|
+
import { NoData } from "@centreon/ui";
|
|
13
9
|
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
10
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
11
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
12
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
13
|
+
import useResizeObserver from "use-resize-observer";
|
|
14
|
+
import Loading from "../../LoadingSkeleton";
|
|
15
|
+
import type { LineChartData, Thresholds } from "../common/models";
|
|
16
|
+
import Chart from "./Chart";
|
|
17
|
+
import { useChartStyles } from "./Chart.styles";
|
|
18
|
+
import LoadingSkeleton from "./LoadingSkeleton";
|
|
19
|
+
import type { GlobalAreaLines, LineChartProps } from "./models";
|
|
20
|
+
import useChartData from "./useChartData";
|
|
20
21
|
|
|
21
22
|
dayjs.extend(localizedFormat);
|
|
22
23
|
dayjs.extend(utcPlugin);
|
|
@@ -52,14 +53,14 @@ const WrapperChart = ({
|
|
|
52
53
|
loading,
|
|
53
54
|
timeShiftZones,
|
|
54
55
|
tooltip = {
|
|
55
|
-
mode:
|
|
56
|
-
sortOrder:
|
|
56
|
+
mode: "all",
|
|
57
|
+
sortOrder: "name",
|
|
57
58
|
},
|
|
58
59
|
annotationEvent,
|
|
59
60
|
legend = {
|
|
60
61
|
display: true,
|
|
61
|
-
mode:
|
|
62
|
-
placement:
|
|
62
|
+
mode: "grid",
|
|
63
|
+
placement: "bottom",
|
|
63
64
|
},
|
|
64
65
|
header,
|
|
65
66
|
lineStyle,
|
|
@@ -76,12 +77,11 @@ const WrapperChart = ({
|
|
|
76
77
|
...rest
|
|
77
78
|
}: Props): JSX.Element | null => {
|
|
78
79
|
const { classes, cx } = useChartStyles();
|
|
79
|
-
|
|
80
80
|
const { adjustedData } = useChartData({ data, end, start });
|
|
81
81
|
const {
|
|
82
82
|
ref,
|
|
83
83
|
width: responsiveWidth,
|
|
84
|
-
height: responsiveHeight
|
|
84
|
+
height: responsiveHeight,
|
|
85
85
|
} = useResizeObserver();
|
|
86
86
|
|
|
87
87
|
useEffect(() => {
|
|
@@ -97,13 +97,17 @@ const WrapperChart = ({
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
if (!adjustedData) {
|
|
101
|
+
return <NoData />;
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
return (
|
|
101
105
|
<div
|
|
102
106
|
ref={ref}
|
|
103
107
|
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
104
108
|
>
|
|
105
109
|
{!responsiveHeight ? (
|
|
106
|
-
<Loading height={height ||
|
|
110
|
+
<Loading height={height || "100%"} width={width} />
|
|
107
111
|
) : (
|
|
108
112
|
<Chart
|
|
109
113
|
annotationEvent={annotationEvent}
|
|
@@ -175,11 +175,6 @@ export interface LegendModel {
|
|
|
175
175
|
mode: 'grid' | 'list';
|
|
176
176
|
placement: 'bottom' | 'left' | 'right';
|
|
177
177
|
renderExtraComponent?: ReactNode;
|
|
178
|
-
secondaryClick?: (props: {
|
|
179
|
-
element: EventTarget | null;
|
|
180
|
-
metricId: number | string;
|
|
181
|
-
position: [number, number];
|
|
182
|
-
}) => void;
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
export interface GetDate {
|
|
@@ -198,4 +193,4 @@ export interface GraphTooltipData {
|
|
|
198
193
|
unit: string;
|
|
199
194
|
value: number;
|
|
200
195
|
}>;
|
|
201
|
-
}
|
|
196
|
+
}
|
|
@@ -19,10 +19,7 @@ interface Props {
|
|
|
19
19
|
header?: LineChartHeader;
|
|
20
20
|
height: number | null;
|
|
21
21
|
isHorizontal?: boolean;
|
|
22
|
-
legend: Pick<
|
|
23
|
-
LegendModel,
|
|
24
|
-
'renderExtraComponent' | 'placement' | 'mode' | 'secondaryClick'
|
|
25
|
-
> & {
|
|
22
|
+
legend: Pick<LegendModel, 'renderExtraComponent' | 'placement' | 'mode'> & {
|
|
26
23
|
displayLegend: boolean;
|
|
27
24
|
legendHeight?: number;
|
|
28
25
|
};
|
|
@@ -104,7 +101,6 @@ const BaseChart = ({
|
|
|
104
101
|
shouldDisplayLegendInCompactMode={
|
|
105
102
|
shouldDisplayLegendInCompactMode
|
|
106
103
|
}
|
|
107
|
-
secondaryClick={legend?.secondaryClick}
|
|
108
104
|
/>
|
|
109
105
|
</div>
|
|
110
106
|
)}
|
|
@@ -126,7 +122,6 @@ const BaseChart = ({
|
|
|
126
122
|
renderExtraComponent={legend.renderExtraComponent}
|
|
127
123
|
setLinesGraph={setLines}
|
|
128
124
|
shouldDisplayLegendInCompactMode={shouldDisplayLegendInCompactMode}
|
|
129
|
-
secondaryClick={legend?.secondaryClick}
|
|
130
125
|
/>
|
|
131
126
|
</div>
|
|
132
127
|
)}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import Typography from '@mui/material/Typography';
|
|
2
4
|
|
|
3
5
|
import { useMemoComponent } from '@centreon/ui';
|
|
@@ -10,7 +12,7 @@ interface Props {
|
|
|
10
12
|
title: string;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
const Header = ({ title, header }: Props):
|
|
15
|
+
const Header = ({ title, header }: Props): ReactElement => {
|
|
14
16
|
const { classes } = ussHeaderChartStyles();
|
|
15
17
|
|
|
16
18
|
const displayTitle = header?.displayTitle ?? true;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Typography } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
|
|
5
|
+
import { labelNoDataForThisPeriod } from '../../Chart/translatedLabels';
|
|
6
|
+
|
|
7
|
+
const NoData = () => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
return (
|
|
10
|
+
<div className={'flex items-center justify-center h-full'}>
|
|
11
|
+
<Typography align="center" variant="body1">
|
|
12
|
+
{t(labelNoDataForThisPeriod)}
|
|
13
|
+
</Typography>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default NoData;
|
|
@@ -362,10 +362,10 @@ describe('timeSeries', () => {
|
|
|
362
362
|
describe(formatMetricValue, () => {
|
|
363
363
|
const cases: Array<TestCase> = [
|
|
364
364
|
[218857269, '', 1000, '218.86m'],
|
|
365
|
-
[218857269, '', 1024, '208.72
|
|
365
|
+
[218857269, '', 1024, '208.72 Mi'],
|
|
366
366
|
[0.12232323445, '', 1000, '0.12'],
|
|
367
|
-
[1024, 'B', 1000, '1
|
|
368
|
-
[1024, 'B', 1024, '1
|
|
367
|
+
[1024, 'B', 1000, '1 KiB'],
|
|
368
|
+
[1024, 'B', 1024, '1 KiB'],
|
|
369
369
|
[null, 'B', 1024, null]
|
|
370
370
|
];
|
|
371
371
|
|
|
@@ -553,7 +553,7 @@ describe('Format value with unit', () => {
|
|
|
553
553
|
return '324.23m';
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
return `309.21
|
|
556
|
+
return `309.21 Mi${unit}`;
|
|
557
557
|
};
|
|
558
558
|
|
|
559
559
|
const humanReadableTestCases = units.map((unit) => {
|