@reltio/dashboard 1.4.1585 → 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.
- package/.DS_Store +0 -0
- package/index.ts +12 -0
- package/package.json +42 -25
- package/public/bundle.js +205 -0
- package/public/bundle.js.LICENSE.txt +59 -0
- package/public/package.json +26 -0
- package/public/types/components/DashboardConfigItem/styles.d.ts +1 -0
- package/{types → public/types}/components/DashboardError/styles.d.ts +1 -1
- package/public/types/components/DashboardLayout/styles.d.ts +1 -0
- package/public/types/components/DashboardLayoutItem/styles.d.ts +1 -0
- package/public/types/components/DashboardLayoutPanel/styles.d.ts +1 -0
- package/public/types/components/DashboardLinearLoader/styles.d.ts +1 -0
- package/{types → public/types}/components/DashboardNoData/styles.d.ts +1 -1
- package/public/types/components/DashboardPerspectiveHeader/styles.d.ts +2 -0
- package/{types → public/types}/components/DashboardPopupMenu/DashboardPopupMenu.d.ts +1 -1
- package/public/types/components/DashboardPopupMenu/styles.d.ts +1 -0
- package/public/types/components/EntityTable/cell-renderers/styles.d.ts +1 -0
- package/{types → public/types}/components/EntityTable/styles.d.ts +1 -1
- package/public/types/components/LayoutItemContent/styles.d.ts +1 -0
- package/public/types/components/LayoutItemHeader/styles.d.ts +1 -0
- package/public/types/components/LayoutItemView/styles.d.ts +1 -0
- package/public/types/components/StatsChart/customized/styles.d.ts +1 -0
- package/public/types/components/WorkflowTaskItem/styles.d.ts +1 -0
- package/public/types/perspective/styles.d.ts +1 -0
- package/public/types/views/chartBased/styles.d.ts +1 -0
- package/public/types/views/custom/styles.d.ts +1 -0
- package/public/types/views/tableBased/styles.d.ts +1 -0
- package/scripts/build/index.js +21 -0
- package/src/HOCs/withPagination.tsx +39 -0
- package/src/components/DashboardConfigItem/DashboardConfigItem.tsx +101 -0
- package/src/components/DashboardConfigItem/__tests__/DashboardConfigItem.specs.tsx +81 -0
- package/src/components/DashboardConfigItem/icons/barChart.svg +12 -0
- package/src/components/DashboardConfigItem/icons/bubbleChart.svg +18 -0
- package/src/components/DashboardConfigItem/icons/customChart.svg +66 -0
- package/src/components/DashboardConfigItem/icons/donutChart.svg +33 -0
- package/src/components/DashboardConfigItem/icons/geomap.svg +23 -0
- package/src/components/DashboardConfigItem/icons/lineChart.svg +16 -0
- package/src/components/DashboardConfigItem/icons/pieChart.svg +27 -0
- package/src/components/DashboardConfigItem/icons/tableWithBars.svg +27 -0
- package/src/components/DashboardConfigItem/icons/treemap.svg +15 -0
- package/src/components/DashboardConfigItem/icons/wordCloud.svg +27 -0
- package/src/components/DashboardConfigItem/styles.ts +56 -0
- package/src/components/DashboardError/DashboardError.tsx +34 -0
- package/src/components/DashboardError/__tests__/DashboardError.test.js +34 -0
- package/src/components/DashboardError/icons/error.svg +113 -0
- package/src/components/DashboardError/styles.ts +30 -0
- package/src/components/DashboardLayout/DashboardLayout.tsx +59 -0
- package/src/components/DashboardLayout/__tests__/DashboardLayout.specs.tsx +56 -0
- package/src/components/DashboardLayout/styles.ts +30 -0
- package/src/components/DashboardLayoutItem/DashboardLayoutItem.tsx +59 -0
- package/src/components/DashboardLayoutItem/__tests__/DashboardLayoutItem.specs.tsx +145 -0
- package/src/components/DashboardLayoutItem/styles.ts +10 -0
- package/src/components/DashboardLayoutPanel/DashboardLayoutPanel.tsx +59 -0
- package/src/components/DashboardLayoutPanel/__tests__/DashboardLayoutPanel.specs.tsx +58 -0
- package/src/components/DashboardLayoutPanel/styles.ts +43 -0
- package/src/components/DashboardLinearLoader/DashboardLinearLoader.tsx +10 -0
- package/src/components/DashboardLinearLoader/__tests__/DashboardLinearLoader.test.js +12 -0
- package/src/components/DashboardLinearLoader/styles.ts +11 -0
- package/src/components/DashboardNoData/.DS_Store +0 -0
- package/src/components/DashboardNoData/DashboardNoData.tsx +21 -0
- package/src/components/DashboardNoData/__tests__/DashboardNoData.test.js +15 -0
- package/src/components/DashboardNoData/icons/noData.svg +68 -0
- package/src/components/DashboardNoData/styles.ts +21 -0
- package/src/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.tsx +43 -0
- package/src/components/DashboardPerspectiveHeader/__tests__/DashboardPerspectiveHeader.specs.tsx +41 -0
- package/src/components/DashboardPerspectiveHeader/styles.ts +24 -0
- package/src/components/DashboardPopupMenu/DashboardPopupMenu.tsx +75 -0
- package/src/components/DashboardPopupMenu/__tests__/DashboardPopupMenu.test.tsx +51 -0
- package/src/components/DashboardPopupMenu/styles.ts +20 -0
- package/src/components/EntityTable/EntityTable.tsx +49 -0
- package/src/components/EntityTable/__tests__/EntityTable.test.tsx +33 -0
- package/src/components/EntityTable/cell-renderers/EntityLabelRenderer.tsx +24 -0
- package/src/components/EntityTable/cell-renderers/HeadCellRenderer.tsx +34 -0
- package/src/components/EntityTable/cell-renderers/__tests__/EntityLabelRenderer.test.tsx +25 -0
- package/src/components/EntityTable/cell-renderers/styles.ts +46 -0
- package/src/components/EntityTable/styles.ts +19 -0
- package/src/components/LayoutItemContent/LayoutItemContent.tsx +63 -0
- package/src/components/LayoutItemContent/__tests__/LayoutItemContent.test.tsx +71 -0
- package/src/components/LayoutItemContent/styles.ts +36 -0
- package/src/components/LayoutItemHeader/LayoutItemHeader.tsx +86 -0
- package/src/components/LayoutItemHeader/__tests__/LayoutItemHeader.specs.tsx +48 -0
- package/src/components/LayoutItemHeader/styles.ts +44 -0
- package/src/components/LayoutItemView/LayoutItemView.tsx +24 -0
- package/src/components/LayoutItemView/styles.ts +11 -0
- package/src/components/StatsChart/StatsChart.tsx +77 -0
- package/src/components/StatsChart/__tests__/StatsChart.test.tsx +106 -0
- package/src/components/StatsChart/customized/CustomAxisTick.tsx +28 -0
- package/src/components/StatsChart/customized/CustomLegend.tsx +37 -0
- package/src/components/StatsChart/customized/CustomTooltip.tsx +41 -0
- package/src/components/StatsChart/customized/styles.ts +53 -0
- package/src/components/StatsChart/getStatsChartSettings.ts +65 -0
- package/src/components/WorkflowTaskItem/WorkflowTaskItem.tsx +67 -0
- package/src/components/WorkflowTaskItem/WorkflowTaskObject.tsx +54 -0
- package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskItem.test.tsx +73 -0
- package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskObject.test.tsx +95 -0
- package/src/components/WorkflowTaskItem/styles.ts +74 -0
- package/src/components/WorkflowTasksList/WorkflowTasksList.tsx +34 -0
- package/src/components/WorkflowTasksList/__tests__/WorkflowTasksList.test.tsx +98 -0
- package/src/components/index.ts +8 -0
- package/src/contexts/DashboardViewIdContext/index.ts +5 -0
- package/src/hooks/__tests__/useActivititesRequest.specs.tsx +106 -0
- package/src/hooks/__tests__/useEntityByTypeRequest.specs.tsx +280 -0
- package/src/hooks/__tests__/useFacetRequest.specs.tsx +437 -0
- package/src/hooks/__tests__/useFilteredEntitiesRequest.specs.tsx +103 -0
- package/src/hooks/__tests__/useSavedSearchesRequest.specs.tsx +201 -0
- package/src/hooks/__tests__/useStatsRequest.specs.tsx +212 -0
- package/src/hooks/__tests__/useWorkflowTasksRequest.specs.tsx +388 -0
- package/src/hooks/useActivitiesRequest.ts +50 -0
- package/src/hooks/useEntityByTypeRequest.ts +67 -0
- package/src/hooks/useFacetRequest.ts +117 -0
- package/src/hooks/useFilteredEntitiesRequest.ts +57 -0
- package/src/hooks/useSavedSearchesRequest.ts +82 -0
- package/src/hooks/useStatsRequest.ts +47 -0
- package/src/hooks/useWorkflowTasksRequest.ts +66 -0
- package/src/index.ts +25 -0
- package/src/perspective/DashboardPerspectiveView.tsx +132 -0
- package/src/perspective/__tests__/DashboardPerspectiveView.specs.tsx +276 -0
- package/src/perspective/__tests__/data/metadata.data.ts +33 -0
- package/src/perspective/__tests__/data/store.data.ts +15 -0
- package/src/perspective/__tests__/helpers.specs.ts +33 -0
- package/src/perspective/helpers.ts +19 -0
- package/src/perspective/index.tsx +65 -0
- package/src/perspective/styles.ts +16 -0
- package/src/services/__tests__/facets.specs.ts +42 -0
- package/src/services/__tests__/filters.specs.ts +60 -0
- package/src/services/__tests__/period.test.ts +33 -0
- package/src/services/__tests__/stats.test.ts +319 -0
- package/src/services/entityTypes.ts +66 -0
- package/src/services/facets.ts +178 -0
- package/src/services/filters.ts +87 -0
- package/src/services/period.ts +33 -0
- package/src/services/savedSearches.ts +20 -0
- package/src/services/stats.ts +191 -0
- package/src/services/workflowTasks.ts +116 -0
- package/src/types/ActivitiesViewFacetConfig.ts +5 -0
- package/src/types/CustomActionViewFacetConfig.ts +5 -0
- package/src/types/DashboardPerspectiveConfig.ts +18 -0
- package/src/types/DashboardSavedState.ts +7 -0
- package/src/types/EntityByTypeViewFacetConfig.ts +7 -0
- package/src/types/EntityData.ts +4 -0
- package/src/types/FilteredEntitiesFacetConfig.ts +6 -0
- package/src/types/FilteredSavedSearchesFacetConfig.ts +6 -0
- package/src/types/PeriodStep.ts +4 -0
- package/src/types/SavedSearchData.ts +6 -0
- package/src/types/SearchOptions.ts +10 -0
- package/src/types/StatsData.ts +14 -0
- package/src/types/WorkflowTasks.ts +26 -0
- package/src/types/index.ts +14 -0
- package/src/views/ViewsFactory.tsx +79 -0
- package/src/views/__tests__/ViewsFactory.specs.tsx +70 -0
- package/src/views/chartBased/DashboardFacet.tsx +71 -0
- package/src/views/chartBased/EntitiesByTypeViewFacet.tsx +60 -0
- package/src/views/chartBased/ProfileStatsFacet.tsx +54 -0
- package/src/views/chartBased/__tests__/DashboardFacet.specs.tsx +358 -0
- package/src/views/chartBased/__tests__/EntitiesByTypeViewFacet.specs.tsx +101 -0
- package/src/views/chartBased/__tests__/ProfileStatsFacet.specs.tsx +106 -0
- package/src/views/chartBased/styles.ts +13 -0
- package/src/views/custom/CustomActionViewFacet.tsx +36 -0
- package/src/views/custom/NotificationInboxFacet.tsx +86 -0
- package/src/views/custom/__tests__/CustomActionViewFacet.specs.tsx +35 -0
- package/src/views/custom/__tests__/NotificationInboxFacet.specs.tsx +144 -0
- package/src/views/custom/styles.ts +31 -0
- package/src/views/tableBased/ActivitiesViewFacet.tsx +79 -0
- package/src/views/tableBased/FilteredEntitiesViewFacet.tsx +67 -0
- package/src/views/tableBased/FilteredSavedSearchesFacet.tsx +85 -0
- package/src/views/tableBased/__tests__/ActivitiesViewFacet.specs.tsx +113 -0
- package/src/views/tableBased/__tests__/FIlteredEntitiesViewFacet.specs.tsx +90 -0
- package/src/views/tableBased/__tests__/FilteredSavedSearchesFacet.specs.tsx +133 -0
- package/src/views/tableBased/helpers.ts +8 -0
- package/src/views/tableBased/styles.ts +7 -0
- package/stories/Dashboards.stories.js +118 -0
- package/stories/utils/dashboardPerspectiveConfig.js +78 -0
- package/stories/utils/dashboardsViewConfig.js +17 -0
- package/stories/utils/mdmStore.js +73 -0
- package/stories/utils/responses.js +10 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +10 -0
- package/bundle.js +0 -2
- package/bundle.js.LICENSE.txt +0 -22
- package/types/components/DashboardConfigItem/styles.d.ts +0 -1
- package/types/components/DashboardLayout/styles.d.ts +0 -1
- package/types/components/DashboardLayoutItem/styles.d.ts +0 -1
- package/types/components/DashboardLayoutPanel/styles.d.ts +0 -1
- package/types/components/DashboardLinearLoader/styles.d.ts +0 -1
- package/types/components/DashboardPerspectiveHeader/styles.d.ts +0 -2
- package/types/components/DashboardPopupMenu/styles.d.ts +0 -1
- package/types/components/EntityTable/cell-renderers/styles.d.ts +0 -1
- package/types/components/LayoutItemContent/styles.d.ts +0 -1
- package/types/components/LayoutItemHeader/styles.d.ts +0 -1
- package/types/components/LayoutItemView/styles.d.ts +0 -1
- package/types/components/StatsChart/customized/styles.d.ts +0 -1
- package/types/components/WorkflowTaskItem/styles.d.ts +0 -1
- package/types/perspective/styles.d.ts +0 -1
- package/types/views/chartBased/styles.d.ts +0 -1
- package/types/views/custom/styles.d.ts +0 -1
- package/types/views/tableBased/styles.d.ts +0 -1
- /package/{types → public/types}/HOCs/withPagination.d.ts +0 -0
- /package/{types → public/types}/components/DashboardConfigItem/DashboardConfigItem.d.ts +0 -0
- /package/{types → public/types}/components/DashboardError/DashboardError.d.ts +0 -0
- /package/{types → public/types}/components/DashboardLayout/DashboardLayout.d.ts +0 -0
- /package/{types → public/types}/components/DashboardLayoutItem/DashboardLayoutItem.d.ts +0 -0
- /package/{types → public/types}/components/DashboardLayoutPanel/DashboardLayoutPanel.d.ts +0 -0
- /package/{types → public/types}/components/DashboardLinearLoader/DashboardLinearLoader.d.ts +0 -0
- /package/{types → public/types}/components/DashboardNoData/DashboardNoData.d.ts +0 -0
- /package/{types → public/types}/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.d.ts +0 -0
- /package/{types → public/types}/components/EntityTable/EntityTable.d.ts +0 -0
- /package/{types → public/types}/components/EntityTable/cell-renderers/EntityLabelRenderer.d.ts +0 -0
- /package/{types → public/types}/components/EntityTable/cell-renderers/HeadCellRenderer.d.ts +0 -0
- /package/{types → public/types}/components/LayoutItemContent/LayoutItemContent.d.ts +0 -0
- /package/{types → public/types}/components/LayoutItemHeader/LayoutItemHeader.d.ts +0 -0
- /package/{types → public/types}/components/LayoutItemView/LayoutItemView.d.ts +0 -0
- /package/{types → public/types}/components/StatsChart/StatsChart.d.ts +0 -0
- /package/{types → public/types}/components/StatsChart/customized/CustomAxisTick.d.ts +0 -0
- /package/{types → public/types}/components/StatsChart/customized/CustomLegend.d.ts +0 -0
- /package/{types → public/types}/components/StatsChart/customized/CustomTooltip.d.ts +0 -0
- /package/{types → public/types}/components/StatsChart/getStatsChartSettings.d.ts +0 -0
- /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskItem.d.ts +0 -0
- /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskObject.d.ts +0 -0
- /package/{types → public/types}/components/WorkflowTasksList/WorkflowTasksList.d.ts +0 -0
- /package/{types → public/types}/components/index.d.ts +0 -0
- /package/{types → public/types}/contexts/DashboardViewIdContext/index.d.ts +0 -0
- /package/{types → public/types}/hooks/useActivitiesRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useEntityByTypeRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useFacetRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useFilteredEntitiesRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useSavedSearchesRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useStatsRequest.d.ts +0 -0
- /package/{types → public/types}/hooks/useWorkflowTasksRequest.d.ts +0 -0
- /package/{types → public/types}/index.d.ts +0 -0
- /package/{types → public/types}/perspective/DashboardPerspectiveView.d.ts +0 -0
- /package/{types → public/types}/perspective/helpers.d.ts +0 -0
- /package/{types → public/types}/perspective/index.d.ts +0 -0
- /package/{types → public/types}/services/entityTypes.d.ts +0 -0
- /package/{types → public/types}/services/facets.d.ts +0 -0
- /package/{types → public/types}/services/filters.d.ts +0 -0
- /package/{types → public/types}/services/period.d.ts +0 -0
- /package/{types → public/types}/services/savedSearches.d.ts +0 -0
- /package/{types → public/types}/services/stats.d.ts +0 -0
- /package/{types → public/types}/services/workflowTasks.d.ts +0 -0
- /package/{types → public/types}/types/ActivitiesViewFacetConfig.d.ts +0 -0
- /package/{types → public/types}/types/CustomActionViewFacetConfig.d.ts +0 -0
- /package/{types → public/types}/types/DashboardPerspectiveConfig.d.ts +0 -0
- /package/{types → public/types}/types/DashboardSavedState.d.ts +0 -0
- /package/{types → public/types}/types/EntityByTypeViewFacetConfig.d.ts +0 -0
- /package/{types → public/types}/types/EntityData.d.ts +0 -0
- /package/{types → public/types}/types/FilteredEntitiesFacetConfig.d.ts +0 -0
- /package/{types → public/types}/types/FilteredSavedSearchesFacetConfig.d.ts +0 -0
- /package/{types → public/types}/types/PeriodStep.d.ts +0 -0
- /package/{types → public/types}/types/SavedSearchData.d.ts +0 -0
- /package/{types → public/types}/types/SearchOptions.d.ts +0 -0
- /package/{types → public/types}/types/StatsData.d.ts +0 -0
- /package/{types → public/types}/types/WorkflowTasks.d.ts +0 -0
- /package/{types → public/types}/types/index.d.ts +0 -0
- /package/{types → public/types}/views/ViewsFactory.d.ts +0 -0
- /package/{types → public/types}/views/chartBased/DashboardFacet.d.ts +0 -0
- /package/{types → public/types}/views/chartBased/EntitiesByTypeViewFacet.d.ts +0 -0
- /package/{types → public/types}/views/chartBased/ProfileStatsFacet.d.ts +0 -0
- /package/{types → public/types}/views/custom/CustomActionViewFacet.d.ts +0 -0
- /package/{types → public/types}/views/custom/NotificationInboxFacet.d.ts +0 -0
- /package/{types → public/types}/views/tableBased/ActivitiesViewFacet.d.ts +0 -0
- /package/{types → public/types}/views/tableBased/FilteredEntitiesViewFacet.d.ts +0 -0
- /package/{types → public/types}/views/tableBased/FilteredSavedSearchesFacet.d.ts +0 -0
- /package/{types → public/types}/views/tableBased/helpers.d.ts +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AttributeType,
|
|
3
|
+
attributeUriToSearchUri,
|
|
4
|
+
buildLookupRecord,
|
|
5
|
+
DashboardConfigFilter,
|
|
6
|
+
formatDataTypeValue,
|
|
7
|
+
getAttrDataTypeDefinition,
|
|
8
|
+
getAttrTypeLookupCode,
|
|
9
|
+
getEntityUriFromAttributeUri,
|
|
10
|
+
getFacets,
|
|
11
|
+
getRoleLabel,
|
|
12
|
+
getTotals,
|
|
13
|
+
isDateType,
|
|
14
|
+
isEntityTypeUri,
|
|
15
|
+
isLookupAttrType,
|
|
16
|
+
isRoleAttrType,
|
|
17
|
+
Metadata,
|
|
18
|
+
parseTimestamp,
|
|
19
|
+
resolveLookupsList
|
|
20
|
+
} from '@reltio/mdm-sdk';
|
|
21
|
+
import {
|
|
22
|
+
always,
|
|
23
|
+
ascend,
|
|
24
|
+
concat,
|
|
25
|
+
curry,
|
|
26
|
+
defaultTo,
|
|
27
|
+
descend,
|
|
28
|
+
evolve,
|
|
29
|
+
ifElse,
|
|
30
|
+
map,
|
|
31
|
+
pipe,
|
|
32
|
+
prop,
|
|
33
|
+
propEq,
|
|
34
|
+
reject,
|
|
35
|
+
sortWith,
|
|
36
|
+
when
|
|
37
|
+
} from 'ramda';
|
|
38
|
+
import {
|
|
39
|
+
buildQuery,
|
|
40
|
+
configFilterToSearchFilter,
|
|
41
|
+
convertFilterToFacetState,
|
|
42
|
+
createEntityTypeFilter,
|
|
43
|
+
createFacetItemFilter,
|
|
44
|
+
createNotEqualFilter,
|
|
45
|
+
isEntityTypeFilter,
|
|
46
|
+
isSomeEntityTypeFilter
|
|
47
|
+
} from './filters';
|
|
48
|
+
import {ChartData} from '@reltio/components';
|
|
49
|
+
import i18n from 'ui-i18n';
|
|
50
|
+
|
|
51
|
+
type FacetsRequest = {
|
|
52
|
+
attribute: string;
|
|
53
|
+
filters: DashboardConfigFilter[];
|
|
54
|
+
globalFilter?: string;
|
|
55
|
+
searchByOv?: boolean;
|
|
56
|
+
activityFilter?: string;
|
|
57
|
+
pageSize?: number;
|
|
58
|
+
orderType?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const requestFacets = ({
|
|
62
|
+
attribute,
|
|
63
|
+
filters,
|
|
64
|
+
globalFilter,
|
|
65
|
+
searchByOv,
|
|
66
|
+
activityFilter,
|
|
67
|
+
pageSize,
|
|
68
|
+
orderType
|
|
69
|
+
}: FacetsRequest): Promise<ChartData[]> => {
|
|
70
|
+
const query = buildQuery(filters, globalFilter, searchByOv, activityFilter);
|
|
71
|
+
const body = [
|
|
72
|
+
{
|
|
73
|
+
fieldName: attribute,
|
|
74
|
+
pageNo: 1,
|
|
75
|
+
orderType,
|
|
76
|
+
pageSize
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
return getFacets({query, body}).then((response) => {
|
|
80
|
+
const getFacetData = pipe(
|
|
81
|
+
prop(attribute),
|
|
82
|
+
defaultTo({}),
|
|
83
|
+
Object.entries,
|
|
84
|
+
map(([key, value]) => ({label: key, group: key, value})),
|
|
85
|
+
sortWith([descend(prop('value')), ascend(prop('label'))])
|
|
86
|
+
);
|
|
87
|
+
return getFacetData(response);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const resolveLookups = curry((lookupCode: string, data: ChartData[]) => {
|
|
92
|
+
const lookupsToResolve = data.map(({label}) => ({codeValue: label, type: lookupCode}));
|
|
93
|
+
return resolveLookupsList(lookupsToResolve).then((response) => {
|
|
94
|
+
const codes = response.flatMap(buildLookupRecord(lookupCode)) as {lookupCode: string; value: string}[];
|
|
95
|
+
return data.map((item) => {
|
|
96
|
+
const code = codes.find(({lookupCode}) => lookupCode === item.label);
|
|
97
|
+
return code ? {...item, label: code.value} : item;
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const buildFacetOthersFilters = curry((fieldName: string, data: ChartData[]) =>
|
|
103
|
+
data.map(pipe(prop('group'), createNotEqualFilter(fieldName)))
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const OTHER_FACET_GROUP = 'Other';
|
|
107
|
+
|
|
108
|
+
export const requestOtherValues = curry(
|
|
109
|
+
({attribute, filters, globalFilter, searchByOv, activityFilter}: FacetsRequest, data: ChartData[]) => {
|
|
110
|
+
const otherFilters = pipe(
|
|
111
|
+
buildFacetOthersFilters(attribute),
|
|
112
|
+
concat(filters),
|
|
113
|
+
map(configFilterToSearchFilter)
|
|
114
|
+
)(data);
|
|
115
|
+
const searchOptions = searchByOv && 'searchByOv';
|
|
116
|
+
return getTotals(otherFilters, {globalFilter, activityFilter, searchOptions}).then(({total}) => {
|
|
117
|
+
return total > 0
|
|
118
|
+
? data.concat([{label: i18n.text('Other'), group: OTHER_FACET_GROUP, value: total}])
|
|
119
|
+
: data;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const resolveRoleLabel = (metadata: Metadata, roleName: string) =>
|
|
125
|
+
getRoleLabel(metadata, 'configuration/roles/' + roleName);
|
|
126
|
+
|
|
127
|
+
export const localizeFacetValues = map((facet: ChartData) => ({
|
|
128
|
+
...facet,
|
|
129
|
+
localizedValue: i18n.number(facet.value)
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
export const resolveFacetLabels = (metadata: Metadata, attrType: AttributeType) =>
|
|
133
|
+
pipe(
|
|
134
|
+
when(() => isLookupAttrType(attrType), resolveLookups(getAttrTypeLookupCode(attrType))),
|
|
135
|
+
when(
|
|
136
|
+
() => isRoleAttrType(attrType),
|
|
137
|
+
map((facet) => ({...facet, label: resolveRoleLabel(metadata, facet.group)}))
|
|
138
|
+
),
|
|
139
|
+
when(
|
|
140
|
+
() => isDateType(attrType.type),
|
|
141
|
+
map(
|
|
142
|
+
evolve({
|
|
143
|
+
label: pipe(
|
|
144
|
+
parseTimestamp,
|
|
145
|
+
formatDataTypeValue({dataTypeDefinition: getAttrDataTypeDefinition(attrType)})
|
|
146
|
+
)
|
|
147
|
+
})
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
export const getFacetFieldName = when(isEntityTypeUri, attributeUriToSearchUri);
|
|
153
|
+
const getFacetEntityTypeUri = ifElse(isEntityTypeUri, getEntityUriFromAttributeUri, always(undefined));
|
|
154
|
+
|
|
155
|
+
export const getFiltersForFacet = (
|
|
156
|
+
attributeUri: string,
|
|
157
|
+
filters: DashboardConfigFilter[] = []
|
|
158
|
+
): DashboardConfigFilter[] => {
|
|
159
|
+
const entityTypeUri = getFacetEntityTypeUri(attributeUri);
|
|
160
|
+
const hasEntityTypeFilter = filters.some((filter) => isEntityTypeFilter(filter, entityTypeUri));
|
|
161
|
+
return entityTypeUri && !hasEntityTypeFilter ? [createEntityTypeFilter(entityTypeUri), ...filters] : filters;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const getFiltersForFacetItem = curry((attributeUri: string, data: ChartData[], group: string) => {
|
|
165
|
+
const fieldName = getFacetFieldName(attributeUri);
|
|
166
|
+
return group === OTHER_FACET_GROUP
|
|
167
|
+
? pipe(reject(propEq('group', OTHER_FACET_GROUP)), buildFacetOthersFilters(fieldName))(data)
|
|
168
|
+
: [createFacetItemFilter(fieldName, group)];
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
export const facetFiltersToSearchState = curry(
|
|
172
|
+
(metadata: Metadata, attributeUri: string, filters: DashboardConfigFilter[]) => {
|
|
173
|
+
const entityType = getFacetEntityTypeUri(attributeUri) || filters.find(isSomeEntityTypeFilter)?.values?.[0];
|
|
174
|
+
return {
|
|
175
|
+
facets: filters.map(convertFilterToFacetState(metadata, entityType))
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addGlobalFilterToQuery,
|
|
3
|
+
buildFilterQueryString,
|
|
4
|
+
DashboardConfigFilter,
|
|
5
|
+
FilterOptions,
|
|
6
|
+
findAttributeTypeByUri,
|
|
7
|
+
getSpecialAttrTypeByFieldName,
|
|
8
|
+
isDateType,
|
|
9
|
+
mapFilterValue,
|
|
10
|
+
Metadata,
|
|
11
|
+
parseTimestamp,
|
|
12
|
+
SearchFilter,
|
|
13
|
+
searchUriToAttrUri,
|
|
14
|
+
wrapInArray
|
|
15
|
+
} from '@reltio/mdm-sdk';
|
|
16
|
+
import {assoc, curry, evolve, includes, map, pipe, prop, when, __} from 'ramda';
|
|
17
|
+
|
|
18
|
+
export const configFilterToSearchFilter = when(
|
|
19
|
+
pipe(prop('filter'), includes(__, [FilterOptions.IN_RANGE, FilterOptions.HAS_ALL])),
|
|
20
|
+
evolve({values: wrapInArray})
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const buildQuery = (
|
|
24
|
+
filters: DashboardConfigFilter[],
|
|
25
|
+
globalFilter?: string,
|
|
26
|
+
searchByOv?: boolean,
|
|
27
|
+
activityFilter?: string
|
|
28
|
+
): string => {
|
|
29
|
+
const query = pipe(
|
|
30
|
+
map(configFilterToSearchFilter),
|
|
31
|
+
buildFilterQueryString(),
|
|
32
|
+
addGlobalFilterToQuery(globalFilter)
|
|
33
|
+
)(filters);
|
|
34
|
+
const result = query ? [`filter=${query}`] : [];
|
|
35
|
+
if (searchByOv) {
|
|
36
|
+
result.push('options=searchByOv');
|
|
37
|
+
}
|
|
38
|
+
if (activityFilter) {
|
|
39
|
+
result.push(`activeness=${activityFilter}`);
|
|
40
|
+
}
|
|
41
|
+
return result.join('&');
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const createNotEqualFilter = curry((fieldName: string, value: string) => ({
|
|
45
|
+
filter: FilterOptions.NOT_EQUALS,
|
|
46
|
+
values: [value],
|
|
47
|
+
fieldName
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
export const convertSearchFilterToDashboardConfigFilter = (searchFilter: SearchFilter): DashboardConfigFilter => ({
|
|
51
|
+
filter: searchFilter?.filter ?? FilterOptions.EQUALS,
|
|
52
|
+
values: (searchFilter?.values ?? []) as string[],
|
|
53
|
+
fieldName: searchFilter?.fieldName ?? ''
|
|
54
|
+
});
|
|
55
|
+
export const createEntityTypeFilter = (entityTypeUri: string) => ({
|
|
56
|
+
filter: FilterOptions.EQUALS,
|
|
57
|
+
fieldName: 'type',
|
|
58
|
+
values: [entityTypeUri]
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const createFacetItemFilter = curry((fieldName: string, group: string) => ({
|
|
62
|
+
filter: FilterOptions.EQUALS,
|
|
63
|
+
values: [group],
|
|
64
|
+
fieldName
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
export const convertFilterToFacetState = curry(
|
|
68
|
+
(metadata: Metadata, entityType: string, filter: DashboardConfigFilter) => {
|
|
69
|
+
const {fieldName} = filter;
|
|
70
|
+
const isEntityAttributeFilter = /^(attributes|analyticsAttributes)/.test(fieldName);
|
|
71
|
+
const attrType = isEntityAttributeFilter
|
|
72
|
+
? findAttributeTypeByUri(metadata, searchUriToAttrUri(fieldName, entityType))
|
|
73
|
+
: getSpecialAttrTypeByFieldName(fieldName);
|
|
74
|
+
|
|
75
|
+
return pipe(
|
|
76
|
+
configFilterToSearchFilter,
|
|
77
|
+
when(() => isEntityAttributeFilter, assoc('entityType', entityType)),
|
|
78
|
+
when(() => isDateType(attrType.type), evolve({values: map(mapFilterValue(parseTimestamp))}))
|
|
79
|
+
)(filter);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export const isSomeEntityTypeFilter = ({filter, fieldName}: DashboardConfigFilter) =>
|
|
84
|
+
filter === FilterOptions.EQUALS && fieldName === 'type';
|
|
85
|
+
|
|
86
|
+
export const isEntityTypeFilter = ({filter, fieldName, values}: DashboardConfigFilter, entityTypeUri: string) =>
|
|
87
|
+
filter === FilterOptions.EQUALS && fieldName === 'type' && values?.[0] === entityTypeUri;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import {defaultTo, map, pipe} from 'ramda';
|
|
3
|
+
import {getDateRangeByValue, getDateRangeByDatePeriod, DatePeriod, DateRangeValue} from '@reltio/mdm-sdk';
|
|
4
|
+
import {PeriodStep} from '../types/PeriodStep';
|
|
5
|
+
|
|
6
|
+
const getStepForTimestampInterval = ([startTime, endTime]) => {
|
|
7
|
+
return endTime - startTime > +moment.duration(1, 'day') ? PeriodStep.DAY : PeriodStep.HOUR;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const getStepForPeriod = pipe(
|
|
11
|
+
(period) => getDateRangeByDatePeriod(period, getDashboardDateRangeByValue),
|
|
12
|
+
getStepForTimestampInterval
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
type GetDateRangeByValue = (value: DatePeriod | [number, number]) => [number, number];
|
|
16
|
+
export const getDashboardDateRangeByValue: GetDateRangeByValue = (value) => {
|
|
17
|
+
const currentDate = moment();
|
|
18
|
+
|
|
19
|
+
switch (value) {
|
|
20
|
+
case DateRangeValue.LAST_WEEK:
|
|
21
|
+
return [moment(currentDate).subtract(6, 'days').valueOf(), currentDate.valueOf()];
|
|
22
|
+
default:
|
|
23
|
+
return getDateRangeByValue(value);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getValuesDateRange = pipe(
|
|
28
|
+
getDashboardDateRangeByValue,
|
|
29
|
+
defaultTo([]),
|
|
30
|
+
map((value) => value && new Date(value))
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export {getStepForPeriod, getValuesDateRange};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {ChartData} from '@reltio/components';
|
|
2
|
+
import {SavedSearchData} from '../types/SavedSearchData';
|
|
3
|
+
|
|
4
|
+
export const savedSearchDataToChartData = (data: SavedSearchData[]): ChartData[] => {
|
|
5
|
+
return data.map(({uri, name, count}) => {
|
|
6
|
+
return {
|
|
7
|
+
value: count || 0,
|
|
8
|
+
label: name || '',
|
|
9
|
+
group: uri
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const savedSearchDataToSearchState = ({uiState, uri}: SavedSearchData) => {
|
|
15
|
+
if (uiState.version === '2.0') {
|
|
16
|
+
return {...uiState, currentSavedSearchUri: uri};
|
|
17
|
+
} else {
|
|
18
|
+
return {...uiState.state, curSavedSearchUri: uri};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
append,
|
|
3
|
+
chain,
|
|
4
|
+
curry,
|
|
5
|
+
evolve,
|
|
6
|
+
groupBy,
|
|
7
|
+
last,
|
|
8
|
+
map,
|
|
9
|
+
pipe,
|
|
10
|
+
pluck,
|
|
11
|
+
prepend,
|
|
12
|
+
prop,
|
|
13
|
+
propEq,
|
|
14
|
+
propOr,
|
|
15
|
+
sum,
|
|
16
|
+
toPairs
|
|
17
|
+
} from 'ramda';
|
|
18
|
+
import moment from 'moment';
|
|
19
|
+
import i18n from 'ui-i18n';
|
|
20
|
+
import {getEntitiesStats, getDateRangeByDatePeriod, DatePeriod} from '@reltio/mdm-sdk';
|
|
21
|
+
import {PeriodStep} from '../types/PeriodStep';
|
|
22
|
+
import {TimestampedStatsEventData, StatsData, StatsEventData} from '../types/StatsData';
|
|
23
|
+
import {getDashboardDateRangeByValue} from '../services/period';
|
|
24
|
+
import {AxisDomain} from 'recharts';
|
|
25
|
+
|
|
26
|
+
const StatsEvents = [
|
|
27
|
+
{
|
|
28
|
+
id: 'created',
|
|
29
|
+
types: ['CREATED'],
|
|
30
|
+
get label() {
|
|
31
|
+
return i18n.text('New');
|
|
32
|
+
},
|
|
33
|
+
color: '#4BAFFF'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'updated',
|
|
37
|
+
types: ['UPDATED'],
|
|
38
|
+
get label() {
|
|
39
|
+
return i18n.text('Updated');
|
|
40
|
+
},
|
|
41
|
+
color: '#0072CE'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'deleted',
|
|
45
|
+
types: ['DELETED'],
|
|
46
|
+
get label() {
|
|
47
|
+
return i18n.text('Deleted');
|
|
48
|
+
},
|
|
49
|
+
color: '#F085F2'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'matched',
|
|
53
|
+
types: ['POTENTIAL_MATCHES_FOUND'],
|
|
54
|
+
get label() {
|
|
55
|
+
return i18n.text('Matched');
|
|
56
|
+
},
|
|
57
|
+
color: '#C4CE00'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'autoMerged',
|
|
61
|
+
types: ['MERGED', 'MERGED_ON_THE_FLY'],
|
|
62
|
+
get label() {
|
|
63
|
+
return i18n.text('Auto-merged');
|
|
64
|
+
},
|
|
65
|
+
color: '#CE5C00'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'mergedManually',
|
|
69
|
+
types: ['MERGED_MANUALLY'],
|
|
70
|
+
get label() {
|
|
71
|
+
return i18n.text('Manually merged');
|
|
72
|
+
},
|
|
73
|
+
color: '#9E7ED3'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'unmerged',
|
|
77
|
+
types: ['SPLITTED'],
|
|
78
|
+
get label() {
|
|
79
|
+
return i18n.text('Unmerged');
|
|
80
|
+
},
|
|
81
|
+
color: '#40CFBB'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'notMatch',
|
|
85
|
+
types: ['NOT_MATCHES_SET'],
|
|
86
|
+
get label() {
|
|
87
|
+
return i18n.text('Not a match');
|
|
88
|
+
},
|
|
89
|
+
color: '#F97061'
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const getStatsEventById = (event: string) => StatsEvents.find(propEq('id', event));
|
|
94
|
+
const getStatsEventName = pipe(getStatsEventById, propOr('', 'label'));
|
|
95
|
+
const getStatsEventColor = pipe(getStatsEventById, prop('color'));
|
|
96
|
+
|
|
97
|
+
const requestStats = (period: DatePeriod): Promise<StatsData[]> => {
|
|
98
|
+
const [startTime, endTime] = getDateRangeByDatePeriod(period, getDashboardDateRangeByValue);
|
|
99
|
+
const getStats = ({facet, types}) =>
|
|
100
|
+
getEntitiesStats({facet, startTime, endTime, types}).then(({facets = {}, total = 0}) => ({
|
|
101
|
+
total,
|
|
102
|
+
data: facets[facet]
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const getEvents = () => {
|
|
106
|
+
const allTypes = chain(prop('types'), StatsEvents);
|
|
107
|
+
const processStats = pipe(propOr([], 'data'), pluck('term'));
|
|
108
|
+
return getStats({facet: 'type', types: allTypes}).then((stats) => processStats(stats));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getEventsData = (presentTypes) => {
|
|
112
|
+
const periodFrame = pipe(
|
|
113
|
+
map(
|
|
114
|
+
evolve({
|
|
115
|
+
term: (term) => moment.utc(term).valueOf()
|
|
116
|
+
})
|
|
117
|
+
),
|
|
118
|
+
prepend({
|
|
119
|
+
term: startTime,
|
|
120
|
+
count: 0
|
|
121
|
+
}),
|
|
122
|
+
append({
|
|
123
|
+
term: endTime,
|
|
124
|
+
count: 0
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
const isEventPresent = (types) => types.some((type) => presentTypes.includes(type));
|
|
128
|
+
|
|
129
|
+
return Promise.all(
|
|
130
|
+
StatsEvents.map(({types, id}) =>
|
|
131
|
+
(isEventPresent(types) ? getStats({facet: 'hour', types}) : Promise.resolve({total: 0, data: []})).then(
|
|
132
|
+
({total, data}) => ({total, data: periodFrame(data), event: id})
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return getEvents().then((events) => (events.length > 0 ? getEventsData(events) : []));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const groupEventsData = curry((step: PeriodStep, eventData: StatsEventData[]): TimestampedStatsEventData[] => {
|
|
142
|
+
return pipe(
|
|
143
|
+
groupBy(({term}) => moment(term).startOf(step)),
|
|
144
|
+
toPairs,
|
|
145
|
+
map(([date, data]) => ({
|
|
146
|
+
term: moment(date).valueOf(),
|
|
147
|
+
count: sum(pluck('count', data))
|
|
148
|
+
}))
|
|
149
|
+
)(eventData);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const interpolateEventsData = curry(
|
|
153
|
+
(step: PeriodStep, eventData: TimestampedStatsEventData[]): TimestampedStatsEventData[] => {
|
|
154
|
+
const [head, ...other] = eventData;
|
|
155
|
+
return other.reduce(
|
|
156
|
+
(acc, item) => {
|
|
157
|
+
const lastTerm = last(acc).term;
|
|
158
|
+
let nextTerm = moment(lastTerm).add(1, step).valueOf();
|
|
159
|
+
const interpolatedItems = [];
|
|
160
|
+
while (nextTerm < item.term) {
|
|
161
|
+
interpolatedItems.push({
|
|
162
|
+
term: nextTerm,
|
|
163
|
+
count: 0
|
|
164
|
+
});
|
|
165
|
+
nextTerm = moment(nextTerm).add(1, step).valueOf();
|
|
166
|
+
}
|
|
167
|
+
return acc.concat(interpolatedItems, item);
|
|
168
|
+
},
|
|
169
|
+
[head]
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const calibrateStatsData = curry((step: PeriodStep, statsData: StatsData[]) => {
|
|
175
|
+
return statsData.map(
|
|
176
|
+
evolve({
|
|
177
|
+
data: pipe(groupEventsData(step), interpolateEventsData(step))
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const getChartDomain = (chartData: StatsData[], tickCount: number): [AxisDomain, AxisDomain] => {
|
|
183
|
+
const counts = chain(pipe(prop('data'), pluck('count')))(chartData);
|
|
184
|
+
const min = Math.min(...counts);
|
|
185
|
+
const max = Math.max(...counts);
|
|
186
|
+
const difference = Math.abs(max - min);
|
|
187
|
+
|
|
188
|
+
return difference < tickCount ? [0, tickCount - 1] : [0, 'auto'];
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export {StatsEvents, requestStats, getStatsEventName, getStatsEventColor, calibrateStatsData, getChartDomain};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
always,
|
|
3
|
+
cond,
|
|
4
|
+
converge,
|
|
5
|
+
curry,
|
|
6
|
+
descend,
|
|
7
|
+
equals,
|
|
8
|
+
filter,
|
|
9
|
+
head,
|
|
10
|
+
isNil,
|
|
11
|
+
keys,
|
|
12
|
+
map,
|
|
13
|
+
otherwise,
|
|
14
|
+
path,
|
|
15
|
+
pipe,
|
|
16
|
+
prop,
|
|
17
|
+
propEq,
|
|
18
|
+
propOr,
|
|
19
|
+
reject,
|
|
20
|
+
sort,
|
|
21
|
+
startsWith,
|
|
22
|
+
T,
|
|
23
|
+
when,
|
|
24
|
+
complement,
|
|
25
|
+
isEmpty
|
|
26
|
+
} from 'ramda';
|
|
27
|
+
import {WorkflowTasksCategories} from '../types/WorkflowTasks';
|
|
28
|
+
import {
|
|
29
|
+
getDataChangeRequest,
|
|
30
|
+
getEntitiesByUris,
|
|
31
|
+
getGroupTasksForTenant,
|
|
32
|
+
getTasksForTenant,
|
|
33
|
+
isEntityUri,
|
|
34
|
+
WorkflowTaskData
|
|
35
|
+
} from '@reltio/mdm-sdk';
|
|
36
|
+
|
|
37
|
+
const getTasksByCategory = cond([
|
|
38
|
+
[equals(WorkflowTasksCategories.MY), always(getTasksForTenant)],
|
|
39
|
+
[equals(WorkflowTasksCategories.TEAM), always(getGroupTasksForTenant)],
|
|
40
|
+
[T, always(() => Promise.resolve({data: []}))]
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const getFirstObjectUri = pipe(propOr([], 'objectURIs'), head);
|
|
44
|
+
const isDCRObjectUri = startsWith('changeRequests/');
|
|
45
|
+
|
|
46
|
+
const notEmpty = complement(isEmpty);
|
|
47
|
+
|
|
48
|
+
const getEntities = pipe(map(getFirstObjectUri), filter(isEntityUri), when(notEmpty, getEntitiesByUris));
|
|
49
|
+
|
|
50
|
+
const getChangeRequests = pipe(
|
|
51
|
+
map(getFirstObjectUri),
|
|
52
|
+
filter(isDCRObjectUri),
|
|
53
|
+
map(pipe(getDataChangeRequest, otherwise(always(null)))),
|
|
54
|
+
(requests) => Promise.all(requests)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const getTaskObjectsData = converge((...requests) => Promise.all(requests), [getEntities, getChangeRequests]);
|
|
58
|
+
|
|
59
|
+
const enrichTaskWithEntity = (entities) => (task) => {
|
|
60
|
+
const entity = entities.find(propEq('uri', getFirstObjectUri(task)));
|
|
61
|
+
return entity
|
|
62
|
+
? {
|
|
63
|
+
...task,
|
|
64
|
+
objects: [entity]
|
|
65
|
+
}
|
|
66
|
+
: task;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const extractObjectsFromChangeRequest = ({objectsInfo = {}, changes = {}, uri}) => {
|
|
70
|
+
const getChange = (key) => path([key, 0], changes);
|
|
71
|
+
const getUri = (key) => {
|
|
72
|
+
const {type} = getChange(key);
|
|
73
|
+
if (type == 'CREATE_ENTITY' || type == 'CREATE_RELATIONSHIP') {
|
|
74
|
+
return uri + '/changes/' + key;
|
|
75
|
+
} else {
|
|
76
|
+
return key;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return pipe(
|
|
80
|
+
keys,
|
|
81
|
+
filter(getChange),
|
|
82
|
+
sort(descend(pipe(getChange, prop('createdTime')))),
|
|
83
|
+
map((key) => ({...objectsInfo[key], uri: getUri(key)}))
|
|
84
|
+
)(objectsInfo);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const enrichTaskWithDCRObjects = (changeRequests) => (task) => {
|
|
88
|
+
const changeRequest = changeRequests.find(propEq('uri', getFirstObjectUri(task)));
|
|
89
|
+
return changeRequest
|
|
90
|
+
? {
|
|
91
|
+
...task,
|
|
92
|
+
objects: extractObjectsFromChangeRequest(changeRequest)
|
|
93
|
+
}
|
|
94
|
+
: task;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const enrichTasksWithObjectsData = (entities, changeRequests, tasks) => {
|
|
98
|
+
changeRequests = reject(isNil, changeRequests);
|
|
99
|
+
return tasks.map(
|
|
100
|
+
pipe(
|
|
101
|
+
when(pipe(getFirstObjectUri, isEntityUri), enrichTaskWithEntity(entities)),
|
|
102
|
+
when(pipe(getFirstObjectUri, isDCRObjectUri), enrichTaskWithDCRObjects(changeRequests))
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const requestWorkflowTasks = curry(
|
|
108
|
+
async (tasksCategory, {workflowPath, environment, tenant, assignee, max, offset}) => {
|
|
109
|
+
const getTasks = getTasksByCategory(tasksCategory);
|
|
110
|
+
const {data, total} = await getTasks({workflowPath, environment, tenant, assignee, max, offset});
|
|
111
|
+
const [entities, changeRequests] = await getTaskObjectsData(data);
|
|
112
|
+
return {data: enrichTasksWithObjectsData(entities, changeRequests, data), total};
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export const isOverdueTask = (task: WorkflowTaskData) => task.dueDate && task.dueDate < Date.now();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {DashboardView as DashboardViewConfig, Layout} from '@reltio/mdm-sdk';
|
|
2
|
+
|
|
3
|
+
export enum ViewStatus {
|
|
4
|
+
UPDATED = 'updated',
|
|
5
|
+
NEW = 'new',
|
|
6
|
+
PERSISTED = 'persisted'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type DashboardView = {
|
|
10
|
+
config: DashboardViewConfig;
|
|
11
|
+
status: ViewStatus;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type DashboardPerspectiveLegacyConfig = {
|
|
15
|
+
id: string;
|
|
16
|
+
layout: Layout;
|
|
17
|
+
version: string;
|
|
18
|
+
};
|