@centreon/ui 23.10.82 → 23.10.83
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
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
1
3
|
import { equals, has, isEmpty, pluck } from 'ramda';
|
|
2
4
|
import dayjs from 'dayjs';
|
|
3
5
|
|
|
@@ -13,6 +15,7 @@ interface CustomTimePeriod {
|
|
|
13
15
|
interface UseMetricsQueryProps {
|
|
14
16
|
baseEndpoint: string;
|
|
15
17
|
metrics: Array<string>;
|
|
18
|
+
refreshCount?: number;
|
|
16
19
|
refreshInterval?: number | false;
|
|
17
20
|
resources?: Array<Resource>;
|
|
18
21
|
timePeriod?: {
|
|
@@ -72,7 +75,8 @@ const useGraphQuery = ({
|
|
|
72
75
|
timePeriod = {
|
|
73
76
|
timePeriodType: 1
|
|
74
77
|
},
|
|
75
|
-
refreshInterval = false
|
|
78
|
+
refreshInterval = false,
|
|
79
|
+
refreshCount
|
|
76
80
|
}: UseMetricsQueryProps): UseMetricsQueryState => {
|
|
77
81
|
const timePeriodToUse = equals(timePeriod?.timePeriodType, -1)
|
|
78
82
|
? {
|
|
@@ -115,7 +119,8 @@ const useGraphQuery = ({
|
|
|
115
119
|
'graph',
|
|
116
120
|
JSON.stringify(definedMetrics),
|
|
117
121
|
JSON.stringify(resources),
|
|
118
|
-
timePeriod
|
|
122
|
+
timePeriod,
|
|
123
|
+
refreshCount || 0
|
|
119
124
|
],
|
|
120
125
|
queryOptions: {
|
|
121
126
|
enabled: areResourcesFullfilled(resources) && !isEmpty(definedMetrics),
|
|
@@ -124,14 +129,19 @@ const useGraphQuery = ({
|
|
|
124
129
|
}
|
|
125
130
|
});
|
|
126
131
|
|
|
127
|
-
const
|
|
132
|
+
const data = useRef<PerformanceGraphData | undefined>(undefined);
|
|
133
|
+
if (graphData) {
|
|
134
|
+
data.current = graphData;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const formattedGraphData = data.current
|
|
128
138
|
? {
|
|
129
139
|
global: {
|
|
130
|
-
base:
|
|
140
|
+
base: data.current.base,
|
|
131
141
|
title: ''
|
|
132
142
|
},
|
|
133
|
-
metrics:
|
|
134
|
-
times:
|
|
143
|
+
metrics: data.current.metrics,
|
|
144
|
+
times: data.current.times
|
|
135
145
|
}
|
|
136
146
|
: undefined;
|
|
137
147
|
|
|
@@ -4,9 +4,12 @@ import { FormikValues, useFormikContext } from 'formik';
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { isEmpty } from 'ramda';
|
|
6
6
|
import pluralize from 'pluralize';
|
|
7
|
+
import { useAtomValue } from 'jotai';
|
|
7
8
|
|
|
8
9
|
import { Typography } from '@mui/material';
|
|
9
10
|
|
|
11
|
+
import { refreshIntervalAtom } from '@centreon/ui-context';
|
|
12
|
+
|
|
10
13
|
import { TextField } from '../../..';
|
|
11
14
|
|
|
12
15
|
import {
|
|
@@ -22,7 +25,9 @@ const GlobalRefreshFieldOption = (): JSX.Element => {
|
|
|
22
25
|
|
|
23
26
|
const { values, setFieldValue } = useFormikContext<FormikValues>();
|
|
24
27
|
|
|
25
|
-
const
|
|
28
|
+
const platformRefreshInterval = useAtomValue(refreshIntervalAtom);
|
|
29
|
+
|
|
30
|
+
const value = values.refresh?.interval;
|
|
26
31
|
|
|
27
32
|
const changeInput = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
28
33
|
setFieldValue(
|
|
@@ -43,7 +48,7 @@ const GlobalRefreshFieldOption = (): JSX.Element => {
|
|
|
43
48
|
}}
|
|
44
49
|
size="compact"
|
|
45
50
|
type="number"
|
|
46
|
-
value={value ||
|
|
51
|
+
value={value || platformRefreshInterval}
|
|
47
52
|
onChange={changeInput}
|
|
48
53
|
/>
|
|
49
54
|
<Typography>{pluralize(t(labelSeconds), value)}</Typography>
|