@reltio/dashboard 1.4.1584 → 1.4.1586-mui5

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 (263) hide show
  1. package/.DS_Store +0 -0
  2. package/index.ts +12 -0
  3. package/package.json +42 -25
  4. package/public/bundle.js +205 -0
  5. package/public/bundle.js.LICENSE.txt +59 -0
  6. package/public/package.json +26 -0
  7. package/public/types/components/DashboardConfigItem/styles.d.ts +1 -0
  8. package/{types → public/types}/components/DashboardError/styles.d.ts +1 -1
  9. package/public/types/components/DashboardLayout/styles.d.ts +1 -0
  10. package/public/types/components/DashboardLayoutItem/styles.d.ts +1 -0
  11. package/public/types/components/DashboardLayoutPanel/styles.d.ts +1 -0
  12. package/public/types/components/DashboardLinearLoader/styles.d.ts +1 -0
  13. package/{types → public/types}/components/DashboardNoData/styles.d.ts +1 -1
  14. package/public/types/components/DashboardPerspectiveHeader/styles.d.ts +2 -0
  15. package/{types → public/types}/components/DashboardPopupMenu/DashboardPopupMenu.d.ts +1 -1
  16. package/public/types/components/DashboardPopupMenu/styles.d.ts +1 -0
  17. package/public/types/components/EntityTable/cell-renderers/styles.d.ts +1 -0
  18. package/{types → public/types}/components/EntityTable/styles.d.ts +1 -1
  19. package/public/types/components/LayoutItemContent/styles.d.ts +1 -0
  20. package/public/types/components/LayoutItemHeader/styles.d.ts +1 -0
  21. package/public/types/components/LayoutItemView/styles.d.ts +1 -0
  22. package/public/types/components/StatsChart/customized/styles.d.ts +1 -0
  23. package/public/types/components/WorkflowTaskItem/styles.d.ts +1 -0
  24. package/public/types/perspective/styles.d.ts +1 -0
  25. package/public/types/views/chartBased/styles.d.ts +1 -0
  26. package/public/types/views/custom/styles.d.ts +1 -0
  27. package/public/types/views/tableBased/styles.d.ts +1 -0
  28. package/scripts/build/index.js +21 -0
  29. package/src/HOCs/withPagination.tsx +39 -0
  30. package/src/components/DashboardConfigItem/DashboardConfigItem.tsx +101 -0
  31. package/src/components/DashboardConfigItem/__tests__/DashboardConfigItem.specs.tsx +81 -0
  32. package/src/components/DashboardConfigItem/icons/barChart.svg +12 -0
  33. package/src/components/DashboardConfigItem/icons/bubbleChart.svg +18 -0
  34. package/src/components/DashboardConfigItem/icons/customChart.svg +66 -0
  35. package/src/components/DashboardConfigItem/icons/donutChart.svg +33 -0
  36. package/src/components/DashboardConfigItem/icons/geomap.svg +23 -0
  37. package/src/components/DashboardConfigItem/icons/lineChart.svg +16 -0
  38. package/src/components/DashboardConfigItem/icons/pieChart.svg +27 -0
  39. package/src/components/DashboardConfigItem/icons/tableWithBars.svg +27 -0
  40. package/src/components/DashboardConfigItem/icons/treemap.svg +15 -0
  41. package/src/components/DashboardConfigItem/icons/wordCloud.svg +27 -0
  42. package/src/components/DashboardConfigItem/styles.ts +56 -0
  43. package/src/components/DashboardError/DashboardError.tsx +34 -0
  44. package/src/components/DashboardError/__tests__/DashboardError.test.js +34 -0
  45. package/src/components/DashboardError/icons/error.svg +113 -0
  46. package/src/components/DashboardError/styles.ts +30 -0
  47. package/src/components/DashboardLayout/DashboardLayout.tsx +59 -0
  48. package/src/components/DashboardLayout/__tests__/DashboardLayout.specs.tsx +56 -0
  49. package/src/components/DashboardLayout/styles.ts +30 -0
  50. package/src/components/DashboardLayoutItem/DashboardLayoutItem.tsx +59 -0
  51. package/src/components/DashboardLayoutItem/__tests__/DashboardLayoutItem.specs.tsx +145 -0
  52. package/src/components/DashboardLayoutItem/styles.ts +10 -0
  53. package/src/components/DashboardLayoutPanel/DashboardLayoutPanel.tsx +59 -0
  54. package/src/components/DashboardLayoutPanel/__tests__/DashboardLayoutPanel.specs.tsx +58 -0
  55. package/src/components/DashboardLayoutPanel/styles.ts +43 -0
  56. package/src/components/DashboardLinearLoader/DashboardLinearLoader.tsx +10 -0
  57. package/src/components/DashboardLinearLoader/__tests__/DashboardLinearLoader.test.js +12 -0
  58. package/src/components/DashboardLinearLoader/styles.ts +11 -0
  59. package/src/components/DashboardNoData/.DS_Store +0 -0
  60. package/src/components/DashboardNoData/DashboardNoData.tsx +21 -0
  61. package/src/components/DashboardNoData/__tests__/DashboardNoData.test.js +15 -0
  62. package/src/components/DashboardNoData/icons/noData.svg +68 -0
  63. package/src/components/DashboardNoData/styles.ts +21 -0
  64. package/src/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.tsx +43 -0
  65. package/src/components/DashboardPerspectiveHeader/__tests__/DashboardPerspectiveHeader.specs.tsx +41 -0
  66. package/src/components/DashboardPerspectiveHeader/styles.ts +24 -0
  67. package/src/components/DashboardPopupMenu/DashboardPopupMenu.tsx +75 -0
  68. package/src/components/DashboardPopupMenu/__tests__/DashboardPopupMenu.test.tsx +51 -0
  69. package/src/components/DashboardPopupMenu/styles.ts +20 -0
  70. package/src/components/EntityTable/EntityTable.tsx +49 -0
  71. package/src/components/EntityTable/__tests__/EntityTable.test.tsx +33 -0
  72. package/src/components/EntityTable/cell-renderers/EntityLabelRenderer.tsx +24 -0
  73. package/src/components/EntityTable/cell-renderers/HeadCellRenderer.tsx +34 -0
  74. package/src/components/EntityTable/cell-renderers/__tests__/EntityLabelRenderer.test.tsx +25 -0
  75. package/src/components/EntityTable/cell-renderers/styles.ts +46 -0
  76. package/src/components/EntityTable/styles.ts +19 -0
  77. package/src/components/LayoutItemContent/LayoutItemContent.tsx +63 -0
  78. package/src/components/LayoutItemContent/__tests__/LayoutItemContent.test.tsx +71 -0
  79. package/src/components/LayoutItemContent/styles.ts +36 -0
  80. package/src/components/LayoutItemHeader/LayoutItemHeader.tsx +86 -0
  81. package/src/components/LayoutItemHeader/__tests__/LayoutItemHeader.specs.tsx +48 -0
  82. package/src/components/LayoutItemHeader/styles.ts +44 -0
  83. package/src/components/LayoutItemView/LayoutItemView.tsx +24 -0
  84. package/src/components/LayoutItemView/styles.ts +11 -0
  85. package/src/components/StatsChart/StatsChart.tsx +77 -0
  86. package/src/components/StatsChart/__tests__/StatsChart.test.tsx +106 -0
  87. package/src/components/StatsChart/customized/CustomAxisTick.tsx +28 -0
  88. package/src/components/StatsChart/customized/CustomLegend.tsx +37 -0
  89. package/src/components/StatsChart/customized/CustomTooltip.tsx +41 -0
  90. package/src/components/StatsChart/customized/styles.ts +53 -0
  91. package/src/components/StatsChart/getStatsChartSettings.ts +65 -0
  92. package/src/components/WorkflowTaskItem/WorkflowTaskItem.tsx +67 -0
  93. package/src/components/WorkflowTaskItem/WorkflowTaskObject.tsx +54 -0
  94. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskItem.test.tsx +73 -0
  95. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskObject.test.tsx +95 -0
  96. package/src/components/WorkflowTaskItem/styles.ts +74 -0
  97. package/src/components/WorkflowTasksList/WorkflowTasksList.tsx +34 -0
  98. package/src/components/WorkflowTasksList/__tests__/WorkflowTasksList.test.tsx +98 -0
  99. package/src/components/index.ts +8 -0
  100. package/src/contexts/DashboardViewIdContext/index.ts +5 -0
  101. package/src/hooks/__tests__/useActivititesRequest.specs.tsx +106 -0
  102. package/src/hooks/__tests__/useEntityByTypeRequest.specs.tsx +280 -0
  103. package/src/hooks/__tests__/useFacetRequest.specs.tsx +437 -0
  104. package/src/hooks/__tests__/useFilteredEntitiesRequest.specs.tsx +103 -0
  105. package/src/hooks/__tests__/useSavedSearchesRequest.specs.tsx +201 -0
  106. package/src/hooks/__tests__/useStatsRequest.specs.tsx +212 -0
  107. package/src/hooks/__tests__/useWorkflowTasksRequest.specs.tsx +388 -0
  108. package/src/hooks/useActivitiesRequest.ts +50 -0
  109. package/src/hooks/useEntityByTypeRequest.ts +67 -0
  110. package/src/hooks/useFacetRequest.ts +117 -0
  111. package/src/hooks/useFilteredEntitiesRequest.ts +57 -0
  112. package/src/hooks/useSavedSearchesRequest.ts +82 -0
  113. package/src/hooks/useStatsRequest.ts +47 -0
  114. package/src/hooks/useWorkflowTasksRequest.ts +66 -0
  115. package/src/index.ts +25 -0
  116. package/src/perspective/DashboardPerspectiveView.tsx +132 -0
  117. package/src/perspective/__tests__/DashboardPerspectiveView.specs.tsx +276 -0
  118. package/src/perspective/__tests__/data/metadata.data.ts +33 -0
  119. package/src/perspective/__tests__/data/store.data.ts +15 -0
  120. package/src/perspective/__tests__/helpers.specs.ts +33 -0
  121. package/src/perspective/helpers.ts +19 -0
  122. package/src/perspective/index.tsx +65 -0
  123. package/src/perspective/styles.ts +16 -0
  124. package/src/services/__tests__/facets.specs.ts +42 -0
  125. package/src/services/__tests__/filters.specs.ts +60 -0
  126. package/src/services/__tests__/period.test.ts +33 -0
  127. package/src/services/__tests__/stats.test.ts +319 -0
  128. package/src/services/entityTypes.ts +66 -0
  129. package/src/services/facets.ts +178 -0
  130. package/src/services/filters.ts +87 -0
  131. package/src/services/period.ts +33 -0
  132. package/src/services/savedSearches.ts +20 -0
  133. package/src/services/stats.ts +191 -0
  134. package/src/services/workflowTasks.ts +116 -0
  135. package/src/types/ActivitiesViewFacetConfig.ts +5 -0
  136. package/src/types/CustomActionViewFacetConfig.ts +5 -0
  137. package/src/types/DashboardPerspectiveConfig.ts +18 -0
  138. package/src/types/DashboardSavedState.ts +7 -0
  139. package/src/types/EntityByTypeViewFacetConfig.ts +7 -0
  140. package/src/types/EntityData.ts +4 -0
  141. package/src/types/FilteredEntitiesFacetConfig.ts +6 -0
  142. package/src/types/FilteredSavedSearchesFacetConfig.ts +6 -0
  143. package/src/types/PeriodStep.ts +4 -0
  144. package/src/types/SavedSearchData.ts +6 -0
  145. package/src/types/SearchOptions.ts +10 -0
  146. package/src/types/StatsData.ts +14 -0
  147. package/src/types/WorkflowTasks.ts +26 -0
  148. package/src/types/index.ts +14 -0
  149. package/src/views/ViewsFactory.tsx +79 -0
  150. package/src/views/__tests__/ViewsFactory.specs.tsx +70 -0
  151. package/src/views/chartBased/DashboardFacet.tsx +71 -0
  152. package/src/views/chartBased/EntitiesByTypeViewFacet.tsx +60 -0
  153. package/src/views/chartBased/ProfileStatsFacet.tsx +54 -0
  154. package/src/views/chartBased/__tests__/DashboardFacet.specs.tsx +358 -0
  155. package/src/views/chartBased/__tests__/EntitiesByTypeViewFacet.specs.tsx +101 -0
  156. package/src/views/chartBased/__tests__/ProfileStatsFacet.specs.tsx +106 -0
  157. package/src/views/chartBased/styles.ts +13 -0
  158. package/src/views/custom/CustomActionViewFacet.tsx +36 -0
  159. package/src/views/custom/NotificationInboxFacet.tsx +86 -0
  160. package/src/views/custom/__tests__/CustomActionViewFacet.specs.tsx +35 -0
  161. package/src/views/custom/__tests__/NotificationInboxFacet.specs.tsx +144 -0
  162. package/src/views/custom/styles.ts +31 -0
  163. package/src/views/tableBased/ActivitiesViewFacet.tsx +79 -0
  164. package/src/views/tableBased/FilteredEntitiesViewFacet.tsx +67 -0
  165. package/src/views/tableBased/FilteredSavedSearchesFacet.tsx +85 -0
  166. package/src/views/tableBased/__tests__/ActivitiesViewFacet.specs.tsx +113 -0
  167. package/src/views/tableBased/__tests__/FIlteredEntitiesViewFacet.specs.tsx +90 -0
  168. package/src/views/tableBased/__tests__/FilteredSavedSearchesFacet.specs.tsx +133 -0
  169. package/src/views/tableBased/helpers.ts +8 -0
  170. package/src/views/tableBased/styles.ts +7 -0
  171. package/stories/Dashboards.stories.js +118 -0
  172. package/stories/utils/dashboardPerspectiveConfig.js +78 -0
  173. package/stories/utils/dashboardsViewConfig.js +17 -0
  174. package/stories/utils/mdmStore.js +73 -0
  175. package/stories/utils/responses.js +10 -0
  176. package/tsconfig.json +14 -0
  177. package/webpack.config.js +10 -0
  178. package/bundle.js +0 -2
  179. package/bundle.js.LICENSE.txt +0 -22
  180. package/types/components/DashboardConfigItem/styles.d.ts +0 -1
  181. package/types/components/DashboardLayout/styles.d.ts +0 -1
  182. package/types/components/DashboardLayoutItem/styles.d.ts +0 -1
  183. package/types/components/DashboardLayoutPanel/styles.d.ts +0 -1
  184. package/types/components/DashboardLinearLoader/styles.d.ts +0 -1
  185. package/types/components/DashboardPerspectiveHeader/styles.d.ts +0 -2
  186. package/types/components/DashboardPopupMenu/styles.d.ts +0 -1
  187. package/types/components/EntityTable/cell-renderers/styles.d.ts +0 -1
  188. package/types/components/LayoutItemContent/styles.d.ts +0 -1
  189. package/types/components/LayoutItemHeader/styles.d.ts +0 -1
  190. package/types/components/LayoutItemView/styles.d.ts +0 -1
  191. package/types/components/StatsChart/customized/styles.d.ts +0 -1
  192. package/types/components/WorkflowTaskItem/styles.d.ts +0 -1
  193. package/types/perspective/styles.d.ts +0 -1
  194. package/types/views/chartBased/styles.d.ts +0 -1
  195. package/types/views/custom/styles.d.ts +0 -1
  196. package/types/views/tableBased/styles.d.ts +0 -1
  197. /package/{types → public/types}/HOCs/withPagination.d.ts +0 -0
  198. /package/{types → public/types}/components/DashboardConfigItem/DashboardConfigItem.d.ts +0 -0
  199. /package/{types → public/types}/components/DashboardError/DashboardError.d.ts +0 -0
  200. /package/{types → public/types}/components/DashboardLayout/DashboardLayout.d.ts +0 -0
  201. /package/{types → public/types}/components/DashboardLayoutItem/DashboardLayoutItem.d.ts +0 -0
  202. /package/{types → public/types}/components/DashboardLayoutPanel/DashboardLayoutPanel.d.ts +0 -0
  203. /package/{types → public/types}/components/DashboardLinearLoader/DashboardLinearLoader.d.ts +0 -0
  204. /package/{types → public/types}/components/DashboardNoData/DashboardNoData.d.ts +0 -0
  205. /package/{types → public/types}/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.d.ts +0 -0
  206. /package/{types → public/types}/components/EntityTable/EntityTable.d.ts +0 -0
  207. /package/{types → public/types}/components/EntityTable/cell-renderers/EntityLabelRenderer.d.ts +0 -0
  208. /package/{types → public/types}/components/EntityTable/cell-renderers/HeadCellRenderer.d.ts +0 -0
  209. /package/{types → public/types}/components/LayoutItemContent/LayoutItemContent.d.ts +0 -0
  210. /package/{types → public/types}/components/LayoutItemHeader/LayoutItemHeader.d.ts +0 -0
  211. /package/{types → public/types}/components/LayoutItemView/LayoutItemView.d.ts +0 -0
  212. /package/{types → public/types}/components/StatsChart/StatsChart.d.ts +0 -0
  213. /package/{types → public/types}/components/StatsChart/customized/CustomAxisTick.d.ts +0 -0
  214. /package/{types → public/types}/components/StatsChart/customized/CustomLegend.d.ts +0 -0
  215. /package/{types → public/types}/components/StatsChart/customized/CustomTooltip.d.ts +0 -0
  216. /package/{types → public/types}/components/StatsChart/getStatsChartSettings.d.ts +0 -0
  217. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskItem.d.ts +0 -0
  218. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskObject.d.ts +0 -0
  219. /package/{types → public/types}/components/WorkflowTasksList/WorkflowTasksList.d.ts +0 -0
  220. /package/{types → public/types}/components/index.d.ts +0 -0
  221. /package/{types → public/types}/contexts/DashboardViewIdContext/index.d.ts +0 -0
  222. /package/{types → public/types}/hooks/useActivitiesRequest.d.ts +0 -0
  223. /package/{types → public/types}/hooks/useEntityByTypeRequest.d.ts +0 -0
  224. /package/{types → public/types}/hooks/useFacetRequest.d.ts +0 -0
  225. /package/{types → public/types}/hooks/useFilteredEntitiesRequest.d.ts +0 -0
  226. /package/{types → public/types}/hooks/useSavedSearchesRequest.d.ts +0 -0
  227. /package/{types → public/types}/hooks/useStatsRequest.d.ts +0 -0
  228. /package/{types → public/types}/hooks/useWorkflowTasksRequest.d.ts +0 -0
  229. /package/{types → public/types}/index.d.ts +0 -0
  230. /package/{types → public/types}/perspective/DashboardPerspectiveView.d.ts +0 -0
  231. /package/{types → public/types}/perspective/helpers.d.ts +0 -0
  232. /package/{types → public/types}/perspective/index.d.ts +0 -0
  233. /package/{types → public/types}/services/entityTypes.d.ts +0 -0
  234. /package/{types → public/types}/services/facets.d.ts +0 -0
  235. /package/{types → public/types}/services/filters.d.ts +0 -0
  236. /package/{types → public/types}/services/period.d.ts +0 -0
  237. /package/{types → public/types}/services/savedSearches.d.ts +0 -0
  238. /package/{types → public/types}/services/stats.d.ts +0 -0
  239. /package/{types → public/types}/services/workflowTasks.d.ts +0 -0
  240. /package/{types → public/types}/types/ActivitiesViewFacetConfig.d.ts +0 -0
  241. /package/{types → public/types}/types/CustomActionViewFacetConfig.d.ts +0 -0
  242. /package/{types → public/types}/types/DashboardPerspectiveConfig.d.ts +0 -0
  243. /package/{types → public/types}/types/DashboardSavedState.d.ts +0 -0
  244. /package/{types → public/types}/types/EntityByTypeViewFacetConfig.d.ts +0 -0
  245. /package/{types → public/types}/types/EntityData.d.ts +0 -0
  246. /package/{types → public/types}/types/FilteredEntitiesFacetConfig.d.ts +0 -0
  247. /package/{types → public/types}/types/FilteredSavedSearchesFacetConfig.d.ts +0 -0
  248. /package/{types → public/types}/types/PeriodStep.d.ts +0 -0
  249. /package/{types → public/types}/types/SavedSearchData.d.ts +0 -0
  250. /package/{types → public/types}/types/SearchOptions.d.ts +0 -0
  251. /package/{types → public/types}/types/StatsData.d.ts +0 -0
  252. /package/{types → public/types}/types/WorkflowTasks.d.ts +0 -0
  253. /package/{types → public/types}/types/index.d.ts +0 -0
  254. /package/{types → public/types}/views/ViewsFactory.d.ts +0 -0
  255. /package/{types → public/types}/views/chartBased/DashboardFacet.d.ts +0 -0
  256. /package/{types → public/types}/views/chartBased/EntitiesByTypeViewFacet.d.ts +0 -0
  257. /package/{types → public/types}/views/chartBased/ProfileStatsFacet.d.ts +0 -0
  258. /package/{types → public/types}/views/custom/CustomActionViewFacet.d.ts +0 -0
  259. /package/{types → public/types}/views/custom/NotificationInboxFacet.d.ts +0 -0
  260. /package/{types → public/types}/views/tableBased/ActivitiesViewFacet.d.ts +0 -0
  261. /package/{types → public/types}/views/tableBased/FilteredEntitiesViewFacet.d.ts +0 -0
  262. /package/{types → public/types}/views/tableBased/FilteredSavedSearchesFacet.d.ts +0 -0
  263. /package/{types → public/types}/views/tableBased/helpers.d.ts +0 -0
@@ -0,0 +1,33 @@
1
+ import {ViewStatus} from './../../types';
2
+ import {createReltioLayout, getViewStatus} from '../helpers';
3
+
4
+ describe('helpers tests', () => {
5
+ describe('createReltioLayout tests', () => {
6
+ it('should return Reltio layout for id', () => {
7
+ expect(createReltioLayout('testId')).toEqual({
8
+ x: 0,
9
+ y: Infinity,
10
+ width: 2,
11
+ height: 10,
12
+ minWidth: undefined,
13
+ minHeight: 10,
14
+ maxWidth: undefined,
15
+ maxHeight: undefined,
16
+ id: 'testId',
17
+ isStatic: false
18
+ });
19
+ });
20
+ });
21
+
22
+ describe('getViewStatus tests', () => {
23
+ it('should return ViewStatus.NEW if savedHash is undefined', () => {
24
+ expect(getViewStatus('hash', undefined)).toBe(ViewStatus.NEW);
25
+ });
26
+ it('should return ViewStatus.UPDATED if savedHash !== viewHash', () => {
27
+ expect(getViewStatus('hash', 'myHash')).toBe(ViewStatus.UPDATED);
28
+ });
29
+ it('should return ViewStatus.PERSISTED if savedHash === viewHash', () => {
30
+ expect(getViewStatus('hash', 'hash')).toBe(ViewStatus.PERSISTED);
31
+ });
32
+ });
33
+ });
@@ -0,0 +1,19 @@
1
+ import {ViewStatus} from '../types';
2
+
3
+ export const createReltioLayout = (id: string) => ({
4
+ x: 0,
5
+ y: Infinity,
6
+ width: 2,
7
+ height: 10,
8
+ minWidth: undefined,
9
+ minHeight: 10,
10
+ maxWidth: undefined,
11
+ maxHeight: undefined,
12
+ id,
13
+ isStatic: false
14
+ });
15
+
16
+ export const getViewStatus = (viewHash: string, savedHash?: string) => {
17
+ if (savedHash) return savedHash === viewHash ? ViewStatus.PERSISTED : ViewStatus.UPDATED;
18
+ return ViewStatus.NEW;
19
+ };
@@ -0,0 +1,65 @@
1
+ import React, {useCallback, useMemo} from 'react';
2
+ import {Provider} from 'react-redux';
3
+ import {Store} from 'redux';
4
+
5
+ import {AdapterMoment} from '@mui/x-date-pickers/AdapterMoment';
6
+ import createGenerateClassName from '@mui/styles/createGenerateClassName';
7
+ import StylesProvider from '@mui/styles/StylesProvider';
8
+ import ReactResizeDetector from 'react-resize-detector';
9
+
10
+ import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider';
11
+ import {ErrorPopup, ReloadFacetProvider, SearchFiltersContext, ViewIdContext} from '@reltio/components';
12
+ import {promisifyCallback, convertOldDashboardConfig, DashboardPerspectiveConfig} from '@reltio/mdm-sdk';
13
+ import DashboardPerspectiveView from './DashboardPerspectiveView';
14
+ import {DashboardPerspectiveLegacyConfig} from '../types/DashboardPerspectiveConfig';
15
+ import {DashboardSavedState} from '../types/DashboardSavedState';
16
+
17
+ const generateClassName = createGenerateClassName({
18
+ productionPrefix: 'dashboardPerspective',
19
+ disableGlobal: true,
20
+ seed: 'clD'
21
+ });
22
+
23
+ type Props = {
24
+ config: DashboardPerspectiveConfig | DashboardPerspectiveLegacyConfig;
25
+ store: Store<unknown>;
26
+ onResize?: (width: number, height: number) => void;
27
+ saveState: (state: DashboardSavedState) => void;
28
+ getSavedState: (clb: (state: DashboardSavedState) => void) => void;
29
+ };
30
+ const emptyArray = [];
31
+ const DashboardPerspective = ({config, store, onResize, saveState, getSavedState}: Props) => {
32
+ const getSavedStatePromisified: () => Promise<DashboardSavedState> = useCallback(promisifyCallback(getSavedState), [
33
+ getSavedState
34
+ ]);
35
+ const processedConfig = useMemo(() => convertOldDashboardConfig(config), [config]);
36
+
37
+ return (
38
+ <Provider store={store}>
39
+ <ViewIdContext.Provider value={processedConfig.id}>
40
+ <StylesProvider generateClassName={generateClassName}>
41
+ <LocalizationProvider dateAdapter={AdapterMoment}>
42
+ <SearchFiltersContext.Provider value={emptyArray}>
43
+ <ReloadFacetProvider>
44
+ <ReactResizeDetector
45
+ handleHeight
46
+ onResize={(width, height) => onResize?.(Math.floor(width), Math.floor(height))}
47
+ />
48
+ {processedConfig && (
49
+ <DashboardPerspectiveView
50
+ config={processedConfig}
51
+ saveState={saveState}
52
+ getSavedState={getSavedStatePromisified}
53
+ />
54
+ )}
55
+ <ErrorPopup />
56
+ </ReloadFacetProvider>
57
+ </SearchFiltersContext.Provider>
58
+ </LocalizationProvider>
59
+ </StylesProvider>
60
+ </ViewIdContext.Provider>
61
+ </Provider>
62
+ );
63
+ };
64
+
65
+ export {DashboardPerspective};
@@ -0,0 +1,16 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles({
4
+ perspectiveView: {
5
+ position: 'absolute',
6
+ top: 0,
7
+ left: 0,
8
+ right: 0,
9
+ bottom: 0,
10
+ overflowX: 'hidden',
11
+ overflowY: 'auto',
12
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
13
+ display: 'flex',
14
+ flexDirection: 'column'
15
+ }
16
+ });
@@ -0,0 +1,42 @@
1
+ import {DashboardConfigFilter, FilterOptions} from '@reltio/mdm-sdk';
2
+ import {getFiltersForFacet} from '../facets';
3
+
4
+ describe('facets tests', () => {
5
+ it('should work correctly getFilersForFacet', () => {
6
+ const attributeUri = 'configuration/entityTypes/Individual/attributes/Status';
7
+ const entityTypeUri = 'configuration/entityTypes/Individual';
8
+ const filters: DashboardConfigFilter[] = [
9
+ {
10
+ filter: FilterOptions.EQUALS,
11
+ fieldName: 'type',
12
+ values: [entityTypeUri]
13
+ },
14
+ {
15
+ filter: FilterOptions.EQUALS,
16
+ fieldName: 'test',
17
+ values: ['test']
18
+ }
19
+ ];
20
+
21
+ expect(getFiltersForFacet(attributeUri, filters)).toEqual([
22
+ {
23
+ filter: FilterOptions.EQUALS,
24
+ fieldName: 'type',
25
+ values: [entityTypeUri]
26
+ },
27
+ {
28
+ filter: FilterOptions.EQUALS,
29
+ fieldName: 'test',
30
+ values: ['test']
31
+ }
32
+ ]);
33
+
34
+ expect(getFiltersForFacet(attributeUri, [])).toEqual([
35
+ {
36
+ filter: FilterOptions.EQUALS,
37
+ fieldName: 'type',
38
+ values: [entityTypeUri]
39
+ }
40
+ ]);
41
+ });
42
+ });
@@ -0,0 +1,60 @@
1
+ import {buildQuery} from '../filters';
2
+
3
+ describe('filters tests', () => {
4
+ const filters = [
5
+ {
6
+ filter: 'equals',
7
+ fieldName: 'type',
8
+ values: ['HCP']
9
+ }
10
+ ];
11
+
12
+ it('should work with empty filters', () => {
13
+ const query = buildQuery([], undefined, false, undefined);
14
+ expect(query).toBe('');
15
+ });
16
+
17
+ it('should work with simple filters', () => {
18
+ const query = buildQuery(filters);
19
+ expect(query).toBe("filter=equals(type,'HCP')");
20
+ });
21
+
22
+ it('should work with range filters', () => {
23
+ const filters = [
24
+ {
25
+ fieldName: 'attributes.Int',
26
+ filter: 'range',
27
+ values: ['1', '2']
28
+ }
29
+ ];
30
+ const query = buildQuery(filters);
31
+ expect(query).toBe('filter=range(attributes.Int,1,2)');
32
+ });
33
+
34
+ it('should work with hasAll filters', () => {
35
+ const filters = [
36
+ {
37
+ fieldName: 'attributes.Int',
38
+ filter: 'hasAll',
39
+ values: ['1', '2']
40
+ }
41
+ ];
42
+ const query = buildQuery(filters);
43
+ expect(query).toBe("filter=equals(attributes.Int,'1') and equals(attributes.Int,'2')");
44
+ });
45
+
46
+ it('should support globalFilter', () => {
47
+ const query = buildQuery(filters, 'globalFilter', false, undefined);
48
+ expect(query).toBe("filter=(equals(type,'HCP')) and (globalFilter)");
49
+ });
50
+
51
+ it('should support searchByOv', () => {
52
+ const query = buildQuery(filters, undefined, true, undefined);
53
+ expect(query).toBe("filter=equals(type,'HCP')&options=searchByOv");
54
+ });
55
+
56
+ it('should support activityFilter', () => {
57
+ const query = buildQuery(filters, undefined, false, 'active');
58
+ expect(query).toBe("filter=equals(type,'HCP')&activeness=active");
59
+ });
60
+ });
@@ -0,0 +1,33 @@
1
+ import {DateRangeValue} from '@reltio/mdm-sdk';
2
+
3
+ import {getDashboardDateRangeByValue} from '../period';
4
+
5
+ describe('getDashboardDateRangeByValue', () => {
6
+ const currentTime = new Date('06-06-2022').getTime();
7
+ beforeAll(() => {
8
+ jest.spyOn(Date, 'now').mockReturnValue(currentTime);
9
+ });
10
+
11
+ it('should work with all actual date range placeholder', () => {
12
+ expect(getDashboardDateRangeByValue(DateRangeValue.LAST_DAY)).toEqual([
13
+ new Date('06-05-2022').getTime(),
14
+ currentTime
15
+ ]);
16
+ expect(getDashboardDateRangeByValue(DateRangeValue.LAST_WEEK)).toEqual([
17
+ new Date('05-31-2022').getTime(),
18
+ currentTime
19
+ ]);
20
+ expect(getDashboardDateRangeByValue(DateRangeValue.LAST_MONTH)).toEqual([
21
+ new Date('05-06-2022').getTime(),
22
+ currentTime
23
+ ]);
24
+ expect(getDashboardDateRangeByValue(DateRangeValue.LAST_6MONTHS)).toEqual([
25
+ new Date('12-06-2021').getTime(),
26
+ currentTime
27
+ ]);
28
+ expect(getDashboardDateRangeByValue(DateRangeValue.LAST_YEAR)).toEqual([
29
+ new Date('06-06-2021').getTime(),
30
+ currentTime
31
+ ]);
32
+ });
33
+ });
@@ -0,0 +1,319 @@
1
+ import {calibrateStatsData, getChartDomain} from '../stats';
2
+ import {PeriodStep} from '../../types/PeriodStep';
3
+ import moment from 'moment';
4
+
5
+ describe('stats services tests', () => {
6
+ describe('calibrateStatsData', () => {
7
+ it('should group data by period step', () => {
8
+ const statsData = [
9
+ {
10
+ total: 157,
11
+ event: 'created',
12
+ data: [
13
+ {
14
+ term: '2021-04-05T08',
15
+ count: 115
16
+ },
17
+ {
18
+ term: '2021-04-05T09',
19
+ count: 41
20
+ },
21
+ {
22
+ term: '2021-04-05T10',
23
+ count: 0
24
+ },
25
+ {
26
+ term: '2021-04-05T11',
27
+ count: 0
28
+ },
29
+ {
30
+ term: '2021-04-05T12',
31
+ count: 0
32
+ },
33
+ {
34
+ term: '2021-04-05T13',
35
+ count: 0
36
+ },
37
+ {
38
+ term: '2021-04-05T14',
39
+ count: 0
40
+ },
41
+ {
42
+ term: '2021-04-05T15',
43
+ count: 0
44
+ },
45
+ {
46
+ term: '2021-04-05T16',
47
+ count: 0
48
+ },
49
+ {
50
+ term: '2021-04-05T17',
51
+ count: 0
52
+ },
53
+ {
54
+ term: '2021-04-05T18',
55
+ count: 0
56
+ },
57
+ {
58
+ term: '2021-04-05T19',
59
+ count: 0
60
+ },
61
+ {
62
+ term: '2021-04-05T20',
63
+ count: 0
64
+ },
65
+ {
66
+ term: '2021-04-05T21',
67
+ count: 0
68
+ },
69
+ {
70
+ term: '2021-04-05T22',
71
+ count: 0
72
+ },
73
+ {
74
+ term: '2021-04-05T23',
75
+ count: 0
76
+ },
77
+ {
78
+ term: '2021-04-06T00',
79
+ count: 0
80
+ },
81
+ {
82
+ term: '2021-04-06T01',
83
+ count: 1
84
+ }
85
+ ]
86
+ }
87
+ ];
88
+ const result = [
89
+ {
90
+ total: 157,
91
+ event: 'created',
92
+ data: [
93
+ {
94
+ term: moment('2021-04-05T00').valueOf(),
95
+ count: 156
96
+ },
97
+ {
98
+ term: moment('2021-04-06T00').valueOf(),
99
+ count: 1
100
+ }
101
+ ]
102
+ }
103
+ ];
104
+ expect(calibrateStatsData(PeriodStep.DAY, statsData)).toEqual(result);
105
+ });
106
+
107
+ it('should interpolate data', () => {
108
+ const statsData = [
109
+ {
110
+ total: 157,
111
+ event: 'created',
112
+ data: [
113
+ {
114
+ term: '2021-04-05T08',
115
+ count: 115
116
+ },
117
+ {
118
+ term: '2021-04-05T09',
119
+ count: 41
120
+ },
121
+ {
122
+ term: '2021-04-06T01',
123
+ count: 1
124
+ }
125
+ ]
126
+ }
127
+ ];
128
+ const result = [
129
+ {
130
+ total: 157,
131
+ event: 'created',
132
+ data: [
133
+ {
134
+ term: moment('2021-04-05T08').valueOf(),
135
+ count: 115
136
+ },
137
+ {
138
+ term: moment('2021-04-05T09').valueOf(),
139
+ count: 41
140
+ },
141
+ {
142
+ term: moment('2021-04-05T10').valueOf(),
143
+ count: 0
144
+ },
145
+ {
146
+ term: moment('2021-04-05T11').valueOf(),
147
+ count: 0
148
+ },
149
+ {
150
+ term: moment('2021-04-05T12').valueOf(),
151
+ count: 0
152
+ },
153
+ {
154
+ term: moment('2021-04-05T13').valueOf(),
155
+ count: 0
156
+ },
157
+ {
158
+ term: moment('2021-04-05T14').valueOf(),
159
+ count: 0
160
+ },
161
+ {
162
+ term: moment('2021-04-05T15').valueOf(),
163
+ count: 0
164
+ },
165
+ {
166
+ term: moment('2021-04-05T16').valueOf(),
167
+ count: 0
168
+ },
169
+ {
170
+ term: moment('2021-04-05T17').valueOf(),
171
+ count: 0
172
+ },
173
+ {
174
+ term: moment('2021-04-05T18').valueOf(),
175
+ count: 0
176
+ },
177
+ {
178
+ term: moment('2021-04-05T19').valueOf(),
179
+ count: 0
180
+ },
181
+ {
182
+ term: moment('2021-04-05T20').valueOf(),
183
+ count: 0
184
+ },
185
+ {
186
+ term: moment('2021-04-05T21').valueOf(),
187
+ count: 0
188
+ },
189
+ {
190
+ term: moment('2021-04-05T22').valueOf(),
191
+ count: 0
192
+ },
193
+ {
194
+ term: moment('2021-04-05T23').valueOf(),
195
+ count: 0
196
+ },
197
+ {
198
+ term: moment('2021-04-06T00').valueOf(),
199
+ count: 0
200
+ },
201
+ {
202
+ term: moment('2021-04-06T01').valueOf(),
203
+ count: 1
204
+ }
205
+ ]
206
+ }
207
+ ];
208
+ expect(calibrateStatsData(PeriodStep.HOUR, statsData)).toEqual(result);
209
+ });
210
+
211
+ it('should interpolate data correctly even for interval including moment of changing the clocks in summer/winter time', () => {
212
+ const statsData = [
213
+ {
214
+ total: 2,
215
+ event: 'created',
216
+ data: [
217
+ {
218
+ term: '2022-10-30T08',
219
+ count: 0
220
+ },
221
+ {
222
+ term: '2022-10-30T09',
223
+ count: 1
224
+ },
225
+ {
226
+ term: '2022-11-01T02',
227
+ count: 1
228
+ }
229
+ ]
230
+ }
231
+ ];
232
+ const result = [
233
+ {
234
+ total: 2,
235
+ event: 'created',
236
+ data: [
237
+ {
238
+ term: moment('2022-10-30T00').valueOf(),
239
+ count: 1
240
+ },
241
+ {
242
+ term: moment('2022-10-31T00').valueOf(),
243
+ count: 0
244
+ },
245
+ {
246
+ term: moment('2022-11-01T00').valueOf(),
247
+ count: 1
248
+ }
249
+ ]
250
+ }
251
+ ];
252
+ expect(calibrateStatsData(PeriodStep.DAY, statsData)).toEqual(result);
253
+ });
254
+ });
255
+
256
+ describe('getChartDomain', () => {
257
+ const tickCount = 8;
258
+ it('should return correct domain if difference between min and max count > tickCount', () => {
259
+ const statsData = [
260
+ {
261
+ event: 'event',
262
+ total: 1,
263
+ data: [
264
+ {term: 'term', count: 0},
265
+ {term: 'term', count: 1}
266
+ ]
267
+ },
268
+ {
269
+ event: 'event2',
270
+ total: 108,
271
+ data: [
272
+ {term: 'term', count: 107},
273
+ {term: 'term', count: 1}
274
+ ]
275
+ }
276
+ ];
277
+
278
+ expect(getChartDomain(statsData, tickCount)).toEqual([0, 'auto']);
279
+ });
280
+
281
+ it('should return correct domain if difference between min and max count < tickCount', () => {
282
+ const statsData = [
283
+ {
284
+ event: 'event',
285
+ total: 7,
286
+ data: [
287
+ {term: 'term', count: 5},
288
+ {term: 'term', count: 2}
289
+ ]
290
+ },
291
+ {
292
+ event: 'event2',
293
+ total: 3,
294
+ data: [
295
+ {term: 'term', count: 2},
296
+ {term: 'term', count: 1}
297
+ ]
298
+ }
299
+ ];
300
+
301
+ expect(getChartDomain(statsData, tickCount)).toEqual([0, tickCount - 1]);
302
+ });
303
+
304
+ it('should return correct domain if difference between min and max count === tickCount', () => {
305
+ const statsData = [
306
+ {
307
+ event: 'event',
308
+ total: 8,
309
+ data: [
310
+ {term: 'term', count: 8},
311
+ {term: 'term', count: 0}
312
+ ]
313
+ }
314
+ ];
315
+
316
+ expect(getChartDomain(statsData, tickCount)).toEqual([0, 'auto']);
317
+ });
318
+ });
319
+ });
@@ -0,0 +1,66 @@
1
+ import {
2
+ getEntityType,
3
+ getInheritancePath,
4
+ getLastUriPart,
5
+ isAvailableEntityType,
6
+ Metadata,
7
+ wrapInArrayIfNeeded
8
+ } from '@reltio/mdm-sdk';
9
+ import {curry, filter, last, map, pipe, prop, either} from 'ramda';
10
+ import {ChartData} from '@reltio/components';
11
+ import {createEntityTypeFilter} from './filters';
12
+
13
+ const typeNameToUri = (typeName: string): string => `configuration/entityTypes/${typeName}`;
14
+ const getUriFromTypeFacet = pipe(prop('group'), typeNameToUri);
15
+
16
+ export const resolveTypeFacetsLabels = curry((metadata: Metadata, typeFacets: ChartData[]): ChartData[] => {
17
+ return typeFacets.map((facet) => {
18
+ const typeUri = getUriFromTypeFacet(facet);
19
+ return {
20
+ ...facet,
21
+ label: getEntityType(metadata, typeUri).label
22
+ };
23
+ });
24
+ });
25
+
26
+ export const getParentEntityTypeFacets = curry((metadata: Metadata, typeFacets: ChartData[]): ChartData[] => {
27
+ const getParentTypeForFacet = pipe(
28
+ getUriFromTypeFacet,
29
+ getInheritancePath(metadata),
30
+ map(getEntityType(metadata)),
31
+ filter(isAvailableEntityType),
32
+ last
33
+ );
34
+ const parentsMap = typeFacets.reduce((acc, facet) => {
35
+ const parentType = getParentTypeForFacet(facet);
36
+ if (parentType) {
37
+ const parentName = getLastUriPart(parentType.uri);
38
+ return {
39
+ ...acc,
40
+ [parentName]: (acc[parentName] || 0) + facet.value
41
+ };
42
+ } else {
43
+ return acc;
44
+ }
45
+ }, {});
46
+ return Object.entries(parentsMap).map(([key, value]) => ({
47
+ group: key,
48
+ label: key,
49
+ value
50
+ })) as ChartData[];
51
+ });
52
+
53
+ export const entityTypeNameToFilters = pipe(typeNameToUri, createEntityTypeFilter, wrapInArrayIfNeeded);
54
+
55
+ const getEntityTypeName = pipe(prop('uri'), getLastUriPart);
56
+
57
+ const findTypeFacetByName = curry((typeFacets: ChartData[], name: string): ChartData => {
58
+ return typeFacets.find((facet) => facet.group === name);
59
+ });
60
+
61
+ const createEmptyEntityTypeFacet = (name: string): ChartData => ({label: name, group: name, value: 0});
62
+
63
+ export const addEmptyEntityTypesFacets = curry(({entityTypes}: Metadata, typeFacets: ChartData[]): ChartData[] => {
64
+ const getFacet = pipe(getEntityTypeName, either(findTypeFacetByName(typeFacets), createEmptyEntityTypeFacet));
65
+ return entityTypes.filter(isAvailableEntityType).map(getFacet);
66
+ });