@itwin/grouping-mapping-widget 0.23.1 → 0.24.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/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/components/Constants.d.ts +3 -0
- package/lib/cjs/components/Constants.js +5 -2
- package/lib/cjs/components/Constants.js.map +1 -1
- package/lib/cjs/components/GroupingMappingContext.js +12 -14
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.js +31 -9
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.d.ts +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.js +1 -1
- package/lib/cjs/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +16 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +21 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js +79 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
- package/lib/cjs/components/Mappings/MappingListItem.d.ts +20 -0
- package/lib/cjs/components/Mappings/MappingListItem.js +96 -0
- package/lib/cjs/components/Mappings/MappingListItem.js.map +1 -0
- package/lib/cjs/components/Mappings/MappingListItem.scss +25 -0
- package/lib/cjs/components/Mappings/MappingsView.d.ts +2 -0
- package/lib/cjs/components/Mappings/MappingsView.js +28 -4
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js +55 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +29 -5
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js +42 -0
- package/lib/cjs/components/Mappings/hooks/useRunExtraction.js.map +1 -0
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +28 -59
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupColorToggle.js +30 -26
- package/lib/cjs/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +61 -166
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +147 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
- package/lib/cjs/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
- package/lib/cjs/components/Properties/PropertyMenu.js +11 -15
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js +12 -0
- package/lib/cjs/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
- package/lib/cjs/components/SharedComponents/DeleteModal.d.ts +1 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js +1 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/cjs/components/context/ExtractionStateJobContext.d.ts +8 -0
- package/lib/cjs/components/context/ExtractionStateJobContext.js +44 -0
- package/lib/cjs/components/context/ExtractionStateJobContext.js.map +1 -0
- package/lib/cjs/components/context/PropertiesGroupColorContext.d.ts +8 -0
- package/lib/cjs/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +7 -10
- package/lib/cjs/components/context/PropertiesGroupColorContext.js.map +1 -0
- package/lib/esm/WidgetShell/GroupingMappingContent.js +2 -2
- package/lib/esm/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/esm/components/Constants.d.ts +3 -0
- package/lib/esm/components/Constants.js +3 -0
- package/lib/esm/components/Constants.js.map +1 -1
- package/lib/esm/components/GroupingMappingContext.js +12 -14
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.js +31 -9
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/groupsHelpers.d.ts +1 -1
- package/lib/esm/components/Groups/groupsHelpers.js +1 -1
- package/lib/esm/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +2 -2
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +27 -18
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js +10 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/QueuedExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js +9 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/RunningExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.d.ts +3 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js +10 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/StartingExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.d.ts +9 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js +14 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStates/TerminalExtractionState.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.d.ts +17 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js +52 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/Extraction/ExtractionStatus.scss +40 -0
- package/lib/esm/components/Mappings/MappingListItem.d.ts +20 -0
- package/lib/esm/components/Mappings/MappingListItem.js +69 -0
- package/lib/esm/components/Mappings/MappingListItem.js.map +1 -0
- package/lib/esm/components/Mappings/MappingListItem.scss +25 -0
- package/lib/esm/components/Mappings/MappingsView.d.ts +2 -0
- package/lib/esm/components/Mappings/MappingsView.js +30 -6
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +3 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +7 -4
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.d.ts +20 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js +49 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappingExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +8 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +30 -6
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useRunExtraction.d.ts +14 -0
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js +38 -0
- package/lib/esm/components/Mappings/hooks/useRunExtraction.js.map +1 -0
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +17 -25
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +18 -25
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +35 -38
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +29 -60
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +37 -40
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupColorToggle.js +32 -28
- package/lib/esm/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +63 -168
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +1 -46
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +34 -37
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js +65 -51
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyUtils.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.d.ts +12 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js +117 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.js.map +1 -0
- package/lib/esm/components/Properties/GroupProperties/GroupsPropertiesSelectionModal.scss +49 -0
- package/lib/esm/components/Properties/PropertyMenu.js +12 -16
- package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTable.js +1 -1
- package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useCalculatedPropertiesQuery.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useCustomCalculationsQuery.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.d.ts +4 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js +8 -0
- package/lib/esm/components/Properties/hooks/useGroupPropertiesQuery.js.map +1 -0
- package/lib/esm/components/SharedComponents/DeleteModal.d.ts +1 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js +1 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/esm/components/context/ExtractionStateJobContext.d.ts +8 -0
- package/lib/esm/components/context/ExtractionStateJobContext.js +17 -0
- package/lib/esm/components/context/ExtractionStateJobContext.js.map +1 -0
- package/lib/esm/components/context/PropertiesGroupColorContext.d.ts +8 -0
- package/lib/esm/components/context/{PropertiesContext.js → PropertiesGroupColorContext.js} +5 -8
- package/lib/esm/components/context/PropertiesGroupColorContext.js.map +1 -0
- package/package.json +3 -2
- package/lib/cjs/components/Properties/hooks/useFetchData.d.ts +0 -7
- package/lib/cjs/components/Properties/hooks/useFetchData.js +0 -43
- package/lib/cjs/components/Properties/hooks/useFetchData.js.map +0 -1
- package/lib/cjs/components/context/PropertiesContext.d.ts +0 -15
- package/lib/cjs/components/context/PropertiesContext.js.map +0 -1
- package/lib/esm/components/Properties/hooks/useFetchData.d.ts +0 -7
- package/lib/esm/components/Properties/hooks/useFetchData.js +0 -37
- package/lib/esm/components/Properties/hooks/useFetchData.js.map +0 -1
- package/lib/esm/components/context/PropertiesContext.d.ts +0 -15
- package/lib/esm/components/context/PropertiesContext.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingsView.js","sourceRoot":"","sources":["../../../../src/components/Mappings/MappingsView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAA2C;AAI3C,wDAG8B;AAC9B,oEAIoC;AACpC,mEAAgE;AAChE,uEAAoE;AACpE,+BAA6B;AAC7B,kFAA0D;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C9B,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAhIW,QAAA,YAAY,gBAgIvB","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"]}
|
|
1
|
+
{"version":3,"file":"MappingsView.js","sourceRoot":"","sources":["../../../../src/components/Mappings/MappingsView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+F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C,CAAC;gBAClC,CAAC,GACD;QAEH,eAAe,IAAI,kBAAkB,IAAI,8BAAC,mDAAwB,IACjE,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,GAC9B,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AA/JW,QAAA,YAAY,gBA+JvB","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, useMemo, useState } 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 SvgPlay,\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 type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport type { ExtractionStatusData } from \"./Extraction/ExtractionStatusIcon\";\nimport { ExtractionStatusIcon } from \"./Extraction/ExtractionStatusIcon\";\nimport { MappingListItem } from \"./MappingListItem\";\nimport type { ExtractionMessageData } from \"./Extraction/ExtractionMessageModal\";\nimport { ExtractionMessageModal } from \"./Extraction/ExtractionMessageModal\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { useExtractionStateJobContext } from \"../context/ExtractionStateJobContext\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport { useRunExtraction } from \"./hooks/useRunExtraction\";\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 initialStateExtractionFlag?: boolean;\n setInitialExtractionStateFlag?: (initialStateExtractionFlag: boolean) => void;\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 const [selectedMappings, setSelectedMappings] = useState<Mapping[]>([]);\n const groupingMappingApiConfig = useGroupingMappingApiConfig();\n const { mappingIdJobInfo } = useExtractionStateJobContext();\n const { runExtraction } = useRunExtraction(groupingMappingApiConfig);\n\n const jobStartEvent = useMemo(\n () => new BeEvent<(mappingId: string) => void>(),\n []\n );\n\n const refreshAll = useCallback(async () => {\n await Promise.all([onRefreshMappings(), onRefreshExtractionStatus()]);\n }, [onRefreshMappings, onRefreshExtractionStatus]);\n\n const onSelectionChange = (mapping: Mapping) => {\n setSelectedMappings((mappingIdList) => {\n return mappingIdList.some((eachId) => mapping.id === eachId.id)\n ? mappingIdList.filter((eachId) => mapping.id !== eachId.id)\n : [...mappingIdList, mapping];\n }\n );\n };\n\n const onRunExtraction = useCallback(async () => {\n await runExtraction(selectedMappings);\n selectedMappings.map((mapping) => {\n jobStartEvent.raiseEvent(mapping.id);\n });\n setSelectedMappings([]);\n }, [selectedMappings, jobStartEvent, runExtraction]);\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 <IconButton\n title=\"Run extraction\"\n onClick={onRunExtraction}\n disabled={selectedMappings.length === 0}\n >\n <SvgPlay />\n </IconButton>\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 <MappingListItem\n key={mapping.id}\n mapping={mapping}\n jobId={mappingIdJobInfo?.get(mapping.id) ?? \"\"}\n jobStartEvent={jobStartEvent}\n onClickMappingTitle={onClickMappingTitle}\n onSelectionChange={onSelectionChange}\n selected={selectedMappings.some(\n (eachMapping) => mapping.id === eachMapping.id\n )}\n onToggleExtraction={onToggleExtraction}\n onRefreshMappings={onRefreshMappings}\n onClickMappingModify={onClickMappingModify}\n setShowDeleteModal={setShowDeleteModal}\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IExtractionClient } from "@itwin/insights-client";
|
|
1
|
+
import type { ExtractionStatus, IExtractionClient } from "@itwin/insights-client";
|
|
2
2
|
import type { GetAccessTokenFn } from "../../context/GroupingApiConfigContext";
|
|
3
3
|
import type { ExtractionMessageData } from "../Extraction/ExtractionMessageModal";
|
|
4
4
|
import type { ExtractionStatusData } from "../Extraction/ExtractionStatusIcon";
|
|
@@ -9,5 +9,7 @@ export declare const useFetchExtractionStatus: ({ iModelId, getAccessToken, extr
|
|
|
9
9
|
}) => import("@tanstack/react-query").UseQueryResult<{
|
|
10
10
|
extractionStatusIcon: ExtractionStatusData;
|
|
11
11
|
extractionMessageData: ExtractionMessageData[];
|
|
12
|
+
latestExtractionResult: IteratorResult<import("@itwin/insights-client").Extraction, any>;
|
|
13
|
+
latestJobStatus: ExtractionStatus | undefined;
|
|
12
14
|
}, unknown>;
|
|
13
15
|
//# sourceMappingURL=useFetchExtractionStatus.d.ts.map
|
|
@@ -13,6 +13,11 @@ const useFetchExtractionStatus = ({ iModelId, getAccessToken, extractionClient,
|
|
|
13
13
|
const latestExtractionResult = await extraction.next();
|
|
14
14
|
let extractionStatusIcon;
|
|
15
15
|
let extractionMessageData = [];
|
|
16
|
+
const jobId = latestExtractionResult.value?.jobId;
|
|
17
|
+
let latestJobStatus;
|
|
18
|
+
if (jobId) {
|
|
19
|
+
latestJobStatus = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
20
|
+
}
|
|
16
21
|
if (latestExtractionResult.done) {
|
|
17
22
|
extractionStatusIcon = {
|
|
18
23
|
iconStatus: "negative",
|
|
@@ -20,9 +25,7 @@ const useFetchExtractionStatus = ({ iModelId, getAccessToken, extractionClient,
|
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
27
|
else {
|
|
23
|
-
|
|
24
|
-
const status = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
25
|
-
if (status.containsIssues) {
|
|
28
|
+
if (latestJobStatus?.containsIssues) {
|
|
26
29
|
const logs = await extractionClient.getExtractionLogs(accessToken, jobId);
|
|
27
30
|
extractionMessageData = logs.filter((log) => log.message !== null).map((log) => ({
|
|
28
31
|
date: log.dateTime,
|
|
@@ -42,7 +45,7 @@ const useFetchExtractionStatus = ({ iModelId, getAccessToken, extractionClient,
|
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
return { extractionStatusIcon, extractionMessageData };
|
|
48
|
+
return { extractionStatusIcon, extractionMessageData, latestExtractionResult, latestJobStatus };
|
|
46
49
|
},
|
|
47
50
|
});
|
|
48
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchExtractionStatus.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useFetchExtractionStatus.ts"],"names":[],"mappings":";;;AAKA,uDAAiD;AAK1C,MAAM,wBAAwB,GAAG,CAAC,EACvC,QAAQ,EACR,cAAc,EACd,gBAAgB,GAKjB,EAAE,EAAE;IACH,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,wBAAwB,EAAE,QAAQ,CAAC;QAC9C,SAAS,EAAE,QAAQ;QACnB,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC,4BAA4B,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YAC3F,MAAM,sBAAsB,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;YAEvD,IAAI,oBAA0C,CAAC;YAC/C,IAAI,qBAAqB,GAA4B,EAAE,CAAC;YAExD,
|
|
1
|
+
{"version":3,"file":"useFetchExtractionStatus.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useFetchExtractionStatus.ts"],"names":[],"mappings":";;;AAKA,uDAAiD;AAK1C,MAAM,wBAAwB,GAAG,CAAC,EACvC,QAAQ,EACR,cAAc,EACd,gBAAgB,GAKjB,EAAE,EAAE;IACH,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,wBAAwB,EAAE,QAAQ,CAAC;QAC9C,SAAS,EAAE,QAAQ;QACnB,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC,4BAA4B,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;YAC3F,MAAM,sBAAsB,GAAG,MAAM,UAAU,C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C,CAAC;AAxDW,QAAA,wBAAwB,4BAwDnC","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 { ExtractionStatus, 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 const jobId = latestExtractionResult.value?.jobId;\n let latestJobStatus: ExtractionStatus|undefined;\n if (jobId) {\n latestJobStatus = await extractionClient.getExtractionStatus(accessToken, jobId);\n }\n\n if (latestExtractionResult.done) {\n extractionStatusIcon = {\n iconStatus: \"negative\",\n iconMessage: \"No extraction found.\",\n };\n } else {\n if (latestJobStatus?.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, latestExtractionResult, latestJobStatus };\n },\n });\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { IExtractionClient } from "@itwin/insights-client";
|
|
3
|
+
import type { Mapping } from "@itwin/insights-client";
|
|
4
|
+
import { ExtractionStates } from "../Extraction/ExtractionStatus";
|
|
5
|
+
import type { GetAccessTokenFn, GroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
6
|
+
export interface MappingExtractionStatusProps extends GroupingMappingApiConfig {
|
|
7
|
+
mapping: Mapping;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface MappingQueryResult {
|
|
11
|
+
mappingId: string;
|
|
12
|
+
finalExtractionStateValue: ExtractionStates;
|
|
13
|
+
}
|
|
14
|
+
export declare const fetchMappingStatus: (mappingId: string, jobId: string, getAccessToken: GetAccessTokenFn, extractionClient: IExtractionClient) => Promise<{
|
|
15
|
+
mappingId: string;
|
|
16
|
+
finalExtractionStateValue: ExtractionStates;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const resetMappingExtractionStatus: (queryClient: QueryClient) => Promise<void>;
|
|
19
|
+
export declare const useFetchMappingExtractionStatus: ({ getAccessToken, mapping, enabled, }: MappingExtractionStatusProps) => import("@tanstack/react-query").UseQueryResult<MappingQueryResult, unknown>;
|
|
20
|
+
//# sourceMappingURL=useFetchMappingExtractionStatus.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFetchMappingExtractionStatus = exports.resetMappingExtractionStatus = exports.fetchMappingStatus = void 0;
|
|
4
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
6
|
+
const Constants_1 = require("../../Constants");
|
|
7
|
+
const ExtractionStatus_1 = require("../Extraction/ExtractionStatus");
|
|
8
|
+
const ExtractionClientContext_1 = require("../../context/ExtractionClientContext");
|
|
9
|
+
const ExtractionStateJobContext_1 = require("../../context/ExtractionStateJobContext");
|
|
10
|
+
const fetchMappingStatus = async (mappingId, jobId, getAccessToken, extractionClient) => {
|
|
11
|
+
const accessToken = await getAccessToken();
|
|
12
|
+
const getFinalExtractionStatus = ((extractionStatusResponse) => {
|
|
13
|
+
switch (extractionStatusResponse.state) {
|
|
14
|
+
case undefined:
|
|
15
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.Starting };
|
|
16
|
+
case insights_client_1.ExtractorState.Running:
|
|
17
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.Running };
|
|
18
|
+
case insights_client_1.ExtractorState.Failed:
|
|
19
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.Failed };
|
|
20
|
+
case insights_client_1.ExtractorState.Queued:
|
|
21
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.Queued };
|
|
22
|
+
case insights_client_1.ExtractorState.Succeeded:
|
|
23
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.Succeeded };
|
|
24
|
+
default:
|
|
25
|
+
return { mappingId, finalExtractionStateValue: ExtractionStatus_1.ExtractionStates.None };
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const extractionStatusResponse = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
29
|
+
return getFinalExtractionStatus(extractionStatusResponse);
|
|
30
|
+
};
|
|
31
|
+
exports.fetchMappingStatus = fetchMappingStatus;
|
|
32
|
+
const resetMappingExtractionStatus = async (queryClient) => {
|
|
33
|
+
await queryClient.invalidateQueries({ queryKey: ["extractionState"] });
|
|
34
|
+
};
|
|
35
|
+
exports.resetMappingExtractionStatus = resetMappingExtractionStatus;
|
|
36
|
+
const useFetchMappingExtractionStatus = ({ getAccessToken, mapping, enabled, }) => {
|
|
37
|
+
const extractionClient = (0, ExtractionClientContext_1.useExtractionClient)();
|
|
38
|
+
const { mappingIdJobInfo } = (0, ExtractionStateJobContext_1.useExtractionStateJobContext)();
|
|
39
|
+
const jobId = mappingIdJobInfo.get(mapping.id);
|
|
40
|
+
const statusQuery = (0, react_query_1.useQuery)({
|
|
41
|
+
queryKey: ["extractionState", jobId],
|
|
42
|
+
queryFn: async () => {
|
|
43
|
+
if (jobId) {
|
|
44
|
+
return (0, exports.fetchMappingStatus)(mapping.id, jobId, getAccessToken, extractionClient);
|
|
45
|
+
}
|
|
46
|
+
// This should not happen as jobId should be defined if enabled is true
|
|
47
|
+
throw new Error("Job ID is undefined");
|
|
48
|
+
},
|
|
49
|
+
enabled: enabled && Boolean(jobId),
|
|
50
|
+
refetchInterval: Constants_1.STATUS_CHECK_INTERVAL,
|
|
51
|
+
});
|
|
52
|
+
return statusQuery;
|
|
53
|
+
};
|
|
54
|
+
exports.useFetchMappingExtractionStatus = useFetchMappingExtractionStatus;
|
|
55
|
+
//# sourceMappingURL=useFetchMappingExtractionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchMappingExtractionStatus.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useFetchMappingExtractionStatus.ts"],"names":[],"mappings":";;;AAKA,uDAAiD;AAEjD,4DAAwD;AAExD,+CAAwD;AACxD,qEAAkE;AAElE,mFAA4E;AAC5E,uFAAuF;AAYhF,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAAiB,EACjB,KAAa,EACb,cAAgC,EAChC,gBAAmC,EACnC,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAE3C,MAAM,wBAAwB,GAAG,CAAC,CAAC,wBAA0C,EAAE,EAAE;QAC/E,QAAO,wBAAwB,CAAC,KAAK,EAAE;YACrC,KAAK,SAAS;gBACZ,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,mCAAgB,CAAC,QAAQ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E,CAAC,CAAC;IAE/C,MAAM,WAAW,GAAG,IAAA,sBAAQ,EAAqB;QAC/C,QAAQ,EAAE,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACpC,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,KAAK,EAAE;gBACT,OAAO,IAAA,0BAAkB,EAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;aAChF;YACD,uEAAuE;YACvE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,EAAE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QAClC,eAAe,EAAE,iCAAqB;KACvC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAvBW,QAAA,+BAA+B,mCAuB1C","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 { QueryClient } from \"@tanstack/react-query\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { ExtractionStatus, IExtractionClient } from \"@itwin/insights-client\";\nimport { ExtractorState } from \"@itwin/insights-client\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { STATUS_CHECK_INTERVAL } from \"../../Constants\";\nimport { ExtractionStates } from \"../Extraction/ExtractionStatus\";\nimport type { GetAccessTokenFn, GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport { useExtractionStateJobContext } from \"../../context/ExtractionStateJobContext\";\n\nexport interface MappingExtractionStatusProps extends GroupingMappingApiConfig {\n mapping: Mapping;\n enabled: boolean;\n}\n\nexport interface MappingQueryResult {\n mappingId: string;\n finalExtractionStateValue: ExtractionStates;\n}\n\nexport const fetchMappingStatus = async (\n mappingId: string,\n jobId: string,\n getAccessToken: GetAccessTokenFn,\n extractionClient: IExtractionClient,\n) => {\n const accessToken = await getAccessToken();\n\n const getFinalExtractionStatus = ((extractionStatusResponse: ExtractionStatus) => {\n switch(extractionStatusResponse.state) {\n case undefined:\n return { mappingId, finalExtractionStateValue: ExtractionStates.Starting};\n case ExtractorState.Running:\n return { mappingId, finalExtractionStateValue: ExtractionStates.Running};\n case ExtractorState.Failed:\n return { mappingId, finalExtractionStateValue: ExtractionStates.Failed};\n case ExtractorState.Queued:\n return { mappingId, finalExtractionStateValue: ExtractionStates.Queued};\n case ExtractorState.Succeeded:\n return { mappingId, finalExtractionStateValue: ExtractionStates.Succeeded};\n default:\n return { mappingId, finalExtractionStateValue: ExtractionStates.None};\n }\n });\n const extractionStatusResponse = await extractionClient.getExtractionStatus(accessToken, jobId);\n return getFinalExtractionStatus(extractionStatusResponse);\n};\n\nexport const resetMappingExtractionStatus = async (queryClient: QueryClient) => {\n await queryClient.invalidateQueries({queryKey: [\"extractionState\"]});\n};\n\nexport const useFetchMappingExtractionStatus = ({\n getAccessToken,\n mapping,\n enabled,\n}: MappingExtractionStatusProps) => {\n const extractionClient = useExtractionClient();\n const { mappingIdJobInfo } = useExtractionStateJobContext();\n const jobId = mappingIdJobInfo.get(mapping.id);\n\n const statusQuery = useQuery<MappingQueryResult>({\n queryKey: [\"extractionState\", jobId],\n queryFn: async () => {\n if (jobId) {\n return fetchMappingStatus(mapping.id, jobId, getAccessToken, extractionClient);\n }\n // This should not happen as jobId should be defined if enabled is true\n throw new Error(\"Job ID is undefined\");\n },\n enabled: enabled && Boolean(jobId), // Only enable the query if enabled is true and jobId is defined\n refetchInterval: STATUS_CHECK_INTERVAL,\n });\n\n return statusQuery;\n};\n"]}
|
|
@@ -11,6 +11,14 @@ export declare const useMappingsOperations: ({ iModelId, getAccessToken, mapping
|
|
|
11
11
|
extractionStatus: {
|
|
12
12
|
extractionStatusIcon: import("../Extraction/ExtractionStatusIcon").ExtractionStatusData;
|
|
13
13
|
extractionMessageData: import("../Extraction/ExtractionMessageModal").ExtractionMessageData[];
|
|
14
|
+
latestExtractionResult: IteratorResult<import("@itwin/insights-client").Extraction, any>;
|
|
15
|
+
latestJobStatus: import("@itwin/insights-client").ExtractionStatus | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
extractionStatusIcon: {
|
|
18
|
+
iconStatus: undefined;
|
|
19
|
+
iconMessage: string;
|
|
20
|
+
};
|
|
21
|
+
extractionMessageData: never[];
|
|
14
22
|
};
|
|
15
23
|
setShowExtractionMessageModal: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
24
|
refreshMappings: () => Promise<void>;
|
|
@@ -6,21 +6,42 @@ exports.useMappingsOperations = void 0;
|
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
9
10
|
const ExtractionClientContext_1 = require("../../context/ExtractionClientContext");
|
|
10
11
|
const react_query_1 = require("@tanstack/react-query");
|
|
11
12
|
const useFetchMappings_1 = require("./useFetchMappings");
|
|
12
13
|
const useFetchExtractionStatus_1 = require("./useFetchExtractionStatus");
|
|
14
|
+
const ExtractionStateJobContext_1 = require("../../context/ExtractionStateJobContext");
|
|
13
15
|
const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }) => {
|
|
14
16
|
const [showImportModal, setShowImportModal] = (0, react_1.useState)(false);
|
|
15
17
|
const [showDeleteModal, setShowDeleteModal] = (0, react_1.useState)(undefined);
|
|
16
18
|
const extractionClient = (0, ExtractionClientContext_1.useExtractionClient)();
|
|
17
19
|
const [showExtractionMessageModal, setShowExtractionMessageModal] = (0, react_1.useState)(false);
|
|
18
20
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
19
|
-
const
|
|
20
|
-
const {
|
|
21
|
+
const [initialStateExtractionFlag, setInitialExtractionStateFlag] = (0, react_1.useState)(true);
|
|
22
|
+
const { mappingIdJobInfo, setMappingIdJobInfo } = (0, ExtractionStateJobContext_1.useExtractionStateJobContext)();
|
|
23
|
+
const { data: mappings, isFetched: isMappingsFetched, isFetching: isLoadingMappings, } = (0, useFetchMappings_1.useFetchMappings)(iModelId, getAccessToken, mappingClient);
|
|
24
|
+
const { data: extractionStatus, isFetched: isExtractionStatusFetched, isFetching: isLoadingExtractionStatus, } = (0, useFetchExtractionStatus_1.useFetchExtractionStatus)({ iModelId, getAccessToken, extractionClient });
|
|
21
25
|
const refreshExtractionStatus = (0, react_1.useCallback)(async () => {
|
|
22
26
|
await queryClient.invalidateQueries({ queryKey: ["iModelExtractionStatus"] });
|
|
27
|
+
setInitialExtractionStateFlag(false);
|
|
23
28
|
}, [queryClient]);
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
if (initialStateExtractionFlag && isMappingsFetched && isExtractionStatusFetched && mappings && extractionStatus && !mappingIdJobInfo.size) {
|
|
31
|
+
const newMappingIdJobInfo = new Map();
|
|
32
|
+
const jobId = extractionStatus.latestExtractionResult.value?.jobId;
|
|
33
|
+
const state = extractionStatus.latestJobStatus?.state;
|
|
34
|
+
if ((state === insights_client_1.ExtractorState.Failed || state === insights_client_1.ExtractorState.Succeeded))
|
|
35
|
+
return;
|
|
36
|
+
!!jobId && mappings.forEach((mapping) => {
|
|
37
|
+
const mappingId = mapping.id;
|
|
38
|
+
const jobId = extractionStatus.latestExtractionResult.value.jobId;
|
|
39
|
+
newMappingIdJobInfo.set(mappingId, jobId);
|
|
40
|
+
});
|
|
41
|
+
setMappingIdJobInfo(newMappingIdJobInfo);
|
|
42
|
+
setInitialExtractionStateFlag(false);
|
|
43
|
+
}
|
|
44
|
+
}, [extractionStatus, initialStateExtractionFlag, isExtractionStatusFetched, isMappingsFetched, mappingIdJobInfo.size, mappings, setMappingIdJobInfo]);
|
|
24
45
|
const refreshMappings = (0, react_1.useCallback)(async () => {
|
|
25
46
|
await queryClient.invalidateQueries({ queryKey: ["mappings"] });
|
|
26
47
|
}, [queryClient]);
|
|
@@ -43,11 +64,14 @@ const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }) => {
|
|
|
43
64
|
await refreshMappings();
|
|
44
65
|
},
|
|
45
66
|
});
|
|
46
|
-
const isLoading = isLoadingMappings ||
|
|
47
|
-
const extractionStatusGated = extractionStatus
|
|
67
|
+
const isLoading = isLoadingMappings || isTogglingExtraction || isDeletingMapping;
|
|
68
|
+
const extractionStatusGated = (!extractionStatus || isLoadingExtractionStatus) ? {
|
|
69
|
+
extractionStatusIcon: {
|
|
48
70
|
iconStatus: undefined,
|
|
49
71
|
iconMessage: "Loading...",
|
|
50
|
-
},
|
|
72
|
+
},
|
|
73
|
+
extractionMessageData: [],
|
|
74
|
+
} : extractionStatus;
|
|
51
75
|
return { mappings, isLoading, showExtractionMessageModal, extractionStatus: extractionStatusGated, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction };
|
|
52
76
|
};
|
|
53
77
|
exports.useMappingsOperations = useMappingsOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,
|
|
1
|
+
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useMappingsOperations.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,iCAAyD;AACzD,4DAAwD;AAGxD,mFAA4E;AAC5E,uDAAoE;AACpE,yDAAsD;AACtD,yEAAsE;AACtE,uFAAuF;AAMhF,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAA2B,EAAE,EAAE;IAC5G,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAsB,KAAK,CA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AqB,yBA6EhC","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, useState } from \"react\";\nimport { ExtractorState } from \"@itwin/insights-client\";\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\";\nimport { useExtractionStateJobContext } from \"../../context/ExtractionStateJobContext\";\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 const [initialStateExtractionFlag, setInitialExtractionStateFlag] = useState<boolean>(true);\n const { mappingIdJobInfo, setMappingIdJobInfo } = useExtractionStateJobContext();\n\n const {\n data: mappings,\n isFetched: isMappingsFetched,\n isFetching: isLoadingMappings,\n } = useFetchMappings(iModelId, getAccessToken, mappingClient);\n\n const {\n data: extractionStatus,\n isFetched: isExtractionStatusFetched,\n isFetching: isLoadingExtractionStatus,\n } = useFetchExtractionStatus({ iModelId, getAccessToken, extractionClient });\n\n const refreshExtractionStatus = useCallback(async () => {\n await queryClient.invalidateQueries({queryKey: [\"iModelExtractionStatus\"]});\n setInitialExtractionStateFlag(false);\n }, [queryClient]);\n\n useEffect(() => {\n if(initialStateExtractionFlag && isMappingsFetched && isExtractionStatusFetched && mappings && extractionStatus && !mappingIdJobInfo.size){\n const newMappingIdJobInfo = new Map<string, string>();\n const jobId = extractionStatus.latestExtractionResult.value?.jobId;\n const state = extractionStatus.latestJobStatus?.state;\n if((state === ExtractorState.Failed || state === ExtractorState.Succeeded)) return;\n !!jobId && mappings.forEach((mapping) => {\n const mappingId = mapping.id;\n const jobId = extractionStatus.latestExtractionResult.value.jobId;\n newMappingIdJobInfo.set(mappingId, jobId);\n });\n setMappingIdJobInfo(newMappingIdJobInfo);\n setInitialExtractionStateFlag(false);\n }\n }, [extractionStatus, initialStateExtractionFlag, isExtractionStatusFetched, isMappingsFetched, mappingIdJobInfo.size, mappings, setMappingIdJobInfo]);\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 || isTogglingExtraction || isDeletingMapping;\n const extractionStatusGated = (!extractionStatus || isLoadingExtractionStatus) ? {\n extractionStatusIcon: {\n iconStatus: undefined,\n iconMessage: \"Loading...\",\n },\n extractionMessageData: [],\n } : extractionStatus;\n\n return { mappings, isLoading, showExtractionMessageModal, extractionStatus: extractionStatusGated, setShowExtractionMessageModal, refreshMappings, refreshExtractionStatus, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction};\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { GroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
3
|
+
import type { Mapping } from "@itwin/insights-client";
|
|
4
|
+
export interface FetchExtractionStatesProps extends GroupingMappingApiConfig {
|
|
5
|
+
jobId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useRunExtraction: ({ iModelId, getAccessToken, }: FetchExtractionStatesProps) => {
|
|
8
|
+
isRunExtractionLoading: boolean;
|
|
9
|
+
isRunExtractionSuccess: boolean;
|
|
10
|
+
isJobStarted: boolean;
|
|
11
|
+
setIsJobStarted: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
12
|
+
runExtraction: import("@tanstack/react-query").UseMutateAsyncFunction<import("@itwin/insights-client").ExtractionRun, unknown, Mapping[], unknown>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useRunExtraction.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRunExtraction = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const ExtractionClientContext_1 = require("../../context/ExtractionClientContext");
|
|
9
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const ExtractionStateJobContext_1 = require("../../context/ExtractionStateJobContext");
|
|
12
|
+
const useRunExtraction = ({ iModelId, getAccessToken, }) => {
|
|
13
|
+
const extractionClient = (0, ExtractionClientContext_1.useExtractionClient)();
|
|
14
|
+
const [isJobStarted, setIsJobStarted] = (0, react_1.useState)(false);
|
|
15
|
+
const { mappingIdJobInfo, setMappingIdJobInfo } = (0, ExtractionStateJobContext_1.useExtractionStateJobContext)();
|
|
16
|
+
const { mutateAsync: runExtraction, isLoading: isRunExtractionLoading, isSuccess: isRunExtractionSuccess } = (0, react_query_1.useMutation)({
|
|
17
|
+
mutationKey: ["runExtraction"],
|
|
18
|
+
mutationFn: async (mappings) => {
|
|
19
|
+
const accessToken = await getAccessToken();
|
|
20
|
+
const mappingIds = mappings.length > 0 ? mappings.map((mapping) => { return { id: mapping.id }; }) : [];
|
|
21
|
+
const extractionRequest = {
|
|
22
|
+
mappings: mappingIds,
|
|
23
|
+
};
|
|
24
|
+
const runExtractionResponse = await extractionClient.runExtraction(accessToken, iModelId, extractionRequest);
|
|
25
|
+
return runExtractionResponse;
|
|
26
|
+
},
|
|
27
|
+
onSuccess: async (runExtractionResponse, mappings) => {
|
|
28
|
+
for (const mapping of mappings) {
|
|
29
|
+
if (mappingIdJobInfo?.get(mapping.id) === undefined) {
|
|
30
|
+
setMappingIdJobInfo((prevMap) => {
|
|
31
|
+
const newMap = new Map(prevMap);
|
|
32
|
+
newMap.set(mapping.id, runExtractionResponse.id);
|
|
33
|
+
return newMap;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return { isRunExtractionLoading, isRunExtractionSuccess, isJobStarted, setIsJobStarted, runExtraction };
|
|
40
|
+
};
|
|
41
|
+
exports.useRunExtraction = useRunExtraction;
|
|
42
|
+
//# sourceMappingURL=useRunExtraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunExtraction.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/hooks/useRunExtraction.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mFAA4E;AAC5E,uDAAoD;AAGpD,iCAAiC;AACjC,uFAAuF;AAMhF,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,cAAc,GACa,EAAE,EAAE;IAC/B,MAAM,gBAAgB,GAAG,IAAA,6C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E,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;wBACjD,OAAO,MAAM,CAAC;oBAChB,CAAC,CAAC,CAAC;iBACJ;aACF;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC;AAC1G,CAAC,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B","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 { useExtractionClient } from \"../../context/ExtractionClientContext\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport type { GroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport type { ExtractionRequestMapping, ExtractionRunRequest, Mapping } from \"@itwin/insights-client\";\nimport { useState } from \"react\";\nimport { useExtractionStateJobContext } from \"../../context/ExtractionStateJobContext\";\n\nexport interface FetchExtractionStatesProps extends GroupingMappingApiConfig {\n jobId?: string;\n}\n\nexport const useRunExtraction = ({\n iModelId,\n getAccessToken,\n}: FetchExtractionStatesProps) => {\n const extractionClient = useExtractionClient();\n const [isJobStarted, setIsJobStarted] = useState<boolean>(false);\n const { mappingIdJobInfo, setMappingIdJobInfo } = useExtractionStateJobContext();\n\n const { mutateAsync: runExtraction, isLoading: isRunExtractionLoading, isSuccess: isRunExtractionSuccess } = useMutation({\n mutationKey: [\"runExtraction\"],\n mutationFn: async (mappings: Mapping[]) => {\n const accessToken = await getAccessToken();\n const mappingIds: ExtractionRequestMapping[] = mappings.length > 0 ? mappings.map((mapping) => { return { id: mapping.id }; }) : [];\n const extractionRequest: ExtractionRunRequest = {\n mappings: mappingIds,\n };\n\n const runExtractionResponse = await extractionClient.runExtraction(accessToken, iModelId, extractionRequest);\n return runExtractionResponse;\n },\n onSuccess: async (runExtractionResponse, mappings) => {\n for (const mapping of mappings){\n if(mappingIdJobInfo?.get(mapping.id) === undefined){\n setMappingIdJobInfo((prevMap: Map<string, string>) => {\n const newMap = new Map(prevMap);\n newMap.set(mapping.id, runExtractionResponse.id);\n return newMap;\n });\n }\n }\n },\n });\n\n return { isRunExtractionLoading, isRunExtractionSuccess, isJobStarted, setIsJobStarted, runExtraction };\n};\n"]}
|
|
@@ -38,43 +38,35 @@ const useValidator_1 = __importDefault(require("../hooks/useValidator"));
|
|
|
38
38
|
require("./CalculatedPropertyAction.scss");
|
|
39
39
|
const insights_client_1 = require("@itwin/insights-client");
|
|
40
40
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
41
|
-
const utils_1 = require("../../../common/utils");
|
|
42
41
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
43
42
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
43
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
44
44
|
const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
45
45
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
46
46
|
const mappingClient = (0, MappingClientContext_1.useMappingClient)();
|
|
47
47
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
48
48
|
const [type, setType] = (0, react_1.useState)(calculatedProperty?.type);
|
|
49
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
50
49
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, {
|
|
61
|
-
propertyName,
|
|
62
|
-
type,
|
|
63
|
-
})
|
|
64
|
-
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, {
|
|
65
|
-
propertyName,
|
|
66
|
-
type,
|
|
67
|
-
});
|
|
50
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
51
|
+
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
52
|
+
const accessToken = await getAccessToken();
|
|
53
|
+
return calculatedProperty
|
|
54
|
+
? mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, { propertyName, type })
|
|
55
|
+
: mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, { propertyName, type });
|
|
56
|
+
}, {
|
|
57
|
+
onSuccess: async () => {
|
|
58
|
+
await queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, group.id] });
|
|
68
59
|
onSaveSuccess();
|
|
69
60
|
setPropertyName("");
|
|
70
61
|
setType(insights_client_1.CalculatedPropertyType.Undefined);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const onSave = () => {
|
|
65
|
+
if (!validator.allValid() || !type) {
|
|
66
|
+
showValidationMessage(true);
|
|
67
|
+
return;
|
|
71
68
|
}
|
|
72
|
-
|
|
73
|
-
(0, utils_1.handleError)(error.status);
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
setIsLoading(false);
|
|
77
|
-
}
|
|
69
|
+
saveMutation(type);
|
|
78
70
|
};
|
|
79
71
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
80
72
|
react_1.default.createElement("div", { className: 'gmw-calculated-properties-action-container' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAG8B;AAC9B,+CAAwC;AACxC,qFAA6D;AAC7D,yEAAiD;AACjD,2CAAyC;AAEzC,4DAAgE;AAChE,mFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../../src/components/Properties/CalculatedProperties/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAG8B;AAC9B,+CAAwC;AACxC,qFAA6D;AAC7D,yEAAiD;AACjD,2CAAyC;AAEzC,4DAAgE;AAChE,mFAAgF;AAChF,qFAAqF;AACrF,6EAAsE;AACtE,uDAAoE;AAU7D,MAAM,wBAAwB,GAAG,CAAC,EACvC,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,GACiB,EAAE,EAAE;IAClC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACnE,MAAM,aAAa,GAAG,IAAA,uCAAgB,GAAE,CAAC;IACzC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAC9C,kBAAkB,EAAE,YAAY,IAAI,EAAE,CACvC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAqC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC/F,MAAM,CAAC,SAAS,EAAE,qBAAqB,CAAC,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAA,4BAAc,GAAE,CAAC;IAErC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,IAAA,yBAAW,EAAC,KAAK,EAAE,IAA4B,EAAE,EAAE;QAC7F,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;QAE3C,OAAO,kBAAkB;YACvB,CAAC,CAAC,aAAa,CAAC,wBAAwB,CACtC,WAAW,EACX,QAAQ,EACR,SAAS,EACT,KAAK,CAAC,EAAE,EACR,kBAAkB,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AE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AA/EW,QAAA,wBAAwB,4BA+EnC","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 {\n Fieldset,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport ActionPanel from \"../../SharedComponents/ActionPanel\";\nimport useValidator from \"../hooks/useValidator\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedProperty, Group } from \"@itwin/insights-client\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport { SharedCalculatedPropertyForms } from \"./SharedCalculatedPropertyForms\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\n\nexport interface CalculatedPropertyActionProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyAction = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType | undefined>(calculatedProperty?.type);\n const [validator, showValidationMessage] = useValidator();\n const queryClient = useQueryClient();\n\n const { mutate: saveMutation, isLoading } = useMutation(async (type: CalculatedPropertyType) => {\n const accessToken = await getAccessToken();\n\n return calculatedProperty\n ? mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n { propertyName, type },\n )\n : mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n { propertyName, type },\n );\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"calculatedProperties\", iModelId, mappingId, group.id] });\n onSaveSuccess();\n setPropertyName(\"\");\n setType(CalculatedPropertyType.Undefined);\n },\n });\n\n const onSave = () => {\n if (!validator.allValid() || !type) {\n showValidationMessage(true);\n return;\n }\n\n saveMutation(type);\n };\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Text variant='small' as='small' className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Text>\n </div>\n <SharedCalculatedPropertyForms\n validator={validator}\n propertyName={propertyName}\n setPropertyName={setPropertyName}\n type={type}\n setType={setType}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js
CHANGED
|
@@ -37,13 +37,14 @@ const react_1 = __importStar(require("react"));
|
|
|
37
37
|
const ActionPanel_1 = __importDefault(require("../../SharedComponents/ActionPanel"));
|
|
38
38
|
const BboxDimensionsDecorator_1 = require("../../../decorators/BboxDimensionsDecorator");
|
|
39
39
|
const useValidator_1 = __importDefault(require("../hooks/useValidator"));
|
|
40
|
-
const utils_1 = require("../../../common/utils");
|
|
41
40
|
const viewerUtils_1 = require("../../../common/viewerUtils");
|
|
42
41
|
require("./CalculatedPropertyActionWithVisuals.scss");
|
|
43
42
|
const MappingClientContext_1 = require("../../context/MappingClientContext");
|
|
44
43
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
44
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
45
45
|
const SharedCalculatedPropertyForms_1 = require("./SharedCalculatedPropertyForms");
|
|
46
46
|
const useKeySetHiliteQueries_1 = require("../../Groups/hooks/useKeySetHiliteQueries");
|
|
47
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
47
48
|
const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
48
49
|
const { getAccessToken, iModelId, iModelConnection } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
49
50
|
if (!iModelConnection) {
|
|
@@ -53,11 +54,11 @@ const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedPrope
|
|
|
53
54
|
const [propertyName, setPropertyName] = (0, react_1.useState)(calculatedProperty?.propertyName ?? "");
|
|
54
55
|
const [type, setType] = (0, react_1.useState)(calculatedProperty?.type);
|
|
55
56
|
const [bboxDecorator, setBboxDecorator] = (0, react_1.useState)();
|
|
56
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
57
57
|
const [inferredSpatialData, setInferredSpatialData] = (0, react_1.useState)();
|
|
58
58
|
const [validator, showValidationMessage] = (0, useValidator_1.default)();
|
|
59
59
|
const [colorProperty, setColorProperty] = (0, react_1.useState)(false);
|
|
60
60
|
const { data } = (0, useKeySetHiliteQueries_1.useGroupKeySetQuery)(group, iModelConnection, true);
|
|
61
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
61
62
|
const resolvedHiliteIds = (0, react_1.useMemo)(() => {
|
|
62
63
|
// Resolved ids, default to an empty array if not available
|
|
63
64
|
return data?.result?.ids ?? [];
|
|
@@ -96,33 +97,25 @@ const CalculatedPropertyActionWithVisuals = ({ mappingId, group, calculatedPrope
|
|
|
96
97
|
: bboxDecorator.clearContext();
|
|
97
98
|
}
|
|
98
99
|
}, [bboxDecorator, colorProperty, inferredSpatialData, type]);
|
|
99
|
-
const
|
|
100
|
+
const { mutate: saveMutation, isLoading } = (0, react_query_1.useMutation)(async (type) => {
|
|
101
|
+
const accessToken = await getAccessToken();
|
|
102
|
+
return calculatedProperty
|
|
103
|
+
? mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, { propertyName, type })
|
|
104
|
+
: mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, { propertyName, type });
|
|
105
|
+
}, {
|
|
106
|
+
onSuccess: async () => {
|
|
107
|
+
await queryClient.invalidateQueries({ queryKey: ["calculatedProperties", iModelId, mappingId, group.id] });
|
|
108
|
+
onSaveSuccess();
|
|
109
|
+
setPropertyName("");
|
|
110
|
+
setType(insights_client_1.CalculatedPropertyType.Undefined);
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const onSave = () => {
|
|
100
114
|
if (!validator.allValid() || !type) {
|
|
101
115
|
showValidationMessage(true);
|
|
102
116
|
return;
|
|
103
117
|
}
|
|
104
|
-
|
|
105
|
-
setIsLoading(true);
|
|
106
|
-
const accessToken = await getAccessToken();
|
|
107
|
-
calculatedProperty
|
|
108
|
-
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, {
|
|
109
|
-
propertyName,
|
|
110
|
-
type,
|
|
111
|
-
})
|
|
112
|
-
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, {
|
|
113
|
-
propertyName,
|
|
114
|
-
type,
|
|
115
|
-
});
|
|
116
|
-
onSaveSuccess();
|
|
117
|
-
setPropertyName("");
|
|
118
|
-
setType(undefined);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
(0, utils_1.handleError)(error.status);
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
setIsLoading(false);
|
|
125
|
-
}
|
|
118
|
+
saveMutation(type);
|
|
126
119
|
};
|
|
127
120
|
const getSpatialData = (value) => inferredSpatialData?.has(BboxDimensionsDecorator_1.BboxDimension[value]) && (react_1.default.createElement("div", null, `${inferredSpatialData
|
|
128
121
|
?.get(BboxDimensionsDecorator_1.BboxDimension[value])
|