@centreon/ui 24.4.59 → 24.4.61

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 (163) hide show
  1. package/package.json +50 -42
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/ActionsList/ActionsList.styles.ts +40 -71
  4. package/src/Button/Icon/index.tsx +1 -1
  5. package/src/Button/Save/StartIcon.tsx +3 -3
  6. package/src/Button/Save/index.tsx +9 -5
  7. package/src/Checkbox/Checkbox.tsx +2 -2
  8. package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
  9. package/src/Dashboard/Item.tsx +1 -1
  10. package/src/Dashboard/Layout.tsx +2 -2
  11. package/src/Dialog/Confirm/index.tsx +10 -2
  12. package/src/Dialog/UnsavedChanges/index.tsx +21 -20
  13. package/src/Dialog/UnsavedChanges/translatedLabels.ts +4 -6
  14. package/src/Dialog/index.tsx +9 -2
  15. package/src/FallbackPage/FallbackPage.tsx +3 -3
  16. package/src/FileDropZone/index.tsx +3 -1
  17. package/src/Form/Form.cypress.spec.tsx +133 -0
  18. package/src/Form/Inputs/List/Content.tsx +62 -0
  19. package/src/Form/Inputs/List/List.styles.ts +29 -0
  20. package/src/Form/Inputs/List/List.tsx +58 -0
  21. package/src/Form/Inputs/List/useList.ts +81 -0
  22. package/src/Form/Inputs/Text.tsx +3 -1
  23. package/src/Form/Inputs/index.tsx +3 -1
  24. package/src/Form/Inputs/models.ts +10 -1
  25. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +154 -0
  26. package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
  27. package/src/Graph/BarStack/BarStack.styles.ts +37 -0
  28. package/src/Graph/BarStack/BarStack.tsx +14 -0
  29. package/src/Graph/BarStack/ResponsiveBarStack.tsx +222 -0
  30. package/src/Graph/BarStack/index.ts +1 -0
  31. package/src/Graph/BarStack/models.ts +20 -0
  32. package/src/Graph/BarStack/useResponsiveBarStack.ts +137 -0
  33. package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
  34. package/src/Graph/Gauge/Gauge.tsx +1 -1
  35. package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
  36. package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
  37. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -2
  38. package/src/Graph/Legend/Legend.tsx +21 -0
  39. package/src/Graph/Legend/index.ts +1 -0
  40. package/src/Graph/Legend/models.ts +11 -0
  41. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
  42. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
  43. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  44. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
  45. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  46. package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
  47. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
  48. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
  49. package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
  50. package/src/Graph/LineChart/helpers/doc.ts +16 -13
  51. package/src/Graph/LineChart/helpers/index.ts +1 -1
  52. package/src/Graph/LineChart/index.stories.tsx +4 -2
  53. package/src/Graph/LineChart/index.tsx +1 -1
  54. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +169 -0
  55. package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
  56. package/src/Graph/PieChart/PieChart.styles.ts +39 -0
  57. package/src/Graph/PieChart/PieChart.tsx +14 -0
  58. package/src/Graph/PieChart/ResponsivePie.tsx +254 -0
  59. package/src/Graph/PieChart/index.ts +1 -0
  60. package/src/Graph/PieChart/models.ts +20 -0
  61. package/src/Graph/PieChart/useResponsivePie.ts +85 -0
  62. package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
  63. package/src/Graph/SingleBar/Thresholds.tsx +2 -2
  64. package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
  65. package/src/Graph/Text/Text.stories.tsx +60 -4
  66. package/src/Graph/Text/Text.tsx +1 -1
  67. package/src/Graph/common/testUtils.ts +71 -0
  68. package/src/Graph/common/timeSeries/index.ts +22 -14
  69. package/src/Graph/common/utils.ts +19 -0
  70. package/src/Graph/index.ts +3 -0
  71. package/src/Graph/translatedLabels.ts +1 -0
  72. package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
  73. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  74. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  75. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  76. package/src/InputField/Select/Autocomplete/Multi/index.tsx +4 -2
  77. package/src/InputField/Select/Autocomplete/index.tsx +129 -116
  78. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  79. package/src/InputField/Select/index.tsx +15 -2
  80. package/src/InputField/Text/index.tsx +2 -2
  81. package/src/Listing/ActionBar/index.tsx +9 -8
  82. package/src/Listing/Cell/DataCell.styles.ts +3 -0
  83. package/src/Listing/Cell/DataCell.tsx +23 -5
  84. package/src/Listing/Header/ListingHeader.tsx +1 -1
  85. package/src/Listing/Listing.cypress.spec.tsx +218 -33
  86. package/src/Listing/Listing.styles.ts +4 -7
  87. package/src/Listing/Row/Row.tsx +7 -3
  88. package/src/Listing/index.stories.tsx +37 -3
  89. package/src/Listing/index.test.tsx +1 -1
  90. package/src/Listing/index.tsx +80 -36
  91. package/src/Listing/models.ts +1 -0
  92. package/src/Listing/useStyleTable.ts +1 -0
  93. package/src/Module/Module.cypress.spec.tsx +129 -0
  94. package/src/Module/index.tsx +2 -4
  95. package/src/PopoverMenu/index.tsx +6 -5
  96. package/src/RichTextEditor/RichTextEditor.tsx +12 -1
  97. package/src/SortableItems/index.tsx +2 -7
  98. package/src/ThemeProvider/index.tsx +24 -0
  99. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
  100. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
  101. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
  102. package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
  103. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
  104. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
  105. package/src/TimePeriods/helpers/index.ts +1 -1
  106. package/src/TimePeriods/index.stories.tsx +12 -4
  107. package/src/TimePeriods/index.tsx +2 -2
  108. package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +27 -0
  109. package/src/Typography/FluidTypography/index.stories.tsx +2 -2
  110. package/src/Typography/FluidTypography/index.tsx +21 -28
  111. package/src/api/QueryProvider.tsx +1 -1
  112. package/src/api/TestQueryProvider.tsx +1 -1
  113. package/src/api/index.ts +3 -3
  114. package/src/api/useFetchQuery/index.ts +27 -23
  115. package/src/api/useMutationQuery/index.test.ts +4 -4
  116. package/src/api/useMutationQuery/index.ts +60 -25
  117. package/src/components/Button/Icon/IconButton.tsx +6 -2
  118. package/src/components/DataTable/DataListing.tsx +6 -0
  119. package/src/components/DataTable/DataTable.cypress.spec.tsx +174 -0
  120. package/src/components/DataTable/DataTable.stories.tsx +40 -0
  121. package/src/components/DataTable/DataTable.styles.ts +3 -0
  122. package/src/components/DataTable/DataTable.tsx +3 -3
  123. package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
  124. package/src/components/DataTable/Item/DataTableItem.tsx +4 -60
  125. package/src/components/DataTable/index.ts +3 -1
  126. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -13
  127. package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
  128. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -0
  129. package/src/components/Form/AccessRights/storiesData.ts +22 -22
  130. package/src/components/Form/Dashboard/DashboardDuplicationForm.tsx +85 -0
  131. package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
  132. package/src/components/Form/Dashboard/index.ts +1 -0
  133. package/src/components/Form/FormActions.tsx +7 -2
  134. package/src/components/ItemComposition/ItemComposition.styles.ts +2 -2
  135. package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
  136. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
  137. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
  138. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
  139. package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
  140. package/src/components/Layout/PageLayout/index.ts +3 -1
  141. package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
  142. package/src/components/List/Item/ListItem.tsx +3 -3
  143. package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +168 -0
  144. package/src/components/Modal/ConfirmationModal/ConfirmationModal.stories.tsx +62 -0
  145. package/src/components/Modal/ConfirmationModal/ConfirmationModal.tsx +87 -0
  146. package/src/components/Modal/Modal.styles.ts +8 -3
  147. package/src/components/Modal/index.ts +2 -0
  148. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
  149. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
  150. package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
  151. package/src/index.ts +2 -2
  152. package/src/queryParameters/url/index.ts +5 -1
  153. package/src/utils/index.ts +1 -1
  154. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +1 -3
  155. package/src/utils/useFullscreen/useFullscreenListener.ts +10 -7
  156. package/src/utils/useInfiniteScrollListing.ts +4 -1
  157. package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
  158. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  159. package/src/utils/usePluralizedTranslation.ts +21 -0
  160. package/src/Typography/FluidTypography/useFluidResizeObserver.ts +0 -56
  161. package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
  162. package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
  163. package/src/utils/useDateTimePickerAdapter.ts +0 -309
@@ -0,0 +1,121 @@
1
+ import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
2
+ import {
3
+ criticalThresholds,
4
+ rangedThresholds,
5
+ successThresholds,
6
+ warningThresholds
7
+ } from '../common/testUtils';
8
+
9
+ import SingleBar from './SingleBar';
10
+ import { SingleBarProps } from './models';
11
+
12
+ const initialize = (
13
+ args: Omit<SingleBarProps, 'data' | 'labels' | 'baseColor'>
14
+ ): void => {
15
+ cy.mount({
16
+ Component: (
17
+ <div style={{ height: '100vh', width: '100vw' }}>
18
+ <SingleBar
19
+ baseColor="#000"
20
+ data={dataLastWeek}
21
+ labels={{
22
+ critical: 'Critical',
23
+ warning: 'Warning'
24
+ }}
25
+ {...args}
26
+ />
27
+ </div>
28
+ )
29
+ });
30
+ };
31
+
32
+ describe('Single bar', () => {
33
+ it('displays the single bar as success when corresponding thresholds are set', () => {
34
+ initialize({ thresholds: successThresholds });
35
+
36
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
37
+ cy.findByTestId('warning-line-0.5').should('be.visible');
38
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
39
+ cy.findByTestId('critical-line-1.5').should('be.visible');
40
+ cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
41
+
42
+ cy.makeSnapshot();
43
+ });
44
+
45
+ it('displays the single bar as warning when corresponding thresholds are set', () => {
46
+ initialize({ thresholds: warningThresholds });
47
+
48
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
49
+ cy.findByTestId('warning-line-0.4').should('be.visible');
50
+ cy.findByTestId('warning-line-0.4-tooltip').should('be.visible');
51
+ cy.findByTestId('critical-line-1.5').should('be.visible');
52
+ cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
53
+
54
+ cy.makeSnapshot();
55
+ });
56
+
57
+ it('displays the single bar as critical when corresponding thresholds are set', () => {
58
+ initialize({ thresholds: criticalThresholds });
59
+
60
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
61
+ cy.findByTestId('warning-line-0.2').should('be.visible');
62
+ cy.findByTestId('warning-line-0.2-tooltip').should('be.visible');
63
+ cy.findByTestId('critical-line-0.3').should('be.visible');
64
+ cy.findByTestId('critical-line-0.3-tooltip').should('be.visible');
65
+
66
+ cy.makeSnapshot();
67
+ });
68
+
69
+ it('displays ranged thresholds', () => {
70
+ initialize({ thresholds: rangedThresholds });
71
+
72
+ cy.findByTestId('warning-line-0.13').should('be.visible');
73
+ cy.findByTestId('warning-line-0.13-tooltip').should('be.visible');
74
+ cy.findByTestId('warning-line-0.5').should('be.visible');
75
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
76
+ cy.findByTestId('critical-line-0.55').should('be.visible');
77
+ cy.findByTestId('critical-line-0.55-tooltip').should('be.visible');
78
+ cy.findByTestId('critical-line-0.65').should('be.visible');
79
+ cy.findByTestId('critical-line-0.65-tooltip').should('be.visible');
80
+
81
+ cy.makeSnapshot();
82
+ });
83
+
84
+ it('displays the threshold tooltip when a threshold is hovered', () => {
85
+ initialize({ thresholds: successThresholds });
86
+
87
+ cy.findByTestId('warning-line-0.5-tooltip').trigger('mouseover');
88
+
89
+ cy.contains('Warning').should('be.visible');
90
+
91
+ cy.findByTestId('critical-line-1.5-tooltip').trigger('mouseover');
92
+
93
+ cy.contains('Critical').should('be.visible');
94
+
95
+ cy.makeSnapshot();
96
+ });
97
+
98
+ it('displays single bar as small when the props is set', () => {
99
+ initialize({ size: 'small', thresholds: successThresholds });
100
+
101
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
102
+
103
+ cy.makeSnapshot();
104
+ });
105
+
106
+ it('displays the value as raw when the prop is set', () => {
107
+ initialize({ displayAsRaw: true, thresholds: successThresholds });
108
+
109
+ cy.contains('0.40663333333 s').should('be.visible');
110
+
111
+ cy.makeSnapshot();
112
+ });
113
+
114
+ it('does not display the value when the prop is set', () => {
115
+ initialize({ showLabels: false, thresholds: successThresholds });
116
+
117
+ cy.contains('0.41 s').should('not.exist');
118
+
119
+ cy.makeSnapshot();
120
+ });
121
+ });
@@ -1,4 +1,4 @@
1
- import { Thresholds } from '../common/models';
1
+ import { Thresholds as ThresholdsModel } from '../common/models';
2
2
 
3
3
  import { ThresholdLine } from './ThresholdLine';
4
4
 
@@ -8,7 +8,7 @@ interface Props {
8
8
  hideTooltip: () => void;
9
9
  showTooltip: (args) => void;
10
10
  size: 'small' | 'medium';
11
- thresholds: Thresholds;
11
+ thresholds: ThresholdsModel;
12
12
  xScale: (value: number) => number;
13
13
  }
14
14
 
@@ -0,0 +1,101 @@
1
+ import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
2
+ import {
3
+ criticalThresholds,
4
+ rangedThresholds,
5
+ successThresholds,
6
+ warningThresholds
7
+ } from '../common/testUtils';
8
+
9
+ import { Text, Props } from './Text';
10
+
11
+ const initialize = (
12
+ args: Omit<Props, 'data' | 'labels' | 'baseColor'>
13
+ ): void => {
14
+ cy.mount({
15
+ Component: (
16
+ <div style={{ height: '100vh', width: '100vw' }}>
17
+ <Text
18
+ baseColor="#000"
19
+ data={dataLastWeek}
20
+ labels={{
21
+ critical: 'Critical',
22
+ warning: 'Warning'
23
+ }}
24
+ {...args}
25
+ />
26
+ </div>
27
+ )
28
+ });
29
+ };
30
+
31
+ describe('Text', () => {
32
+ it('displays the text as success when corresponding thresholds are set', () => {
33
+ initialize({ thresholds: successThresholds });
34
+
35
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(136, 185, 34)');
36
+ cy.contains('Warning: 0.5 s').should('be.visible');
37
+ cy.contains('Critical: 1.5 s').should('be.visible');
38
+
39
+ cy.makeSnapshot();
40
+ });
41
+
42
+ it('displays the text as warning when corresponding thresholds are set', () => {
43
+ initialize({ thresholds: warningThresholds });
44
+
45
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(253, 155, 39)');
46
+ cy.contains('Warning: 0.4 s').should('be.visible');
47
+ cy.contains('Critical: 1.5 s').should('be.visible');
48
+
49
+ cy.makeSnapshot();
50
+ });
51
+
52
+ it('displays the text as critical when corresponding thresholds are set', () => {
53
+ initialize({ thresholds: criticalThresholds });
54
+
55
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(255, 74, 74)');
56
+ cy.contains('Warning: 0.2 s').should('be.visible');
57
+ cy.contains('Critical: 0.3 s').should('be.visible');
58
+
59
+ cy.makeSnapshot();
60
+ });
61
+
62
+ it('displays ranged thresholds', () => {
63
+ initialize({ thresholds: rangedThresholds });
64
+
65
+ cy.contains('Warning: 0.13 s - 0.5 s').should('be.visible');
66
+ cy.contains('Critical: 0.55 s - 0.65 s').should('be.visible');
67
+
68
+ cy.makeSnapshot();
69
+ });
70
+
71
+ it('displays the value as raw when the prop is set', () => {
72
+ initialize({ displayAsRaw: true, thresholds: successThresholds });
73
+
74
+ cy.contains('0.40663333333 s').should('be.visible');
75
+
76
+ cy.makeSnapshot();
77
+ });
78
+
79
+ it('does not display the text', () => {
80
+ initialize({ data: undefined, thresholds: successThresholds });
81
+
82
+ cy.contains('0.41 s').should('not.exist');
83
+
84
+ cy.makeSnapshot();
85
+ });
86
+
87
+ it('displays text with default values when the data is empty', () => {
88
+ initialize({
89
+ data: {
90
+ global: {},
91
+ metrics: [],
92
+ times: []
93
+ },
94
+ thresholds: successThresholds
95
+ });
96
+
97
+ cy.contains('0').should('be.visible');
98
+
99
+ cy.makeSnapshot();
100
+ });
101
+ });
@@ -24,7 +24,21 @@ export const success: Story = {
24
24
  critical: 'Critical',
25
25
  warning: 'Warning'
26
26
  },
27
- thresholds: [0.5, 1.5]
27
+ thresholds: {
28
+ critical: [
29
+ {
30
+ label: 'Critical',
31
+ value: 1.5
32
+ }
33
+ ],
34
+ enabled: true,
35
+ warning: [
36
+ {
37
+ label: 'Warning',
38
+ value: 0.5
39
+ }
40
+ ]
41
+ }
28
42
  },
29
43
  render: Template
30
44
  };
@@ -36,7 +50,21 @@ export const warning: Story = {
36
50
  critical: 'Critical',
37
51
  warning: 'Warning'
38
52
  },
39
- thresholds: [0.2, 0.5]
53
+ thresholds: {
54
+ critical: [
55
+ {
56
+ label: 'Critical',
57
+ value: 1.5
58
+ }
59
+ ],
60
+ enabled: true,
61
+ warning: [
62
+ {
63
+ label: 'Warning',
64
+ value: 0.4
65
+ }
66
+ ]
67
+ }
40
68
  },
41
69
  render: Template
42
70
  };
@@ -48,7 +76,21 @@ export const critical: Story = {
48
76
  critical: 'Critical',
49
77
  warning: 'Warning'
50
78
  },
51
- thresholds: [0.13, 0.35]
79
+ thresholds: {
80
+ critical: [
81
+ {
82
+ label: 'Critical',
83
+ value: 0.3
84
+ }
85
+ ],
86
+ enabled: true,
87
+ warning: [
88
+ {
89
+ label: 'Warning',
90
+ value: 0.2
91
+ }
92
+ ]
93
+ }
52
94
  },
53
95
  render: Template
54
96
  };
@@ -61,7 +103,21 @@ export const rawValue: Story = {
61
103
  critical: 'Critical',
62
104
  warning: 'Warning'
63
105
  },
64
- thresholds: [0.5, 1.5]
106
+ thresholds: {
107
+ critical: [
108
+ {
109
+ label: 'Critical',
110
+ value: 1.5
111
+ }
112
+ ],
113
+ enabled: true,
114
+ warning: [
115
+ {
116
+ label: 'Warning',
117
+ value: 0.5
118
+ }
119
+ ]
120
+ }
65
121
  },
66
122
  render: Template
67
123
  };
@@ -11,7 +11,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
11
11
 
12
12
  import { useTextStyles } from './Text.styles';
13
13
 
14
- interface Props {
14
+ export interface Props {
15
15
  baseColor?: string;
16
16
  data?: LineChartData;
17
17
  displayAsRaw?: boolean;
@@ -0,0 +1,71 @@
1
+ export const successThresholds = {
2
+ critical: [
3
+ {
4
+ label: 'Critical',
5
+ value: 1.5
6
+ }
7
+ ],
8
+ enabled: true,
9
+ warning: [
10
+ {
11
+ label: 'Warning',
12
+ value: 0.5
13
+ }
14
+ ]
15
+ };
16
+
17
+ export const warningThresholds = {
18
+ critical: [
19
+ {
20
+ label: 'Critical',
21
+ value: 1.5
22
+ }
23
+ ],
24
+ enabled: true,
25
+ warning: [
26
+ {
27
+ label: 'Warning',
28
+ value: 0.4
29
+ }
30
+ ]
31
+ };
32
+
33
+ export const criticalThresholds = {
34
+ critical: [
35
+ {
36
+ label: 'Critical',
37
+ value: 0.3
38
+ }
39
+ ],
40
+ enabled: true,
41
+ warning: [
42
+ {
43
+ label: 'Warning',
44
+ value: 0.2
45
+ }
46
+ ]
47
+ };
48
+
49
+ export const rangedThresholds = {
50
+ critical: [
51
+ {
52
+ label: 'Critical',
53
+ value: 0.55
54
+ },
55
+ {
56
+ label: 'Critical',
57
+ value: 0.65
58
+ }
59
+ ],
60
+ enabled: true,
61
+ warning: [
62
+ {
63
+ label: 'Warning',
64
+ value: 0.13
65
+ },
66
+ {
67
+ label: 'Warning',
68
+ value: 0.5
69
+ }
70
+ ]
71
+ };
@@ -179,7 +179,7 @@ const getMetricValuesForUnit = ({
179
179
  ) as Array<number>;
180
180
 
181
181
  return pipe(
182
- filter(propEq('unit', unit)) as (line) => Array<Line>,
182
+ filter(propEq(unit, 'unit')) as (line) => Array<Line>,
183
183
  map(prop('metric_id')),
184
184
  map(getTimeSeriesValuesForMetric),
185
185
  flatten,
@@ -203,7 +203,7 @@ const getLineForMetric = ({
203
203
  lines,
204
204
  metric_id
205
205
  }: LineForMetricProps): Line | undefined =>
206
- find(propEq('metric_id', metric_id), lines);
206
+ find(propEq(metric_id, 'metric_id'), lines);
207
207
 
208
208
  interface LinesTimeSeries {
209
209
  lines: Array<Line>;
@@ -275,7 +275,7 @@ interface HasStackedLines {
275
275
  }
276
276
 
277
277
  const hasUnitStackedLines = ({ lines, unit }: HasStackedLines): boolean =>
278
- pipe(getSortedStackedLines, any(propEq('unit', unit)))(lines);
278
+ pipe(getSortedStackedLines, any(propEq(unit, 'unit')))(lines);
279
279
 
280
280
  const getTimeSeriesForLines = ({
281
281
  lines,
@@ -476,15 +476,7 @@ const registerMsUnitToNumeral = (): null => {
476
476
 
477
477
  registerMsUnitToNumeral();
478
478
 
479
- const formatMetricValue = ({
480
- value,
481
- unit,
482
- base = 1000
483
- }: FormatMetricValueProps): string | null => {
484
- if (isNil(value)) {
485
- return null;
486
- }
487
-
479
+ const getBase1024 = ({ unit, base }): boolean => {
488
480
  const base2Units = [
489
481
  'B',
490
482
  'bytes',
@@ -497,7 +489,19 @@ const formatMetricValue = ({
497
489
  'b'
498
490
  ];
499
491
 
500
- const base1024 = base2Units.includes(unit) || Number(base) === 1024;
492
+ return base2Units.includes(unit) || Number(base) === 1024;
493
+ };
494
+
495
+ const formatMetricValue = ({
496
+ value,
497
+ unit,
498
+ base = 1000
499
+ }: FormatMetricValueProps): string | null => {
500
+ if (isNil(value)) {
501
+ return null;
502
+ }
503
+
504
+ const base1024 = getBase1024({ base, unit });
501
505
 
502
506
  const formatSuffix = cond([
503
507
  [equals('ms'), always(' ms')],
@@ -525,6 +529,8 @@ const formatMetricValueWithUnit = ({
525
529
  return null;
526
530
  }
527
531
 
532
+ const base1024 = getBase1024({ base, unit });
533
+
528
534
  if (isRaw) {
529
535
  const unitText = equals('%', unit) ? unit : ` ${unit}`;
530
536
 
@@ -537,7 +543,9 @@ const formatMetricValueWithUnit = ({
537
543
 
538
544
  const formattedMetricValue = formatMetricValue({ base, unit, value });
539
545
 
540
- return formattedMetricValue;
546
+ return base1024 || !unit || equals(unit, 'ms')
547
+ ? formattedMetricValue
548
+ : `${formattedMetricValue} ${unit}`;
541
549
  };
542
550
 
543
551
  const getStackedYScale = ({
@@ -11,6 +11,7 @@ import {
11
11
  lte,
12
12
  pluck
13
13
  } from 'ramda';
14
+ import numeral from 'numeral';
14
15
 
15
16
  import { Theme } from '@mui/material';
16
17
 
@@ -73,3 +74,21 @@ export const getColorFromDataAndTresholds = ({
73
74
  [T, always(theme.palette.error.main)]
74
75
  ])(data);
75
76
  };
77
+
78
+ interface ValueByUnitProps {
79
+ total: number;
80
+ unit: 'percentage' | 'number';
81
+ value: number;
82
+ }
83
+
84
+ export const getValueByUnit = ({
85
+ unit,
86
+ value,
87
+ total
88
+ }: ValueByUnitProps): string => {
89
+ if (equals(unit, 'number')) {
90
+ return numeral(value).format('0a').toUpperCase();
91
+ }
92
+
93
+ return `${((value * 100) / total).toFixed(1)}%`;
94
+ };
@@ -2,4 +2,7 @@ export { default as LineChart } from './LineChart';
2
2
  export { Gauge } from './Gauge';
3
3
  export { SingleBar } from './SingleBar';
4
4
  export { Text as GraphText } from './Text';
5
+
5
6
  export { HeatMap } from './HeatMap';
7
+ export { BarStack } from './BarStack';
8
+ export { PieChart } from './PieChart';
@@ -0,0 +1 @@
1
+ export const labelNoDataFound = 'No Data Available';
@@ -292,13 +292,16 @@ const ConnectedAutocompleteField = (
292
292
  }
293
293
  }, [optionsOpen]);
294
294
 
295
- useEffect(() => {
296
- setSearchParameter(
297
- !isEmpty(searchConditions)
298
- ? { conditions: searchConditions }
299
- : undefined
300
- );
301
- }, useDeepCompare([searchConditions]));
295
+ useEffect(
296
+ () => {
297
+ setSearchParameter(
298
+ !isEmpty(searchConditions)
299
+ ? { conditions: searchConditions }
300
+ : undefined
301
+ );
302
+ },
303
+ useDeepCompare([searchConditions])
304
+ );
302
305
 
303
306
  useEffect(() => {
304
307
  if (!autocompleteChangedValue && !props?.value) {
@@ -49,7 +49,7 @@ const SortableList = ({
49
49
  const dragEnd = ({ items: newItems }): void =>
50
50
  changeItemsOrder(
51
51
  map(
52
- (item) => find(propEq('id', item), items),
52
+ (item) => find(propEq(item, 'id'), items),
53
53
  newItems
54
54
  ) as Array<DraggableSelectEntry>
55
55
  );
@@ -49,7 +49,7 @@ const SortableListContent = ({
49
49
  return;
50
50
  }
51
51
 
52
- const itemIndex = findIndex(propEq('id', id), items);
52
+ const itemIndex = findIndex(propEq(id, 'id'), items);
53
53
 
54
54
  itemHover?.(null);
55
55
  itemClick?.({ index: itemIndex, item: { createOption, id, name } });
@@ -77,7 +77,7 @@ const DraggableAutocomplete = (
77
77
  const deleteValue = (id): void => {
78
78
  itemHover?.(null);
79
79
  setSelectedValues((values: Array<DraggableSelectEntry>) => {
80
- const index = findIndex(propEq('id', id), values);
80
+ const index = findIndex(propEq(id, 'id'), values);
81
81
 
82
82
  const newSelectedValues = remove(index, 1, values);
83
83
 
@@ -1,4 +1,4 @@
1
- import { includes, map, prop, reject } from 'ramda';
1
+ import { includes, map, prop, reject, sortBy, toLower, compose } from 'ramda';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Chip, ChipProps, Tooltip } from '@mui/material';
@@ -85,9 +85,11 @@ const MultiAutocompleteField = ({
85
85
  return includes(id, valueIds);
86
86
  };
87
87
 
88
+ const sortByName = sortBy(compose(toLower, prop(optionProperty)));
89
+
88
90
  const autocompleteOptions = disableSortedOptions
89
91
  ? options
90
- : [...values, ...reject(isOptionSelected, options)];
92
+ : sortByName([...values, ...reject(isOptionSelected, options)]);
91
93
 
92
94
  return (
93
95
  <Autocomplete