@centreon/ui 23.10.18-MON-17793-create-graph-component-centreon-ui.0 → 23.10.18

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.
Files changed (58) hide show
  1. package/package.json +1 -2
  2. package/src/Graph/Axes/UnitLabel.tsx +0 -20
  3. package/src/Graph/Axes/index.tsx +0 -99
  4. package/src/Graph/Axes/models.ts +0 -26
  5. package/src/Graph/Axes/useAxisY.ts +0 -100
  6. package/src/Graph/Graph.tsx +0 -231
  7. package/src/Graph/Grids/index.tsx +0 -20
  8. package/src/Graph/Header/index.tsx +0 -34
  9. package/src/Graph/InteractionWithGraph/AnchorPoint/RegularAnchorPoint.tsx +0 -88
  10. package/src/Graph/InteractionWithGraph/AnchorPoint/StackedAnchorPoint.tsx +0 -97
  11. package/src/Graph/InteractionWithGraph/AnchorPoint/index.tsx +0 -56
  12. package/src/Graph/InteractionWithGraph/AnchorPoint/models.ts +0 -25
  13. package/src/Graph/InteractionWithGraph/AnchorPoint/useAnchorPoint.ts +0 -109
  14. package/src/Graph/InteractionWithGraph/Bar.tsx +0 -21
  15. package/src/Graph/InteractionWithGraph/ZoomPreview/index.tsx +0 -38
  16. package/src/Graph/InteractionWithGraph/ZoomPreview/models.ts +0 -17
  17. package/src/Graph/InteractionWithGraph/ZoomPreview/useZoomPreview.ts +0 -101
  18. package/src/Graph/InteractionWithGraph/ZoomPreview/zoomPreviewAtoms.ts +0 -5
  19. package/src/Graph/InteractionWithGraph/index.tsx +0 -93
  20. package/src/Graph/InteractionWithGraph/interactionWithGraphAtoms.ts +0 -7
  21. package/src/Graph/InteractionWithGraph/mouseTimeValueAtoms.ts +0 -49
  22. package/src/Graph/Lines/RegularLines/index.tsx +0 -99
  23. package/src/Graph/Lines/RegularLines/useRegularLines.ts +0 -15
  24. package/src/Graph/Lines/StackedLines/index.tsx +0 -74
  25. package/src/Graph/Lines/StackedLines/useStackedLines.ts +0 -39
  26. package/src/Graph/Lines/index.tsx +0 -153
  27. package/src/Graph/Lines/models.ts +0 -32
  28. package/src/Graph/LoadingProgress.tsx +0 -46
  29. package/src/Graph/common/index.ts +0 -33
  30. package/src/Graph/data.json +0 -1338
  31. package/src/Graph/helpers/doc.ts +0 -323
  32. package/src/Graph/helpers/index.ts +0 -15
  33. package/src/Graph/index.stories.tsx +0 -30
  34. package/src/Graph/index.tsx +0 -66
  35. package/src/Graph/models.ts +0 -68
  36. package/src/Graph/timeSeries/index.test.ts +0 -484
  37. package/src/Graph/timeSeries/index.ts +0 -512
  38. package/src/Graph/timeSeries/models.ts +0 -119
  39. package/src/Graph/useGraphData.ts +0 -117
  40. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +0 -57
  41. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +0 -78
  42. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/ErrorText.tsx +0 -14
  43. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +0 -169
  44. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/index.tsx +0 -76
  45. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -61
  46. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +0 -91
  47. package/src/TimePeriods/CustomTimePeriod/index.tsx +0 -63
  48. package/src/TimePeriods/DateTimePickerInput.tsx +0 -99
  49. package/src/TimePeriods/SelectedTimePeriod.tsx +0 -99
  50. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +0 -497
  51. package/src/TimePeriods/helpers/index.ts +0 -25
  52. package/src/TimePeriods/index.stories.tsx +0 -74
  53. package/src/TimePeriods/index.tsx +0 -77
  54. package/src/TimePeriods/models.ts +0 -103
  55. package/src/TimePeriods/timePeriods.styles.ts +0 -20
  56. package/src/TimePeriods/timePeriodsAtoms.ts +0 -113
  57. package/src/TimePeriods/useDateTimePickerAdapter.ts +0 -329
  58. package/src/TimePeriods/useSortTimePeriods.ts +0 -24
@@ -1,323 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { equals, isEmpty, isNil } from 'ramda';
3
-
4
- interface InitialValue {
5
- section: string;
6
- sectionDescription?: string;
7
- type: string;
8
- }
9
-
10
- const getInitialValue = ({ section, type }: InitialValue): string => `
11
- <details>
12
- <summary>${section} ${getCustomText(type)}</summary>
13
- >`;
14
-
15
- interface Prop {
16
- description: string;
17
- type: string;
18
- }
19
-
20
- interface Section {
21
- description?: string;
22
- name: string;
23
- note?: string;
24
- props: Array<Record<string, Prop>>;
25
- type: string;
26
- }
27
-
28
- interface Description {
29
- sections: Array<Section>;
30
- }
31
-
32
- export const getCustomText = (text: string): string =>
33
- `<span style="color:#1EA7FD;fontSize:12px">(${text})</span>`;
34
-
35
- export const getBodyDescription = ({ key, description, type }): string =>
36
- `<strong>${key}</strong> : ${description} ${getCustomText(type)} <br>`;
37
-
38
- export const getDescription = ({ sections }: Description): string => {
39
- const descriptionBody = sections.map((item) => {
40
- const { name, props, type: typeSection } = item;
41
-
42
- if (isNil(props) || isEmpty(props)) {
43
- return `${getInitialValue({
44
- section: name,
45
- type: typeSection
46
- })}<br></details>`;
47
- }
48
-
49
- const formattedProps = props.reduce((accumulator, currentValue, index) => {
50
- const key = Object.keys(currentValue)[0];
51
- const { description, type } = currentValue[key];
52
- const body = `${accumulator} ${getBodyDescription({
53
- description,
54
- key,
55
- type
56
- })}`;
57
-
58
- if (!equals(index, props.length - 1)) {
59
- return body;
60
- }
61
-
62
- return `${body}</details>`;
63
- }, getInitialValue({ section: name, type: typeSection }));
64
-
65
- return formattedProps as string;
66
- });
67
-
68
- const result = descriptionBody.reduce(
69
- (accumulate, currentValue) => `${accumulate}${currentValue}`
70
- );
71
-
72
- return result;
73
- };
74
-
75
- export const propsAxisX = [
76
- {
77
- xAxisTickFormat: {
78
- description:
79
- 'string of the formatted date for the tick text, reference to the format of dayjs',
80
- type: 'string'
81
- }
82
- }
83
- ];
84
-
85
- export const propsAxisY = [
86
- { display: { description: 'display or not the axis', type: 'boolean' } },
87
- {
88
- displayUnit: {
89
- description: 'display or not the unit of the axis',
90
- type: 'boolean'
91
- }
92
- }
93
- ];
94
-
95
- const defaultBaseUrl =
96
- 'http://localhost:3000/centreon/api/latest/monitoring/hosts/151/services/1160/metrics/performance';
97
- const defaultStart = new Date(
98
- dayjs(Date.now()).subtract(24, 'hour').toDate().getTime()
99
- ).toISOString();
100
-
101
- const defaultEnd = new Date(Date.now()).toISOString();
102
-
103
- export const argTypes = {
104
- anchorPoint: {
105
- control: 'object',
106
- description: getDescription({
107
- sections: [
108
- {
109
- name: 'areaRegularLinesAnchorPoint',
110
- props: [
111
- {
112
- display: {
113
- description: 'display or not the anchor point',
114
- type: 'boolean'
115
- }
116
- }
117
- ],
118
- type: 'object'
119
- },
120
- {
121
- name: 'areaStackedLinesAnchorPoint',
122
- props: [
123
- {
124
- display: {
125
- description: 'display or not the anchor point',
126
- type: 'boolean'
127
- }
128
- }
129
- ],
130
- type: 'object'
131
- }
132
- ]
133
- }),
134
- table: {
135
- category: 'Graph interaction',
136
- type: {
137
- detail:
138
- 'displays the timing, circle, vertical and horizontal line for each point of the corresponding graph (line) according to the interaction of the mouse with the graph',
139
- summary: 'object'
140
- }
141
- }
142
- },
143
- axis: {
144
- axisX: {
145
- xAxisTickFormat: { control: 'text' }
146
- },
147
- axisYLeft: {
148
- display: { control: 'boolean' },
149
- displayUnit: { control: 'boolean' }
150
- },
151
- axisYRight: {
152
- displayUnit: { control: 'boolean' }
153
- },
154
- control: 'object',
155
- description: getDescription({
156
- sections: [
157
- {
158
- name: 'axisX',
159
- props: propsAxisX,
160
- type: 'object'
161
- },
162
- {
163
- name: 'axisYLeft',
164
- props: propsAxisY,
165
- type: 'object'
166
- },
167
- {
168
- name: 'axisYRight',
169
- props: propsAxisY,
170
- type: 'object'
171
- }
172
- ]
173
- }),
174
- table: {
175
- category: 'Graph component',
176
- type: { detail: 'control the axis of the graph', summary: 'object' }
177
- }
178
- },
179
- baseUrl: {
180
- control: {
181
- type: 'text'
182
- },
183
- description: 'base url to get graph data',
184
- name: 'baseUrl',
185
- table: {
186
- category: 'Graph data',
187
- defaultValue: {
188
- summary: defaultBaseUrl
189
- },
190
- type: { required: true, summary: 'string' }
191
- }
192
- },
193
- end: {
194
- control: 'text',
195
- description: 'the end of the interval of time to get graph data',
196
- table: {
197
- category: 'Graph data',
198
- type: {
199
- detail: 'the end of the interval',
200
- summary: 'ISOString (required*)'
201
- }
202
- }
203
- },
204
- height: {
205
- control: 'number',
206
- description: 'the height of the graph',
207
- table: {
208
- category: 'Sizes',
209
- type: { summary: 'number' }
210
- }
211
- },
212
- shapeLines: {
213
- control: 'object',
214
- description: getDescription({
215
- sections: [
216
- {
217
- name: 'areaRegularLines',
218
- props: [
219
- {
220
- display: {
221
- description: 'display or not the area regular lines',
222
- type: 'boolean'
223
- }
224
- }
225
- ],
226
- type: 'object'
227
- },
228
- {
229
- name: 'areaStackedLines',
230
- props: [
231
- {
232
- display: {
233
- description: 'display or not the area',
234
- type: 'boolean'
235
- }
236
- }
237
- ],
238
- type: 'object'
239
- }
240
- ]
241
- }),
242
- table: {
243
- category: 'Graph component',
244
- type: { detail: 'control the lines of the graph', summary: 'object' }
245
- }
246
- },
247
- start: {
248
- control: 'text',
249
- description: 'the beginning of the interval of time to get graph data',
250
- name: 'start',
251
- table: {
252
- category: 'Graph data',
253
- type: {
254
- detail: 'the beginning of the interval',
255
- summary: 'ISOString (required*)'
256
- }
257
- }
258
- },
259
- width: {
260
- control: 'number',
261
- description: 'the width of the graph',
262
- table: {
263
- category: 'Sizes',
264
- type: { summary: 'number' }
265
- }
266
- },
267
- zoomPreview: {
268
- control: 'object',
269
- description: getDescription({
270
- sections: [
271
- {
272
- name: '',
273
- props: [
274
- {
275
- display: {
276
- description: 'enable or not the zoomPreview',
277
- type: 'boolean'
278
- }
279
- }
280
- ],
281
- type: 'object'
282
- }
283
- ]
284
- }),
285
- table: {
286
- category: 'Graph interaction',
287
- type: {
288
- summary: 'apply zoom to a specific zoon'
289
- }
290
- }
291
- }
292
- };
293
-
294
- export const args = {
295
- anchorPoint: {
296
- areaRegularLinesAnchorPoint: {
297
- display: true
298
- },
299
- areaStackedLinesAnchorPoint: {
300
- display: true
301
- }
302
- },
303
- axis: {
304
- axisX: { xAxisTickFormat: 'LT' },
305
- axisYLeft: { displayUnit: true },
306
- axisYRight: { display: true, displayUnit: true }
307
- },
308
- baseUrl: defaultBaseUrl,
309
- end: defaultEnd,
310
- height: 500,
311
- shapeLines: {
312
- areaRegularLines: {
313
- display: true
314
- },
315
- areaStackedLines: {
316
- display: true
317
- }
318
- },
319
- start: defaultStart,
320
- zoomPreview: {
321
- display: true
322
- }
323
- };
@@ -1,15 +0,0 @@
1
- import { prop, propEq, reject, sortBy } from 'ramda';
2
-
3
- import { getLineData, getTimeSeries } from '../timeSeries';
4
- import { LinesData } from '../Lines/models';
5
- import { GraphData } from '../models';
6
-
7
- export const adjustGraphData = (graphData: GraphData): LinesData => {
8
- const lines = getLineData(graphData);
9
- const sortedLines = sortBy(prop('name'), lines);
10
- const displayedLines = reject(propEq('display', false), sortedLines);
11
-
12
- const timeSeries = getTimeSeries(graphData);
13
-
14
- return { lines: displayedLines, timeSeries };
15
- };
@@ -1,30 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
-
3
- import AwesomeTimePeriod from '../TimePeriods';
4
-
5
- import { argTypes, args as argumentsData } from './helpers/doc';
6
-
7
- import Graph from './index';
8
-
9
- const meta: Meta<typeof Graph> = {
10
- component: Graph,
11
- tags: ['autodocs']
12
- };
13
- export default meta;
14
-
15
- type Story = StoryObj<typeof Graph>;
16
-
17
- const Template: Story = {
18
- render: (args) => (
19
- <>
20
- <AwesomeTimePeriod />
21
- <Graph {...args} />
22
- </>
23
- )
24
- };
25
-
26
- export const Playground: Story = {
27
- ...Template,
28
- argTypes,
29
- args: argumentsData
30
- };
@@ -1,66 +0,0 @@
1
- import { Responsive } from '@visx/visx';
2
- import dayjs from 'dayjs';
3
- import 'dayjs/locale/en';
4
- import 'dayjs/locale/es';
5
- import 'dayjs/locale/fr';
6
- import 'dayjs/locale/pt';
7
- import localizedFormat from 'dayjs/plugin/localizedFormat';
8
- import timezonePlugin from 'dayjs/plugin/timezone';
9
- import utcPlugin from 'dayjs/plugin/utc';
10
-
11
- import Graph from './Graph';
12
- import { GlobalAreaLines, GraphProps } from './models';
13
- import useGraphData from './useGraphData';
14
-
15
- dayjs.extend(localizedFormat);
16
- dayjs.extend(utcPlugin);
17
- dayjs.extend(timezonePlugin);
18
-
19
- interface Props extends GraphProps {
20
- baseUrl: string;
21
- end: string;
22
- shapeLines: GlobalAreaLines;
23
- start: string;
24
- }
25
-
26
- const WrapperGraph = ({
27
- baseUrl,
28
- end,
29
- start,
30
- height,
31
- width,
32
- shapeLines,
33
- axis,
34
- anchorPoint,
35
- zoomPreview
36
- }: Props): JSX.Element | null => {
37
- const { data, loading } = useGraphData({ baseUrl, end, start });
38
-
39
- if (!data) {
40
- return null;
41
- }
42
-
43
- return (
44
- <div>
45
- <Responsive.ParentSize>
46
- {({
47
- height: responsiveHeight,
48
- width: responsiveWidth
49
- }): JSX.Element => (
50
- <Graph
51
- anchorPoint={anchorPoint}
52
- axis={axis}
53
- graphData={data}
54
- height={height ?? responsiveHeight}
55
- loading={loading}
56
- shapeLines={shapeLines}
57
- width={width ?? responsiveWidth}
58
- zoomPreview={zoomPreview}
59
- />
60
- )}
61
- </Responsive.ParentSize>
62
- </div>
63
- );
64
- };
65
-
66
- export default WrapperGraph;
@@ -1,68 +0,0 @@
1
- import { Line, Metric, TimeValue } from './timeSeries/models';
2
- import { AxisX, Axis as AxisYLeft, AxisYRight } from './Axes/models';
3
- import { AreaRegularLines, AreaStackedLines } from './Lines/models';
4
-
5
- export interface GraphData {
6
- global;
7
- metrics: Array<Metric>;
8
- times: Array<string>;
9
- }
10
-
11
- export interface GraphEndpoint {
12
- baseUrl: string;
13
- queryParameters: GraphParameters;
14
- }
15
- export interface Data {
16
- baseAxis: number;
17
- lines: Array<Line>;
18
- queryParameters: GraphParameters;
19
- timeSeries: Array<TimeValue>;
20
- title: string;
21
- }
22
-
23
- export interface GraphParameters {
24
- end: string;
25
- start: string;
26
- }
27
-
28
- export interface AnchorPoint {
29
- display: boolean;
30
- }
31
-
32
- export interface AreaAnchorPoint {
33
- areaRegularLinesAnchorPoint: AnchorPoint;
34
- areaStackedLinesAnchorPoint: AnchorPoint;
35
- }
36
-
37
- export interface ShapeLines {
38
- areaRegularLines?: AreaRegularLines;
39
- areaStackedLines?: AreaStackedLines;
40
- }
41
-
42
- export interface Axis {
43
- axisX?: AxisX;
44
- axisYLeft?: AxisYLeft;
45
- axisYRight?: AxisYRight;
46
- }
47
-
48
- export interface ZoomPreview {
49
- [x: string]: unknown;
50
- display?: boolean;
51
- }
52
-
53
- export interface GraphProps {
54
- anchorPoint?: AreaAnchorPoint;
55
- axis?: Axis;
56
- height: number;
57
- width: number;
58
- zoomPreview?: ZoomPreview;
59
- }
60
-
61
- export interface Area {
62
- display: boolean;
63
- }
64
-
65
- export interface GlobalAreaLines {
66
- areaRegularLines: Area;
67
- areaStackedLines: Area;
68
- }