@itwin/grouping-mapping-widget 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/hooks/useMemoizedCollectionPick.d.ts +2 -0
- package/lib/cjs/common/hooks/useMemoizedCollectionPick.js +31 -0
- package/lib/cjs/common/hooks/useMemoizedCollectionPick.js.map +1 -0
- package/lib/cjs/components/GroupingMappingContext.js +31 -13
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useFetchGroups.d.ts +5 -0
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js +18 -0
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js.map +1 -0
- package/lib/cjs/components/Mappings/Editing/MappingAction.js +21 -30
- package/lib/cjs/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.d.ts +6 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +46 -39
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatusIcon.d.ts +7 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatusIcon.js.map +1 -1
- package/lib/cjs/components/Mappings/{ConfirmMappingsImport.d.ts → Import/ConfirmMappingsImport.d.ts} +1 -1
- package/lib/cjs/components/Mappings/{ConfirmMappingsImport.js → Import/ConfirmMappingsImport.js} +27 -20
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -0
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js +4 -7
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectIModel.js +30 -49
- package/lib/cjs/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.d.ts +6 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.js +39 -52
- package/lib/cjs/components/Mappings/Import/SelectITwin.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectMappings.js +13 -36
- package/lib/cjs/components/Mappings/Import/SelectMappings.js.map +1 -1
- package/lib/cjs/components/Mappings/Mappings.js +5 -27
- package/lib/cjs/components/Mappings/Mappings.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.d.ts +5 -4
- package/lib/cjs/components/Mappings/MappingsView.js +29 -7
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +13 -0
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +50 -0
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.d.ts +4 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js +14 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +9 -10
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +35 -108
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js +2 -1
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/SharedComponents/DeleteModal.d.ts +2 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js +15 -19
- package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js +10 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/common/hooks/useMemoizedCollectionPick.d.ts +2 -0
- package/lib/esm/common/hooks/useMemoizedCollectionPick.js +27 -0
- package/lib/esm/common/hooks/useMemoizedCollectionPick.js.map +1 -0
- package/lib/esm/components/GroupingMappingContext.js +31 -13
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useFetchGroups.d.ts +5 -0
- package/lib/esm/components/Groups/hooks/useFetchGroups.js +13 -0
- package/lib/esm/components/Groups/hooks/useFetchGroups.js.map +1 -0
- package/lib/esm/components/Mappings/Editing/MappingAction.js +22 -31
- package/lib/esm/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.d.ts +6 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +46 -39
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStatusIcon.d.ts +7 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStatusIcon.js.map +1 -1
- package/lib/esm/components/Mappings/{ConfirmMappingsImport.d.ts → Import/ConfirmMappingsImport.d.ts} +1 -1
- package/lib/esm/components/Mappings/{ConfirmMappingsImport.js → Import/ConfirmMappingsImport.js} +27 -20
- package/lib/esm/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -0
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js +4 -7
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectIModel.js +31 -50
- package/lib/esm/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectITwin.d.ts +6 -1
- package/lib/esm/components/Mappings/Import/SelectITwin.js +39 -53
- package/lib/esm/components/Mappings/Import/SelectITwin.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectMappings.js +14 -37
- package/lib/esm/components/Mappings/Import/SelectMappings.js.map +1 -1
- package/lib/esm/components/Mappings/Mappings.js +3 -9
- package/lib/esm/components/Mappings/Mappings.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.d.ts +5 -4
- package/lib/esm/components/Mappings/MappingsView.js +10 -7
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +13 -0
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +46 -0
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.d.ts +4 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js +10 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +9 -10
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +36 -109
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTable.js +2 -1
- package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
- package/lib/esm/components/SharedComponents/DeleteModal.d.ts +2 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js +16 -20
- package/lib/esm/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.js +10 -1
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/package.json +9 -4
- package/lib/cjs/components/Mappings/ConfirmMappingsImport.js.map +0 -1
- package/lib/cjs/components/context/ExtractionStatusDataContext.d.ts +0 -20
- package/lib/cjs/components/context/ExtractionStatusDataContext.js +0 -26
- package/lib/cjs/components/context/ExtractionStatusDataContext.js.map +0 -1
- package/lib/esm/components/Mappings/ConfirmMappingsImport.js.map +0 -1
- package/lib/esm/components/context/ExtractionStatusDataContext.d.ts +0 -20
- package/lib/esm/components/context/ExtractionStatusDataContext.js +0 -22
- package/lib/esm/components/context/ExtractionStatusDataContext.js.map +0 -1
- /package/lib/cjs/components/Mappings/{ConfirmMappingsImport.scss → Import/ConfirmMappingsImport.scss} +0 -0
- /package/lib/esm/components/Mappings/{ConfirmMappingsImport.scss → Import/ConfirmMappingsImport.scss} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMemoizedCollectionPick = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
// Workaround for github.com/TanStack/query/issues/5137. Will be removed when updating to the latest version of react-query and React 18.
|
|
11
|
+
function shallowCompareObjects(a, b) {
|
|
12
|
+
return Object.keys(a).every((key) => a[key] === b[key]);
|
|
13
|
+
}
|
|
14
|
+
function shallowCompareCollections(a, b) {
|
|
15
|
+
return a.length === b.length && a.every((item, index) => shallowCompareObjects(item, b[index]));
|
|
16
|
+
}
|
|
17
|
+
function useMemoizedCollectionPick(array, pickValue) {
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
const stablePickValue = (0, react_1.useMemo)(() => pickValue, [JSON.stringify(pickValue)]);
|
|
20
|
+
const value = (0, react_1.useMemo)(() => array.map((item) => (0, lodash_1.pick)(item, stablePickValue)), [array, stablePickValue]);
|
|
21
|
+
const prevValue = (0, react_1.useRef)(value);
|
|
22
|
+
return (0, react_1.useMemo)(() => {
|
|
23
|
+
if (shallowCompareCollections(value, prevValue.current)) {
|
|
24
|
+
return prevValue.current;
|
|
25
|
+
}
|
|
26
|
+
prevValue.current = value;
|
|
27
|
+
return value;
|
|
28
|
+
}, [value]);
|
|
29
|
+
}
|
|
30
|
+
exports.useMemoizedCollectionPick = useMemoizedCollectionPick;
|
|
31
|
+
//# sourceMappingURL=useMemoizedCollectionPick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMemoizedCollectionPick.js","sourceRoot":"","sources":["../../../../src/common/hooks/useMemoizedCollectionPick.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;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K,CAAC,CAAC,CAAC;AACd,CAAC;AAZD,8DAYC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { useMemo, useRef } from \"react\";\nimport { pick } from \"lodash\";\n\n// Workaround for github.com/TanStack/query/issues/5137. Will be removed when updating to the latest version of react-query and React 18.\nfunction shallowCompareObjects<T extends { [key: string]: any }>(a: T, b: T): boolean {\n return Object.keys(a).every((key) => a[key] === b[key]);\n}\n\nfunction shallowCompareCollections<T extends {}>(a: T[], b: T[]) {\n return a.length === b.length && a.every((item, index) => shallowCompareObjects(item, b[index]));\n}\n\nexport function useMemoizedCollectionPick<T extends {}, P extends keyof T>(array: T[], pickValue: readonly P[]): Pick<T, P>[] {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stablePickValue = useMemo(() => pickValue, [JSON.stringify(pickValue)]);\n const value = useMemo(() => array.map((item) => pick(item, stablePickValue)), [array, stablePickValue]);\n const prevValue = useRef(value);\n return useMemo(() => {\n if (shallowCompareCollections(value, prevValue.current)) {\n return prevValue.current;\n }\n prevValue.current = value;\n return value;\n }, [value]);\n}\n"]}
|
|
@@ -33,8 +33,34 @@ const GroupHilitedElementsContext_1 = require("./context/GroupHilitedElementsCon
|
|
|
33
33
|
const PropertiesContext_1 = require("./context/PropertiesContext");
|
|
34
34
|
const appui_react_1 = require("@itwin/appui-react");
|
|
35
35
|
const ExtractionClientContext_1 = require("./context/ExtractionClientContext");
|
|
36
|
-
const
|
|
36
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
37
|
+
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
38
|
+
const utils_1 = require("../common/utils");
|
|
37
39
|
const authorizationClientGetAccessToken = async () => (await core_frontend_1.IModelApp.authorizationClient?.getAccessToken()) ?? "";
|
|
40
|
+
const queryClient = new react_query_1.QueryClient({
|
|
41
|
+
defaultOptions: {
|
|
42
|
+
queries: {
|
|
43
|
+
refetchOnWindowFocus: false,
|
|
44
|
+
staleTime: 20 * 60 * 1000, // 20 minutes
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
queryCache: new react_query_1.QueryCache({
|
|
48
|
+
onError: (error) => {
|
|
49
|
+
if (error.status)
|
|
50
|
+
itwinui_react_1.toaster.negative((0, utils_1.getErrorMessage)(error.status));
|
|
51
|
+
else
|
|
52
|
+
itwinui_react_1.toaster.negative("An error occurred while fetching data.");
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
mutationCache: new react_query_1.MutationCache({
|
|
56
|
+
onError: (error) => {
|
|
57
|
+
if (error.status)
|
|
58
|
+
itwinui_react_1.toaster.negative((0, utils_1.getErrorMessage)(error.status));
|
|
59
|
+
else
|
|
60
|
+
itwinui_react_1.toaster.negative("A network error occured while processing this action.");
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
38
64
|
const GroupingMappingContext = (props) => {
|
|
39
65
|
const activeIModelConntextion = (0, appui_react_1.useActiveIModelConnection)();
|
|
40
66
|
const clientProp = props.client ?? props.prefix;
|
|
@@ -61,8 +87,6 @@ const GroupingMappingContext = (props) => {
|
|
|
61
87
|
const [isOverlappedColored, setIsOverlappedColored] = (0, react_1.useState)(false);
|
|
62
88
|
const [currentHilitedGroups, setCurrentHilitedGroups] = (0, react_1.useState)(1);
|
|
63
89
|
const [overlappedElementGroupPairs, setOverlappedElementGroupPairs] = (0, react_1.useState)([]);
|
|
64
|
-
const [extractionStatusIcon, setExtractionStatusIcon] = (0, react_1.useState)({ iconStatus: undefined, iconMessage: "Loading..." });
|
|
65
|
-
const [extractionMessageData, setExtractionMessageData] = (0, react_1.useState)([]);
|
|
66
90
|
(0, react_1.useEffect)(() => {
|
|
67
91
|
setApiConfig(() => ({
|
|
68
92
|
prefix: props.prefix,
|
|
@@ -115,16 +139,10 @@ const GroupingMappingContext = (props) => {
|
|
|
115
139
|
customUIs,
|
|
116
140
|
setCustomUIs,
|
|
117
141
|
}), [customUIs]);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
setExtractionStatusIcon,
|
|
123
|
-
}), [extractionStatusIcon, extractionMessageData]);
|
|
124
|
-
return (react_1.default.createElement(GroupingApiConfigContext_1.GroupingMappingApiConfigContext.Provider, { value: apiConfig },
|
|
125
|
-
react_1.default.createElement(MappingClientContext_1.MappingClientContext.Provider, { value: mappingClient },
|
|
126
|
-
react_1.default.createElement(ExtractionClientContext_1.ExtractionClientContext.Provider, { value: extractionClient },
|
|
127
|
-
react_1.default.createElement(ExtractionStatusDataContext_1.ExtractionStatusDataContext.Provider, { value: extractionStatusDataValue },
|
|
142
|
+
return (react_1.default.createElement(react_query_1.QueryClientProvider, { client: queryClient },
|
|
143
|
+
react_1.default.createElement(GroupingApiConfigContext_1.GroupingMappingApiConfigContext.Provider, { value: apiConfig },
|
|
144
|
+
react_1.default.createElement(MappingClientContext_1.MappingClientContext.Provider, { value: mappingClient },
|
|
145
|
+
react_1.default.createElement(ExtractionClientContext_1.ExtractionClientContext.Provider, { value: extractionClient },
|
|
128
146
|
react_1.default.createElement(GroupingMappingCustomUIContext_1.GroupingMappingCustomUIContext.Provider, { value: customUIContextValue },
|
|
129
147
|
react_1.default.createElement(GroupHilitedElementsContext_1.GroupHilitedElementsContext.Provider, { value: hilitedElementsContextValue },
|
|
130
148
|
react_1.default.createElement(PropertiesContext_1.PropertiesContext.Provider, { value: propertiesContextValue }, props.children))))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingContext.js","sourceRoot":"","sources":["../../../src/components/GroupingMappingContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAoE;AAEpE,wDAAiD;AAMjD,iFAAqF;AACrF,yEAGwC;AAExC,6FAAyH;AAGzH,uFAAoF;AACpF,mEAAgE;AAChE,oDAA+D;AAC/D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K,EAAE,2BAA2B;4BACtE,8BAAC,qCAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACL,CACN,CACL,CACS,CAC5C,CAAC;AACJ,CAAC,CAAC;AAvHW,QAAA,sBAAsB,0BAuHjC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n ClientPrefix,\n GetAccessTokenFn,\n GroupingMappingApiConfig,\n} from \"./context/GroupingApiConfigContext\";\nimport { GroupingMappingApiConfigContext } from \"./context/GroupingApiConfigContext\";\nimport {\n createMappingClient,\n MappingClientContext,\n} from \"./context/MappingClientContext\";\nimport type { CalculatedProperty, CustomCalculation, Group, GroupProperty, IExtractionClient, IMappingsClient } from \"@itwin/insights-client\";\nimport { createGroupingMappingCustomUI, GroupingMappingCustomUIContext } from \"./context/GroupingMappingCustomUIContext\";\nimport type { GroupingMappingCustomUI } from \"./customUI/GroupingMappingCustomUI\";\nimport type { OverlappedElementGroupPairs, OverlappedInfo, QueryCacheItem } from \"./context/GroupHilitedElementsContext\";\nimport { GroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { PropertiesContext } from \"./context/PropertiesContext\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { createExtractionClient, ExtractionClientContext } from \"./context/ExtractionClientContext\";\nimport type { ExtractionMessageData, ExtractionStatusData, IExtractionStatusDataProps } from \"./context/ExtractionStatusDataContext\";\nimport { ExtractionStatusDataContext } from \"./context/ExtractionStatusDataContext\";\n\nexport interface GroupingMappingContextProps {\n /**\n * Custom callback to retrieve access token.\n */\n getAccessToken?: GetAccessTokenFn;\n /**\n * The iTwin iModel Id.\n */\n iModelId: string;\n /**\n * Used for iTwin and iModel APIs.\n * Also used for Mapping API if a custom {@link client} is not provided.\n */\n prefix?: ClientPrefix;\n /**\n * A custom implementation of MappingClient.\n */\n client?: IMappingsClient;\n /**\n * A custom implementation of ExtractionClient.\n */\n extractionClient?: IExtractionClient;\n /**\n * Custom UI to add and update groups or provide additional group context capabilities.\n */\n customUIs?: GroupingMappingCustomUI[];\n /**\n * A custom iModelConnection to use instead of the active iModelConnection from UiFramework.\n */\n iModelConnection?: IModelConnection;\n children?: React.ReactNode;\n}\n\nconst authorizationClientGetAccessToken = async () =>\n (await IModelApp.authorizationClient?.getAccessToken()) ?? \"\";\n\nexport const GroupingMappingContext = (props: GroupingMappingContextProps) => {\n const activeIModelConntextion = useActiveIModelConnection();\n const clientProp: IMappingsClient | ClientPrefix = props.client ?? props.prefix;\n const extractionClientProp: IExtractionClient | ClientPrefix = props.extractionClient ?? props.prefix;\n const [mappingClient, setMappingClient] = useState<IMappingsClient>(createMappingClient(clientProp));\n const [extractionClient, setExtractionClient] = useState<IExtractionClient>(createExtractionClient(extractionClientProp));\n const [customUIs, setCustomUIs] = useState<GroupingMappingCustomUI[]>(\n createGroupingMappingCustomUI(props.customUIs),\n );\n const [apiConfig, setApiConfig] = useState<GroupingMappingApiConfig>({\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelId: props.iModelId,\n prefix: props.prefix,\n });\n const hilitedElementsQueryCache = useRef<Map<string, QueryCacheItem>>(new Map());\n const [hiddenGroupsIds, setHiddenGroupsIds] = useState<Set<string>>(new Set());\n const [showGroupColor, setShowGroupColor] = useState<boolean>(false);\n const [propertiesShowGroup, setPropertiesShowGroup] = useState<boolean>(false);\n const [groups, setGroups] = useState<Group[]>([]);\n const [groupProperties, setGroupProperties] = useState<GroupProperty[]>([]);\n const [calculatedProperties, setCalculatedProperties] = useState<CalculatedProperty[]>([]);\n const [customCalculationProperties, setCustomCalculationProperties] = useState<CustomCalculation[]>([]);\n const [numberOfVisualizedGroups, setNumberOfVisualizedGroups] = useState(0);\n const [overlappedElementsInfo, setOverlappedElementsInfo] = useState<Map<string, OverlappedInfo[]>>(new Map());\n const [groupElementsInfo, setGroupElementsInfo] = useState<Map<string, number>>(new Map());\n const [isOverlappedColored, setIsOverlappedColored] = useState<boolean>(false);\n const [currentHilitedGroups, setCurrentHilitedGroups] = useState<number>(1);\n const [overlappedElementGroupPairs, setOverlappedElementGroupPairs] = useState<OverlappedElementGroupPairs[]>([]);\n const [extractionStatusIcon, setExtractionStatusIcon] = useState<ExtractionStatusData>({iconStatus: undefined, iconMessage: \"Loading...\"});\n const [extractionMessageData, setExtractionMessageData] = useState<ExtractionMessageData[]>([]);\n useEffect(() => {\n setApiConfig(() => ({\n prefix: props.prefix,\n iModelId: props.iModelId,\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelConnection: props.iModelConnection ?? activeIModelConntextion,\n }));\n }, [activeIModelConntextion, props.getAccessToken, props.iModelConnection, props.iModelId, props.prefix]);\n\n useEffect(() => {\n setMappingClient(createMappingClient(clientProp));\n }, [clientProp]);\n\n useEffect(() => {\n setExtractionClient(createExtractionClient(extractionClientProp));\n }, [extractionClientProp]);\n\n useEffect(() => {\n setCustomUIs(createGroupingMappingCustomUI(props.customUIs));\n }, [props.customUIs]);\n\n const hilitedElementsContextValue = useMemo(\n () => ({\n showGroupColor,\n setShowGroupColor,\n hiddenGroupsIds,\n setHiddenGroupsIds,\n hilitedElementsQueryCache,\n groups,\n setGroups,\n numberOfVisualizedGroups,\n setNumberOfVisualizedGroups,\n overlappedElementsInfo,\n setOverlappedElementsInfo,\n groupElementsInfo,\n setGroupElementsInfo,\n isOverlappedColored,\n setIsOverlappedColored,\n currentHilitedGroups,\n setCurrentHilitedGroups,\n overlappedElementGroupPairs,\n setOverlappedElementGroupPairs,\n }),\n [showGroupColor, hiddenGroupsIds, groups, numberOfVisualizedGroups, overlappedElementsInfo, groupElementsInfo, isOverlappedColored, currentHilitedGroups, overlappedElementGroupPairs]\n );\n\n const propertiesContextValue = useMemo(\n () => ({\n showGroupColor: propertiesShowGroup,\n setShowGroupColor: setPropertiesShowGroup,\n groupProperties,\n setGroupProperties,\n calculatedProperties,\n setCalculatedProperties,\n customCalculationProperties,\n setCustomCalculationProperties,\n }),\n [calculatedProperties, customCalculationProperties, groupProperties, propertiesShowGroup]\n );\n\n const customUIContextValue = useMemo(() => ({\n customUIs,\n setCustomUIs,\n }), [customUIs]);\n\n const extractionStatusDataValue: IExtractionStatusDataProps = useMemo (() => ({\n extractionStatusIcon,\n extractionMessageData,\n setExtractionMessageData,\n setExtractionStatusIcon,\n }), [extractionStatusIcon, extractionMessageData]);\n\n return (\n <GroupingMappingApiConfigContext.Provider value={apiConfig}>\n <MappingClientContext.Provider value={mappingClient}>\n <ExtractionClientContext.Provider value={extractionClient}>\n <ExtractionStatusDataContext.Provider value={extractionStatusDataValue}>\n <GroupingMappingCustomUIContext.Provider value={customUIContextValue}>\n <GroupHilitedElementsContext.Provider value={hilitedElementsContextValue}>\n <PropertiesContext.Provider value={propertiesContextValue}>\n {props.children}\n </PropertiesContext.Provider>\n </GroupHilitedElementsContext.Provider>\n </GroupingMappingCustomUIContext.Provider>\n </ExtractionStatusDataContext.Provider>\n </ExtractionClientContext.Provider>\n </MappingClientContext.Provider>\n </GroupingMappingApiConfigContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GroupingMappingContext.js","sourceRoot":"","sources":["../../../src/components/GroupingMappingContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAoE;AAEpE,wDAAiD;AAMjD,iFAAqF;AACrF,yEAGwC;AAExC,6FAAyH;AAGzH,uFAAoF;AACpF,mEAAgE;AAChE,oDAA+D;AAC/D,+EAAoG;AACpG,uDAAoG;AACpG,wDAA+C;AAC/C,2CAAkD;AAmClD,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,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YACxD,8BAAC,2CAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa;gBACjD,8BAAC,iDAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;oBACvD,8BAAC,+DAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB;wBAClE,8BAAC,yDAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,2BAA2B;4BACtE,8BAAC,qCAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACT,CACL,CACS,CACvB,CACvB,CAAC;AACJ,CAAC,CAAC;AA/GW,QAAA,sBAAsB,0BA+GjC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n ClientPrefix,\n GetAccessTokenFn,\n GroupingMappingApiConfig,\n} from \"./context/GroupingApiConfigContext\";\nimport { GroupingMappingApiConfigContext } from \"./context/GroupingApiConfigContext\";\nimport {\n createMappingClient,\n MappingClientContext,\n} from \"./context/MappingClientContext\";\nimport type { CalculatedProperty, CustomCalculation, Group, GroupProperty, IExtractionClient, IMappingsClient } from \"@itwin/insights-client\";\nimport { createGroupingMappingCustomUI, GroupingMappingCustomUIContext } from \"./context/GroupingMappingCustomUIContext\";\nimport type { GroupingMappingCustomUI } from \"./customUI/GroupingMappingCustomUI\";\nimport type { OverlappedElementGroupPairs, OverlappedInfo, QueryCacheItem } from \"./context/GroupHilitedElementsContext\";\nimport { GroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { PropertiesContext } from \"./context/PropertiesContext\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { createExtractionClient, ExtractionClientContext } from \"./context/ExtractionClientContext\";\nimport { MutationCache, QueryCache, QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport { getErrorMessage } from \"../common/utils\";\n\nexport interface GroupingMappingContextProps {\n /**\n * Custom callback to retrieve access token.\n */\n getAccessToken?: GetAccessTokenFn;\n /**\n * The iTwin iModel Id.\n */\n iModelId: string;\n /**\n * Used for iTwin and iModel APIs.\n * Also used for Mapping API if a custom {@link client} is not provided.\n */\n prefix?: ClientPrefix;\n /**\n * A custom implementation of MappingClient.\n */\n client?: IMappingsClient;\n /**\n * A custom implementation of ExtractionClient.\n */\n extractionClient?: IExtractionClient;\n /**\n * Custom UI to add and update groups or provide additional group context capabilities.\n */\n customUIs?: GroupingMappingCustomUI[];\n /**\n * A custom iModelConnection to use instead of the active iModelConnection from UiFramework.\n */\n iModelConnection?: IModelConnection;\n children?: React.ReactNode;\n}\n\nconst authorizationClientGetAccessToken = async () =>\n (await IModelApp.authorizationClient?.getAccessToken()) ?? \"\";\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n staleTime: 20 * 60 * 1000, // 20 minutes\n },\n },\n queryCache: new QueryCache({\n onError: (error: any) => {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"An error occurred while fetching data.\");\n },\n }),\n mutationCache: new MutationCache({\n onError: (error: any) => {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"A network error occured while processing this action.\");\n },\n }),\n});\n\nexport const GroupingMappingContext = (props: GroupingMappingContextProps) => {\n const activeIModelConntextion = useActiveIModelConnection();\n const clientProp: IMappingsClient | ClientPrefix = props.client ?? props.prefix;\n const extractionClientProp: IExtractionClient | ClientPrefix = props.extractionClient ?? props.prefix;\n const [mappingClient, setMappingClient] = useState<IMappingsClient>(createMappingClient(clientProp));\n const [extractionClient, setExtractionClient] = useState<IExtractionClient>(createExtractionClient(extractionClientProp));\n const [customUIs, setCustomUIs] = useState<GroupingMappingCustomUI[]>(\n createGroupingMappingCustomUI(props.customUIs),\n );\n const [apiConfig, setApiConfig] = useState<GroupingMappingApiConfig>({\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelId: props.iModelId,\n prefix: props.prefix,\n });\n const hilitedElementsQueryCache = useRef<Map<string, QueryCacheItem>>(new Map());\n const [hiddenGroupsIds, setHiddenGroupsIds] = useState<Set<string>>(new Set());\n const [showGroupColor, setShowGroupColor] = useState<boolean>(false);\n const [propertiesShowGroup, setPropertiesShowGroup] = useState<boolean>(false);\n const [groups, setGroups] = useState<Group[]>([]);\n const [groupProperties, setGroupProperties] = useState<GroupProperty[]>([]);\n const [calculatedProperties, setCalculatedProperties] = useState<CalculatedProperty[]>([]);\n const [customCalculationProperties, setCustomCalculationProperties] = useState<CustomCalculation[]>([]);\n const [numberOfVisualizedGroups, setNumberOfVisualizedGroups] = useState(0);\n const [overlappedElementsInfo, setOverlappedElementsInfo] = useState<Map<string, OverlappedInfo[]>>(new Map());\n const [groupElementsInfo, setGroupElementsInfo] = useState<Map<string, number>>(new Map());\n const [isOverlappedColored, setIsOverlappedColored] = useState<boolean>(false);\n const [currentHilitedGroups, setCurrentHilitedGroups] = useState<number>(1);\n const [overlappedElementGroupPairs, setOverlappedElementGroupPairs] = useState<OverlappedElementGroupPairs[]>([]);\n\n useEffect(() => {\n setApiConfig(() => ({\n prefix: props.prefix,\n iModelId: props.iModelId,\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelConnection: props.iModelConnection ?? activeIModelConntextion,\n }));\n }, [activeIModelConntextion, props.getAccessToken, props.iModelConnection, props.iModelId, props.prefix]);\n\n useEffect(() => {\n setMappingClient(createMappingClient(clientProp));\n }, [clientProp]);\n\n useEffect(() => {\n setExtractionClient(createExtractionClient(extractionClientProp));\n }, [extractionClientProp]);\n\n useEffect(() => {\n setCustomUIs(createGroupingMappingCustomUI(props.customUIs));\n }, [props.customUIs]);\n\n const hilitedElementsContextValue = useMemo(\n () => ({\n showGroupColor,\n setShowGroupColor,\n hiddenGroupsIds,\n setHiddenGroupsIds,\n hilitedElementsQueryCache,\n groups,\n setGroups,\n numberOfVisualizedGroups,\n setNumberOfVisualizedGroups,\n overlappedElementsInfo,\n setOverlappedElementsInfo,\n groupElementsInfo,\n setGroupElementsInfo,\n isOverlappedColored,\n setIsOverlappedColored,\n currentHilitedGroups,\n setCurrentHilitedGroups,\n overlappedElementGroupPairs,\n setOverlappedElementGroupPairs,\n }),\n [showGroupColor, hiddenGroupsIds, groups, numberOfVisualizedGroups, overlappedElementsInfo, groupElementsInfo, isOverlappedColored, currentHilitedGroups, overlappedElementGroupPairs]\n );\n\n const propertiesContextValue = useMemo(\n () => ({\n showGroupColor: propertiesShowGroup,\n setShowGroupColor: setPropertiesShowGroup,\n groupProperties,\n setGroupProperties,\n calculatedProperties,\n setCalculatedProperties,\n customCalculationProperties,\n setCustomCalculationProperties,\n }),\n [calculatedProperties, customCalculationProperties, groupProperties, propertiesShowGroup]\n );\n\n const customUIContextValue = useMemo(() => ({\n customUIs,\n setCustomUIs,\n }), [customUIs]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <GroupingMappingApiConfigContext.Provider value={apiConfig}>\n <MappingClientContext.Provider value={mappingClient}>\n <ExtractionClientContext.Provider value={extractionClient}>\n <GroupingMappingCustomUIContext.Provider value={customUIContextValue}>\n <GroupHilitedElementsContext.Provider value={hilitedElementsContextValue}>\n <PropertiesContext.Provider value={propertiesContextValue}>\n {props.children}\n </PropertiesContext.Provider>\n </GroupHilitedElementsContext.Provider>\n </GroupingMappingCustomUIContext.Provider>\n </ExtractionClientContext.Provider>\n </MappingClientContext.Provider>\n </GroupingMappingApiConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IMappingsClient } from "@itwin/insights-client";
|
|
2
|
+
import type { GetAccessTokenFn } from "../../context/GroupingApiConfigContext";
|
|
3
|
+
export declare const fetchGroups: (iModelId: string, mappingId: string, getAccessToken: GetAccessTokenFn, mappingsClient: IMappingsClient) => Promise<import("@itwin/insights-client").Group[]>;
|
|
4
|
+
export declare const useFetchGroups: (iModelId: string, mappingId: string, getAccessToken: GetAccessTokenFn, mappingsClient: IMappingsClient) => import("@tanstack/react-query").UseQueryResult<import("@itwin/insights-client").Group[], unknown>;
|
|
5
|
+
//# sourceMappingURL=useFetchGroups.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFetchGroups = exports.fetchGroups = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const fetchGroups = async (iModelId, mappingId, getAccessToken, mappingsClient) => {
|
|
6
|
+
const accessToken = await getAccessToken();
|
|
7
|
+
const groups = await mappingsClient.getGroups(accessToken, iModelId, mappingId);
|
|
8
|
+
return groups;
|
|
9
|
+
};
|
|
10
|
+
exports.fetchGroups = fetchGroups;
|
|
11
|
+
const useFetchGroups = (iModelId, mappingId, getAccessToken, mappingsClient) => {
|
|
12
|
+
return (0, react_query_1.useQuery)({
|
|
13
|
+
queryKey: ["groups", mappingId],
|
|
14
|
+
queryFn: async () => (0, exports.fetchGroups)(iModelId, mappingId, getAccessToken, mappingsClient),
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.useFetchGroups = useFetchGroups;
|
|
18
|
+
//# sourceMappingURL=useFetchGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchGroups.js","sourceRoot":"","sources":["../../../../../src/components/Groups/hooks/useFetchGroups.ts"],"names":[],"mappings":";;;AAKA,uDAAiD;AAG1C,MAAM,WAAW,GAAG,KAAK,EAC9B,QAAgB,EAChB,SAAiB,EACjB,cAAgC,EAChC,cAA+B,EAChC,EAAE;IACD,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AATW,QAAA,WAAW,eAStB;AAEK,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,cAAgC,EAAE,cAA+B,EAAE,EAAE;IACvI,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC/B,OAAO,EAAG,KAAK,IAAI,EAAE,CAAC,IAAA,mBAAW,EAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC;KACvF,CAAC,CAAC;AACL,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { IMappingsClient } from \"@itwin/insights-client\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { GetAccessTokenFn } from \"../../context/GroupingApiConfigContext\";\n\nexport const fetchGroups = async (\n iModelId: string,\n mappingId: string,\n getAccessToken: GetAccessTokenFn,\n mappingsClient: IMappingsClient\n)=> {\n const accessToken = await getAccessToken();\n const groups = await mappingsClient.getGroups(accessToken, iModelId, mappingId);\n return groups;\n};\n\nexport const useFetchGroups = (iModelId: string, mappingId: string, getAccessToken: GetAccessTokenFn, mappingsClient: IMappingsClient) => {\n return useQuery({\n queryKey: [\"groups\", mappingId],\n queryFn: async () => fetchGroups(iModelId, mappingId, getAccessToken, mappingsClient),\n });\n};\n"]}
|
|
@@ -35,6 +35,7 @@ require("./MappingAction.scss");
|
|
|
35
35
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
36
36
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
37
37
|
const utils_1 = require("../../../common/utils");
|
|
38
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
38
39
|
const defaultDisplayStrings = {
|
|
39
40
|
mappingDetails: "Mapping Details",
|
|
40
41
|
};
|
|
@@ -47,40 +48,30 @@ const MappingAction = ({ mapping, onSaveSuccess, onClickCancel, displayStrings:
|
|
|
47
48
|
extractionEnabled: mapping?.extractionEnabled ?? true,
|
|
48
49
|
});
|
|
49
50
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
50
|
-
const
|
|
51
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
51
52
|
const displayStrings = react_1.default.useMemo(() => ({ ...defaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
if (!validator.allValid()) {
|
|
55
|
-
showValidationMessage(true);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
setIsLoading(true);
|
|
53
|
+
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)({
|
|
54
|
+
mutationFn: async (newMapping) => {
|
|
59
55
|
const accessToken = await getAccessToken();
|
|
60
|
-
mapping
|
|
61
|
-
?
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
: await mappingClient.createMapping(accessToken, iModelId, {
|
|
67
|
-
mappingName: values.name,
|
|
68
|
-
description: values.description,
|
|
69
|
-
extractionEnabled: values.extractionEnabled,
|
|
70
|
-
});
|
|
71
|
-
setValues({
|
|
72
|
-
name: mapping?.mappingName ?? "",
|
|
73
|
-
description: mapping?.description ?? "",
|
|
74
|
-
extractionEnabled: mapping?.extractionEnabled ?? true,
|
|
75
|
-
});
|
|
56
|
+
return mapping
|
|
57
|
+
? mappingClient.updateMapping(accessToken, iModelId, mapping.id, newMapping)
|
|
58
|
+
: mappingClient.createMapping(accessToken, iModelId, newMapping);
|
|
59
|
+
},
|
|
60
|
+
onSuccess: async () => {
|
|
61
|
+
await queryClient.invalidateQueries({ queryKey: ["mappings"] });
|
|
76
62
|
onSaveSuccess();
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const onSave = async () => {
|
|
66
|
+
if (!validator.allValid()) {
|
|
67
|
+
showValidationMessage(true);
|
|
68
|
+
return;
|
|
77
69
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
70
|
+
saveMutation({
|
|
71
|
+
mappingName: values.name,
|
|
72
|
+
description: values.description,
|
|
73
|
+
extractionEnabled: values.extractionEnabled,
|
|
74
|
+
});
|
|
84
75
|
};
|
|
85
76
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
86
77
|
react_1.default.createElement("div", { className: 'gmw-details-form-container' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingAction.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Editing/MappingAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAkF;AAClF,+CAAwC;AACxC,qFAA6D;AAC7D,oFAAsF;AACtF,gCAA8B;AAC9B,6EAAsE;AAEtE,qFAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"MappingAction.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Editing/MappingAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAkF;AAClF,+CAAwC;AACxC,qFAA6D;AAC7D,oFAAsF;AACtF,gCAA8B;AAC9B,6EAAsE;AAEtE,qFAAqF;AACrF,iDAA0D;AAC1D,uDAAoE;AAEpE,MAAM,qBAAqB,GAAG;IAC5B,cAAc,EAAE,iBAAiB;CAClC,CAAC;AASK,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAsB,EAAE,EAAE;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AE;wBACvB,IAAA,yBAAiB,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;wBAC5C,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBACnC,CAAC,GACD;gBACF,8BAAC,4BAAY,IACX,EAAE,EAAC,aAAa,EAChB,IAAI,EAAC,aAAa,EAClB,KAAK,EAAC,aAAa,EACnB,KAAK,EAAE,MAAM,CAAC,WAAW,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;wBAClB,IAAA,yBAAiB,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;oBAC9C,CAAC,GACD;gBACF,8BAAC,4BAAY,IACX,EAAE,EAAC,mBAAmB,EACtB,IAAI,EAAC,mBAAmB,EACxB,KAAK,EAAC,0BAA0B,EAChC,aAAa,EAAC,OAAO,EACrB,OAAO,EAAE,MAAM,CAAC,iBAAiB,EACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;wBAClB,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC3E,CAAC,GACD,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,MAAM,CAAC,IAAI,EAC9B,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAvGW,QAAA,aAAa,iBAuGxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Fieldset, LabeledInput, Text, ToggleSwitch } from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../../Properties/hooks/useValidator\";\nimport \"./MappingAction.scss\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport type { Mapping, MappingCreate } from \"@itwin/insights-client\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { handleInputChange } from \"../../../common/utils\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nconst defaultDisplayStrings = {\n mappingDetails: \"Mapping Details\",\n};\n\nexport interface MappingActionProps {\n mapping?: Mapping;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nexport const MappingAction = ({ mapping, onSaveSuccess, onClickCancel, displayStrings: userDisplayStrings }: MappingActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [values, setValues] = useState({\n name: mapping?.mappingName ?? \"\",\n description: mapping?.description ?? \"\",\n extractionEnabled: mapping?.extractionEnabled ?? true,\n });\n const [validator, showValidationMessage] = useValidator();\n const queryClient = useQueryClient();\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const { mutate: saveMutation, isLoading } = useMutation(\n {\n mutationFn: async (newMapping: MappingCreate) => {\n const accessToken = await getAccessToken();\n return mapping\n ? mappingClient.updateMapping(accessToken, iModelId, mapping.id, newMapping)\n : mappingClient.createMapping(accessToken, iModelId, newMapping);\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"mappings\"] });\n onSaveSuccess();\n },\n }\n );\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n saveMutation({\n mappingName: values.name,\n description: values.description,\n extractionEnabled: values.extractionEnabled,\n });\n };\n\n return (\n <>\n <div className='gmw-details-form-container'>\n <Fieldset legend={displayStrings.mappingDetails} className='gmw-details-form'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n <LabeledInput\n id='name'\n name='name'\n label='Name'\n value={values.name}\n required\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", values.name, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", values.name, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n handleInputChange(event, values, setValues);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledInput\n id='description'\n name='description'\n label='Description'\n value={values.description}\n onChange={(event) => {\n handleInputChange(event, values, setValues);\n }}\n />\n <ToggleSwitch\n id='extractionEnabled'\n name='extractionEnabled'\n label='Extract data from iModel'\n labelPosition=\"right\"\n checked={values.extractionEnabled}\n onChange={(event) => {\n setValues({ ...values, extractionEnabled: event.currentTarget.checked });\n }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!values.name}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ExtractionMessageData } from "../../context/ExtractionStatusDataContext";
|
|
3
2
|
import "./ExtractionMessageModal.scss";
|
|
3
|
+
export interface ExtractionMessageData {
|
|
4
|
+
date: string;
|
|
5
|
+
category: string;
|
|
6
|
+
level: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
4
9
|
export interface ExtractionMessageModalProps {
|
|
5
10
|
isOpen: boolean;
|
|
6
11
|
onClose: () => void;
|
|
@@ -33,51 +33,57 @@ const ExtractionLogCustomFilter_1 = require("./ExtractionLogCustomFilter");
|
|
|
33
33
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
34
34
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
35
35
|
const useMappingsOperations_1 = require("../hooks/useMappingsOperations");
|
|
36
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
37
|
+
const useMemoizedCollectionPick_1 = require("../../../common/hooks/useMemoizedCollectionPick");
|
|
38
|
+
const useFetchGroups_1 = require("../../Groups/hooks/useFetchGroups");
|
|
36
39
|
const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData, timestamp }) => {
|
|
37
|
-
const [formattedExtractionMessage, setFormattedExtractionMessage] = (0, react_1.useState)(
|
|
40
|
+
const [formattedExtractionMessage, setFormattedExtractionMessage] = (0, react_1.useState)(undefined);
|
|
38
41
|
const groupingMappingApiConfig = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
39
42
|
const mappingClient = (0, MappingClientContext_1.useMappingClient)();
|
|
40
|
-
const { mappings } = (0, useMappingsOperations_1.useMappingsOperations)({ ...groupingMappingApiConfig, mappingClient });
|
|
43
|
+
const { mappings, isLoading: isMappingsLoading } = (0, useMappingsOperations_1.useMappingsOperations)({ ...groupingMappingApiConfig, mappingClient });
|
|
41
44
|
const [formattedTimestamp, setFormattedTimestamp] = (0, react_1.useState)("");
|
|
42
|
-
const getMappingName = (0, react_1.useCallback)(
|
|
43
|
-
return mappings.find((mapping) =>
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
const getMappingName = (0, react_1.useCallback)((mappingId, mappings) => {
|
|
46
|
+
return mappings.find((mapping) => mapping.id === mappingId)?.mappingName ?? "";
|
|
47
|
+
}, []);
|
|
48
|
+
// Extract groupIds and mappingIds from messages
|
|
49
|
+
const extractionInfo = (0, react_1.useMemo)(() => {
|
|
50
|
+
return extractionMessageData.reduce((acc, message) => {
|
|
51
|
+
const splittedMessage = message.message.split(" ");
|
|
52
|
+
const mappingId = splittedMessage[splittedMessage.indexOf("MappingId:") + 1]?.match(/^([^,]+),$/)?.[1];
|
|
53
|
+
const groupId = splittedMessage[splittedMessage.indexOf("GroupId:") + 1]?.match(/^([^,]+).$/)?.[1];
|
|
54
|
+
if (mappingId && groupId) {
|
|
55
|
+
acc.push({ mappingId, groupId });
|
|
56
|
+
}
|
|
57
|
+
return acc;
|
|
58
|
+
}, []);
|
|
59
|
+
}, [extractionMessageData]);
|
|
60
|
+
// useQueries to fetch all group names
|
|
61
|
+
const groupQueriesResults = (0, react_query_1.useQueries)({
|
|
62
|
+
queries: extractionInfo.map(({ mappingId }) => ({
|
|
63
|
+
queryKey: ["groups", mappingId],
|
|
64
|
+
queryFn: async () => (0, useFetchGroups_1.fetchGroups)(groupingMappingApiConfig.iModelId, mappingId, groupingMappingApiConfig.getAccessToken, mappingClient),
|
|
65
|
+
})),
|
|
66
|
+
});
|
|
67
|
+
// Workaround to get data from useQueries with more stability
|
|
68
|
+
const pickedResult = (0, useMemoizedCollectionPick_1.useMemoizedCollectionPick)(groupQueriesResults, ["data", "error", "isLoading", "isSuccess"]);
|
|
53
69
|
(0, react_1.useEffect)(() => {
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const mappingName = await getMappingName(mappingId[1]);
|
|
66
|
-
replacedMessage = replacedMessage.replace(/MappingId: [\w-]+/, `Mapping: ${mappingName}`);
|
|
67
|
-
}
|
|
68
|
-
if (replacedMessage.includes("GroupId:")) {
|
|
69
|
-
const groupId = splittedMessage[splittedMessage.indexOf("GroupId:") + 1].match(/^([^,]+).$/) ?? [];
|
|
70
|
-
const groupName = await getGroupNames(mappingId[1], groupId[1], groupsCache);
|
|
71
|
-
replacedMessage = replacedMessage.replace(/GroupId: [\w-]+/, `Group: ${groupName}`);
|
|
72
|
-
}
|
|
73
|
-
return { ...extractionMessage, message: replacedMessage };
|
|
70
|
+
if (pickedResult.every((query) => query.isSuccess) && mappings) {
|
|
71
|
+
const formattedMessages = extractionMessageData.map((extractionMessage, index) => {
|
|
72
|
+
let replacedMessage = extractionMessage.message;
|
|
73
|
+
const { mappingId, groupId } = extractionInfo[index];
|
|
74
|
+
const groupName = pickedResult[index].data.find((group) => group.id === groupId)?.groupName;
|
|
75
|
+
if (replacedMessage.includes("MappingId:")) {
|
|
76
|
+
const mappingName = getMappingName(mappingId, mappings);
|
|
77
|
+
replacedMessage = replacedMessage.replace(/MappingId: [\w-]+/, `Mapping: ${mappingName}`);
|
|
78
|
+
}
|
|
79
|
+
if (replacedMessage.includes("GroupId:")) {
|
|
80
|
+
replacedMessage = replacedMessage.replace(/GroupId: [\w-]+/, `Group: ${groupName ? groupName : "<Not Found>"}`);
|
|
74
81
|
}
|
|
82
|
+
return { ...extractionMessage, message: replacedMessage };
|
|
75
83
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
void formatMessages();
|
|
80
|
-
}, [extractionMessageData, groupingMappingApiConfig, mappings, mappingClient, getGroupNames, getMappingName]);
|
|
84
|
+
setFormattedExtractionMessage(formattedMessages);
|
|
85
|
+
}
|
|
86
|
+
}, [extractionMessageData, mappings, extractionInfo, getMappingName, pickedResult]);
|
|
81
87
|
(0, react_1.useEffect)(() => {
|
|
82
88
|
const newDateTime = new Date(timestamp);
|
|
83
89
|
const options = {
|
|
@@ -119,13 +125,14 @@ const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData, timest
|
|
|
119
125
|
Filter: itwinui_react_1.tableFilters.TextFilter(translatedLabels),
|
|
120
126
|
},
|
|
121
127
|
], [translatedLabels]);
|
|
128
|
+
const isLoading = pickedResult.some((query) => query.isLoading) || isMappingsLoading;
|
|
122
129
|
return (react_1.default.createElement(itwinui_react_1.Modal, { className: "gmw-message-modal-container", title: "Extraction Logs", isOpen: isOpen, onClose: onClose, closeOnExternalClick: false },
|
|
123
130
|
react_1.default.createElement(itwinui_react_1.ModalContent, null,
|
|
124
131
|
react_1.default.createElement("div", { className: "gmw-timestamp-icon" },
|
|
125
132
|
react_1.default.createElement(itwinui_react_1.Icon, { title: "Extraction Timestamp", size: "medium" },
|
|
126
133
|
react_1.default.createElement(itwinui_icons_react_1.SvgClock, null)),
|
|
127
134
|
react_1.default.createElement(itwinui_react_1.Text, null, formattedTimestamp)),
|
|
128
|
-
react_1.default.createElement(itwinui_react_1.Table, { columns: columns, data: formattedExtractionMessage, emptyTableContent: "", emptyFilteredTableContent: "No results match filters.", className: "gmw-extraction-message-table-container" })),
|
|
135
|
+
react_1.default.createElement(itwinui_react_1.Table, { columns: columns, data: formattedExtractionMessage ?? [], emptyTableContent: "", emptyFilteredTableContent: "No results match filters.", className: "gmw-extraction-message-table-container", isLoading: isLoading })),
|
|
129
136
|
react_1.default.createElement(itwinui_react_1.ModalButtonBar, null,
|
|
130
137
|
react_1.default.createElement(itwinui_react_1.Button, { onClick: onClose, styleType: "high-visibility" }, "Close"))));
|
|
131
138
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractionMessageModal.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionMessageModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiI;AACjI,+CAAyE;AAGzE,yCAAuC;AACvC,oEAAsD;AAEtD,kEAA+D;AAC/D,2EAAwE;AACxE,qFAAqF;AACrF,6EAAsE;AACtE,0EAAuE;AAUhE,MAAM,sBAAsB,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAA+B,EAAE,EAAE;IAC3H,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAAG,IAAA,gBAAQ,EAA0B,EAAE,CAAC,CAAC;IAC1G,MAAM,wBAAwB,GAAG,IAAA,sDAA2B,GAAE,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,6CAAqB,EAAC,EAAC,GAAG,wBAAwB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0B,EAChC,iBAAiB,EAAE,EAAE,EACrB,yBAAyB,EAAC,2BAA2B,EACrD,SAAS,EAAC,wCAAwC,GAClD,CACW;QACf,8BAAC,8BAAc;YACb,8BAAC,sBAAM,IACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,iBAAiB,YAGpB,CACM,CACX,CACT,CAAC;AACJ,CAAC,CAAC;AAvJW,QAAA,sBAAsB,0BAuJjC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Button, DefaultCell, Icon, Modal, ModalButtonBar, ModalContent, Table, tableFilters, Text } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../../../common/utils\";\nimport type { ExtractionMessageData } from \"../../context/ExtractionStatusDataContext\";\nimport \"./ExtractionMessageModal.scss\";\nimport { SvgClock } from \"@itwin/itwinui-icons-react\";\nimport type { CellRendererProps, Column } from \"react-table\";\nimport { StatusIcon } from \"../../SharedComponents/StatusIcon\";\nimport { ExtractionLogCustomFilter } from \"./ExtractionLogCustomFilter\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useMappingsOperations } from \"../hooks/useMappingsOperations\";\nimport type { Group } from \"@itwin/insights-client\";\n\nexport interface ExtractionMessageModalProps {\n isOpen: boolean;\n onClose: () => void;\n extractionMessageData: ExtractionMessageData[];\n timestamp: string;\n}\n\nexport const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData, timestamp }: ExtractionMessageModalProps) => {\n const [formattedExtractionMessage, setFormattedExtractionMessage] = useState<ExtractionMessageData[]>([]);\n const groupingMappingApiConfig = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const { mappings } = useMappingsOperations({...groupingMappingApiConfig, mappingClient});\n const [formattedTimestamp, setFormattedTimestamp] = useState<string>(\"\");\n\n const getMappingName = useCallback(async (mappingId: string) => {\n return mappings.find((mapping) => {return mapping.id === mappingId;})?.mappingName ?? \"\";\n }, [mappings]);\n\n const getGroupNames = useCallback(async (mappingId: string, groupId: string, groupsCache: Map<string, Group[]>) => {\n const accessToken = await groupingMappingApiConfig.getAccessToken();\n if(!groupsCache.has(mappingId)){\n const groups = await mappingClient.getGroups(\n accessToken,\n groupingMappingApiConfig.iModelId,\n mappingId\n );\n groupsCache.set(mappingId, groups);\n }\n return groupsCache.get(mappingId)?.find((group) => {return group.id === groupId;})?.groupName ?? \"\";\n }, [groupingMappingApiConfig, mappingClient]);\n\n useEffect(() => {\n const formatMessages = async () => {\n const groupsCache = new Map<string,Group[]>();\n const extractionMessageDataPromises = extractionMessageData.map(async (extractionMessage) => {\n {\n let replacedMessage = extractionMessage.message;\n const splittedMessage = replacedMessage.split(\" \");\n const mappingId = splittedMessage[splittedMessage.indexOf(\"MappingId:\") + 1].match(/^([^,]+),$/) ?? [];\n if(extractionMessage.message.includes(\"iModel\")){\n replacedMessage = replacedMessage.replace(/iModel [\\w-]+/, \"iModel\");\n }\n if(replacedMessage.includes(\"MappingId:\")){\n const mappingName = await getMappingName(mappingId[1]);\n replacedMessage = replacedMessage.replace(/MappingId: [\\w-]+/, `Mapping: ${mappingName}`);\n }\n if(replacedMessage.includes(\"GroupId:\")){\n const groupId = splittedMessage[splittedMessage.indexOf(\"GroupId:\") + 1].match(/^([^,]+).$/) ?? [];\n const groupName = await getGroupNames(mappingId[1], groupId[1], groupsCache);\n replacedMessage = replacedMessage.replace(/GroupId: [\\w-]+/, `Group: ${groupName}`);\n }\n return {...extractionMessage, message: replacedMessage};\n }\n });\n\n const newMessages = await Promise.all(extractionMessageDataPromises);\n setFormattedExtractionMessage(newMessages);\n };\n void formatMessages();\n }, [extractionMessageData, groupingMappingApiConfig, mappings, mappingClient, getGroupNames, getMappingName]);\n\n useEffect(() => {\n const newDateTime: Date = new Date(timestamp);\n const options: Intl.DateTimeFormatOptions = {\n day: \"numeric\", month: \"numeric\", year: \"numeric\",\n hour: \"2-digit\", minute: \"2-digit\",\n };\n setFormattedTimestamp(newDateTime.toLocaleString(undefined, options));\n }, [timestamp]);\n\n const translatedLabels = useMemo(() => ({\n filter: \"Filter\",\n clear: \"Clear\",\n }), []);\n\n const columns = useMemo(\n (): Column<CreateTypeFromInterface<ExtractionMessageData>>[] => [\n {\n id: \"category\",\n Header: \"Category\",\n accessor: \"category\",\n fieldType: \"text\",\n Filter: ExtractionLogCustomFilter,\n filter: \"equals\",\n },\n {\n id: \"level\",\n Header: \"Level\",\n accessor: \"level\",\n cellRenderer: ({ cellElementProps, cellProps }: CellRendererProps<CreateTypeFromInterface<ExtractionMessageData>>) => {\n const level = cellProps.row.original.level;\n return (\n <DefaultCell\n cellElementProps={cellElementProps}\n cellProps={cellProps}\n startIcon={\n level === \"Error\" ? (\n <StatusIcon status='error' />\n ) : level === \"Warning\" ? (\n <StatusIcon status='warning' />\n ) : level === \"Info\" ? (\n <StatusIcon status='informational' />\n ) : <StatusIcon status='trace' />\n }\n >\n {level}\n </DefaultCell>\n );\n },\n Filter: ExtractionLogCustomFilter,\n filter: \"equals\",\n },\n {\n id: \"message\",\n Header: \"Message\",\n accessor: \"message\",\n width: \"25vw\",\n fieldType: \"text\",\n Filter: tableFilters.TextFilter(translatedLabels),\n },\n ],\n [translatedLabels]\n );\n return (\n <Modal className=\"gmw-message-modal-container\"\n title=\"Extraction Logs\"\n isOpen={isOpen}\n onClose={onClose}\n closeOnExternalClick={false}\n >\n <ModalContent>\n <div className=\"gmw-timestamp-icon\">\n <Icon\n title=\"Extraction Timestamp\"\n size=\"medium\"\n >\n <SvgClock />\n </Icon>\n <Text>{formattedTimestamp}</Text>\n </div>\n <Table<CreateTypeFromInterface<ExtractionMessageData>>\n columns={columns}\n data={formattedExtractionMessage}\n emptyTableContent={\"\"}\n emptyFilteredTableContent=\"No results match filters.\"\n className=\"gmw-extraction-message-table-container\"\n />\n </ModalContent>\n <ModalButtonBar>\n <Button\n onClick={onClose}\n styleType=\"high-visibility\"\n >\n Close\n </Button>\n </ModalButtonBar>\n </Modal>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ExtractionMessageModal.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionMessageModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiI;AACjI,+CAAyE;AAEzE,yCAAuC;AACvC,oEAAsD;AAEtD,kEAA+D;AAC/D,2EAAwE;AACxE,qFAAqF;AACrF,6EAAsE;AACtE,0EAAuE;AAEvE,uDAAmD;AACnD,+FAA4F;AAC5F,sEAAgE;AAgBzD,MAAM,sBAAsB,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAA+B,EAAE,EAAE;IAC3H,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAAG,IAAA,gBAAQ,EAAsC,SAAS,CAAC,CAAC;IAC7H,MAAM,wBAAwB,GAAG,IAAA,sDAA2B,GAAE,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,IAAA,6CAAqB,EAAC,EAAE,GAAG,wBAAwB,EAAE,aAAa,EAAE,CAAC,CAAC;IACzH,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,CAAC,SAAiB,EAAE,QAAmB,EAAE,EAAE;QAC5E,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,WAAW,IAAI,EAAE,CAAC;IACjF,CAAC,EAAE,E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AAS,EAAE,SAAS,GACpB,CACW;QACf,8BAAC,8BAAc;YACb,8BAAC,sBAAM,IACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,iBAAiB,YAGpB,CACM,CACX,CACT,CAAC;AACJ,CAAC,CAAC;AAnKW,QAAA,sBAAsB,0BAmKjC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Button, DefaultCell, Icon, Modal, ModalButtonBar, ModalContent, Table, tableFilters, Text } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../../../common/utils\";\nimport \"./ExtractionMessageModal.scss\";\nimport { SvgClock } from \"@itwin/itwinui-icons-react\";\nimport type { CellRendererProps, Column } from \"react-table\";\nimport { StatusIcon } from \"../../SharedComponents/StatusIcon\";\nimport { ExtractionLogCustomFilter } from \"./ExtractionLogCustomFilter\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useMappingsOperations } from \"../hooks/useMappingsOperations\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { useQueries } from \"@tanstack/react-query\";\nimport { useMemoizedCollectionPick } from \"../../../common/hooks/useMemoizedCollectionPick\";\nimport { fetchGroups } from \"../../Groups/hooks/useFetchGroups\";\n\nexport interface ExtractionMessageData {\n date: string;\n category: string;\n level: string;\n message: string;\n}\n\nexport interface ExtractionMessageModalProps {\n isOpen: boolean;\n onClose: () => void;\n extractionMessageData: ExtractionMessageData[];\n timestamp: string;\n}\n\nexport const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData, timestamp }: ExtractionMessageModalProps) => {\n const [formattedExtractionMessage, setFormattedExtractionMessage] = useState<ExtractionMessageData[] | undefined>(undefined);\n const groupingMappingApiConfig = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const { mappings, isLoading: isMappingsLoading } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });\n const [formattedTimestamp, setFormattedTimestamp] = useState<string>(\"\");\n\n const getMappingName = useCallback((mappingId: string, mappings: Mapping[]) => {\n return mappings.find((mapping) => mapping.id === mappingId)?.mappingName ?? \"\";\n }, []);\n\n // Extract groupIds and mappingIds from messages\n const extractionInfo = useMemo(() => {\n return extractionMessageData.reduce<{\n mappingId: string;\n groupId: string;\n }[]>((acc, message) => {\n const splittedMessage = message.message.split(\" \");\n const mappingId = splittedMessage[splittedMessage.indexOf(\"MappingId:\") + 1]?.match(/^([^,]+),$/)?.[1];\n const groupId = splittedMessage[splittedMessage.indexOf(\"GroupId:\") + 1]?.match(/^([^,]+).$/)?.[1];\n\n if (mappingId && groupId) {\n acc.push({ mappingId, groupId });\n }\n return acc;\n }, []);\n }, [extractionMessageData]);\n\n // useQueries to fetch all group names\n const groupQueriesResults = useQueries({\n queries: extractionInfo.map(({ mappingId }) => ({\n queryKey: [\"groups\", mappingId],\n queryFn: async () => fetchGroups(groupingMappingApiConfig.iModelId, mappingId, groupingMappingApiConfig.getAccessToken, mappingClient),\n })),\n });\n\n // Workaround to get data from useQueries with more stability\n const pickedResult = useMemoizedCollectionPick(groupQueriesResults, [\"data\", \"error\", \"isLoading\", \"isSuccess\"]);\n\n useEffect(() => {\n if (pickedResult.every((query) => query.isSuccess) && mappings) {\n const formattedMessages = extractionMessageData.map((extractionMessage, index) => {\n let replacedMessage: string = extractionMessage.message;\n\n const { mappingId, groupId } = extractionInfo[index];\n const groupName = pickedResult[index].data!.find((group) => group.id === groupId)?.groupName;\n\n if (replacedMessage.includes(\"MappingId:\")) {\n const mappingName = getMappingName(mappingId, mappings);\n replacedMessage = replacedMessage.replace(/MappingId: [\\w-]+/, `Mapping: ${mappingName}`);\n }\n\n if (replacedMessage.includes(\"GroupId:\")) {\n replacedMessage = replacedMessage.replace(/GroupId: [\\w-]+/, `Group: ${groupName ? groupName : \"<Not Found>\"}`);\n }\n\n return { ...extractionMessage, message: replacedMessage };\n });\n\n setFormattedExtractionMessage(formattedMessages);\n }\n }, [extractionMessageData, mappings, extractionInfo, getMappingName, pickedResult]);\n\n useEffect(() => {\n const newDateTime: Date = new Date(timestamp);\n const options: Intl.DateTimeFormatOptions = {\n day: \"numeric\", month: \"numeric\", year: \"numeric\",\n hour: \"2-digit\", minute: \"2-digit\",\n };\n setFormattedTimestamp(newDateTime.toLocaleString(undefined, options));\n }, [timestamp]);\n\n const translatedLabels = useMemo(() => ({\n filter: \"Filter\",\n clear: \"Clear\",\n }), []);\n\n const columns = useMemo(\n (): Column<CreateTypeFromInterface<ExtractionMessageData>>[] => [\n {\n id: \"category\",\n Header: \"Category\",\n accessor: \"category\",\n fieldType: \"text\",\n Filter: ExtractionLogCustomFilter,\n filter: \"equals\",\n },\n {\n id: \"level\",\n Header: \"Level\",\n accessor: \"level\",\n cellRenderer: ({ cellElementProps, cellProps }: CellRendererProps<CreateTypeFromInterface<ExtractionMessageData>>) => {\n const level = cellProps.row.original.level;\n return (\n <DefaultCell\n cellElementProps={cellElementProps}\n cellProps={cellProps}\n startIcon={\n level === \"Error\" ? (\n <StatusIcon status='error' />\n ) : level === \"Warning\" ? (\n <StatusIcon status='warning' />\n ) : level === \"Info\" ? (\n <StatusIcon status='informational' />\n ) : <StatusIcon status='trace' />\n }\n >\n {level}\n </DefaultCell>\n );\n },\n Filter: ExtractionLogCustomFilter,\n filter: \"equals\",\n },\n {\n id: \"message\",\n Header: \"Message\",\n accessor: \"message\",\n width: \"25vw\",\n fieldType: \"text\",\n Filter: tableFilters.TextFilter(translatedLabels),\n },\n ],\n [translatedLabels]\n );\n const isLoading = pickedResult.some((query) => query.isLoading) || isMappingsLoading;\n\n return (\n <Modal className=\"gmw-message-modal-container\"\n title=\"Extraction Logs\"\n isOpen={isOpen}\n onClose={onClose}\n closeOnExternalClick={false}\n >\n <ModalContent>\n <div className=\"gmw-timestamp-icon\">\n <Icon\n title=\"Extraction Timestamp\"\n size=\"medium\"\n >\n <SvgClock />\n </Icon>\n <Text>{formattedTimestamp}</Text>\n </div>\n <Table<CreateTypeFromInterface<ExtractionMessageData>>\n columns={columns}\n data={formattedExtractionMessage ?? []}\n emptyTableContent={\"\"}\n emptyFilteredTableContent=\"No results match filters.\"\n className=\"gmw-extraction-message-table-container\"\n isLoading={isLoading}\n />\n </ModalContent>\n <ModalButtonBar>\n <Button\n onClick={onClose}\n styleType=\"high-visibility\"\n >\n Close\n </Button>\n </ModalButtonBar>\n </Modal>\n );\n};\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
declare type IconStatus = "negative" | "positive" | "warning" | undefined;
|
|
3
|
+
export interface ExtractionStatusData {
|
|
4
|
+
iconStatus: IconStatus;
|
|
5
|
+
iconMessage: string;
|
|
6
|
+
}
|
|
2
7
|
export interface ExtractionStatusIconProps {
|
|
3
|
-
iconStatus:
|
|
8
|
+
iconStatus: IconStatus;
|
|
4
9
|
onClick: () => void;
|
|
5
10
|
iconMessage: string;
|
|
6
11
|
}
|
|
7
12
|
export declare const ExtractionStatusIcon: ({ iconStatus, onClick, iconMessage }: ExtractionStatusIconProps) => JSX.Element;
|
|
13
|
+
export {};
|
|
8
14
|
//# sourceMappingURL=ExtractionStatusIcon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractionStatusIcon.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionStatusIcon.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,wDAA+E;AAC/E,kDAA0B;AAC1B,oEAAwD;
|
|
1
|
+
{"version":3,"file":"ExtractionStatusIcon.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionStatusIcon.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,wDAA+E;AAC/E,kDAA0B;AAC1B,oEAAwD;AAcjD,MAAM,oBAAoB,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAA6B,EAAE,EAAE;IACtG,OAAO,CACL,8BAAC,uBAAO,IAAC,OAAO,EAAE,WAAW;QAC3B,8BAAC,0BAAU,IAAC,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,OAAO;YACjD,8BAAC,kCAAkB,IAAC,MAAM,EAAE,UAAU;gBACpC,8BAAC,gCAAU,OAAG,CACK,CACV,CACL,CACX,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,oBAAoB,wBAU/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IconButton, NotificationMarker, Tooltip } from \"@itwin/itwinui-react\";\nimport React from \"react\";\nimport { SvgProcess } from \"@itwin/itwinui-icons-react\";\n\ntype IconStatus = \"negative\" | \"positive\" | \"warning\" | undefined;\nexport interface ExtractionStatusData {\n iconStatus: IconStatus;\n iconMessage: string;\n}\n\nexport interface ExtractionStatusIconProps {\n iconStatus: IconStatus;\n onClick: () => void;\n iconMessage: string;\n}\n\nexport const ExtractionStatusIcon = ({ iconStatus, onClick, iconMessage }: ExtractionStatusIconProps) => {\n return (\n <Tooltip content={iconMessage}>\n <IconButton styleType='borderless' onClick={onClick}>\n <NotificationMarker status={iconStatus}>\n <SvgProcess />\n </NotificationMarker>\n </IconButton>\n </Tooltip>\n );\n};\n"]}
|