@centreon/ui 23.10.18-MON-17793-create-graph-component-centreon-ui.20 → 23.10.18-MON-17793-create-graph-component-centreon-ui.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Graph/BasicComponents/Lines/index.tsx +10 -2
- package/src/Graph/{icons → Icons}/Downtime.tsx +1 -1
- package/src/Graph/InteractiveComponents/AnchorPoint/GuidingLines.tsx +39 -0
- package/src/Graph/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +4 -12
- package/src/Graph/InteractiveComponents/AnchorPoint/index.tsx +9 -37
- package/src/Graph/InteractiveComponents/AnchorPoint/models.ts +14 -0
- package/src/Graph/InteractiveComponents/Annotations/Area/Downtime.tsx +1 -1
- package/src/Graph/index.stories.tsx +5 -8
- package/src/api/useRequest/index.ts +9 -6
- /package/src/{Graph → @assets}/icons/downtime.icon.svg +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.18-MON-17793-create-graph-component-centreon-ui.
|
|
3
|
+
"version": "23.10.18-MON-17793-create-graph-component-centreon-ui.22",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -3,6 +3,7 @@ import { MutableRefObject } from 'react';
|
|
|
3
3
|
import { ScaleLinear } from 'd3-scale';
|
|
4
4
|
import { isNil } from 'ramda';
|
|
5
5
|
|
|
6
|
+
import GuidingLines from '../../InteractiveComponents/AnchorPoint/GuidingLines';
|
|
6
7
|
import RegularAnchorPoint from '../../InteractiveComponents/AnchorPoint/RegularAnchorPoint';
|
|
7
8
|
import { displayArea } from '../../helpers/index';
|
|
8
9
|
import { GlobalAreaLines } from '../../models';
|
|
@@ -107,6 +108,15 @@ const Lines = ({
|
|
|
107
108
|
/>
|
|
108
109
|
)}
|
|
109
110
|
|
|
111
|
+
{displayAnchor && (
|
|
112
|
+
<GuidingLines
|
|
113
|
+
graphHeight={height}
|
|
114
|
+
graphWidth={width}
|
|
115
|
+
timeSeries={timeSeries}
|
|
116
|
+
xScale={xScale}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
|
|
110
120
|
{displayAreaRegularLines
|
|
111
121
|
? regularLines.map(
|
|
112
122
|
({
|
|
@@ -136,8 +146,6 @@ const Lines = ({
|
|
|
136
146
|
{displayAnchor && (
|
|
137
147
|
<RegularAnchorPoint
|
|
138
148
|
areaColor={areaColor}
|
|
139
|
-
graphHeight={height}
|
|
140
|
-
graphWidth={width}
|
|
141
149
|
lineColor={lineColor}
|
|
142
150
|
metric={metric}
|
|
143
151
|
timeSeries={timeSeries}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
2
2
|
|
|
3
|
-
import { ReactComponent as IconDowntime } from '
|
|
3
|
+
import { ReactComponent as IconDowntime } from '../../@assets/icons/downtime.icon.svg';
|
|
4
4
|
|
|
5
5
|
const Downtime = (props: SvgIconProps): JSX.Element => (
|
|
6
6
|
<SvgIcon component={IconDowntime} {...props} />
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Shape } from '@visx/visx';
|
|
2
|
+
|
|
3
|
+
import { grey } from '@mui/material/colors';
|
|
4
|
+
|
|
5
|
+
import useTickGraph from './useTickGraph';
|
|
6
|
+
import { GuidingLines } from './models';
|
|
7
|
+
|
|
8
|
+
const GuidingLines = ({
|
|
9
|
+
timeSeries,
|
|
10
|
+
xScale,
|
|
11
|
+
graphHeight,
|
|
12
|
+
graphWidth
|
|
13
|
+
}: GuidingLines): JSX.Element => {
|
|
14
|
+
const { positionX, positionY } = useTickGraph({
|
|
15
|
+
timeSeries,
|
|
16
|
+
xScale
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<Shape.Line
|
|
22
|
+
from={{ x: positionX, y: 0 }}
|
|
23
|
+
pointerEvents="none"
|
|
24
|
+
stroke={grey[400]}
|
|
25
|
+
strokeWidth={1}
|
|
26
|
+
to={{ x: positionX, y: graphHeight }}
|
|
27
|
+
/>
|
|
28
|
+
<Shape.Line
|
|
29
|
+
from={{ x: 0, y: positionY }}
|
|
30
|
+
pointerEvents="none"
|
|
31
|
+
stroke={grey[400]}
|
|
32
|
+
strokeWidth={1}
|
|
33
|
+
to={{ x: graphWidth, y: positionY }}
|
|
34
|
+
/>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default GuidingLines;
|
|
@@ -5,19 +5,15 @@ import { bisectDate, getDates } from '../../timeSeries';
|
|
|
5
5
|
import { TimeValue } from '../../timeSeries/models';
|
|
6
6
|
|
|
7
7
|
import useTickGraph from './useTickGraph';
|
|
8
|
+
import { GetYAnchorPoint } from './models';
|
|
8
9
|
|
|
9
10
|
import AnchorPoint from '.';
|
|
10
11
|
|
|
11
12
|
interface Props {
|
|
12
13
|
areaColor: string;
|
|
13
|
-
graphHeight: number;
|
|
14
|
-
graphWidth: number;
|
|
15
14
|
lineColor: string;
|
|
16
15
|
metric: string;
|
|
17
|
-
positionX?: number;
|
|
18
|
-
positionY?: number;
|
|
19
16
|
timeSeries: Array<TimeValue>;
|
|
20
|
-
timeTick?: Date;
|
|
21
17
|
transparency: number;
|
|
22
18
|
xScale: ScaleTime<number, number>;
|
|
23
19
|
yScale: ScaleLinear<number, number>;
|
|
@@ -28,7 +24,7 @@ const getYAnchorPoint = ({
|
|
|
28
24
|
timeSeries,
|
|
29
25
|
yScale,
|
|
30
26
|
metric
|
|
31
|
-
}:
|
|
27
|
+
}: GetYAnchorPoint): number => {
|
|
32
28
|
const index = bisectDate(getDates(timeSeries), timeTick);
|
|
33
29
|
const timeValue = timeSeries[index];
|
|
34
30
|
|
|
@@ -42,10 +38,9 @@ const RegularAnchorPoint = ({
|
|
|
42
38
|
timeSeries,
|
|
43
39
|
areaColor,
|
|
44
40
|
transparency,
|
|
45
|
-
lineColor
|
|
46
|
-
...rest
|
|
41
|
+
lineColor
|
|
47
42
|
}: Props): JSX.Element | null => {
|
|
48
|
-
const { timeTick
|
|
43
|
+
const { timeTick } = useTickGraph({
|
|
49
44
|
timeSeries,
|
|
50
45
|
xScale
|
|
51
46
|
});
|
|
@@ -71,12 +66,9 @@ const RegularAnchorPoint = ({
|
|
|
71
66
|
<AnchorPoint
|
|
72
67
|
areaColor={areaColor}
|
|
73
68
|
lineColor={lineColor}
|
|
74
|
-
positionX={positionX}
|
|
75
|
-
positionY={positionY}
|
|
76
69
|
transparency={transparency}
|
|
77
70
|
x={xAnchorPoint}
|
|
78
71
|
y={yAnchorPoint}
|
|
79
|
-
{...rest}
|
|
80
72
|
/>
|
|
81
73
|
);
|
|
82
74
|
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { Shape } from '@visx/visx';
|
|
2
|
-
|
|
3
|
-
import { grey } from '@mui/material/colors';
|
|
4
|
-
|
|
5
1
|
interface Props {
|
|
6
2
|
areaColor: string;
|
|
7
|
-
graphHeight: number;
|
|
8
|
-
graphWidth: number;
|
|
9
3
|
lineColor: string;
|
|
10
|
-
positionX?: number;
|
|
11
|
-
positionY?: number;
|
|
12
4
|
transparency: number;
|
|
13
5
|
x: number;
|
|
14
6
|
y: number;
|
|
@@ -19,37 +11,17 @@ const Point = ({
|
|
|
19
11
|
lineColor,
|
|
20
12
|
transparency,
|
|
21
13
|
x,
|
|
22
|
-
y
|
|
23
|
-
...rest
|
|
14
|
+
y
|
|
24
15
|
}: Props): JSX.Element => {
|
|
25
|
-
const { positionX, positionY, graphHeight, graphWidth } = rest;
|
|
26
|
-
|
|
27
16
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/>
|
|
37
|
-
|
|
38
|
-
<Shape.Line
|
|
39
|
-
from={{ x: positionX, y: 0 }}
|
|
40
|
-
pointerEvents="none"
|
|
41
|
-
stroke={grey[400]}
|
|
42
|
-
strokeWidth={1}
|
|
43
|
-
to={{ x: positionX, y: graphHeight }}
|
|
44
|
-
/>
|
|
45
|
-
<Shape.Line
|
|
46
|
-
from={{ x: 0, y: positionY }}
|
|
47
|
-
pointerEvents="none"
|
|
48
|
-
stroke={grey[400]}
|
|
49
|
-
strokeWidth={1}
|
|
50
|
-
to={{ x: graphWidth, y: positionY }}
|
|
51
|
-
/>
|
|
52
|
-
</g>
|
|
17
|
+
<circle
|
|
18
|
+
cx={x}
|
|
19
|
+
cy={y}
|
|
20
|
+
fill={areaColor}
|
|
21
|
+
fillOpacity={(1 - transparency * 0.01).toString()}
|
|
22
|
+
r={3}
|
|
23
|
+
stroke={lineColor}
|
|
24
|
+
/>
|
|
53
25
|
);
|
|
54
26
|
};
|
|
55
27
|
|
|
@@ -23,3 +23,17 @@ export interface StackData {
|
|
|
23
23
|
data: TimeValue;
|
|
24
24
|
}
|
|
25
25
|
export type StackValue = [number, number, StackData];
|
|
26
|
+
|
|
27
|
+
export interface GuidingLines {
|
|
28
|
+
graphHeight: number;
|
|
29
|
+
graphWidth: number;
|
|
30
|
+
timeSeries: Array<TimeValue>;
|
|
31
|
+
xScale: ScaleLinear<number, number>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GetYAnchorPoint {
|
|
35
|
+
metric: string;
|
|
36
|
+
timeSeries: Array<TimeValue>;
|
|
37
|
+
timeTick: Date;
|
|
38
|
+
yScale: ScaleLinear<number, number>;
|
|
39
|
+
}
|
|
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
2
2
|
|
|
3
3
|
import { useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import IconDowntime from '../../../
|
|
5
|
+
import IconDowntime from '../../../Icons/Downtime';
|
|
6
6
|
import { labelDowntime } from '../../../translatedLabels';
|
|
7
7
|
import EventAnnotations from '../EventAnnotations';
|
|
8
8
|
import { Args } from '../models';
|
|
@@ -50,7 +50,7 @@ interface Random {
|
|
|
50
50
|
|
|
51
51
|
const Threshold = (args): JSX.Element => {
|
|
52
52
|
const [currentFactorMultiplication, setCurrentFactorMultiplication] =
|
|
53
|
-
useState<number>();
|
|
53
|
+
useState<number>(2.5);
|
|
54
54
|
const [countedCircles, setCountedCircles] = useState<number>();
|
|
55
55
|
|
|
56
56
|
const getRandomInt = ({ min, max }: Random): number => {
|
|
@@ -122,7 +122,7 @@ const GraphAndCLS = (args): JSX.Element => {
|
|
|
122
122
|
setTimeout(() => {
|
|
123
123
|
setLoading(false);
|
|
124
124
|
setData(dataLastDay as unknown as GraphData);
|
|
125
|
-
},
|
|
125
|
+
}, 100000);
|
|
126
126
|
}, []);
|
|
127
127
|
|
|
128
128
|
return (
|
|
@@ -257,7 +257,7 @@ const GraphAndTimePeriod = (args): JSX.Element => {
|
|
|
257
257
|
const GraphAndExclusionPeriod = (args): JSX.Element => {
|
|
258
258
|
const [dataExclusionPeriods, setDataExclusionPeriods] = useState<
|
|
259
259
|
Array<GraphData>
|
|
260
|
-
>([]);
|
|
260
|
+
>([exclusionPeriodFirstPeriod as unknown as GraphData]);
|
|
261
261
|
|
|
262
262
|
const handleClick = (data): void => {
|
|
263
263
|
setDataExclusionPeriods([...dataExclusionPeriods, data]);
|
|
@@ -270,14 +270,11 @@ const GraphAndExclusionPeriod = (args): JSX.Element => {
|
|
|
270
270
|
aria-label="outlined primary button group"
|
|
271
271
|
variant="contained"
|
|
272
272
|
>
|
|
273
|
-
<Button onClick={(): void => handleClick(exclusionPeriodFirstPeriod)}>
|
|
274
|
-
first
|
|
275
|
-
</Button>
|
|
276
273
|
<Button onClick={(): void => handleClick(exclusionPeriodSecondPeriod)}>
|
|
277
|
-
|
|
274
|
+
first
|
|
278
275
|
</Button>
|
|
279
276
|
<Button onClick={(): void => handleClick(exclusionPeriodThirdPeriod)}>
|
|
280
|
-
|
|
277
|
+
second
|
|
281
278
|
</Button>
|
|
282
279
|
</ButtonGroup>
|
|
283
280
|
<WrapperGraph
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import 'ulog';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import { pathOr, defaultTo, path, includes } from 'ramda';
|
|
5
|
+
import { pathOr, defaultTo, path, includes, or } from 'ramda';
|
|
6
6
|
import anylogger from 'anylogger';
|
|
7
7
|
import { JsonDecoder } from 'ts.data.json';
|
|
8
8
|
|
|
@@ -42,12 +42,15 @@ const useRequest = <TResult>({
|
|
|
42
42
|
|
|
43
43
|
const showRequestErrorMessage = (error): void => {
|
|
44
44
|
log.error(error);
|
|
45
|
-
const message = defaultTo(
|
|
46
|
-
pathOr(defaultFailureMessage, ['response', 'data', 'message']),
|
|
47
|
-
getErrorMessage
|
|
48
|
-
)(error);
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
const message = or(
|
|
47
|
+
pathOr(undefined, ['response', 'data', 'message'], error),
|
|
48
|
+
pathOr(defaultFailureMessage, ['response', 'data'], error)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const errorMessage = defaultTo(message, getErrorMessage?.(error));
|
|
52
|
+
|
|
53
|
+
showErrorMessage(errorMessage as string);
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
const sendRequest = (params): Promise<TResult> => {
|
|
File without changes
|