@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
|
@@ -2,21 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import React
|
|
5
|
+
import React from "react";
|
|
6
6
|
import { useMappingClient } from "../context/MappingClientContext";
|
|
7
7
|
import { useGroupingMappingApiConfig } from "../context/GroupingApiConfigContext";
|
|
8
8
|
import { MappingsView } from "./MappingsView";
|
|
9
9
|
import { useMappingsOperations } from "./hooks/useMappingsOperations";
|
|
10
|
-
import { Alert } from "@itwin/itwinui-react";
|
|
11
10
|
export const Mappings = (props) => {
|
|
12
11
|
const groupingMappingApiConfig = useGroupingMappingApiConfig();
|
|
13
12
|
const mappingClient = useMappingClient();
|
|
14
|
-
const { mappings, isLoading,
|
|
15
|
-
|
|
16
|
-
if (!errorMessage)
|
|
17
|
-
return;
|
|
18
|
-
return (React.createElement(Alert, { type: "negative", onClose: () => setErrorMessage(undefined) }, errorMessage));
|
|
19
|
-
}, [errorMessage, setErrorMessage]);
|
|
20
|
-
return (React.createElement(MappingsView, { mappings: mappings, isLoading: isLoading, extractionStatusData: extractionStatusIcon, showExtractionMessageModal: showExtractionMessageModal, extractionMessageData: extractionMessageData, setShowExtractionMessageModal: setShowExtractionMessageModal, onRefresh: refresh, onToggleExtraction: toggleExtraction, onDelete: onDelete, showImportModal: showImportModal, setShowImportModal: setShowImportModal, showDeleteModal: showDeleteModal, setShowDeleteModal: setShowDeleteModal, isTogglingExtraction: isTogglingExtraction, alert: renderAlert(), ...props }));
|
|
13
|
+
const { mappings, isLoading, showExtractionMessageModal, extractionStatus, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });
|
|
14
|
+
return (React.createElement(MappingsView, { mappings: mappings ?? [], isLoading: isLoading, extractionStatusData: extractionStatus.extractionStatusIcon, showExtractionMessageModal: showExtractionMessageModal, extractionMessageData: extractionStatus.extractionMessageData, setShowExtractionMessageModal: setShowExtractionMessageModal, onRefreshMappings: refreshMappings, onRefreshExtractionStatus: refreshExtractionStatus, onToggleExtraction: toggleExtraction, onDelete: onDelete, showImportModal: showImportModal, setShowImportModal: setShowImportModal, showDeleteModal: showDeleteModal, setShowDeleteModal: setShowDeleteModal, isTogglingExtraction: isTogglingExtraction, ...props }));
|
|
21
15
|
};
|
|
22
16
|
//# sourceMappingURL=Mappings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mappings.js","sourceRoot":"","sources":["../../../../src/components/Mappings/Mappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Mappings.js","sourceRoot":"","sources":["../../../../src/components/Mappings/Mappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAWtE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC/C,MAAM,wBAAwB,GAAG,2BAA2B,EAAE,CAAC;IAC/D,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,0BAA0B,EAC1B,gBAAgB,EAChB,6BAA6B,EAC7B,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,GAAG,qBAAqB,CAAC,EAAE,GAAG,wBAAwB,EAAE,aAAa,EAAE,CAAC,CAAC;IAE1E,OAAO,CACL,oBAAC,YAAY,IACX,QAAQ,EAAE,QAAQ,IAAI,EAAE,EACxB,SAAS,EAAE,SAAS,EACpB,oBAAoB,EAAE,gBAAgB,CAAC,oBAAoB,EAC3D,0BAA0B,EAAE,0BAA0B,EACtD,qBAAqB,EAAE,gBAAgB,CAAC,qBAAqB,EAC7D,6BAA6B,EAAE,6BAA6B,EAC5D,iBAAiB,EAAE,eAAe,EAClC,yBAAyB,EAAE,uBAAuB,EAClD,kBAAkB,EAAE,gBAAgB,EACpC,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,kBAAkB,EACtC,oBAAoB,EAAE,oBAAoB,KACtC,KAAK,GACT,CACH,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 from \"react\";\nimport { useMappingClient } from \"../context/MappingClientContext\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { CreateTypeFromInterface } from \"../../common/utils\";\nimport type { mappingViewDefaultDisplayStrings } from \"./MappingsView\";\nimport { MappingsView } from \"./MappingsView\";\nimport { useMappingsOperations } from \"./hooks/useMappingsOperations\";\n\nexport type IMappingTyped = CreateTypeFromInterface<Mapping>;\n\nexport interface MappingsProps {\n onClickAddMapping?: () => void;\n onClickMappingTitle?: (mapping: Mapping) => void;\n onClickMappingModify?: (mapping: Mapping) => void;\n displayStrings?: Partial<typeof mappingViewDefaultDisplayStrings>;\n}\n\nexport const Mappings = (props: MappingsProps) => {\n const groupingMappingApiConfig = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const {\n mappings,\n isLoading,\n showExtractionMessageModal,\n extractionStatus,\n setShowExtractionMessageModal,\n refreshMappings,\n refreshExtractionStatus,\n toggleExtraction,\n onDelete,\n setShowImportModal,\n showImportModal,\n setShowDeleteModal,\n showDeleteModal,\n isTogglingExtraction,\n } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });\n\n return (\n <MappingsView\n mappings={mappings ?? []}\n isLoading={isLoading}\n extractionStatusData={extractionStatus.extractionStatusIcon}\n showExtractionMessageModal={showExtractionMessageModal}\n extractionMessageData={extractionStatus.extractionMessageData}\n setShowExtractionMessageModal={setShowExtractionMessageModal}\n onRefreshMappings={refreshMappings}\n onRefreshExtractionStatus={refreshExtractionStatus}\n onToggleExtraction={toggleExtraction}\n onDelete={onDelete}\n showImportModal={showImportModal}\n setShowImportModal={setShowImportModal}\n showDeleteModal={showDeleteModal}\n setShowDeleteModal={setShowDeleteModal}\n isTogglingExtraction={isTogglingExtraction}\n {...props}\n />\n );\n};\n"]}
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import type { Alert } from "@itwin/itwinui-react";
|
|
3
3
|
import "./MappingsView.scss";
|
|
4
4
|
import type { Mapping } from "@itwin/insights-client";
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
5
|
+
import type { ExtractionStatusData } from "./Extraction/ExtractionStatusIcon";
|
|
6
|
+
import type { ExtractionMessageData } from "./Extraction/ExtractionMessageModal";
|
|
7
7
|
export declare const mappingViewDefaultDisplayStrings: {
|
|
8
8
|
mappings: string;
|
|
9
9
|
iTwins: string;
|
|
@@ -22,7 +22,8 @@ export interface MappingsViewProps {
|
|
|
22
22
|
extractionMessageData: ExtractionMessageData[];
|
|
23
23
|
setShowExtractionMessageModal: (show: boolean) => void;
|
|
24
24
|
isTogglingExtraction: boolean;
|
|
25
|
-
|
|
25
|
+
onRefreshMappings: () => Promise<void>;
|
|
26
|
+
onRefreshExtractionStatus: () => Promise<void>;
|
|
26
27
|
onToggleExtraction: (mapping: Mapping) => Promise<void>;
|
|
27
28
|
onDelete: (mapping: Mapping) => Promise<void>;
|
|
28
29
|
showDeleteModal: Mapping | undefined;
|
|
@@ -35,5 +36,5 @@ export interface MappingsViewProps {
|
|
|
35
36
|
onClickMappingModify?: (mapping: Mapping) => void;
|
|
36
37
|
alert?: React.ReactElement<typeof Alert>;
|
|
37
38
|
}
|
|
38
|
-
export declare const MappingsView: ({ mappings, isLoading, extractionStatusData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction,
|
|
39
|
+
export declare const MappingsView: ({ mappings, isLoading, extractionStatusData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction, onRefreshMappings, onRefreshExtractionStatus, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }: MappingsViewProps) => JSX.Element;
|
|
39
40
|
//# sourceMappingURL=MappingsView.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React, { useCallback } from "react";
|
|
6
6
|
import { Button, IconButton, } from "@itwin/itwinui-react";
|
|
7
7
|
import { SvgAdd, SvgImport, SvgRefresh, } from "@itwin/itwinui-icons-react";
|
|
8
8
|
import { EmptyMessage } from "../SharedComponents/EmptyMessage";
|
|
@@ -25,8 +25,11 @@ export const mappingViewDefaultDisplayStrings = {
|
|
|
25
25
|
iModelName: "Name",
|
|
26
26
|
iModelDescription: "Description",
|
|
27
27
|
};
|
|
28
|
-
export const MappingsView = ({ mappings, isLoading, extractionStatusData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction,
|
|
28
|
+
export const MappingsView = ({ mappings, isLoading, extractionStatusData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction, onRefreshMappings, onRefreshExtractionStatus, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }) => {
|
|
29
29
|
const displayStrings = React.useMemo(() => ({ ...mappingViewDefaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
30
|
+
const refreshAll = useCallback(async () => {
|
|
31
|
+
await Promise.all([onRefreshMappings(), onRefreshExtractionStatus()]);
|
|
32
|
+
}, [onRefreshMappings, onRefreshExtractionStatus]);
|
|
30
33
|
return (React.createElement(React.Fragment, null,
|
|
31
34
|
React.createElement(BlockingOverlay, { isVisible: isTogglingExtraction }),
|
|
32
35
|
React.createElement("div", { className: "gmw-mappings-view-container" },
|
|
@@ -42,16 +45,16 @@ export const MappingsView = ({ mappings, isLoading, extractionStatusData, showEx
|
|
|
42
45
|
setShowExtractionMessageModal(true);
|
|
43
46
|
}
|
|
44
47
|
}, iconMessage: extractionStatusData.iconMessage }),
|
|
45
|
-
React.createElement(IconButton, { title: "Refresh", onClick:
|
|
48
|
+
React.createElement(IconButton, { title: "Refresh", onClick: refreshAll, disabled: isLoading, styleType: 'borderless' },
|
|
46
49
|
React.createElement(SvgRefresh, null)))),
|
|
47
50
|
alert,
|
|
48
51
|
React.createElement("div", { className: 'gmw-mappings-border' }),
|
|
49
|
-
isLoading ? (React.createElement(LoadingOverlay, null)) : mappings.length === 0 ? (React.createElement(EmptyMessage, { message: `No ${displayStrings.mappings} available.` })) : (React.createElement("div", { className: "gmw-mappings-list" }, mappings.map((mapping) => (React.createElement(HorizontalTile, { key: mapping.id, title: mapping.mappingName ? mapping.mappingName : "Untitled", subText: mapping.description ?? "", subtextToolTip: mapping.description ?? "", titleTooltip: mapping.mappingName, onClickTitle: onClickMappingTitle ? () => onClickMappingTitle(mapping) : undefined, actionGroup: React.createElement(MappingUIActionGroup, { mapping: mapping, onToggleExtraction: onToggleExtraction, onRefresh:
|
|
50
|
-
React.createElement(ExtractionMessageModal, { isOpen: showExtractionMessageModal, onClose: () => setShowExtractionMessageModal(false), extractionMessageData: extractionMessageData, timestamp: extractionMessageData.length === 0 ? "" : extractionMessageData[0].date }),
|
|
52
|
+
isLoading ? (React.createElement(LoadingOverlay, null)) : mappings.length === 0 ? (React.createElement(EmptyMessage, { message: `No ${displayStrings.mappings} available.` })) : (React.createElement("div", { className: "gmw-mappings-list" }, mappings.map((mapping) => (React.createElement(HorizontalTile, { key: mapping.id, title: mapping.mappingName ? mapping.mappingName : "Untitled", subText: mapping.description ?? "", subtextToolTip: mapping.description ?? "", titleTooltip: mapping.mappingName, onClickTitle: onClickMappingTitle ? () => onClickMappingTitle(mapping) : undefined, actionGroup: React.createElement(MappingUIActionGroup, { mapping: mapping, onToggleExtraction: onToggleExtraction, onRefresh: onRefreshMappings, onClickMappingModify: onClickMappingModify, setShowDeleteModal: setShowDeleteModal }) })))))),
|
|
53
|
+
showExtractionMessageModal && React.createElement(ExtractionMessageModal, { isOpen: showExtractionMessageModal, onClose: () => setShowExtractionMessageModal(false), extractionMessageData: extractionMessageData, timestamp: extractionMessageData.length === 0 ? "" : extractionMessageData[0].date }),
|
|
51
54
|
showDeleteModal &&
|
|
52
55
|
React.createElement(DeleteModal, { entityName: showDeleteModal?.mappingName, onClose: () => setShowDeleteModal(undefined), onDelete: async () => {
|
|
53
56
|
await onDelete(showDeleteModal);
|
|
54
|
-
}
|
|
55
|
-
showImportModal && setShowImportModal && React.createElement(MappingImportWizardModal, { show: showImportModal, setShow: setShowImportModal, onFinish:
|
|
57
|
+
} }),
|
|
58
|
+
showImportModal && setShowImportModal && React.createElement(MappingImportWizardModal, { show: showImportModal, setShow: setShowImportModal, onFinish: onRefreshMappings, displayStrings: displayStrings })));
|
|
56
59
|
};
|
|
57
60
|
//# sourceMappingURL=MappingsView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingsView.js","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AClF;QACD,eAAe;YACd,oBAAC,WAAW,IACV,UAAU,EAAE,eAAe,EAAE,WAAW,EACxC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAC5C,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC,EACD,OAAO,EAAE,SAAS,GAClB;QAEH,eAAe,IAAI,kBAAkB,IAAI,oBAAC,wBAAwB,IACjE,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,SAAS,EACnB,cAAc,EAAE,cAAc,GAC9B,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 React from \"react\";\nimport type {\n Alert,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n IconButton,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgAdd,\n SvgImport,\n SvgRefresh,\n} from \"@itwin/itwinui-icons-react\";\nimport { EmptyMessage } from \"../SharedComponents/EmptyMessage\";\nimport { LoadingOverlay } from \"../SharedComponents/LoadingOverlay\";\nimport \"./MappingsView.scss\";\nimport DeleteModal from \"../SharedComponents/DeleteModal\";\nimport { MappingImportWizardModal } from \"./Import/MappingImportWizardModal\";\nimport { HorizontalTile } from \"../SharedComponents/HorizontalTile\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { MappingUIActionGroup } from \"./MappingViewActionGroup\";\nimport type { ExtractionMessageData } from \"../context/ExtractionStatusDataContext\";\nimport type { ExtractionStatusData } from \"../context/ExtractionStatusDataContext\";\nimport { ExtractionStatusIcon } from \"./Extraction/ExtractionStatusIcon\";\nimport { ExtractionMessageModal } from \"./Extraction/ExtractionMessageModal\";\n\nexport const mappingViewDefaultDisplayStrings = {\n mappings: \"Mappings\",\n iTwins: \"iTwins\",\n iTwinNumber: \"Number\",\n iTwinName: \"Name\",\n iTwinStatus: \"Status\",\n iModels: \"iModels\",\n iModelName: \"Name\",\n iModelDescription: \"Description\",\n};\n\nexport interface MappingsViewProps {\n mappings: Mapping[];\n isLoading: boolean;\n extractionStatusData: ExtractionStatusData;\n showExtractionMessageModal: boolean;\n extractionMessageData: ExtractionMessageData[];\n setShowExtractionMessageModal: (show: boolean) => void;\n isTogglingExtraction: boolean;\n onRefresh: () => Promise<void>;\n onToggleExtraction: (mapping: Mapping) => Promise<void>;\n onDelete: (mapping: Mapping) => Promise<void>;\n showDeleteModal: Mapping | undefined;\n setShowDeleteModal: (mapping?: Mapping) => void;\n displayStrings?: Partial<typeof mappingViewDefaultDisplayStrings>;\n showImportModal?: boolean;\n setShowImportModal?: (show: boolean) => void;\n onClickAddMapping?: () => void;\n onClickMappingTitle?: (mapping: Mapping) => void;\n onClickMappingModify?: (mapping: Mapping) => void;\n alert?: React.ReactElement<typeof Alert>;\n}\n\nexport const MappingsView = ({\n mappings,\n isLoading,\n extractionStatusData,\n showExtractionMessageModal,\n extractionMessageData,\n setShowExtractionMessageModal,\n isTogglingExtraction,\n onRefresh,\n onToggleExtraction,\n onDelete,\n showDeleteModal,\n setShowDeleteModal,\n displayStrings: userDisplayStrings,\n showImportModal,\n setShowImportModal,\n onClickAddMapping,\n onClickMappingTitle,\n onClickMappingModify,\n alert,\n}: MappingsViewProps) => {\n const displayStrings = React.useMemo(\n () => ({ ...mappingViewDefaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n return (\n <>\n <BlockingOverlay isVisible={isTogglingExtraction} />\n <div className=\"gmw-mappings-view-container\">\n <div className=\"gmw-table-toolbar\">\n <div className=\"gmw-button-spacing\">\n {onClickAddMapping &&\n <Button\n startIcon={<SvgAdd />}\n onClick={onClickAddMapping}\n styleType=\"high-visibility\"\n title=\"New Mapping\"\n >\n New\n </Button>\n }\n {showImportModal !== undefined && setShowImportModal && <IconButton\n title={`Import ${displayStrings.mappings}`}\n onClick={() => setShowImportModal(true)}\n >\n <SvgImport />\n </IconButton>\n }\n </div>\n <div className=\"gmw-button-spacing\">\n <ExtractionStatusIcon\n iconStatus={extractionStatusData.iconStatus}\n onClick={() => {\n if (extractionStatusData.iconStatus === \"negative\") {\n setShowExtractionMessageModal(true);\n }\n }}\n iconMessage={extractionStatusData.iconMessage}\n />\n <IconButton\n title=\"Refresh\"\n onClick={onRefresh}\n disabled={isLoading}\n styleType='borderless'\n >\n <SvgRefresh />\n </IconButton>\n </div>\n </div>\n {alert}\n <div className='gmw-mappings-border' />\n {isLoading ? (\n <LoadingOverlay />\n ) : mappings.length === 0 ? (\n <EmptyMessage message={`No ${displayStrings.mappings} available.`} />\n ) : (\n <div className=\"gmw-mappings-list\">\n {mappings.map((mapping) => (\n <HorizontalTile\n key={mapping.id}\n title={mapping.mappingName ? mapping.mappingName : \"Untitled\"}\n subText={mapping.description ?? \"\"}\n subtextToolTip={mapping.description ?? \"\"}\n titleTooltip={mapping.mappingName}\n onClickTitle={onClickMappingTitle ? () => onClickMappingTitle(mapping) : undefined}\n actionGroup={\n <MappingUIActionGroup\n mapping={mapping}\n onToggleExtraction={onToggleExtraction}\n onRefresh={onRefresh}\n onClickMappingModify={onClickMappingModify}\n setShowDeleteModal={setShowDeleteModal}\n />\n }\n />\n ))}\n </div>\n )}\n </div>\n <ExtractionMessageModal\n isOpen={showExtractionMessageModal}\n onClose={() => setShowExtractionMessageModal(false)}\n extractionMessageData={extractionMessageData}\n timestamp={extractionMessageData.length === 0 ? \"\" : extractionMessageData[0].date}\n />\n {showDeleteModal &&\n <DeleteModal\n entityName={showDeleteModal?.mappingName}\n onClose={() => setShowDeleteModal(undefined)}\n onDelete={async () => {\n await onDelete(showDeleteModal);\n }}\n refresh={onRefresh}\n />\n }\n {showImportModal && setShowImportModal && <MappingImportWizardModal\n show={showImportModal}\n setShow={setShowImportModal}\n onFinish={onRefresh}\n displayStrings={displayStrings}\n />}\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"MappingsView.js","sourceRoot":"","sources":["../../../../src/components/Mappings/MappingsView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,EACL,MAAM,EACN,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,QAAQ;IACrB,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,MAAM;IAClB,iBAAiB,EAAE,aAAa;CACjC,CAAC;AAyBF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,6BAA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B,oBAAoB,EAAE,oBAAoB,EAC1C,kBAAkB,EAAE,kBAAkB,GACtC,GAEJ,CACH,CAAC,CACE,CACP,CACG;QACL,0BAA0B,IAAI,oBAAC,sBAAsB,IACpD,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,GAAG,EAAE,CAAC,6BAA6B,CAAC,KAAK,CAAC,EACnD,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,qBAAqB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI,GAClF;QACD,eAAe;YACd,oBAAC,WAAW,IACV,UAAU,EAAE,eAAe,EAAE,WAAW,EACxC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAC5C,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC,GACD;QAEH,eAAe,IAAI,kBAAkB,IAAI,oBAAC,wBAAwB,IACjE,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,GAC9B,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 React, { useCallback } from \"react\";\nimport type {\n Alert,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n IconButton,\n} from \"@itwin/itwinui-react\";\nimport {\n SvgAdd,\n SvgImport,\n SvgRefresh,\n} from \"@itwin/itwinui-icons-react\";\nimport { EmptyMessage } from \"../SharedComponents/EmptyMessage\";\nimport { LoadingOverlay } from \"../SharedComponents/LoadingOverlay\";\nimport \"./MappingsView.scss\";\nimport DeleteModal from \"../SharedComponents/DeleteModal\";\nimport { MappingImportWizardModal } from \"./Import/MappingImportWizardModal\";\nimport { HorizontalTile } from \"../SharedComponents/HorizontalTile\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { MappingUIActionGroup } from \"./MappingViewActionGroup\";\nimport type { ExtractionStatusData } from \"./Extraction/ExtractionStatusIcon\";\nimport { ExtractionStatusIcon } from \"./Extraction/ExtractionStatusIcon\";\nimport type { ExtractionMessageData } from \"./Extraction/ExtractionMessageModal\";\nimport { ExtractionMessageModal } from \"./Extraction/ExtractionMessageModal\";\n\nexport const mappingViewDefaultDisplayStrings = {\n mappings: \"Mappings\",\n iTwins: \"iTwins\",\n iTwinNumber: \"Number\",\n iTwinName: \"Name\",\n iTwinStatus: \"Status\",\n iModels: \"iModels\",\n iModelName: \"Name\",\n iModelDescription: \"Description\",\n};\n\nexport interface MappingsViewProps {\n mappings: Mapping[];\n isLoading: boolean;\n extractionStatusData: ExtractionStatusData;\n showExtractionMessageModal: boolean;\n extractionMessageData: ExtractionMessageData[];\n setShowExtractionMessageModal: (show: boolean) => void;\n isTogglingExtraction: boolean;\n onRefreshMappings: () => Promise<void>;\n onRefreshExtractionStatus: () => Promise<void>;\n onToggleExtraction: (mapping: Mapping) => Promise<void>;\n onDelete: (mapping: Mapping) => Promise<void>;\n showDeleteModal: Mapping | undefined;\n setShowDeleteModal: (mapping?: Mapping) => void;\n displayStrings?: Partial<typeof mappingViewDefaultDisplayStrings>;\n showImportModal?: boolean;\n setShowImportModal?: (show: boolean) => void;\n onClickAddMapping?: () => void;\n onClickMappingTitle?: (mapping: Mapping) => void;\n onClickMappingModify?: (mapping: Mapping) => void;\n alert?: React.ReactElement<typeof Alert>;\n}\n\nexport const MappingsView = ({\n mappings,\n isLoading,\n extractionStatusData,\n showExtractionMessageModal,\n extractionMessageData,\n setShowExtractionMessageModal,\n isTogglingExtraction,\n onRefreshMappings,\n onRefreshExtractionStatus,\n onToggleExtraction,\n onDelete,\n showDeleteModal,\n setShowDeleteModal,\n displayStrings: userDisplayStrings,\n showImportModal,\n setShowImportModal,\n onClickAddMapping,\n onClickMappingTitle,\n onClickMappingModify,\n alert,\n}: MappingsViewProps) => {\n const displayStrings = React.useMemo(\n () => ({ ...mappingViewDefaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const refreshAll = useCallback(async () => {\n await Promise.all([onRefreshMappings(), onRefreshExtractionStatus()]);\n }, [onRefreshMappings, onRefreshExtractionStatus]);\n\n return (\n <>\n <BlockingOverlay isVisible={isTogglingExtraction} />\n <div className=\"gmw-mappings-view-container\">\n <div className=\"gmw-table-toolbar\">\n <div className=\"gmw-button-spacing\">\n {onClickAddMapping &&\n <Button\n startIcon={<SvgAdd />}\n onClick={onClickAddMapping}\n styleType=\"high-visibility\"\n title=\"New Mapping\"\n >\n New\n </Button>\n }\n {showImportModal !== undefined && setShowImportModal && <IconButton\n title={`Import ${displayStrings.mappings}`}\n onClick={() => setShowImportModal(true)}\n >\n <SvgImport />\n </IconButton>\n }\n </div>\n <div className=\"gmw-button-spacing\">\n <ExtractionStatusIcon\n iconStatus={extractionStatusData.iconStatus}\n onClick={() => {\n if (extractionStatusData.iconStatus === \"negative\") {\n setShowExtractionMessageModal(true);\n }\n }}\n iconMessage={extractionStatusData.iconMessage}\n />\n <IconButton\n title=\"Refresh\"\n onClick={refreshAll}\n disabled={isLoading}\n styleType='borderless'\n >\n <SvgRefresh />\n </IconButton>\n </div>\n </div>\n {alert}\n <div className='gmw-mappings-border' />\n {isLoading ? (\n <LoadingOverlay />\n ) : mappings.length === 0 ? (\n <EmptyMessage message={`No ${displayStrings.mappings} available.`} />\n ) : (\n <div className=\"gmw-mappings-list\">\n {mappings.map((mapping) => (\n <HorizontalTile\n key={mapping.id}\n title={mapping.mappingName ? mapping.mappingName : \"Untitled\"}\n subText={mapping.description ?? \"\"}\n subtextToolTip={mapping.description ?? \"\"}\n titleTooltip={mapping.mappingName}\n onClickTitle={onClickMappingTitle ? () => onClickMappingTitle(mapping) : undefined}\n actionGroup={\n <MappingUIActionGroup\n mapping={mapping}\n onToggleExtraction={onToggleExtraction}\n onRefresh={onRefreshMappings}\n onClickMappingModify={onClickMappingModify}\n setShowDeleteModal={setShowDeleteModal}\n />\n }\n />\n ))}\n </div>\n )}\n </div>\n {showExtractionMessageModal && <ExtractionMessageModal\n isOpen={showExtractionMessageModal}\n onClose={() => setShowExtractionMessageModal(false)}\n extractionMessageData={extractionMessageData}\n timestamp={extractionMessageData.length === 0 ? \"\" : extractionMessageData[0].date}\n />}\n {showDeleteModal &&\n <DeleteModal\n entityName={showDeleteModal?.mappingName}\n onClose={() => setShowDeleteModal(undefined)}\n onDelete={async () => {\n await onDelete(showDeleteModal);\n }}\n />\n }\n {showImportModal && setShowImportModal && <MappingImportWizardModal\n show={showImportModal}\n setShow={setShowImportModal}\n onFinish={onRefreshMappings}\n displayStrings={displayStrings}\n />}\n </>\n );\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IExtractionClient } from "@itwin/insights-client";
|
|
2
|
+
import type { GetAccessTokenFn } from "../../context/GroupingApiConfigContext";
|
|
3
|
+
import type { ExtractionMessageData } from "../Extraction/ExtractionMessageModal";
|
|
4
|
+
import type { ExtractionStatusData } from "../Extraction/ExtractionStatusIcon";
|
|
5
|
+
export declare const useFetchExtractionStatus: ({ iModelId, getAccessToken, extractionClient, }: {
|
|
6
|
+
iModelId: string;
|
|
7
|
+
getAccessToken: GetAccessTokenFn;
|
|
8
|
+
extractionClient: IExtractionClient;
|
|
9
|
+
}) => import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
extractionStatusIcon: ExtractionStatusData;
|
|
11
|
+
extractionMessageData: ExtractionMessageData[];
|
|
12
|
+
}, unknown>;
|
|
13
|
+
//# sourceMappingURL=useFetchExtractionStatus.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
export const useFetchExtractionStatus = ({ iModelId, getAccessToken, extractionClient, }) => {
|
|
3
|
+
return useQuery({
|
|
4
|
+
queryKey: ["iModelExtractionStatus", iModelId],
|
|
5
|
+
staleTime: Infinity,
|
|
6
|
+
placeholderData: undefined,
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
const accessToken = await getAccessToken();
|
|
9
|
+
const extraction = extractionClient.getExtractionHistoryIterator(accessToken, iModelId, 1);
|
|
10
|
+
const latestExtractionResult = await extraction.next();
|
|
11
|
+
let extractionStatusIcon;
|
|
12
|
+
let extractionMessageData = [];
|
|
13
|
+
if (latestExtractionResult.done) {
|
|
14
|
+
extractionStatusIcon = {
|
|
15
|
+
iconStatus: "negative",
|
|
16
|
+
iconMessage: "No extraction found.",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const jobId = latestExtractionResult.value.jobId;
|
|
21
|
+
const status = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
22
|
+
if (status.containsIssues) {
|
|
23
|
+
const logs = await extractionClient.getExtractionLogs(accessToken, jobId);
|
|
24
|
+
extractionMessageData = logs.filter((log) => log.message !== null).map((log) => ({
|
|
25
|
+
date: log.dateTime,
|
|
26
|
+
category: log.category,
|
|
27
|
+
level: log.level,
|
|
28
|
+
message: log.message ?? "",
|
|
29
|
+
}));
|
|
30
|
+
extractionStatusIcon = {
|
|
31
|
+
iconStatus: "negative",
|
|
32
|
+
iconMessage: "Extraction contains issues. Click to view extraction logs.",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
extractionStatusIcon = {
|
|
37
|
+
iconStatus: "positive",
|
|
38
|
+
iconMessage: "Extraction successful.",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { extractionStatusIcon, extractionMessageData };
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useFetchExtractionStatus.js.map
|
|
@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C,OAAO,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;wBAC/E,IAAI,EAAE,GAAG,CAAC,QAAQ;wBAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;wBACtB,KAAK,EAAE,GAAG,CAAC,KAAK;wBAChB,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;qBAC3B,CAAC,CAAC,CAAC;oBACJ,oBAAoB,GAAG;wBACrB,UAAU,EAAE,UAAU;wBACtB,WAAW,EAAE,4DAA4D;qBAC1E,CAAC;iBACH;qBAAM;oBACL,oBAAoB,GAAG;wBACrB,UAAU,EAAE,UAAU;wBACtB,WAAW,EAAE,wBAAwB;qBACtC,CAAC;iBACH;aACF;YAED,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;QACzD,CAAC;KACF,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 { IExtractionClient } from \"@itwin/insights-client\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { GetAccessTokenFn } from \"../../context/GroupingApiConfigContext\";\nimport type { ExtractionMessageData } from \"../Extraction/ExtractionMessageModal\";\nimport type { ExtractionStatusData } from \"../Extraction/ExtractionStatusIcon\";\n\nexport const useFetchExtractionStatus = ({\n iModelId,\n getAccessToken,\n extractionClient,\n}: {\n iModelId: string;\n getAccessToken: GetAccessTokenFn;\n extractionClient: IExtractionClient;\n}) => {\n return useQuery({\n queryKey: [\"iModelExtractionStatus\", iModelId],\n staleTime: Infinity,\n placeholderData: undefined,\n queryFn: async () => {\n const accessToken = await getAccessToken();\n const extraction = extractionClient.getExtractionHistoryIterator(accessToken, iModelId, 1);\n const latestExtractionResult = await extraction.next();\n\n let extractionStatusIcon: ExtractionStatusData;\n let extractionMessageData: ExtractionMessageData[] = [];\n\n if (latestExtractionResult.done) {\n extractionStatusIcon = {\n iconStatus: \"negative\",\n iconMessage: \"No extraction found.\",\n };\n } else {\n const jobId = latestExtractionResult.value.jobId;\n const status = await extractionClient.getExtractionStatus(accessToken, jobId);\n\n if (status.containsIssues) {\n const logs = await extractionClient.getExtractionLogs(accessToken, jobId);\n extractionMessageData = logs.filter((log) => log.message !== null).map((log) => ({\n date: log.dateTime,\n category: log.category,\n level: log.level,\n message: log.message ?? \"\",\n }));\n extractionStatusIcon = {\n iconStatus: \"negative\",\n iconMessage: \"Extraction contains issues. Click to view extraction logs.\",\n };\n } else {\n extractionStatusIcon = {\n iconStatus: \"positive\",\n iconMessage: \"Extraction successful.\",\n };\n }\n }\n\n return { extractionStatusIcon, extractionMessageData };\n },\n });\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IMappingsClient } from "@itwin/insights-client";
|
|
2
|
+
import type { GetAccessTokenFn } from "../../context/GroupingApiConfigContext";
|
|
3
|
+
export declare const useFetchMappings: (iModelId: string, getAccessToken: GetAccessTokenFn, mappingsClient: IMappingsClient) => import("@tanstack/react-query").UseQueryResult<import("@itwin/insights-client").Mapping[], unknown>;
|
|
4
|
+
//# sourceMappingURL=useFetchMappings.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
export const useFetchMappings = (iModelId, getAccessToken, mappingsClient) => useQuery({
|
|
3
|
+
queryKey: ["mappings", iModelId],
|
|
4
|
+
queryFn: async () => {
|
|
5
|
+
const accessToken = await getAccessToken();
|
|
6
|
+
const mappings = await mappingsClient.getMappings(accessToken, iModelId);
|
|
7
|
+
return mappings.sort((a, b) => a.mappingName.localeCompare(b.mappingName));
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=useFetchMappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchMappings.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useFetchMappings.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,cAAgC,EAAE,cAA+B,EAAE,EAAE,CACtH,QAAQ,CAAC;IACP,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7E,CAAC;CAAC,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 useFetchMappings = (iModelId: string, getAccessToken: GetAccessTokenFn, mappingsClient: IMappingsClient) =>\n useQuery({\n queryKey: [\"mappings\", iModelId],\n queryFn: async () => {\n const accessToken = await getAccessToken();\n const mappings = await mappingsClient.getMappings(accessToken, iModelId);\n return mappings.sort((a, b) => a.mappingName.localeCompare(b.mappingName));\n }});\n"]}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IMappingsClient, Mapping } from "@itwin/insights-client";
|
|
3
3
|
import type { GroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
4
|
-
import type { ExtractionStatusData } from "../../context/ExtractionStatusDataContext";
|
|
5
|
-
import type { ExtractionMessageData } from "../../context/ExtractionStatusDataContext";
|
|
6
4
|
export interface MappingsOperationsProps extends GroupingMappingApiConfig {
|
|
7
5
|
mappingClient: IMappingsClient;
|
|
8
6
|
}
|
|
9
7
|
export declare const useMappingsOperations: ({ iModelId, getAccessToken, mappingClient }: MappingsOperationsProps) => {
|
|
10
|
-
mappings: Mapping[];
|
|
8
|
+
mappings: Mapping[] | undefined;
|
|
11
9
|
isLoading: boolean;
|
|
12
|
-
extractionStatusIcon: ExtractionStatusData;
|
|
13
10
|
showExtractionMessageModal: boolean;
|
|
14
|
-
|
|
11
|
+
extractionStatus: {
|
|
12
|
+
extractionStatusIcon: import("../Extraction/ExtractionStatusIcon").ExtractionStatusData;
|
|
13
|
+
extractionMessageData: import("../Extraction/ExtractionMessageModal").ExtractionMessageData[];
|
|
14
|
+
};
|
|
15
15
|
setShowExtractionMessageModal: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
refreshMappings: () => Promise<void>;
|
|
17
|
+
refreshExtractionStatus: () => Promise<void>;
|
|
18
|
+
toggleExtraction: import("@tanstack/react-query").UseMutateAsyncFunction<void, unknown, Mapping, unknown>;
|
|
19
|
+
onDelete: import("@tanstack/react-query").UseMutateAsyncFunction<void, unknown, Mapping, unknown>;
|
|
19
20
|
setShowImportModal: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
|
20
21
|
showImportModal: boolean | undefined;
|
|
21
22
|
setShowDeleteModal: import("react").Dispatch<import("react").SetStateAction<Mapping | undefined>>;
|
|
22
23
|
showDeleteModal: Mapping | undefined;
|
|
23
24
|
isTogglingExtraction: boolean;
|
|
24
|
-
errorMessage: string | undefined;
|
|
25
|
-
setErrorMessage: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
26
25
|
};
|
|
27
26
|
//# sourceMappingURL=useMappingsOperations.d.ts.map
|
|
@@ -2,122 +2,49 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { useCallback,
|
|
6
|
-
import { getErrorMessage } from "../../../common/utils";
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
7
6
|
import { useExtractionClient } from "../../context/ExtractionClientContext";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
setIsLoading(true);
|
|
12
|
-
const accessToken = await getAccessToken();
|
|
13
|
-
const mappings = await mappingsClient.getMappings(accessToken, iModelId);
|
|
14
|
-
setMappings(mappings.sort((a, b) => a.mappingName.localeCompare(b.mappingName)));
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
setErrorMessage(getErrorMessage(error.status));
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
setIsLoading(false);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const fetchExtractionStatus = async (iModelId, getAccessToken, extractionClient, setExtractionStatusIcon, setExtractionMessageData) => {
|
|
24
|
-
try {
|
|
25
|
-
setExtractionStatusIcon({
|
|
26
|
-
iconStatus: undefined,
|
|
27
|
-
iconMessage: "Loading...",
|
|
28
|
-
});
|
|
29
|
-
const accessToken = await getAccessToken();
|
|
30
|
-
const extraction = extractionClient.getExtractionHistoryIterator(accessToken, iModelId, 1);
|
|
31
|
-
const latestExtractionResult = await extraction.next();
|
|
32
|
-
if (latestExtractionResult.done) {
|
|
33
|
-
setExtractionStatusIcon({
|
|
34
|
-
iconStatus: "negative",
|
|
35
|
-
iconMessage: "No extraction found.",
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const jobId = latestExtractionResult.value.jobId;
|
|
40
|
-
const status = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
41
|
-
if (status.containsIssues) {
|
|
42
|
-
const logs = await extractionClient.getExtractionLogs(accessToken, jobId);
|
|
43
|
-
const filteredLogs = logs.filter((log) => log.message !== null);
|
|
44
|
-
const extractionMessageData = filteredLogs.map((filteredLog) => ({
|
|
45
|
-
date: filteredLog.dateTime,
|
|
46
|
-
category: filteredLog.category,
|
|
47
|
-
level: filteredLog.level,
|
|
48
|
-
message: String(filteredLog.message),
|
|
49
|
-
}));
|
|
50
|
-
setExtractionMessageData(extractionMessageData);
|
|
51
|
-
setExtractionStatusIcon({
|
|
52
|
-
iconStatus: "negative",
|
|
53
|
-
iconMessage: "Extraction contains issues. Click to view extraction logs.",
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
setExtractionStatusIcon({
|
|
58
|
-
iconStatus: "positive",
|
|
59
|
-
iconMessage: "Extraction successful.",
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
setExtractionStatusIcon({
|
|
66
|
-
iconStatus: "negative",
|
|
67
|
-
iconMessage: "Operation failed. Please try again.",
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
7
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
8
|
+
import { useFetchMappings } from "./useFetchMappings";
|
|
9
|
+
import { useFetchExtractionStatus } from "./useFetchExtractionStatus";
|
|
71
10
|
export const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }) => {
|
|
72
11
|
const [showImportModal, setShowImportModal] = useState(false);
|
|
73
12
|
const [showDeleteModal, setShowDeleteModal] = useState(undefined);
|
|
74
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
75
|
-
const [mappings, setMappings] = useState([]);
|
|
76
13
|
const extractionClient = useExtractionClient();
|
|
77
|
-
const [errorMessage, setErrorMessage] = useState(undefined);
|
|
78
|
-
const [isTogglingExtraction, setIsTogglingExtraction] = useState(false);
|
|
79
|
-
const { extractionStatusIcon, extractionMessageData, setExtractionStatusIcon, setExtractionMessageData } = useExtractionStatusDataContext();
|
|
80
14
|
const [showExtractionMessageModal, setShowExtractionMessageModal] = useState(false);
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const refresh = useCallback(async () => {
|
|
94
|
-
setMappings([]);
|
|
95
|
-
await Promise.all([
|
|
96
|
-
fetchExtractionStatus(iModelId, getAccessToken, extractionClient, setExtractionStatusIcon, setExtractionMessageData),
|
|
97
|
-
fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage),
|
|
98
|
-
]);
|
|
99
|
-
}, [extractionClient, getAccessToken, mappingClient, iModelId, setExtractionMessageData, setExtractionStatusIcon]);
|
|
100
|
-
const toggleExtraction = useCallback(async (mapping) => {
|
|
101
|
-
try {
|
|
102
|
-
setIsTogglingExtraction(true);
|
|
15
|
+
const queryClient = useQueryClient();
|
|
16
|
+
const { data: mappings, isFetching: isLoadingMappings, } = useFetchMappings(iModelId, getAccessToken, mappingClient);
|
|
17
|
+
const { data: extractionStatus, isFetching: isLoadingExtractionStatus, } = useFetchExtractionStatus({ iModelId, getAccessToken, extractionClient });
|
|
18
|
+
const refreshExtractionStatus = useCallback(async () => {
|
|
19
|
+
await queryClient.invalidateQueries({ queryKey: ["iModelExtractionStatus"] });
|
|
20
|
+
}, [queryClient]);
|
|
21
|
+
const refreshMappings = useCallback(async () => {
|
|
22
|
+
await queryClient.invalidateQueries({ queryKey: ["mappings"] });
|
|
23
|
+
}, [queryClient]);
|
|
24
|
+
const { mutateAsync: toggleExtraction, isLoading: isTogglingExtraction } = useMutation({
|
|
25
|
+
mutationFn: async (mapping) => {
|
|
26
|
+
const accessToken = await getAccessToken();
|
|
103
27
|
const newState = !mapping.extractionEnabled;
|
|
28
|
+
await mappingClient.updateMapping(accessToken, iModelId, mapping.id, { extractionEnabled: newState });
|
|
29
|
+
},
|
|
30
|
+
onSuccess: async () => {
|
|
31
|
+
await refreshMappings();
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const { mutateAsync: onDelete, isLoading: isDeletingMapping } = useMutation({
|
|
35
|
+
mutationFn: async (mapping) => {
|
|
104
36
|
const accessToken = await getAccessToken();
|
|
105
|
-
await mappingClient.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const accessToken = await getAccessToken();
|
|
118
|
-
await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);
|
|
119
|
-
await refresh();
|
|
120
|
-
};
|
|
121
|
-
return { mappings, isLoading, extractionStatusIcon, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };
|
|
37
|
+
await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);
|
|
38
|
+
},
|
|
39
|
+
onSuccess: async () => {
|
|
40
|
+
await refreshMappings();
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const isLoading = isLoadingMappings || isLoadingExtractionStatus || isTogglingExtraction || isDeletingMapping;
|
|
44
|
+
const extractionStatusGated = extractionStatus ?? { extractionStatusIcon: {
|
|
45
|
+
iconStatus: undefined,
|
|
46
|
+
iconMessage: "Loading...",
|
|
47
|
+
}, extractionMessageData: [] };
|
|
48
|
+
return { mappings, isLoading, showExtractionMessageModal, extractionStatus: extractionStatusGated, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction };
|
|
122
49
|
};
|
|
123
50
|
//# sourceMappingURL=useMappingsOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAG5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,MAAM,aAAa,GAAG,KAAK,EACzB,WAA4D,EAC5D,QAAgB,EAChB,YAA2D,EAC3D,cAAgC,EAChC,cAA+B,EAC/B,eAAsD,EACtD,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACzE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;KAClF;IAAC,OAAO,KAAU,EAAE;QACnB,eAAe,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KAChD;YAAS;QACR,YAAY,CAAC,KAAK,CAAC,CAAC;KACrB;AACH,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,QAAgB,EAChB,cAAgC,EAChC,gBAAmC,EACnC,uBAA6E,EAC7E,wBAAkF,EAClF,EAAE;IACF,IAAI;QACF,uBAAuB,CAAC;YACtB,UAAU,EAAE,SAAS;YACrB,WAAW,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C,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,EAAE;gBACnE,iBAAiB,EAAE,QAAQ;aAC5B,CAAC,CAAC;SACJ;QAAC,OAAO,KAAU,EAAE;YACnB,eAAe,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;SAChD;gBAAS;YACR,uBAAuB,CAAC,KAAK,CAAC,CAAC;SAChC;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;IAE9C,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAgB,EAAE,EAAE;QAC1C,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAC3C,MAAM,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QACrE,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC7S,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 { useCallback, useEffect, useRef, useState } from \"react\";\nimport { getErrorMessage } from \"../../../common/utils\";\nimport type { IExtractionClient, IMappingsClient, Mapping } from \"@itwin/insights-client\";\nimport type { GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { GetAccessTokenFn } from \"../../context/GroupingApiConfigContext\";\nimport { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport type { ExtractionStatusData } from \"../../context/ExtractionStatusDataContext\";\nimport type { ExtractionMessageData } from \"../../context/ExtractionStatusDataContext\";\nimport { useExtractionStatusDataContext } from \"../../context/ExtractionStatusDataContext\";\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n getAccessToken: GetAccessTokenFn,\n mappingsClient: IMappingsClient,\n setErrorMessage: (message: string | undefined) => void\n) => {\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const mappings = await mappingsClient.getMappings(accessToken, iModelId);\n setMappings(mappings.sort((a, b) => a.mappingName.localeCompare(b.mappingName)));\n } catch (error: any) {\n setErrorMessage(getErrorMessage(error.status));\n } finally {\n setIsLoading(false);\n }\n};\n\nconst fetchExtractionStatus = async (\n iModelId: string,\n getAccessToken: GetAccessTokenFn,\n extractionClient: IExtractionClient,\n setExtractionStatusIcon: (extractionStatusIcon: ExtractionStatusData) => void,\n setExtractionMessageData: (extractionMessageData: ExtractionMessageData[]) => void\n) => {\n try {\n setExtractionStatusIcon({\n iconStatus: undefined,\n iconMessage: \"Loading...\",\n });\n const accessToken = await getAccessToken();\n const extraction = extractionClient.getExtractionHistoryIterator(accessToken, iModelId, 1);\n const latestExtractionResult = await extraction.next();\n if(latestExtractionResult.done){\n setExtractionStatusIcon({\n iconStatus: \"negative\",\n iconMessage: \"No extraction found.\",\n });\n } else {\n const jobId = latestExtractionResult.value.jobId;\n const status = await extractionClient.getExtractionStatus(accessToken, jobId);\n if (status.containsIssues) {\n const logs = await extractionClient.getExtractionLogs(accessToken, jobId);\n const filteredLogs = logs.filter((log) => log.message !== null);\n const extractionMessageData = filteredLogs.map((filteredLog) => ({\n date: filteredLog.dateTime,\n category: filteredLog.category,\n level: filteredLog.level,\n message: String(filteredLog.message),\n }));\n setExtractionMessageData(extractionMessageData);\n setExtractionStatusIcon({\n iconStatus: \"negative\",\n iconMessage: \"Extraction contains issues. Click to view extraction logs.\",\n });\n } else {\n setExtractionStatusIcon({\n iconStatus: \"positive\",\n iconMessage: \"Extraction successful.\",\n });\n }\n }\n } catch (error: any) {\n setExtractionStatusIcon({\n iconStatus: \"negative\",\n iconMessage: \"Operation failed. Please try again.\",\n });\n }\n};\n\nexport interface MappingsOperationsProps extends GroupingMappingApiConfig {\n mappingClient: IMappingsClient;\n}\n\nexport const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }: MappingsOperationsProps) => {\n const [showImportModal, setShowImportModal] = useState<boolean | undefined>(false);\n const [showDeleteModal, setShowDeleteModal] = useState<Mapping | undefined>(undefined);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [mappings, setMappings] = useState<Mapping[]>([]);\n const extractionClient = useExtractionClient();\n const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);\n const [isTogglingExtraction, setIsTogglingExtraction] = useState<boolean>(false);\n const {extractionStatusIcon, extractionMessageData, setExtractionStatusIcon, setExtractionMessageData} = useExtractionStatusDataContext();\n const [showExtractionMessageModal, setShowExtractionMessageModal] = useState<boolean>(false);\n const previousStatusIcon = useRef<ExtractionStatusData>();\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);\n }, [getAccessToken, mappingClient, iModelId]);\n\n useEffect(() => {\n previousStatusIcon.current = extractionStatusIcon;\n }, [extractionStatusIcon]);\n\n useEffect(() => {\n if(previousStatusIcon.current?.iconStatus === undefined) {\n void fetchExtractionStatus(\n iModelId,\n getAccessToken,\n extractionClient,\n setExtractionStatusIcon,\n setExtractionMessageData\n );\n }\n }, [iModelId, getAccessToken, extractionClient, isLoading, setExtractionStatusIcon, setExtractionMessageData]);\n\n const refresh = useCallback(async () => {\n setMappings([]);\n await Promise.all([\n fetchExtractionStatus(iModelId, getAccessToken, extractionClient, setExtractionStatusIcon, setExtractionMessageData),\n fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage),\n ]);\n }, [extractionClient, getAccessToken, mappingClient, iModelId, setExtractionMessageData, setExtractionStatusIcon]);\n\n const toggleExtraction = useCallback(async (mapping: Mapping) => {\n try {\n setIsTogglingExtraction(true);\n const newState = !mapping.extractionEnabled;\n const accessToken = await getAccessToken();\n await mappingClient.updateMapping(accessToken, iModelId, mapping.id, {\n extractionEnabled: newState,\n });\n } catch (error: any) {\n setErrorMessage(getErrorMessage(error.status));\n } finally {\n setIsTogglingExtraction(false);\n }\n }, [getAccessToken, iModelId, mappingClient]);\n\n const onDelete = async (mapping: Mapping) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);\n await refresh();\n };\n\n return { mappings, isLoading, extractionStatusIcon, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAMtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAA2B,EAAE,EAAE;IAC5G,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAsB,KAAK,CAAC,CAAC;IACnF,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAsB,SAAS,CAAC,C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AAC,CAAC;QACxG,CAAC;QACD,SAAS,EAAE,KAAK,IAAI,EAAE;YACpB,MAAM,eAAe,EAAE,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAC,GAAG,WAAW,CAAC;QACzE,UAAU,EAAE,KAAK,EAAE,OAAgB,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;YAC3C,MAAM,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,SAAS,EAAE,KAAK,IAAI,EAAE;YACpB,MAAM,eAAe,EAAE,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,iBAAiB,IAAI,yBAAyB,IAAI,oBAAoB,IAAI,iBAAiB,CAAC;IAC9G,MAAM,qBAAqB,GAAG,gBAAgB,IAAI,EAAC,oBAAoB,EAAE;YACvE,UAAU,EAAE,SAAS;YACrB,WAAW,EAAE,YAAY;SAC1B,EAAE,qBAAqB,EAAG,EAAE,EAAC,CAAC;IAE/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,eAAe,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAC1S,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 { useCallback, useState } from \"react\";\nimport type { IMappingsClient, Mapping } from \"@itwin/insights-client\";\nimport type { GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useFetchMappings } from \"./useFetchMappings\";\nimport { useFetchExtractionStatus } from \"./useFetchExtractionStatus\";\n\nexport interface MappingsOperationsProps extends GroupingMappingApiConfig {\n mappingClient: IMappingsClient;\n}\n\nexport const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }: MappingsOperationsProps) => {\n const [showImportModal, setShowImportModal] = useState<boolean | undefined>(false);\n const [showDeleteModal, setShowDeleteModal] = useState<Mapping | undefined>(undefined);\n const extractionClient = useExtractionClient();\n const [showExtractionMessageModal, setShowExtractionMessageModal] = useState<boolean>(false);\n const queryClient = useQueryClient();\n\n const {\n data: mappings,\n isFetching: isLoadingMappings,\n } = useFetchMappings(iModelId, getAccessToken, mappingClient);\n\n const {\n data: extractionStatus,\n isFetching: isLoadingExtractionStatus,\n } = useFetchExtractionStatus({ iModelId, getAccessToken, extractionClient });\n\n const refreshExtractionStatus = useCallback(async () => {\n await queryClient.invalidateQueries({queryKey: [\"iModelExtractionStatus\"]});\n }, [queryClient]);\n\n const refreshMappings = useCallback(async () => {\n await queryClient.invalidateQueries({queryKey: [\"mappings\"]});\n }, [queryClient]);\n\n const { mutateAsync: toggleExtraction, isLoading: isTogglingExtraction } = useMutation({\n mutationFn: async (mapping: Mapping) => {\n const accessToken = await getAccessToken();\n const newState = !mapping.extractionEnabled;\n await mappingClient.updateMapping(accessToken, iModelId, mapping.id, { extractionEnabled: newState });\n },\n onSuccess: async () => {\n await refreshMappings();\n },\n });\n\n const { mutateAsync: onDelete, isLoading: isDeletingMapping} = useMutation({\n mutationFn: async (mapping: Mapping) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);\n },\n onSuccess: async () => {\n await refreshMappings();\n },\n });\n\n const isLoading = isLoadingMappings || isLoadingExtractionStatus || isTogglingExtraction || isDeletingMapping;\n const extractionStatusGated = extractionStatus ?? {extractionStatusIcon: {\n iconStatus: undefined,\n iconMessage: \"Loading...\",\n }, extractionMessageData : []};\n\n return { mappings, isLoading, showExtractionMessageModal, extractionStatus: extractionStatusGated, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction};\n};\n"]}
|
|
@@ -22,6 +22,7 @@ export const PropertyTable = ({ propertyType, columnsFactory, data, isLoading, o
|
|
|
22
22
|
return (React.createElement("div", { className: "gmw-property-table-container" },
|
|
23
23
|
React.createElement(PropertyTableToolbar, { propertyType: propertyType, onClickAddProperty: onClickAdd, refreshProperties: refreshProperties, isLoading: isLoading }),
|
|
24
24
|
React.createElement(Table, { data: isLoading ? [] : data, density: 'extra-condensed', columns: memoizedColumns, emptyTableContent: `No ${propertyType} Properties`, isSortable: true, isLoading: isLoading }),
|
|
25
|
-
|
|
25
|
+
showDeleteModal &&
|
|
26
|
+
React.createElement(DeleteModal, { entityName: showDeleteModal.propertyName, onClose: handleCloseDeleteModal, onDelete: handleDeleteProperty, refresh: refreshProperties })));
|
|
26
27
|
};
|
|
27
28
|
//# sourceMappingURL=PropertyTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyTable.js","sourceRoot":"","sources":["../../../../src/components/Properties/PropertyTable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9D,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,sBAAsB,CAAC;AAiB9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAA8B,EACzD,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,SAAS,EACT,UAAU,EACV,i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,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAC3B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,MAAM,YAAY,aAAa,EAClD,UAAU,QACV,SAAS,EAAE,SAAS,GACpB;QACD,eAAe;YACd,oBAAC,WAAW,IACV,UAAU,EAAE,eAAe,CAAC,YAAY,EACxC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,iBAAiB,GAC1B,CACA,CACP,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 { Table } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { Column } from \"react-table\";\nimport type { CreateTypeFromInterface } from \"../../common/utils\";\nimport DeleteModal from \"../SharedComponents/DeleteModal\";\nimport { PropertyTableToolbar } from \"./PropertyTableToolbar\";\nimport \"./PropertyTable.scss\";\n\nexport interface PropertyTableItem {\n propertyName: string;\n id: string;\n}\n\nexport interface PropertyTableProps<T extends PropertyTableItem> {\n propertyType: string;\n columnsFactory: (handleShowDeleteModal: (value: T) => void) => Array<Column<T>>;\n data: T[];\n isLoading: boolean;\n onClickAdd?: () => void;\n refreshProperties: () => Promise<void>;\n deleteProperty: (propertyId: string) => Promise<void>;\n}\n\nexport const PropertyTable = <T extends PropertyTableItem>({\n propertyType,\n columnsFactory,\n data,\n isLoading,\n onClickAdd,\n refreshProperties,\n deleteProperty,\n}: PropertyTableProps<T>) => {\n\n const [showDeleteModal, setShowDeleteModal] = useState<T | undefined>(undefined);\n\n const handleDeleteProperty = useCallback(async () => {\n await deleteProperty(showDeleteModal?.id ?? \"\");\n }, [deleteProperty, showDeleteModal?.id]);\n\n const handleShowDeleteModal = useCallback((property: T) => {\n setShowDeleteModal(property);\n }, []);\n\n const handleCloseDeleteModal = () => {\n setShowDeleteModal(undefined);\n };\n\n const memoizedColumns = useMemo(() =>\n columnsFactory(handleShowDeleteModal), [columnsFactory, handleShowDeleteModal]);\n\n return (\n <div className=\"gmw-property-table-container\">\n <PropertyTableToolbar\n propertyType={propertyType}\n onClickAddProperty={onClickAdd}\n refreshProperties={refreshProperties}\n isLoading={isLoading}\n />\n <Table<CreateTypeFromInterface<T>>\n data={isLoading ? [] : data}\n density='extra-condensed'\n columns={memoizedColumns}\n emptyTableContent={`No ${propertyType} Properties`}\n isSortable\n isLoading={isLoading}\n />\n {showDeleteModal &&\n <DeleteModal\n entityName={showDeleteModal.propertyName}\n onClose={handleCloseDeleteModal}\n onDelete={handleDeleteProperty}\n refresh={refreshProperties}\n />}\n </div>\n );\n};\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./DeleteModal.scss";
|
|
3
3
|
export interface DeleteModalProps {
|
|
4
|
-
entityName
|
|
4
|
+
entityName: string;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onDelete: () => Promise<void>;
|
|
7
|
-
refresh
|
|
7
|
+
refresh?: () => Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const DeleteModal: ({ entityName, onClose, onDelete, refresh, }: DeleteModalProps) => JSX.Element;
|
|
10
10
|
export default DeleteModal;
|