@centreon/ui 24.10.29 → 24.10.31
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/Gauge/PieData.tsx +2 -2
- package/src/Graph/Gauge/Thresholds.tsx +2 -2
- package/src/Graph/Gauge/utils.ts +12 -4
- package/src/Listing/ActionBar/Pagination.tsx +2 -1
- package/src/Listing/ActionBar/index.tsx +109 -8
- package/src/Listing/index.tsx +19 -2
- package/src/Listing/translatedLabels.ts +4 -0
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
|
|
|
9
9
|
import AnimatedPie from './AnimatedPie';
|
|
10
10
|
import { thresholdThickness } from './Thresholds';
|
|
11
11
|
import { GaugeProps } from './models';
|
|
12
|
-
import {
|
|
12
|
+
import { getAngles } from './utils';
|
|
13
13
|
|
|
14
14
|
const dataThickness = 45;
|
|
15
15
|
|
|
@@ -43,7 +43,7 @@ const PieData = ({
|
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<Pie
|
|
46
|
-
{...
|
|
46
|
+
{...getAngles()}
|
|
47
47
|
data={pieData}
|
|
48
48
|
innerRadius={radius - dataThickness * dataThicknessFactor}
|
|
49
49
|
outerRadius={
|
|
@@ -6,7 +6,7 @@ import { useTheme } from '@mui/material';
|
|
|
6
6
|
|
|
7
7
|
import AnimatedPie from './AnimatedPie';
|
|
8
8
|
import { GaugeProps } from './models';
|
|
9
|
-
import {
|
|
9
|
+
import { getAngles } from './utils';
|
|
10
10
|
|
|
11
11
|
export const thresholdThickness = 12;
|
|
12
12
|
|
|
@@ -90,7 +90,7 @@ const Thresholds = ({
|
|
|
90
90
|
<>
|
|
91
91
|
{arcs.map(({ thresholdArc, thresholdScaleOrdinal }) => (
|
|
92
92
|
<Pie
|
|
93
|
-
{...
|
|
93
|
+
{...getAngles()}
|
|
94
94
|
data={thresholdArc}
|
|
95
95
|
innerRadius={radius - thresholdThickness * thresholdThicknessFactor}
|
|
96
96
|
key={`arc-${thresholdArc[0].name}`}
|
package/src/Graph/Gauge/utils.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { includes } from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getAngles = () =>
|
|
4
|
+
includes('Firefox', window.navigator.userAgent)
|
|
5
|
+
? {
|
|
6
|
+
endAngle: (2 * Math.PI) / 3,
|
|
7
|
+
startAngle: -(2 * Math.PI) / 3
|
|
8
|
+
}
|
|
9
|
+
: {
|
|
10
|
+
endAngle: -(2 * Math.PI) / 3,
|
|
11
|
+
startAngle: (2 * Math.PI) / 3
|
|
12
|
+
};
|
|
@@ -35,7 +35,8 @@ const MemoizedPagination = memo(
|
|
|
35
35
|
equals(prevProps.page, nextProps.page) &&
|
|
36
36
|
equals(prevProps.count, nextProps.count) &&
|
|
37
37
|
equals(prevProps.labelRowsPerPage, nextProps.labelRowsPerPage) &&
|
|
38
|
-
equals(prevProps.className, nextProps.className)
|
|
38
|
+
equals(prevProps.className, nextProps.className) &&
|
|
39
|
+
prevProps.labelDisplayedRows === nextProps.labelDisplayedRows
|
|
39
40
|
);
|
|
40
41
|
|
|
41
42
|
export default MemoizedPagination;
|
|
@@ -5,13 +5,28 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
5
5
|
|
|
6
6
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
|
7
7
|
import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward';
|
|
8
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
8
9
|
import Divider from '@mui/material/Divider';
|
|
10
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
9
11
|
|
|
10
12
|
import { ListingVariant, userAtom } from '@centreon/ui-context';
|
|
11
13
|
|
|
12
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type ChangeEvent,
|
|
16
|
+
type MouseEvent,
|
|
17
|
+
type ReactNode,
|
|
18
|
+
useCallback
|
|
19
|
+
} from 'react';
|
|
20
|
+
|
|
21
|
+
import { IconButton, type ListingProps } from '../..';
|
|
13
22
|
import { useMemoComponent } from '../../utils';
|
|
14
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
labelApproximateCount,
|
|
25
|
+
labelApproximateCountTooltip,
|
|
26
|
+
labelComputingExactCount,
|
|
27
|
+
labelOf,
|
|
28
|
+
labelRowsPerPage
|
|
29
|
+
} from '../translatedLabels';
|
|
15
30
|
|
|
16
31
|
import ColumnMultiSelect from './ColumnMultiSelect';
|
|
17
32
|
import StyledPagination from './Pagination';
|
|
@@ -88,6 +103,9 @@ type Props = Pick<
|
|
|
88
103
|
| 'customPaginationClassName'
|
|
89
104
|
| 'listingVariant'
|
|
90
105
|
| 'viewerModeConfiguration'
|
|
106
|
+
| 'approximateTotalRows'
|
|
107
|
+
| 'onApproximateCountClick'
|
|
108
|
+
| 'isApproximateCountLoading'
|
|
91
109
|
>;
|
|
92
110
|
|
|
93
111
|
const MemoListingActionBar = ({
|
|
@@ -107,7 +125,10 @@ const MemoListingActionBar = ({
|
|
|
107
125
|
widthToMoveTablePagination = 550,
|
|
108
126
|
actionsBarMemoProps = [],
|
|
109
127
|
viewerModeConfiguration,
|
|
110
|
-
listingVariant
|
|
128
|
+
listingVariant,
|
|
129
|
+
approximateTotalRows = false,
|
|
130
|
+
onApproximateCountClick,
|
|
131
|
+
isApproximateCountLoading = false
|
|
111
132
|
}: Props): JSX.Element => {
|
|
112
133
|
const marginWidthTableListing = 30;
|
|
113
134
|
const { classes, cx } = useStyles({
|
|
@@ -118,17 +139,89 @@ const MemoListingActionBar = ({
|
|
|
118
139
|
|
|
119
140
|
const { themeMode } = useAtomValue(userAtom);
|
|
120
141
|
|
|
121
|
-
const changeRowPerPage = (
|
|
142
|
+
const changeRowPerPage = (
|
|
143
|
+
event: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
|
|
144
|
+
): void => {
|
|
122
145
|
onLimitChange?.(event.target.value);
|
|
123
146
|
onPaginate?.(0);
|
|
124
147
|
};
|
|
125
148
|
|
|
126
|
-
const changePage = (
|
|
149
|
+
const changePage = (
|
|
150
|
+
_: MouseEvent<HTMLButtonElement> | null,
|
|
151
|
+
value: number
|
|
152
|
+
): void => {
|
|
127
153
|
onPaginate?.(value);
|
|
128
154
|
};
|
|
129
155
|
|
|
130
|
-
const labelDisplayedRows = (
|
|
131
|
-
|
|
156
|
+
const labelDisplayedRows = useCallback(
|
|
157
|
+
({
|
|
158
|
+
from,
|
|
159
|
+
to,
|
|
160
|
+
count
|
|
161
|
+
}: {
|
|
162
|
+
count: number;
|
|
163
|
+
from: number;
|
|
164
|
+
to: number;
|
|
165
|
+
}): ReactNode => {
|
|
166
|
+
const range = `${from}-${to} ${t(labelOf)} `;
|
|
167
|
+
|
|
168
|
+
if (!approximateTotalRows) {
|
|
169
|
+
return `${range}${count}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (isApproximateCountLoading) {
|
|
173
|
+
return (
|
|
174
|
+
<span
|
|
175
|
+
style={{ alignItems: 'center', display: 'inline-flex', gap: 4 }}
|
|
176
|
+
>
|
|
177
|
+
{range}
|
|
178
|
+
<CircularProgress size={10} />
|
|
179
|
+
<span>{t(labelComputingExactCount)}</span>
|
|
180
|
+
</span>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const approximateLabel = (
|
|
185
|
+
<button
|
|
186
|
+
onClick={onApproximateCountClick}
|
|
187
|
+
style={{
|
|
188
|
+
background: 'none',
|
|
189
|
+
border: 'none',
|
|
190
|
+
color: 'inherit',
|
|
191
|
+
cursor: onApproximateCountClick ? 'pointer' : 'default',
|
|
192
|
+
font: 'inherit',
|
|
193
|
+
fontWeight: 600,
|
|
194
|
+
padding: 0,
|
|
195
|
+
textDecoration: onApproximateCountClick
|
|
196
|
+
? 'underline dotted'
|
|
197
|
+
: 'none'
|
|
198
|
+
}}
|
|
199
|
+
type="button"
|
|
200
|
+
>
|
|
201
|
+
{t(labelApproximateCount)}
|
|
202
|
+
</button>
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<span>
|
|
207
|
+
{range}
|
|
208
|
+
{onApproximateCountClick ? (
|
|
209
|
+
<Tooltip title={t(labelApproximateCountTooltip)}>
|
|
210
|
+
{approximateLabel}
|
|
211
|
+
</Tooltip>
|
|
212
|
+
) : (
|
|
213
|
+
approximateLabel
|
|
214
|
+
)}
|
|
215
|
+
</span>
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
[
|
|
219
|
+
approximateTotalRows,
|
|
220
|
+
isApproximateCountLoading,
|
|
221
|
+
onApproximateCountClick,
|
|
222
|
+
t
|
|
223
|
+
]
|
|
224
|
+
);
|
|
132
225
|
|
|
133
226
|
return useMemoComponent({
|
|
134
227
|
Component: (
|
|
@@ -223,6 +316,8 @@ const MemoListingActionBar = ({
|
|
|
223
316
|
),
|
|
224
317
|
columnConfiguration,
|
|
225
318
|
customPaginationClassName,
|
|
319
|
+
approximateTotalRows,
|
|
320
|
+
isApproximateCountLoading,
|
|
226
321
|
...actionsBarMemoProps
|
|
227
322
|
]
|
|
228
323
|
});
|
|
@@ -245,7 +340,10 @@ const ListingActionBar = ({
|
|
|
245
340
|
widthToMoveTablePagination,
|
|
246
341
|
customPaginationClassName,
|
|
247
342
|
listingVariant,
|
|
248
|
-
viewerModeConfiguration
|
|
343
|
+
viewerModeConfiguration,
|
|
344
|
+
approximateTotalRows,
|
|
345
|
+
onApproximateCountClick,
|
|
346
|
+
isApproximateCountLoading
|
|
249
347
|
}: Props): JSX.Element | null => {
|
|
250
348
|
if (
|
|
251
349
|
not(paginated) &&
|
|
@@ -259,13 +357,16 @@ const ListingActionBar = ({
|
|
|
259
357
|
<MemoListingActionBar
|
|
260
358
|
actions={actions}
|
|
261
359
|
actionsBarMemoProps={actionsBarMemoProps}
|
|
360
|
+
approximateTotalRows={approximateTotalRows}
|
|
262
361
|
columnConfiguration={columnConfiguration}
|
|
263
362
|
columns={columns}
|
|
264
363
|
currentPage={currentPage}
|
|
265
364
|
customPaginationClassName={customPaginationClassName}
|
|
365
|
+
isApproximateCountLoading={isApproximateCountLoading}
|
|
266
366
|
limit={limit}
|
|
267
367
|
listingVariant={listingVariant}
|
|
268
368
|
moveTablePagination={moveTablePagination}
|
|
369
|
+
onApproximateCountClick={onApproximateCountClick}
|
|
269
370
|
paginated={paginated}
|
|
270
371
|
totalRows={totalRows}
|
|
271
372
|
viewerModeConfiguration={viewerModeConfiguration}
|
package/src/Listing/index.tsx
CHANGED
|
@@ -137,6 +137,9 @@ export interface Props<TRow> {
|
|
|
137
137
|
labelExpand: string;
|
|
138
138
|
};
|
|
139
139
|
totalRows?: number;
|
|
140
|
+
approximateTotalRows?: boolean;
|
|
141
|
+
onApproximateCountClick?: () => void;
|
|
142
|
+
isApproximateCountLoading?: boolean;
|
|
140
143
|
viewerModeConfiguration?: ViewerModeConfiguration;
|
|
141
144
|
widthToMoveTablePagination?: number;
|
|
142
145
|
}
|
|
@@ -197,7 +200,10 @@ const Listing = <
|
|
|
197
200
|
getRowProperty: () => '',
|
|
198
201
|
labelCollapse: 'Collapse',
|
|
199
202
|
labelExpand: 'Expand'
|
|
200
|
-
}
|
|
203
|
+
},
|
|
204
|
+
approximateTotalRows = false,
|
|
205
|
+
onApproximateCountClick,
|
|
206
|
+
isApproximateCountLoading = false
|
|
201
207
|
}: Props<TRow>): JSX.Element => {
|
|
202
208
|
const currentVisibleColumns = getVisibleColumns({
|
|
203
209
|
columnConfiguration,
|
|
@@ -533,13 +539,16 @@ const Listing = <
|
|
|
533
539
|
<ListingActionBar
|
|
534
540
|
actions={actions}
|
|
535
541
|
actionsBarMemoProps={actionsBarMemoProps}
|
|
542
|
+
approximateTotalRows={approximateTotalRows}
|
|
536
543
|
columnConfiguration={columnConfiguration}
|
|
537
544
|
columns={columns}
|
|
538
545
|
currentPage={currentPage}
|
|
539
546
|
customPaginationClassName={customPaginationClassName}
|
|
547
|
+
isApproximateCountLoading={isApproximateCountLoading}
|
|
540
548
|
limit={limit}
|
|
541
549
|
listingVariant={listingVariant}
|
|
542
550
|
moveTablePagination={moveTablePagination}
|
|
551
|
+
onApproximateCountClick={onApproximateCountClick}
|
|
543
552
|
paginated={paginated}
|
|
544
553
|
totalRows={totalRows}
|
|
545
554
|
viewerModeConfiguration={viewerModeConfiguration}
|
|
@@ -743,20 +752,26 @@ export const MemoizedListing = <TRow extends { id: string | number }>({
|
|
|
743
752
|
moveTablePagination,
|
|
744
753
|
widthToMoveTablePagination,
|
|
745
754
|
listingVariant,
|
|
755
|
+
approximateTotalRows,
|
|
756
|
+
onApproximateCountClick,
|
|
757
|
+
isApproximateCountLoading,
|
|
746
758
|
...props
|
|
747
759
|
}: MemoizedListingProps<TRow>): JSX.Element =>
|
|
748
760
|
useMemoComponent({
|
|
749
761
|
Component: (
|
|
750
762
|
<Listing
|
|
763
|
+
approximateTotalRows={approximateTotalRows}
|
|
751
764
|
checkable={checkable}
|
|
752
765
|
columnConfiguration={columnConfiguration}
|
|
753
766
|
columns={columns}
|
|
754
767
|
currentPage={currentPage}
|
|
755
768
|
innerScrollDisabled={innerScrollDisabled}
|
|
769
|
+
isApproximateCountLoading={isApproximateCountLoading}
|
|
756
770
|
limit={limit}
|
|
757
771
|
listingVariant={listingVariant}
|
|
758
772
|
loading={loading}
|
|
759
773
|
moveTablePagination={moveTablePagination}
|
|
774
|
+
onApproximateCountClick={onApproximateCountClick}
|
|
760
775
|
paginated={paginated}
|
|
761
776
|
rowColorConditions={rowColorConditions}
|
|
762
777
|
rows={rows}
|
|
@@ -787,7 +802,9 @@ export const MemoizedListing = <TRow extends { id: string | number }>({
|
|
|
787
802
|
sortOrder,
|
|
788
803
|
sortField,
|
|
789
804
|
innerScrollDisabled,
|
|
790
|
-
listingVariant
|
|
805
|
+
listingVariant,
|
|
806
|
+
approximateTotalRows,
|
|
807
|
+
isApproximateCountLoading
|
|
791
808
|
]
|
|
792
809
|
});
|
|
793
810
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export const labelTo = 'to';
|
|
2
2
|
export const labelNoResultFound = 'No result found';
|
|
3
3
|
export const labelOf = 'of';
|
|
4
|
+
export const labelApproximateCount = '1,000+';
|
|
5
|
+
export const labelApproximateCountTooltip =
|
|
6
|
+
'More than 1,000 resources match your search. Click to continue.';
|
|
7
|
+
export const labelComputingExactCount = 'Loading...';
|
|
4
8
|
export const labelRowsPerPage = 'Rows per page';
|
|
5
9
|
export const labelFirstPage = 'First page';
|
|
6
10
|
export const labelLastPage = 'Last page';
|