@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
|
@@ -11,8 +11,34 @@ import { GroupHilitedElementsContext } from "./context/GroupHilitedElementsConte
|
|
|
11
11
|
import { PropertiesContext } from "./context/PropertiesContext";
|
|
12
12
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
13
13
|
import { createExtractionClient, ExtractionClientContext } from "./context/ExtractionClientContext";
|
|
14
|
-
import {
|
|
14
|
+
import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
15
|
+
import { toaster } from "@itwin/itwinui-react";
|
|
16
|
+
import { getErrorMessage } from "../common/utils";
|
|
15
17
|
const authorizationClientGetAccessToken = async () => (await IModelApp.authorizationClient?.getAccessToken()) ?? "";
|
|
18
|
+
const queryClient = new QueryClient({
|
|
19
|
+
defaultOptions: {
|
|
20
|
+
queries: {
|
|
21
|
+
refetchOnWindowFocus: false,
|
|
22
|
+
staleTime: 20 * 60 * 1000, // 20 minutes
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
queryCache: new QueryCache({
|
|
26
|
+
onError: (error) => {
|
|
27
|
+
if (error.status)
|
|
28
|
+
toaster.negative(getErrorMessage(error.status));
|
|
29
|
+
else
|
|
30
|
+
toaster.negative("An error occurred while fetching data.");
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
mutationCache: new MutationCache({
|
|
34
|
+
onError: (error) => {
|
|
35
|
+
if (error.status)
|
|
36
|
+
toaster.negative(getErrorMessage(error.status));
|
|
37
|
+
else
|
|
38
|
+
toaster.negative("A network error occured while processing this action.");
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
16
42
|
export const GroupingMappingContext = (props) => {
|
|
17
43
|
const activeIModelConntextion = useActiveIModelConnection();
|
|
18
44
|
const clientProp = props.client ?? props.prefix;
|
|
@@ -39,8 +65,6 @@ export const GroupingMappingContext = (props) => {
|
|
|
39
65
|
const [isOverlappedColored, setIsOverlappedColored] = useState(false);
|
|
40
66
|
const [currentHilitedGroups, setCurrentHilitedGroups] = useState(1);
|
|
41
67
|
const [overlappedElementGroupPairs, setOverlappedElementGroupPairs] = useState([]);
|
|
42
|
-
const [extractionStatusIcon, setExtractionStatusIcon] = useState({ iconStatus: undefined, iconMessage: "Loading..." });
|
|
43
|
-
const [extractionMessageData, setExtractionMessageData] = useState([]);
|
|
44
68
|
useEffect(() => {
|
|
45
69
|
setApiConfig(() => ({
|
|
46
70
|
prefix: props.prefix,
|
|
@@ -93,16 +117,10 @@ export const GroupingMappingContext = (props) => {
|
|
|
93
117
|
customUIs,
|
|
94
118
|
setCustomUIs,
|
|
95
119
|
}), [customUIs]);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
setExtractionStatusIcon,
|
|
101
|
-
}), [extractionStatusIcon, extractionMessageData]);
|
|
102
|
-
return (React.createElement(GroupingMappingApiConfigContext.Provider, { value: apiConfig },
|
|
103
|
-
React.createElement(MappingClientContext.Provider, { value: mappingClient },
|
|
104
|
-
React.createElement(ExtractionClientContext.Provider, { value: extractionClient },
|
|
105
|
-
React.createElement(ExtractionStatusDataContext.Provider, { value: extractionStatusDataValue },
|
|
120
|
+
return (React.createElement(QueryClientProvider, { client: queryClient },
|
|
121
|
+
React.createElement(GroupingMappingApiConfigContext.Provider, { value: apiConfig },
|
|
122
|
+
React.createElement(MappingClientContext.Provider, { value: mappingClient },
|
|
123
|
+
React.createElement(ExtractionClientContext.Provider, { value: extractionClient },
|
|
106
124
|
React.createElement(GroupingMappingCustomUIContext.Provider, { value: customUIContextValue },
|
|
107
125
|
React.createElement(GroupHilitedElementsContext.Provider, { value: hilitedElementsContextValue },
|
|
108
126
|
React.createElement(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,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE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QAAQ,IAAC,KAAK,EAAE,aAAa;YACjD,oBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;gBACvD,oBAAC,2BAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,yBAAyB;oBACpE,oBAAC,8BAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB;wBAClE,oBAAC,2BAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,2BAA2B;4BACtE,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACL,CACN,CACL,CACS,CAC5C,CAAC;AACJ,CAAC,CAAC","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,OAAO,KAAK,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ACvL,CAAC;IAEF,MAAM,sBAAsB,GAAG,OAAO,CACpC,GAAG,EAAE,CAAC,CAAC;QACL,cAAc,EAAE,mBAAmB;QACnC,iBAAiB,EAAE,sBAAsB;QACzC,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,uBAAuB;QACvB,2BAA2B;QAC3B,8BAA8B;KAC/B,CAAC,EACF,CAAC,oBAAoB,EAAE,2BAA2B,EAAE,eAAe,EAAE,mBAAmB,CAAC,CAC1F,CAAC;IAEF,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,SAAS;QACT,YAAY;KACb,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;QACtC,oBAAC,+BAA+B,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS;YACxD,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa;gBACjD,oBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;oBACvD,oBAAC,8BAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB;wBAClE,oBAAC,2BAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,2BAA2B;4BACtE,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACT,CACL,CACS,CACvB,CACvB,CAAC;AACJ,CAAC,CAAC","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,13 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
export const fetchGroups = async (iModelId, mappingId, getAccessToken, mappingsClient) => {
|
|
3
|
+
const accessToken = await getAccessToken();
|
|
4
|
+
const groups = await mappingsClient.getGroups(accessToken, iModelId, mappingId);
|
|
5
|
+
return groups;
|
|
6
|
+
};
|
|
7
|
+
export const useFetchGroups = (iModelId, mappingId, getAccessToken, mappingsClient) => {
|
|
8
|
+
return useQuery({
|
|
9
|
+
queryKey: ["groups", mappingId],
|
|
10
|
+
queryFn: async () => fetchGroups(iModelId, mappingId, getAccessToken, mappingsClient),
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useFetchGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchGroups.js","sourceRoot":"","sources":["../../../../../src/components/Groups/hooks/useFetchGroups.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,MAAM,CAAC,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;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,cAAgC,EAAE,cAA+B,EAAE,EAAE;IACvI,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC/B,OAAO,EAAG,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC;KACvF,CAAC,CAAC;AACL,CAAC,CAAC","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"]}
|
|
@@ -9,7 +9,8 @@ import useValidator, { NAME_REQUIREMENTS } from "../../Properties/hooks/useValid
|
|
|
9
9
|
import "./MappingAction.scss";
|
|
10
10
|
import { useMappingClient } from "../../context/MappingClientContext";
|
|
11
11
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
12
|
-
import {
|
|
12
|
+
import { handleInputChange } from "../../../common/utils";
|
|
13
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
13
14
|
const defaultDisplayStrings = {
|
|
14
15
|
mappingDetails: "Mapping Details",
|
|
15
16
|
};
|
|
@@ -22,40 +23,30 @@ export const MappingAction = ({ mapping, onSaveSuccess, onClickCancel, displaySt
|
|
|
22
23
|
extractionEnabled: mapping?.extractionEnabled ?? true,
|
|
23
24
|
});
|
|
24
25
|
const [validator, showValidationMessage] = useValidator();
|
|
25
|
-
const
|
|
26
|
+
const queryClient = useQueryClient();
|
|
26
27
|
const displayStrings = React.useMemo(() => ({ ...defaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (!validator.allValid()) {
|
|
30
|
-
showValidationMessage(true);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
setIsLoading(true);
|
|
28
|
+
const { mutate: saveMutation, isLoading } = useMutation({
|
|
29
|
+
mutationFn: async (newMapping) => {
|
|
34
30
|
const accessToken = await getAccessToken();
|
|
35
|
-
mapping
|
|
36
|
-
?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: await mappingClient.createMapping(accessToken, iModelId, {
|
|
42
|
-
mappingName: values.name,
|
|
43
|
-
description: values.description,
|
|
44
|
-
extractionEnabled: values.extractionEnabled,
|
|
45
|
-
});
|
|
46
|
-
setValues({
|
|
47
|
-
name: mapping?.mappingName ?? "",
|
|
48
|
-
description: mapping?.description ?? "",
|
|
49
|
-
extractionEnabled: mapping?.extractionEnabled ?? true,
|
|
50
|
-
});
|
|
31
|
+
return mapping
|
|
32
|
+
? mappingClient.updateMapping(accessToken, iModelId, mapping.id, newMapping)
|
|
33
|
+
: mappingClient.createMapping(accessToken, iModelId, newMapping);
|
|
34
|
+
},
|
|
35
|
+
onSuccess: async () => {
|
|
36
|
+
await queryClient.invalidateQueries({ queryKey: ["mappings"] });
|
|
51
37
|
onSaveSuccess();
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const onSave = async () => {
|
|
41
|
+
if (!validator.allValid()) {
|
|
42
|
+
showValidationMessage(true);
|
|
43
|
+
return;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
45
|
+
saveMutation({
|
|
46
|
+
mappingName: values.name,
|
|
47
|
+
description: values.description,
|
|
48
|
+
extractionEnabled: values.extractionEnabled,
|
|
49
|
+
});
|
|
59
50
|
};
|
|
60
51
|
return (React.createElement(React.Fragment, null,
|
|
61
52
|
React.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,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,qCAAqC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,EAAE;wBAClB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;oBAC9C,CAAC,GACD;gBACF,oBAAC,YAAY,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,oBAAC,WAAW,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","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;
|
|
@@ -11,51 +11,57 @@ import { ExtractionLogCustomFilter } from "./ExtractionLogCustomFilter";
|
|
|
11
11
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
12
12
|
import { useMappingClient } from "../../context/MappingClientContext";
|
|
13
13
|
import { useMappingsOperations } from "../hooks/useMappingsOperations";
|
|
14
|
+
import { useQueries } from "@tanstack/react-query";
|
|
15
|
+
import { useMemoizedCollectionPick } from "../../../common/hooks/useMemoizedCollectionPick";
|
|
16
|
+
import { fetchGroups } from "../../Groups/hooks/useFetchGroups";
|
|
14
17
|
export const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData, timestamp }) => {
|
|
15
|
-
const [formattedExtractionMessage, setFormattedExtractionMessage] = useState(
|
|
18
|
+
const [formattedExtractionMessage, setFormattedExtractionMessage] = useState(undefined);
|
|
16
19
|
const groupingMappingApiConfig = useGroupingMappingApiConfig();
|
|
17
20
|
const mappingClient = useMappingClient();
|
|
18
|
-
const { mappings } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });
|
|
21
|
+
const { mappings, isLoading: isMappingsLoading } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });
|
|
19
22
|
const [formattedTimestamp, setFormattedTimestamp] = useState("");
|
|
20
|
-
const getMappingName = useCallback(
|
|
21
|
-
return mappings.find((mapping) =>
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
const getMappingName = useCallback((mappingId, mappings) => {
|
|
24
|
+
return mappings.find((mapping) => mapping.id === mappingId)?.mappingName ?? "";
|
|
25
|
+
}, []);
|
|
26
|
+
// Extract groupIds and mappingIds from messages
|
|
27
|
+
const extractionInfo = useMemo(() => {
|
|
28
|
+
return extractionMessageData.reduce((acc, message) => {
|
|
29
|
+
const splittedMessage = message.message.split(" ");
|
|
30
|
+
const mappingId = splittedMessage[splittedMessage.indexOf("MappingId:") + 1]?.match(/^([^,]+),$/)?.[1];
|
|
31
|
+
const groupId = splittedMessage[splittedMessage.indexOf("GroupId:") + 1]?.match(/^([^,]+).$/)?.[1];
|
|
32
|
+
if (mappingId && groupId) {
|
|
33
|
+
acc.push({ mappingId, groupId });
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
}, []);
|
|
37
|
+
}, [extractionMessageData]);
|
|
38
|
+
// useQueries to fetch all group names
|
|
39
|
+
const groupQueriesResults = useQueries({
|
|
40
|
+
queries: extractionInfo.map(({ mappingId }) => ({
|
|
41
|
+
queryKey: ["groups", mappingId],
|
|
42
|
+
queryFn: async () => fetchGroups(groupingMappingApiConfig.iModelId, mappingId, groupingMappingApiConfig.getAccessToken, mappingClient),
|
|
43
|
+
})),
|
|
44
|
+
});
|
|
45
|
+
// Workaround to get data from useQueries with more stability
|
|
46
|
+
const pickedResult = useMemoizedCollectionPick(groupQueriesResults, ["data", "error", "isLoading", "isSuccess"]);
|
|
31
47
|
useEffect(() => {
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const mappingName = await getMappingName(mappingId[1]);
|
|
44
|
-
replacedMessage = replacedMessage.replace(/MappingId: [\w-]+/, `Mapping: ${mappingName}`);
|
|
45
|
-
}
|
|
46
|
-
if (replacedMessage.includes("GroupId:")) {
|
|
47
|
-
const groupId = splittedMessage[splittedMessage.indexOf("GroupId:") + 1].match(/^([^,]+).$/) ?? [];
|
|
48
|
-
const groupName = await getGroupNames(mappingId[1], groupId[1], groupsCache);
|
|
49
|
-
replacedMessage = replacedMessage.replace(/GroupId: [\w-]+/, `Group: ${groupName}`);
|
|
50
|
-
}
|
|
51
|
-
return { ...extractionMessage, message: replacedMessage };
|
|
48
|
+
if (pickedResult.every((query) => query.isSuccess) && mappings) {
|
|
49
|
+
const formattedMessages = extractionMessageData.map((extractionMessage, index) => {
|
|
50
|
+
let replacedMessage = extractionMessage.message;
|
|
51
|
+
const { mappingId, groupId } = extractionInfo[index];
|
|
52
|
+
const groupName = pickedResult[index].data.find((group) => group.id === groupId)?.groupName;
|
|
53
|
+
if (replacedMessage.includes("MappingId:")) {
|
|
54
|
+
const mappingName = getMappingName(mappingId, mappings);
|
|
55
|
+
replacedMessage = replacedMessage.replace(/MappingId: [\w-]+/, `Mapping: ${mappingName}`);
|
|
56
|
+
}
|
|
57
|
+
if (replacedMessage.includes("GroupId:")) {
|
|
58
|
+
replacedMessage = replacedMessage.replace(/GroupId: [\w-]+/, `Group: ${groupName ? groupName : "<Not Found>"}`);
|
|
52
59
|
}
|
|
60
|
+
return { ...extractionMessage, message: replacedMessage };
|
|
53
61
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
void formatMessages();
|
|
58
|
-
}, [extractionMessageData, groupingMappingApiConfig, mappings, mappingClient, getGroupNames, getMappingName]);
|
|
62
|
+
setFormattedExtractionMessage(formattedMessages);
|
|
63
|
+
}
|
|
64
|
+
}, [extractionMessageData, mappings, extractionInfo, getMappingName, pickedResult]);
|
|
59
65
|
useEffect(() => {
|
|
60
66
|
const newDateTime = new Date(timestamp);
|
|
61
67
|
const options = {
|
|
@@ -97,13 +103,14 @@ export const ExtractionMessageModal = ({ isOpen, onClose, extractionMessageData,
|
|
|
97
103
|
Filter: tableFilters.TextFilter(translatedLabels),
|
|
98
104
|
},
|
|
99
105
|
], [translatedLabels]);
|
|
106
|
+
const isLoading = pickedResult.some((query) => query.isLoading) || isMappingsLoading;
|
|
100
107
|
return (React.createElement(Modal, { className: "gmw-message-modal-container", title: "Extraction Logs", isOpen: isOpen, onClose: onClose, closeOnExternalClick: false },
|
|
101
108
|
React.createElement(ModalContent, null,
|
|
102
109
|
React.createElement("div", { className: "gmw-timestamp-icon" },
|
|
103
110
|
React.createElement(Icon, { title: "Extraction Timestamp", size: "medium" },
|
|
104
111
|
React.createElement(SvgClock, null)),
|
|
105
112
|
React.createElement(Text, null, formattedTimestamp)),
|
|
106
|
-
React.createElement(Table, { columns: columns, data: formattedExtractionMessage, emptyTableContent: "", emptyFilteredTableContent: "No results match filters.", className: "gmw-extraction-message-table-container" })),
|
|
113
|
+
React.createElement(Table, { columns: columns, data: formattedExtractionMessage ?? [], emptyTableContent: "", emptyFilteredTableContent: "No results match filters.", className: "gmw-extraction-message-table-container", isLoading: isLoading })),
|
|
107
114
|
React.createElement(ModalButtonBar, null,
|
|
108
115
|
React.createElement(Button, { onClick: onClose, styleType: "high-visibility" }, "Close"))));
|
|
109
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractionMessageModal.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionMessageModal.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE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,oBAAC,UAAU,IAAC,MAAM,EAAC,eAAe,GAAG,CACtC,CAAC,CAAC,CAAC,oBAAC,UAAU,IAAC,MAAM,EAAC,OAAO,GAAG,IAGlC,KAAK,CACM,CACf,CAAC;YACJ,CAAC;YACD,MAAM,EAAE,yBAAyB;YACjC,MAAM,EAAE,QAAQ;SACjB;QACD;YACE,EAAE,EAAE,SAAS;YACb,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,MAAM;YACjB,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,gBAAgB,CAAC;SAClD;KACF,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IACF,OAAO,CACL,oBAAC,KAAK,IAAC,SAAS,EAAC,6BAA6B,EAC5C,KAAK,EAAC,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,KAAK;QAE3B,oBAAC,YAAY;YACX,6BAAK,SAAS,EAAC,oBAAoB;gBACjC,oBAAC,IAAI,IACH,KAAK,EAAC,sBAAsB,EAC5B,IAAI,EAAC,QAAQ;oBAEb,oBAAC,QAAQ,OAAG,CACP;gBACP,oBAAC,IAAI,QAAE,kBAAkB,CAAQ,CAC7B;YACN,oBAAC,KAAK,IACJ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,0BAA0B,EAChC,iBAAiB,EAAE,EAAE,EACrB,yBAAyB,EAAC,2BAA2B,EACrD,SAAS,EAAC,wCAAwC,GAClD,CACW;QACf,oBAAC,cAAc;YACb,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,iBAAiB,YAGpB,CACM,CACX,CACT,CAAC;AACJ,CAAC,CAAC","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,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,sBAAsB,C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,2BAA2B,EACrD,SAAS,EAAC,wCAAwC,EAClD,SAAS,EAAE,SAAS,GACpB,CACW;QACf,oBAAC,cAAc;YACb,oBAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,iBAAiB,YAGpB,CACM,CACX,CACT,CAAC;AACJ,CAAC,CAAC","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,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ExtractionStatusIcon.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Extraction/ExtractionStatusIcon.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAcxD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAA6B,EAAE,EAAE;IACtG,OAAO,CACL,oBAAC,OAAO,IAAC,OAAO,EAAE,WAAW;QAC3B,oBAAC,UAAU,IAAC,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,OAAO;YACjD,oBAAC,kBAAkB,IAAC,MAAM,EAAE,UAAU;gBACpC,oBAAC,UAAU,OAAG,CACK,CACV,CACL,CACX,CAAC;AACJ,CAAC,CAAC","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"]}
|
package/lib/esm/components/Mappings/{ConfirmMappingsImport.js → Import/ConfirmMappingsImport.js}
RENAMED
|
@@ -6,10 +6,10 @@ import { Button, LabeledInput, MiddleTextTruncation, ProgressLinear, Text, } fro
|
|
|
6
6
|
import React, { useEffect, useState } from "react";
|
|
7
7
|
import "./ConfirmMappingsImport.scss";
|
|
8
8
|
import { SvgStatusSuccessHollow } from "@itwin/itwinui-icons-react";
|
|
9
|
-
import useValidator, { NAME_REQUIREMENTS } from "
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import useValidator, { NAME_REQUIREMENTS } from "../../Properties/hooks/useValidator";
|
|
10
|
+
import { useMappingClient } from "../../context/MappingClientContext";
|
|
11
|
+
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
12
|
+
import { useMutation } from "@tanstack/react-query";
|
|
13
13
|
const defaultDisplayStrings = {
|
|
14
14
|
mappings: "Mappings",
|
|
15
15
|
};
|
|
@@ -35,26 +35,33 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
|
|
|
35
35
|
};
|
|
36
36
|
setSelectedMappings(newState);
|
|
37
37
|
};
|
|
38
|
+
const importMutation = useMutation({
|
|
39
|
+
mutationFn: async (selectedMapping) => {
|
|
40
|
+
const accessToken = await getAccessToken();
|
|
41
|
+
await mappingClient.copyMapping(accessToken, sourceiModelId, selectedMapping.id, {
|
|
42
|
+
targetIModelId: iModelId,
|
|
43
|
+
mappingName: selectedMapping.mappingName,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
onMutate: async (selectedMapping) => {
|
|
47
|
+
setCurrentlyImporting(selectedMapping.mappingName);
|
|
48
|
+
},
|
|
49
|
+
onSuccess: () => {
|
|
50
|
+
setImportCount((count) => count + 1);
|
|
51
|
+
},
|
|
52
|
+
onError: () => {
|
|
53
|
+
setErrored(true);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
38
56
|
const onImport = async () => {
|
|
39
57
|
if (!validator.allValid()) {
|
|
40
58
|
showValidationMessage(true);
|
|
41
59
|
return;
|
|
42
60
|
}
|
|
43
61
|
setImporting(true);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const accessToken = await getAccessToken();
|
|
48
|
-
await mappingClient.copyMapping(accessToken, sourceiModelId, selectedMapping.id ?? "", {
|
|
49
|
-
targetIModelId: iModelId ?? "",
|
|
50
|
-
mappingName: selectedMapping.mappingName ?? "",
|
|
51
|
-
});
|
|
52
|
-
setImportCount((importCount) => importCount + 1);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
handleError(error);
|
|
57
|
-
setErrored(true);
|
|
62
|
+
setImportCount(0);
|
|
63
|
+
for (const mapping of selectedMappings) {
|
|
64
|
+
await importMutation.mutateAsync(mapping);
|
|
58
65
|
}
|
|
59
66
|
};
|
|
60
67
|
return (React.createElement(React.Fragment, null, importing ? (React.createElement("div", { className: 'gmw-import-progress-container' },
|
|
@@ -77,13 +84,13 @@ const ConfirmMappingImport = ({ sourceiModelId, selectedMappings, importing, set
|
|
|
77
84
|
], status: !errored ?
|
|
78
85
|
importCount === selectedMappings.length ? "positive" : undefined : "negative" })),
|
|
79
86
|
React.createElement("div", { className: 'gmw-import-action-panel' },
|
|
80
|
-
React.createElement(Button, { disabled: !errored && importCount
|
|
87
|
+
React.createElement(Button, { disabled: !errored && importCount === selectedMappings.length, onClick: () => {
|
|
81
88
|
setImporting(false);
|
|
82
89
|
setImportCount(0);
|
|
83
90
|
setCurrentlyImporting("");
|
|
84
91
|
setErrored(false);
|
|
85
92
|
} }, "Back"),
|
|
86
|
-
React.createElement(Button, { styleType: 'high-visibility', disabled: !errored && importCount !== selectedMappings.length, onClick:
|
|
93
|
+
React.createElement(Button, { styleType: 'high-visibility', disabled: !errored && importCount !== selectedMappings.length, onClick: onFinish }, "Close")))) : (React.createElement("div", { className: 'gmw-rename-confirm-container ' },
|
|
87
94
|
React.createElement("div", { className: 'gmw-mapping-rename-container' },
|
|
88
95
|
React.createElement("div", { className: 'gmw-mapping-row-header-container' },
|
|
89
96
|
React.createElement("div", { className: 'gmw-mapping-row' },
|