@centreon/ui 23.10.1-sync-dev-23-10-x-develop-oss.0 → 23.10.1-sync-release-34346.0
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 +6 -1
- package/public/mockServiceWorker.js +2 -2
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +3 -1
- package/src/Form/Inputs/models.ts +1 -0
- package/src/Graph/Gauge/Gauge.stories.tsx +15 -2
- package/src/Graph/HeatMap/HeatMap.stories.tsx +105 -0
- package/src/Graph/HeatMap/HeatMap.styles.tsx +29 -0
- package/src/Graph/HeatMap/HeatMap.tsx +12 -0
- package/src/Graph/HeatMap/HeatMapData.json +137 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +98 -0
- package/src/Graph/HeatMap/index.ts +1 -0
- package/src/Graph/HeatMap/model.ts +33 -0
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +1 -1
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +2 -4
- package/src/Graph/LineChart/Legend/InteractiveValue.tsx +3 -3
- package/src/Graph/LineChart/Legend/Legend.styles.ts +78 -32
- package/src/Graph/LineChart/Legend/LegendContent.tsx +12 -6
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +69 -21
- package/src/Graph/LineChart/Legend/index.tsx +51 -23
- package/src/Graph/LineChart/Legend/models.ts +5 -0
- package/src/Graph/LineChart/Legend/useLegend.ts +9 -10
- package/src/Graph/LineChart/LineChart.tsx +17 -3
- package/src/Graph/index.ts +1 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +1 -0
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +1 -0
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +15 -3
- package/src/InputField/Text/index.tsx +6 -1
- package/src/Module/LicensedModule/LicenseCheck/index.tsx +24 -9
- package/src/Module/LicensedModule/index.tsx +7 -1
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +100 -52
- package/src/RichTextEditor/RichTextEditor.tsx +9 -3
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +21 -20
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +35 -77
- package/src/RichTextEditor/plugins/ToolbarPlugin/FormatButtons.tsx +29 -83
- package/src/RichTextEditor/plugins/ToolbarPlugin/LinkButton.tsx +106 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +155 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +23 -39
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +24 -14
- package/src/RichTextEditor/plugins/ToolbarPlugin/UndoRedoButtons.tsx +6 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +5 -10
- package/src/RichTextEditor/translatedLabels.ts +3 -0
- package/src/ThemeProvider/palettes.ts +4 -4
- package/src/Typography/EllipsisTypography.tsx +18 -0
- package/src/Typography/Subtitle.tsx +55 -0
- package/src/api/buildListingEndpoint/models.ts +2 -1
- package/src/api/customFetch.ts +12 -3
- package/src/api/useFetchQuery/index.ts +22 -5
- package/src/api/useGraphQuery/index.ts +4 -1
- package/src/api/useMutationQuery/index.ts +12 -2
- package/src/components/Form/AccessRightsV2/AccessRights.cypress.spec.tsx +350 -0
- package/src/components/Form/AccessRightsV2/AccessRights.stories.tsx +119 -0
- package/src/components/Form/AccessRightsV2/AccessRights.styles.ts +10 -0
- package/src/components/Form/AccessRightsV2/AccessRights.tsx +60 -0
- package/src/components/Form/AccessRightsV2/Actions/Actions.styles.ts +14 -0
- package/src/components/Form/AccessRightsV2/Actions/Actions.tsx +81 -0
- package/src/components/Form/AccessRightsV2/Actions/useActions.ts +79 -0
- package/src/components/Form/AccessRightsV2/List/Item.tsx +90 -0
- package/src/components/Form/AccessRightsV2/List/List.styles.tsx +45 -0
- package/src/components/Form/AccessRightsV2/List/List.tsx +52 -0
- package/src/components/Form/AccessRightsV2/List/ListItemSkeleton.tsx +18 -0
- package/src/components/Form/AccessRightsV2/List/ListSkeleton.tsx +22 -0
- package/src/components/Form/AccessRightsV2/List/RemoveAccessRight.tsx +38 -0
- package/src/components/Form/AccessRightsV2/List/StateChip.tsx +28 -0
- package/src/components/Form/AccessRightsV2/List/useItem.ts +64 -0
- package/src/components/Form/AccessRightsV2/Provider.tsx +15 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ContactSwitch.tsx +42 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ShareInput.styles.ts +9 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ShareInput.tsx +77 -0
- package/src/components/Form/AccessRightsV2/ShareInput/useShareInput.tsx +109 -0
- package/src/components/Form/AccessRightsV2/Stats/Stats.tsx +36 -0
- package/src/components/Form/AccessRightsV2/atoms.ts +97 -0
- package/src/components/Form/AccessRightsV2/common/RoleSelectField.styles.tsx +7 -0
- package/src/components/Form/AccessRightsV2/common/RoleSelectField.tsx +45 -0
- package/src/components/Form/AccessRightsV2/models.ts +54 -0
- package/src/components/Form/AccessRightsV2/storiesData.ts +221 -0
- package/src/components/Form/AccessRightsV2/useAccessRightsInitValues.ts +51 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/Header/PageHeader/PageHeader.styles.ts +28 -1
- package/src/components/Header/PageHeader/PageHeaderMessage.tsx +32 -0
- package/src/components/Header/PageHeader/index.ts +2 -0
- package/src/components/ItemComposition/Item.tsx +2 -2
- package/src/components/ItemComposition/ItemComposition.styles.ts +3 -0
- package/src/components/ItemComposition/ItemComposition.tsx +4 -2
- package/src/components/List/Item/ListItem.styles.ts +6 -0
- package/src/components/List/Item/ListItem.tsx +3 -1
- package/src/components/List/Item/Text.tsx +5 -3
- package/src/components/Menu/Button/MenuButton.tsx +4 -2
- package/src/components/Menu/MenuItem.tsx +5 -3
- package/src/components/Menu/MenuItems.tsx +4 -3
- package/src/components/Modal/Modal.styles.ts +4 -2
- package/src/index.ts +5 -0
- package/src/utils/useInfiniteScrollListing.ts +22 -7
- package/src/utils/useLocaleDateTimeFormat/index.ts +3 -0
- package/src/Graph/LineChart/Legend/Marker.tsx +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.1-sync-
|
|
3
|
+
"version": "23.10.1-sync-release-34346.0",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -119,6 +119,8 @@
|
|
|
119
119
|
"d3-array": "3.2.0",
|
|
120
120
|
"humanize-duration": "^3.27.3",
|
|
121
121
|
"lexical": "0.11.3",
|
|
122
|
+
"msw": "0.49.1",
|
|
123
|
+
"msw-storybook-addon": "^1.10.0",
|
|
122
124
|
"notistack": "^2.0.8",
|
|
123
125
|
"react-grid-layout": "^1.3.4",
|
|
124
126
|
"react-html-parser": "^2.0.2",
|
|
@@ -152,5 +154,8 @@
|
|
|
152
154
|
"jest-junit": {
|
|
153
155
|
"suiteName": "jest tests",
|
|
154
156
|
"output": "./junit.xml"
|
|
157
|
+
},
|
|
158
|
+
"msw": {
|
|
159
|
+
"workerDirectory": "public"
|
|
155
160
|
}
|
|
156
161
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* tslint:disable */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Mock Service Worker (
|
|
5
|
+
* Mock Service Worker (0.49.1).
|
|
6
6
|
* @see https://github.com/mswjs/msw
|
|
7
7
|
* - Please do NOT modify this file.
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
@@ -300,4 +300,4 @@ function sleep(timeMs) {
|
|
|
300
300
|
async function respondWithMock(response) {
|
|
301
301
|
await sleep(response.delay)
|
|
302
302
|
return new Response(response.body, response)
|
|
303
|
-
}
|
|
303
|
+
}
|
|
@@ -25,7 +25,8 @@ const ConnectedAutocomplete = ({
|
|
|
25
25
|
connectedAutocomplete,
|
|
26
26
|
change,
|
|
27
27
|
additionalMemoProps,
|
|
28
|
-
type
|
|
28
|
+
type,
|
|
29
|
+
disableSortedOptions = false
|
|
29
30
|
}: InputPropsWithoutGroup): JSX.Element => {
|
|
30
31
|
const { t } = useTranslation();
|
|
31
32
|
|
|
@@ -106,6 +107,7 @@ const ConnectedAutocomplete = ({
|
|
|
106
107
|
<AutocompleteField
|
|
107
108
|
dataTestId={dataTestId}
|
|
108
109
|
disableClearable={false}
|
|
110
|
+
disableSortedOptions={disableSortedOptions}
|
|
109
111
|
disabled={disabled}
|
|
110
112
|
error={error}
|
|
111
113
|
field={filterKey}
|
|
@@ -139,8 +139,21 @@ export const RawValue: Story = {
|
|
|
139
139
|
args: {
|
|
140
140
|
data: dataLastWeek,
|
|
141
141
|
displayAsRaw: true,
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
thresholds: {
|
|
143
|
+
critical: [
|
|
144
|
+
{
|
|
145
|
+
label: 'Critical',
|
|
146
|
+
value: 0.6
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
enabled: true,
|
|
150
|
+
warning: [
|
|
151
|
+
{
|
|
152
|
+
label: 'Warning',
|
|
153
|
+
value: 0.5
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
144
157
|
},
|
|
145
158
|
render: Template
|
|
146
159
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { makeStyles } from 'tss-react/mui';
|
|
3
|
+
|
|
4
|
+
import { Box, Typography } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
import EllipsisTypography from '../../Typography/EllipsisTypography';
|
|
7
|
+
|
|
8
|
+
import heatMapData from './HeatMapData.json';
|
|
9
|
+
|
|
10
|
+
import { HeatMap } from '.';
|
|
11
|
+
|
|
12
|
+
interface Data {
|
|
13
|
+
counter: number;
|
|
14
|
+
host: string;
|
|
15
|
+
service: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const meta: Meta<typeof HeatMap<Data>> = {
|
|
19
|
+
component: HeatMap
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof HeatMap<Data>>;
|
|
24
|
+
|
|
25
|
+
const TileContent = ({
|
|
26
|
+
isSmallestSize,
|
|
27
|
+
data
|
|
28
|
+
}: {
|
|
29
|
+
data: Data;
|
|
30
|
+
isSmallestSize: boolean;
|
|
31
|
+
}): JSX.Element | false =>
|
|
32
|
+
!isSmallestSize && (
|
|
33
|
+
<Box
|
|
34
|
+
sx={{
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
color: 'common.black',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
width: '100%'
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<EllipsisTypography textAlign="center">{data.host}</EllipsisTypography>
|
|
43
|
+
<EllipsisTypography textAlign="center">{data.service}</EllipsisTypography>
|
|
44
|
+
<EllipsisTypography textAlign="center">{data.counter}</EllipsisTypography>
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const TooltipContent = ({ data }: { data: Data }): JSX.Element => {
|
|
49
|
+
return (
|
|
50
|
+
<Box sx={{ backgroundColor: 'common.white', color: 'common.black' }}>
|
|
51
|
+
<Box
|
|
52
|
+
sx={{
|
|
53
|
+
backgroundColor: 'common.black',
|
|
54
|
+
color: 'common.white',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
py: 1,
|
|
58
|
+
width: '100%'
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<Typography>{data.host}</Typography>
|
|
62
|
+
</Box>
|
|
63
|
+
<Box sx={{ px: 1, textAlign: 'center' }}>
|
|
64
|
+
<Typography>{data.service}</Typography>
|
|
65
|
+
<Typography>{data.counter}</Typography>
|
|
66
|
+
</Box>
|
|
67
|
+
</Box>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const useStyles = makeStyles()((theme) => ({
|
|
72
|
+
arrow: {
|
|
73
|
+
color: theme.palette.common.black
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
const Template = (args): JSX.Element => {
|
|
78
|
+
const { classes } = useStyles();
|
|
79
|
+
|
|
80
|
+
return <HeatMap {...args} arrowClassName={classes.arrow} />;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const normal: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
children: TileContent,
|
|
86
|
+
tiles: heatMapData
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const withTooltip: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
children: TileContent,
|
|
93
|
+
tiles: heatMapData,
|
|
94
|
+
tooltipContent: TooltipContent
|
|
95
|
+
},
|
|
96
|
+
render: Template
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const tilesWithFixedSize: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
children: TileContent,
|
|
102
|
+
tileSizeFixed: true,
|
|
103
|
+
tiles: heatMapData
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useHeatMapStyles = makeStyles()((theme) => ({
|
|
4
|
+
arrow: {
|
|
5
|
+
transform: 'transled3d(0px, 8px, 0px)'
|
|
6
|
+
},
|
|
7
|
+
heatMapTile: {
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
aspectRatio: '1 / 1',
|
|
10
|
+
borderRadius: theme.shape.borderRadius,
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
width: '100%'
|
|
14
|
+
},
|
|
15
|
+
heatMapTileContent: {
|
|
16
|
+
height: `calc(100% - ${theme.spacing(1)})`,
|
|
17
|
+
width: `calc(100% - ${theme.spacing(1)})`
|
|
18
|
+
},
|
|
19
|
+
heatMapTooltip: {
|
|
20
|
+
backgroundColor: theme.palette.background.paper,
|
|
21
|
+
color: theme.palette.text.primary,
|
|
22
|
+
marginLeft: `${theme.spacing(1.25)} !important`,
|
|
23
|
+
padding: 0,
|
|
24
|
+
position: 'relative'
|
|
25
|
+
},
|
|
26
|
+
heatMapTooltipArrow: {
|
|
27
|
+
transform: `translate3d(0px, ${theme.spacing(1)}, 0px) !important`
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ParentSize } from '../..';
|
|
2
|
+
|
|
3
|
+
import ResponsiveHeatMap from './ResponsiveHeatMap';
|
|
4
|
+
import { HeatMapProps } from './model';
|
|
5
|
+
|
|
6
|
+
const HeatMap = <TData,>(props: HeatMapProps<TData>): JSX.Element => (
|
|
7
|
+
<ParentSize>
|
|
8
|
+
{({ width }) => <ResponsiveHeatMap<TData> {...props} width={width} />}
|
|
9
|
+
</ParentSize>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default HeatMap;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "Orbaxter",
|
|
4
|
+
"backgroundColor": "#88B922",
|
|
5
|
+
"data": {
|
|
6
|
+
"host": "Server",
|
|
7
|
+
"service": "Service Counter",
|
|
8
|
+
"counter": 53
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "Interfind",
|
|
13
|
+
"backgroundColor": "#88B922",
|
|
14
|
+
"data": {
|
|
15
|
+
"host": "Server",
|
|
16
|
+
"service": "Service Counter",
|
|
17
|
+
"counter": 779
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "Ecratic",
|
|
22
|
+
"backgroundColor": "#E3E3E3",
|
|
23
|
+
"data": {
|
|
24
|
+
"host": "Server",
|
|
25
|
+
"service": "Service Counter",
|
|
26
|
+
"counter": 504
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "Earthwax",
|
|
31
|
+
"backgroundColor": "#88B922",
|
|
32
|
+
"data": {
|
|
33
|
+
"host": "Server",
|
|
34
|
+
"service": "Service Counter",
|
|
35
|
+
"counter": 374
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "Cytrak",
|
|
40
|
+
"backgroundColor": "#FF6666",
|
|
41
|
+
"data": {
|
|
42
|
+
"host": "Server",
|
|
43
|
+
"service": "Service Counter",
|
|
44
|
+
"counter": 957
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "Exiand",
|
|
49
|
+
"backgroundColor": "#1EBEB3",
|
|
50
|
+
"data": {
|
|
51
|
+
"host": "Server",
|
|
52
|
+
"service": "Service Counter",
|
|
53
|
+
"counter": 281
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "Ginkogene",
|
|
58
|
+
"backgroundColor": "#FF6666",
|
|
59
|
+
"data": {
|
|
60
|
+
"host": "Server",
|
|
61
|
+
"service": "Service Counter",
|
|
62
|
+
"counter": 472
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "Quailcom",
|
|
67
|
+
"backgroundColor": "#88B922",
|
|
68
|
+
"data": {
|
|
69
|
+
"host": "Server",
|
|
70
|
+
"service": "Service Counter",
|
|
71
|
+
"counter": 770
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "Cormoran",
|
|
76
|
+
"backgroundColor": "#FF6666",
|
|
77
|
+
"data": {
|
|
78
|
+
"host": "Server",
|
|
79
|
+
"service": "Service Counter",
|
|
80
|
+
"counter": 908
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "Emergent",
|
|
85
|
+
"backgroundColor": "#1EBEB3",
|
|
86
|
+
"data": {
|
|
87
|
+
"host": "Server",
|
|
88
|
+
"service": "Service Counter",
|
|
89
|
+
"counter": 969
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "Limozen",
|
|
94
|
+
"backgroundColor": "#E3E3E3",
|
|
95
|
+
"data": {
|
|
96
|
+
"host": "Server",
|
|
97
|
+
"service": "Service Counter",
|
|
98
|
+
"counter": 33
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "Gogol",
|
|
103
|
+
"backgroundColor": "#1EBEB3",
|
|
104
|
+
"data": {
|
|
105
|
+
"host": "Server",
|
|
106
|
+
"service": "Service Counter",
|
|
107
|
+
"counter": 870
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": "Luxuria",
|
|
112
|
+
"backgroundColor": "#FD9B27",
|
|
113
|
+
"data": {
|
|
114
|
+
"host": "Server",
|
|
115
|
+
"service": "Service Counter",
|
|
116
|
+
"counter": 270
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": "Fossiel",
|
|
121
|
+
"backgroundColor": "#1EBEB3",
|
|
122
|
+
"data": {
|
|
123
|
+
"host": "Server",
|
|
124
|
+
"service": "Service Counter",
|
|
125
|
+
"counter": 955
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "Hawkster",
|
|
130
|
+
"backgroundColor": "#88B922",
|
|
131
|
+
"data": {
|
|
132
|
+
"host": "Server",
|
|
133
|
+
"service": "Service Counter",
|
|
134
|
+
"counter": 28
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { scaleLinear } from '@visx/scale';
|
|
4
|
+
import { T, equals, gt, lt } from 'ramda';
|
|
5
|
+
|
|
6
|
+
import { Box } from '@mui/material';
|
|
7
|
+
|
|
8
|
+
import { Tooltip } from '../../components';
|
|
9
|
+
|
|
10
|
+
import { HeatMapProps } from './model';
|
|
11
|
+
import { useHeatMapStyles } from './HeatMap.styles';
|
|
12
|
+
|
|
13
|
+
const gap = 8;
|
|
14
|
+
const maxTileSize = 120;
|
|
15
|
+
const smallestTileSize = 44;
|
|
16
|
+
|
|
17
|
+
const ResponsiveHeatMap = <TData,>({
|
|
18
|
+
width,
|
|
19
|
+
children,
|
|
20
|
+
tiles,
|
|
21
|
+
arrowClassName,
|
|
22
|
+
tooltipContent,
|
|
23
|
+
tileSizeFixed,
|
|
24
|
+
displayTooltipCondition = T
|
|
25
|
+
}: HeatMapProps<TData> & { width: number }): JSX.Element | null => {
|
|
26
|
+
const { classes, cx } = useHeatMapStyles();
|
|
27
|
+
|
|
28
|
+
const tileSize = useMemo(() => {
|
|
29
|
+
const scaleWidth = scaleLinear({
|
|
30
|
+
clamp: true,
|
|
31
|
+
domain: [680, 1056],
|
|
32
|
+
range: [76, maxTileSize]
|
|
33
|
+
});
|
|
34
|
+
const tileWidth = scaleWidth(width);
|
|
35
|
+
|
|
36
|
+
const tilesLength = tiles.length;
|
|
37
|
+
|
|
38
|
+
const maxTotalTilesWidth =
|
|
39
|
+
tilesLength * maxTileSize + (tilesLength - 1) * gap;
|
|
40
|
+
const theoricalTotalTilesWidth =
|
|
41
|
+
tilesLength * tileWidth + (tilesLength - 1) * gap;
|
|
42
|
+
|
|
43
|
+
if (lt(width, 680) && gt(maxTotalTilesWidth, width)) {
|
|
44
|
+
return smallestTileSize;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (lt(theoricalTotalTilesWidth, width)) {
|
|
48
|
+
return maxTileSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tileSizeFixed ? maxTileSize : tileWidth;
|
|
52
|
+
}, [width, tiles]);
|
|
53
|
+
|
|
54
|
+
const isSmallestSize = equals(tileSize, smallestTileSize);
|
|
55
|
+
|
|
56
|
+
if (equals(width, 0)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Box
|
|
62
|
+
sx={{
|
|
63
|
+
display: 'grid',
|
|
64
|
+
gap: 1,
|
|
65
|
+
gridTemplateColumns: `repeat(auto-fit, ${tileSize}px)`
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{tiles.map(({ backgroundColor, id, data }) => (
|
|
69
|
+
<Box className={classes.heatMapTile} key={id} sx={{ backgroundColor }}>
|
|
70
|
+
<Tooltip
|
|
71
|
+
hasCaret
|
|
72
|
+
classes={{
|
|
73
|
+
arrow: cx(classes.heatMapTooltipArrow, arrowClassName),
|
|
74
|
+
tooltip: classes.heatMapTooltip
|
|
75
|
+
}}
|
|
76
|
+
followCursor={false}
|
|
77
|
+
label={
|
|
78
|
+
displayTooltipCondition?.(data) &&
|
|
79
|
+
tooltipContent?.({
|
|
80
|
+
backgroundColor,
|
|
81
|
+
data,
|
|
82
|
+
id,
|
|
83
|
+
isSmallestSize
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
position="right-start"
|
|
87
|
+
>
|
|
88
|
+
<div className={classes.heatMapTileContent}>
|
|
89
|
+
{children({ backgroundColor, data, id, isSmallestSize })}
|
|
90
|
+
</div>
|
|
91
|
+
</Tooltip>
|
|
92
|
+
</Box>
|
|
93
|
+
))}
|
|
94
|
+
</Box>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default ResponsiveHeatMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HeatMap } from './HeatMap';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface Tile<TData> {
|
|
4
|
+
backgroundColor: string;
|
|
5
|
+
data: TData;
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ChildrenProps<TData> {
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
data: TData;
|
|
12
|
+
id: string;
|
|
13
|
+
isSmallestSize: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface HeatMapProps<TData> {
|
|
17
|
+
arrowClassName?: string;
|
|
18
|
+
children: ({
|
|
19
|
+
backgroundColor,
|
|
20
|
+
id,
|
|
21
|
+
data,
|
|
22
|
+
isSmallestSize
|
|
23
|
+
}: ChildrenProps<TData>) => ReactElement | boolean | null;
|
|
24
|
+
displayTooltipCondition?: (data: TData) => boolean;
|
|
25
|
+
tileSizeFixed?: boolean;
|
|
26
|
+
tiles: Array<Tile<TData>>;
|
|
27
|
+
tooltipContent?: ({
|
|
28
|
+
backgroundColor,
|
|
29
|
+
id,
|
|
30
|
+
data,
|
|
31
|
+
isSmallestSize
|
|
32
|
+
}: ChildrenProps<TData>) => ReactElement | boolean | null;
|
|
33
|
+
}
|
|
@@ -46,7 +46,7 @@ const RegularLine = ({
|
|
|
46
46
|
defined: (value): boolean => !isNil(value[metric_id]),
|
|
47
47
|
opacity: 1,
|
|
48
48
|
stroke: lineColor,
|
|
49
|
-
strokeWidth: !highlight ?
|
|
49
|
+
strokeWidth: !highlight ? 2 : 3,
|
|
50
50
|
unit,
|
|
51
51
|
x: (timeValue): number => xScale(getTime(timeValue)) as number,
|
|
52
52
|
y: (timeValue): number => yScale(prop(metric_id, timeValue)) ?? null
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { equals, propEq, reject } from 'ramda';
|
|
4
4
|
|
|
5
5
|
import { Line } from '../../common/timeSeries/models';
|
|
6
6
|
|
|
@@ -51,9 +51,7 @@ const useFilterLines = ({
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setLinesGraph(sortedLines);
|
|
54
|
+
setLinesGraph(filteredLines);
|
|
57
55
|
}, [lines, displayThreshold]);
|
|
58
56
|
|
|
59
57
|
return { displayedLines, newLines: linesGraph ?? lines };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Typography } from '@mui/material';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useLegendValueStyles } from './Legend.styles';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
value?: string | null;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const InteractiveValue = ({ value }: Props): JSX.Element | null => {
|
|
10
|
-
const { classes } =
|
|
10
|
+
const { classes } = useLegendValueStyles({});
|
|
11
11
|
if (!value) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
|
-
<Typography className={classes.
|
|
16
|
+
<Typography className={classes.text} variant="h6">
|
|
17
17
|
{value}
|
|
18
18
|
</Typography>
|
|
19
19
|
);
|