@itwin/grouping-mapping-widget 0.18.1 → 0.19.1
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/formula/FormulaFunctionProvider.js +1 -0
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +3 -1
- package/lib/cjs/grouping-mapping-widget.js +7 -3
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js +9 -5
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/cjs/widget/components/ExtractionLogCustomFilter.d.ts +4 -0
- package/lib/cjs/widget/components/ExtractionLogCustomFilter.js +42 -0
- package/lib/cjs/widget/components/ExtractionLogCustomFilter.js.map +1 -0
- package/lib/cjs/widget/components/ExtractionMessageModal.d.ts +11 -0
- package/lib/cjs/widget/components/ExtractionMessageModal.js +87 -0
- package/lib/cjs/widget/components/ExtractionMessageModal.js.map +1 -0
- package/lib/cjs/widget/components/ExtractionMessageModal.scss +19 -0
- package/lib/cjs/widget/components/ExtractionStatusIcon.d.ts +8 -0
- package/lib/cjs/widget/components/ExtractionStatusIcon.js +21 -0
- package/lib/cjs/widget/components/ExtractionStatusIcon.js.map +1 -0
- package/lib/cjs/widget/components/GroupItem.d.ts +2 -2
- package/lib/cjs/widget/components/GroupItem.js.map +1 -1
- package/lib/cjs/widget/components/GroupMenuActions.d.ts +2 -2
- package/lib/cjs/widget/components/GroupMenuActions.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingContext.d.ts +5 -1
- package/lib/cjs/widget/components/GroupingMappingContext.js +10 -3
- package/lib/cjs/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/widget/components/Groups.d.ts +16 -0
- package/lib/cjs/widget/components/Groups.js +46 -0
- package/lib/cjs/widget/components/Groups.js.map +1 -0
- package/lib/cjs/widget/components/GroupsView.d.ts +31 -0
- package/lib/cjs/widget/components/GroupsView.js +37 -0
- package/lib/cjs/widget/components/GroupsView.js.map +1 -0
- package/lib/{esm/widget/components/Grouping.scss → cjs/widget/components/GroupsView.scss} +4 -8
- package/lib/cjs/widget/components/GroupsVisualization.d.ts +2 -2
- package/lib/cjs/widget/components/GroupsVisualization.js +21 -23
- package/lib/cjs/widget/components/GroupsVisualization.js.map +1 -1
- package/lib/cjs/widget/components/Mappings.js +2 -2
- package/lib/cjs/widget/components/Mappings.js.map +1 -1
- package/lib/cjs/widget/components/MappingsView.d.ts +7 -1
- package/lib/cjs/widget/components/MappingsView.js +12 -3
- package/lib/cjs/widget/components/MappingsView.js.map +1 -1
- package/lib/cjs/widget/components/StatusIcon.d.ts +1 -0
- package/lib/cjs/widget/components/StatusIcon.js +4 -3
- package/lib/cjs/widget/components/StatusIcon.js.map +1 -1
- package/lib/cjs/widget/components/context/ExtractionClientContext.d.ts +8 -0
- package/lib/cjs/widget/components/context/ExtractionClientContext.js +33 -0
- package/lib/cjs/widget/components/context/ExtractionClientContext.js.map +1 -0
- package/lib/cjs/widget/components/hooks/useGroupsOperations.d.ts +20 -0
- package/lib/cjs/widget/components/hooks/useGroupsOperations.js +67 -0
- package/lib/cjs/widget/components/hooks/useGroupsOperations.js.map +1 -0
- package/lib/cjs/widget/components/hooks/useMappingsOperations.d.ts +14 -0
- package/lib/cjs/widget/components/hooks/useMappingsOperations.js +59 -1
- package/lib/cjs/widget/components/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/widget/components/utils.d.ts +1 -0
- package/lib/cjs/widget/components/utils.js +6 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/viewerUtils.js +2 -5
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.js +1 -0
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +3 -1
- package/lib/esm/grouping-mapping-widget.js +3 -1
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/test/GroupingMappingCustomUI.test.js +10 -6
- package/lib/esm/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/esm/widget/components/ExtractionLogCustomFilter.d.ts +4 -0
- package/lib/esm/widget/components/ExtractionLogCustomFilter.js +19 -0
- package/lib/esm/widget/components/ExtractionLogCustomFilter.js.map +1 -0
- package/lib/esm/widget/components/ExtractionMessageModal.d.ts +11 -0
- package/lib/esm/widget/components/ExtractionMessageModal.js +64 -0
- package/lib/esm/widget/components/ExtractionMessageModal.js.map +1 -0
- package/lib/esm/widget/components/ExtractionMessageModal.scss +19 -0
- package/lib/esm/widget/components/ExtractionStatusIcon.d.ts +8 -0
- package/lib/esm/widget/components/ExtractionStatusIcon.js +14 -0
- package/lib/esm/widget/components/ExtractionStatusIcon.js.map +1 -0
- package/lib/esm/widget/components/GroupItem.d.ts +2 -2
- package/lib/esm/widget/components/GroupItem.js.map +1 -1
- package/lib/esm/widget/components/GroupMenuActions.d.ts +2 -2
- package/lib/esm/widget/components/GroupMenuActions.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingContext.d.ts +5 -1
- package/lib/esm/widget/components/GroupingMappingContext.js +10 -3
- package/lib/esm/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/widget/components/Groups.d.ts +16 -0
- package/lib/esm/widget/components/Groups.js +23 -0
- package/lib/esm/widget/components/Groups.js.map +1 -0
- package/lib/esm/widget/components/GroupsView.d.ts +31 -0
- package/lib/esm/widget/components/GroupsView.js +30 -0
- package/lib/esm/widget/components/GroupsView.js.map +1 -0
- package/lib/{cjs/widget/components/Grouping.scss → esm/widget/components/GroupsView.scss} +4 -8
- package/lib/esm/widget/components/GroupsVisualization.d.ts +2 -2
- package/lib/esm/widget/components/GroupsVisualization.js +22 -24
- package/lib/esm/widget/components/GroupsVisualization.js.map +1 -1
- package/lib/esm/widget/components/Mappings.js +2 -2
- package/lib/esm/widget/components/Mappings.js.map +1 -1
- package/lib/esm/widget/components/MappingsView.d.ts +7 -1
- package/lib/esm/widget/components/MappingsView.js +12 -3
- package/lib/esm/widget/components/MappingsView.js.map +1 -1
- package/lib/esm/widget/components/StatusIcon.d.ts +1 -0
- package/lib/esm/widget/components/StatusIcon.js +5 -4
- package/lib/esm/widget/components/StatusIcon.js.map +1 -1
- package/lib/esm/widget/components/context/ExtractionClientContext.d.ts +8 -0
- package/lib/esm/widget/components/context/ExtractionClientContext.js +27 -0
- package/lib/esm/widget/components/context/ExtractionClientContext.js.map +1 -0
- package/lib/esm/widget/components/hooks/useGroupsOperations.d.ts +20 -0
- package/lib/esm/widget/components/hooks/useGroupsOperations.js +63 -0
- package/lib/esm/widget/components/hooks/useGroupsOperations.js.map +1 -0
- package/lib/esm/widget/components/hooks/useMappingsOperations.d.ts +14 -0
- package/lib/esm/widget/components/hooks/useMappingsOperations.js +59 -1
- package/lib/esm/widget/components/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/widget/components/utils.d.ts +1 -0
- package/lib/esm/widget/components/utils.js +4 -0
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/viewerUtils.js +3 -6
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/widget/components/Grouping.d.ts +0 -22
- package/lib/cjs/widget/components/Grouping.js +0 -96
- package/lib/cjs/widget/components/Grouping.js.map +0 -1
- package/lib/esm/widget/components/Grouping.d.ts +0 -22
- package/lib/esm/widget/components/Grouping.js +0 -70
- package/lib/esm/widget/components/Grouping.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupsVisualization.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupsVisualization.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,8BA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AE,cAAc,EAC9B,aAAa,EAAI,aAAa,GAC9B,CACE,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 type { Group } from \"@itwin/insights-client\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useGroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport {\n getHiliteIdsFromGroups,\n hideGroup,\n hideGroups,\n visualizeGroupColors,\n} from \"./groupsHelpers\";\nimport {\n clearEmphasizedElements,\n clearEmphasizedOverriddenElements,\n clearHiddenElements,\n hideElements,\n zoomToElements,\n} from \"./viewerUtils\";\nimport type { ActionButtonRenderer, ActionButtonRendererProps, GroupingProps } from \"./Grouping\";\nimport { Groupings } from \"./Grouping\";\nimport { GroupColorLegend } from \"./GroupColorLegend\";\nimport { GroupVisualizationActions } from \"./GroupsVisualizationActions\";\nimport { GroupsShowHideButtons } from \"./GroupsShowHideButtons\";\nimport \"./GroupsVisualization.scss\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nexport interface GroupsVisualizationProps extends GroupingProps {\n isNonEmphasizedSelectable?: boolean;\n emphasizeElements?: boolean;\n}\n\nexport const GroupsVisualization = ({\n emphasizeElements = true,\n isNonEmphasizedSelectable = false,\n onClickGroupModify,\n onClickAddGroup,\n ...rest\n}: GroupsVisualizationProps) => {\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const firstUpdate = useRef(true);\n const [isLoadingQuery, setLoadingQuery] = useState<boolean>(false);\n const [isVisualizing, setIsVisualizing] =useState<boolean>(false);\n const {\n hilitedElementsQueryCache,\n groups,\n hiddenGroupsIds,\n showGroupColor,\n setHiddenGroupsIds,\n setNumberOfVisualizedGroups,\n } = useGroupHilitedElementsContext();\n\n const getHiliteIdsFromGroupsWrapper = useCallback(\n async (groups: Group[]): Promise<string[]> =>\n iModelConnection\n ? getHiliteIdsFromGroups(\n iModelConnection,\n groups,\n hilitedElementsQueryCache\n )\n : [],\n [iModelConnection, hilitedElementsQueryCache]\n );\n\n const visualizeGroupColorsWrapper = useCallback(\n async () => {\n setIsVisualizing(true);\n setLoadingQuery(true);\n const groupsCopy = [...groups];\n await visualizeGroupColors(\n iModelConnection,\n groupsCopy,\n hiddenGroupsIds,\n hilitedElementsQueryCache,\n setNumberOfVisualizedGroups,\n emphasizeElements,\n );\n isNonEmphasizedSelectable && clearEmphasizedElements();\n setLoadingQuery(false);\n setIsVisualizing(false);\n setNumberOfVisualizedGroups(0);\n },\n [\n iModelConnection,\n groups,\n hiddenGroupsIds,\n hilitedElementsQueryCache,\n emphasizeElements,\n isNonEmphasizedSelectable,\n setNumberOfVisualizedGroups,\n ]\n );\n\n useEffect(() => {\n const visualize = async () => {\n if (firstUpdate.current) {\n firstUpdate.current = false;\n return;\n }\n if (groups.length > 0 && showGroupColor) {\n await visualizeGroupColorsWrapper();\n } else {\n clearEmphasizedOverriddenElements();\n }\n };\n void visualize();\n }, [groups, showGroupColor, visualizeGroupColorsWrapper]);\n\n const hideAllGroups = useCallback(\n async () => {\n setLoadingQuery(true);\n await hideGroups(iModelConnection, groups, hilitedElementsQueryCache);\n setLoadingQuery(false);\n },\n [groups, hilitedElementsQueryCache, iModelConnection]\n );\n\n const hideSingleGroupWrapper = useCallback(\n async (group: Group) => {\n setLoadingQuery(true);\n await hideGroup(iModelConnection, group, hilitedElementsQueryCache);\n setLoadingQuery(false);\n },\n [hilitedElementsQueryCache, iModelConnection]\n );\n\n const showGroup = useCallback(\n async (viewGroup: Group) => {\n clearHiddenElements();\n\n // hide group Ids filter\n const newHiddenGroups: Group[] = groups.filter((g) => hiddenGroupsIds.has(g.id) && g.id !== viewGroup.id);\n\n // view group Ids filter\n const viewGroups = groups.filter((g) => !hiddenGroupsIds.has(g.id) || g.id === viewGroup.id);\n const viewIds = await getHiliteIdsFromGroupsWrapper(viewGroups);\n\n let hiddenIds = await getHiliteIdsFromGroupsWrapper(newHiddenGroups);\n hiddenIds = hiddenIds.filter((id) => !viewIds.includes(id));\n hideElements(hiddenIds);\n },\n [groups, hiddenGroupsIds, getHiliteIdsFromGroupsWrapper]\n );\n\n const showAll = useCallback(async () => {\n setLoadingQuery(true);\n\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n const allIds = await getHiliteIdsFromGroupsWrapper(groups);\n await zoomToElements(allIds);\n\n setLoadingQuery(false);\n }, [getHiliteIdsFromGroupsWrapper, groups, setHiddenGroupsIds]);\n\n const hideAll = useCallback(async () => {\n await hideAllGroups();\n setHiddenGroupsIds(\n new Set(groups.map((g) => g.id))\n );\n const allIds = await getHiliteIdsFromGroupsWrapper(groups);\n await zoomToElements(allIds);\n }, [\n setHiddenGroupsIds,\n groups,\n hideAllGroups,\n getHiliteIdsFromGroupsWrapper,\n ]);\n\n const onModify = useCallback(\n async (group: Group, type: string) => {\n if (!onClickGroupModify) return;\n if (group.id && hiddenGroupsIds.has(group.id)) {\n await showGroup(group);\n setHiddenGroupsIds(new Set([...hiddenGroupsIds].filter((id) => id !== group.id)));\n }\n clearEmphasizedElements();\n onClickGroupModify(group, type);\n },\n [hiddenGroupsIds, onClickGroupModify, setHiddenGroupsIds, showGroup]\n );\n\n const onAddGroup = useCallback(\n (type: string) => {\n if (!onClickAddGroup) return;\n onClickAddGroup(type);\n clearEmphasizedElements();\n },\n [onClickAddGroup]\n );\n\n const groupActionButtonRenderers: ActionButtonRenderer[] = useMemo(() => [\n (props: ActionButtonRendererProps) =>\n showGroupColor ? <GroupColorLegend {...props} groups={groups} /> : [],\n (props: ActionButtonRendererProps) => (\n <GroupsShowHideButtons\n {...props}\n isLoadingQuery={isLoadingQuery}\n showGroup={showGroup}\n hideGroup={hideSingleGroupWrapper}\n />\n ),\n ].flat(), [groups, hideSingleGroupWrapper, isLoadingQuery, showGroup, showGroupColor]);\n\n return (\n <div className=\"gmw-groups-vis-container\">\n <GroupVisualizationActions\n isLoadingQuery={isLoadingQuery}\n showAll={showAll}\n hideAll={hideAll}\n />\n <Groupings\n onClickGroupModify={onModify}\n onClickAddGroup={onAddGroup}\n actionButtonRenderers={groupActionButtonRenderers}\n {...rest}\n disableActions={isLoadingQuery}\n isVisualizing = {isVisualizing}\n />\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GroupsVisualization.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupsVisualization.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,uBAAuB,EACvB,iCAAiC,EACjC,mBAAmB,EACnB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAQjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,iBAAiB,GAAG,IAAI,EACxB,yBAAyB,GAAG,KAAK,EACjC,kBAAkB,EAClB,eAAe,EACf,GAAG,IAAI,EACkB,EAAE,EAAE;IAC7B,MAAM,EAAE,gBAAgB,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAC3D,IAAI,CAA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C,CAAC,CAAC,oBAAC,gBAAgB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC,CAAC,CAAC,EAAE;QACvE,CAAC,KAAgC,EAAE,EAAE,CAAC,CACpC,oBAAC,qBAAqB,OAChB,KAAK,EACT,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,sBAAsB,GACjC,CACH;KACF,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,sBAAsB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEvF,OAAO,CACL,6BAAK,SAAS,EAAC,0BAA0B;QACvC,oBAAC,yBAAyB,IACxB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAChB;QACF,oBAAC,MAAM,IACL,kBAAkB,EAAE,QAAQ,EAC5B,eAAe,EAAE,UAAU,EAC3B,qBAAqB,EAAE,0BAA0B,KAC7C,IAAI,EACR,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,GAC5B,CACE,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 type { Group } from \"@itwin/insights-client\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useGroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport {\n getHiliteIdsFromGroups,\n hideGroup,\n hideGroups,\n visualizeGroupColors,\n} from \"./groupsHelpers\";\nimport {\n clearEmphasizedElements,\n clearEmphasizedOverriddenElements,\n clearHiddenElements,\n hideElements,\n} from \"./viewerUtils\";\nimport type { GroupsProps } from \"./Groups\";\nimport { Groups } from \"./Groups\";\nimport { GroupColorLegend } from \"./GroupColorLegend\";\nimport { GroupVisualizationActions } from \"./GroupsVisualizationActions\";\nimport { GroupsShowHideButtons } from \"./GroupsShowHideButtons\";\nimport \"./GroupsVisualization.scss\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { ActionButtonRenderer, ActionButtonRendererProps } from \"./GroupsView\";\n\nexport interface GroupsVisualizationProps extends GroupsProps {\n isNonEmphasizedSelectable?: boolean;\n emphasizeElements?: boolean;\n}\n\nexport const GroupsVisualization = ({\n emphasizeElements = true,\n isNonEmphasizedSelectable = false,\n onClickGroupModify,\n onClickAddGroup,\n ...rest\n}: GroupsVisualizationProps) => {\n const { iModelConnection } = useGroupingMappingApiConfig();\n if (!iModelConnection) {\n throw new Error(\"This component requires an active iModelConnection.\");\n }\n const firstUpdate = useRef(true);\n const [isLoadingQuery, setLoadingQuery] = useState<boolean>(false);\n const [isVisualizing, setIsVisualizing] = useState<boolean>(false);\n const {\n hilitedElementsQueryCache,\n groups,\n hiddenGroupsIds,\n showGroupColor,\n setHiddenGroupsIds,\n setNumberOfVisualizedGroups,\n } = useGroupHilitedElementsContext();\n\n const getHiliteIdsFromGroupsWrapper = useCallback(\n async (groups: Group[]): Promise<string[]> =>\n iModelConnection\n ? getHiliteIdsFromGroups(\n iModelConnection,\n groups,\n hilitedElementsQueryCache\n )\n : [],\n [iModelConnection, hilitedElementsQueryCache]\n );\n\n const handleVisualizationStates = useCallback((start = true) => {\n setIsVisualizing(start);\n setLoadingQuery(start);\n if (!start) {\n setNumberOfVisualizedGroups(0);\n }\n }, [setNumberOfVisualizedGroups]);\n\n const triggerVisualization = useCallback(async () => {\n handleVisualizationStates(true);\n const groupsCopy = [...groups];\n await visualizeGroupColors(\n iModelConnection,\n groupsCopy,\n hiddenGroupsIds,\n hilitedElementsQueryCache,\n setNumberOfVisualizedGroups,\n emphasizeElements,\n );\n isNonEmphasizedSelectable && clearEmphasizedElements();\n handleVisualizationStates(false);\n }, [handleVisualizationStates, groups, iModelConnection, hiddenGroupsIds, hilitedElementsQueryCache, setNumberOfVisualizedGroups, emphasizeElements, isNonEmphasizedSelectable]);\n\n useEffect(() => {\n const visualize = async () => {\n if (firstUpdate.current) {\n firstUpdate.current = false;\n return;\n }\n if (groups.length > 0 && showGroupColor) {\n await triggerVisualization();\n } else {\n clearEmphasizedOverriddenElements();\n }\n };\n void visualize();\n // We don't want to trigger full visualization when toggling individual groups.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [groups, showGroupColor]);\n\n const hideAllGroups = useCallback(\n async () => {\n setLoadingQuery(true);\n await hideGroups(iModelConnection, groups, hilitedElementsQueryCache);\n setLoadingQuery(false);\n },\n [groups, hilitedElementsQueryCache, iModelConnection]\n );\n\n const hideSingleGroupWrapper = useCallback(\n async (group: Group) => {\n setLoadingQuery(true);\n await hideGroup(iModelConnection, group, hilitedElementsQueryCache);\n setLoadingQuery(false);\n },\n [hilitedElementsQueryCache, iModelConnection]\n );\n\n const showGroup = useCallback(\n async (viewGroup: Group) => {\n setLoadingQuery(true);\n clearHiddenElements();\n\n // hide group Ids filter\n const newHiddenGroups: Group[] = groups.filter((g) => hiddenGroupsIds.has(g.id) && g.id !== viewGroup.id);\n\n // view group Ids filter\n const viewGroups = groups.filter((g) => !hiddenGroupsIds.has(g.id) || g.id === viewGroup.id);\n const viewIds = await getHiliteIdsFromGroupsWrapper(viewGroups);\n\n let hiddenIds = await getHiliteIdsFromGroupsWrapper(newHiddenGroups);\n hiddenIds = hiddenIds.filter((id) => !viewIds.includes(id));\n hideElements(hiddenIds);\n setLoadingQuery(false);\n },\n [groups, hiddenGroupsIds, getHiliteIdsFromGroupsWrapper]\n );\n\n const showAll = useCallback(async () => {\n setLoadingQuery(true);\n\n clearHiddenElements();\n setHiddenGroupsIds(new Set());\n await getHiliteIdsFromGroupsWrapper(groups);\n\n setLoadingQuery(false);\n }, [getHiliteIdsFromGroupsWrapper, groups, setHiddenGroupsIds]);\n\n const hideAll = useCallback(async () => {\n await hideAllGroups();\n setHiddenGroupsIds(\n new Set(groups.map((g) => g.id))\n );\n await getHiliteIdsFromGroupsWrapper(groups);\n }, [\n setHiddenGroupsIds,\n groups,\n hideAllGroups,\n getHiliteIdsFromGroupsWrapper,\n ]);\n\n const onModify = useCallback(\n async (group: Group, type: string) => {\n if (!onClickGroupModify) return;\n if (group.id && hiddenGroupsIds.has(group.id)) {\n await showGroup(group);\n setHiddenGroupsIds(new Set([...hiddenGroupsIds].filter((id) => id !== group.id)));\n }\n clearEmphasizedElements();\n onClickGroupModify(group, type);\n },\n [hiddenGroupsIds, onClickGroupModify, setHiddenGroupsIds, showGroup]\n );\n\n const onAddGroup = useCallback(\n (type: string) => {\n if (!onClickAddGroup) return;\n onClickAddGroup(type);\n clearEmphasizedElements();\n },\n [onClickAddGroup]\n );\n\n const groupActionButtonRenderers: ActionButtonRenderer[] = useMemo(() => [\n (props: ActionButtonRendererProps) =>\n showGroupColor ? <GroupColorLegend {...props} groups={groups} /> : [],\n (props: ActionButtonRendererProps) => (\n <GroupsShowHideButtons\n {...props}\n isLoadingQuery={isLoadingQuery}\n showGroup={showGroup}\n hideGroup={hideSingleGroupWrapper}\n />\n ),\n ].flat(), [groups, hideSingleGroupWrapper, isLoadingQuery, showGroup, showGroupColor]);\n\n return (\n <div className=\"gmw-groups-vis-container\">\n <GroupVisualizationActions\n isLoadingQuery={isLoadingQuery}\n showAll={showAll}\n hideAll={hideAll}\n />\n <Groups\n onClickGroupModify={onModify}\n onClickAddGroup={onAddGroup}\n actionButtonRenderers={groupActionButtonRenderers}\n {...rest}\n disableActions={isLoadingQuery}\n isVisualizing={isVisualizing}\n />\n </div>\n );\n};\n"]}
|
|
@@ -11,12 +11,12 @@ import { Alert } from "@itwin/itwinui-react";
|
|
|
11
11
|
export const Mappings = (props) => {
|
|
12
12
|
const groupingMappingApiConfig = useGroupingMappingApiConfig();
|
|
13
13
|
const mappingClient = useMappingClient();
|
|
14
|
-
const { mappings, isLoading, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage, } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });
|
|
14
|
+
const { mappings, isLoading, extractionIconData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage, } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });
|
|
15
15
|
const renderAlert = useCallback(() => {
|
|
16
16
|
if (!errorMessage)
|
|
17
17
|
return;
|
|
18
18
|
return (React.createElement(Alert, { type: "negative", onClose: () => setErrorMessage(undefined) }, errorMessage));
|
|
19
19
|
}, [errorMessage, setErrorMessage]);
|
|
20
|
-
return (React.createElement(MappingsView, { mappings: mappings, isLoading: isLoading, onRefresh: refresh, onToggleExtraction: toggleExtraction, onDelete: onDelete, showImportModal: showImportModal, setShowImportModal: setShowImportModal, showDeleteModal: showDeleteModal, setShowDeleteModal: setShowDeleteModal, isTogglingExtraction: isTogglingExtraction, alert: renderAlert(), ...props }));
|
|
20
|
+
return (React.createElement(MappingsView, { mappings: mappings, isLoading: isLoading, extractionIconData: extractionIconData, 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 }));
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=Mappings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mappings.js","sourceRoot":"","sources":["../../../../src/widget/components/Mappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,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AE,KAChB,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, { useCallback } from \"react\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport type { mappingViewDefaultDisplayStrings } from \"./MappingsView\";\nimport { MappingsView } from \"./MappingsView\";\nimport { useMappingsOperations } from \"./hooks/useMappingsOperations\";\nimport { Alert } from \"@itwin/itwinui-react\";\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 refresh,\n toggleExtraction,\n onDelete,\n setShowImportModal,\n showImportModal,\n setShowDeleteModal,\n showDeleteModal,\n isTogglingExtraction,\n errorMessage,\n setErrorMessage,\n } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });\n\n const renderAlert = useCallback(() => {\n if (!errorMessage) return;\n return (\n <Alert type=\"negative\" onClose={() => setErrorMessage(undefined)}>\n {errorMessage}\n </Alert>\n );\n }, [errorMessage, setErrorMessage]);\n\n return (\n <MappingsView\n mappings={mappings}\n isLoading={isLoading}\n onRefresh={refresh}\n onToggleExtraction={toggleExtraction}\n onDelete={onDelete}\n showImportModal={showImportModal}\n setShowImportModal={setShowImportModal}\n showDeleteModal={showDeleteModal}\n setShowDeleteModal={setShowDeleteModal}\n isTogglingExtraction={isTogglingExtraction}\n alert={renderAlert()}\n {...props}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Mappings.js","sourceRoot":"","sources":["../../../../src/widget/components/Mappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAGjF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAW7C,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,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,6BAA6B,EAC7B,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,eAAe,GAChB,GAAG,qBAAqB,CAAC,EAAE,GAAG,wBAAwB,EAAE,aAAa,EAAE,CAAC,CAAC;IAE1E,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,OAAO,CACL,oBAAC,KAAK,IAAC,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,IAC7D,YAAY,CACP,CACT,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,oBAAC,YAAY,IACX,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,0BAA0B,EAAE,0BAA0B,EACtD,qBAAqB,EAAE,qBAAqB,EAC5C,6BAA6B,EAAE,6BAA6B,EAC5D,SAAS,EAAE,OAAO,EAClB,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,EAC1C,KAAK,EAAE,WAAW,EAAE,KAChB,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, { useCallback } from \"react\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport type { mappingViewDefaultDisplayStrings } from \"./MappingsView\";\nimport { MappingsView } from \"./MappingsView\";\nimport { useMappingsOperations } from \"./hooks/useMappingsOperations\";\nimport { Alert } from \"@itwin/itwinui-react\";\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 extractionIconData,\n showExtractionMessageModal,\n extractionMessageData,\n setShowExtractionMessageModal,\n refresh,\n toggleExtraction,\n onDelete,\n setShowImportModal,\n showImportModal,\n setShowDeleteModal,\n showDeleteModal,\n isTogglingExtraction,\n errorMessage,\n setErrorMessage,\n } = useMappingsOperations({ ...groupingMappingApiConfig, mappingClient });\n\n const renderAlert = useCallback(() => {\n if (!errorMessage) return;\n return (\n <Alert type=\"negative\" onClose={() => setErrorMessage(undefined)}>\n {errorMessage}\n </Alert>\n );\n }, [errorMessage, setErrorMessage]);\n\n return (\n <MappingsView\n mappings={mappings}\n isLoading={isLoading}\n extractionIconData={extractionIconData}\n showExtractionMessageModal={showExtractionMessageModal}\n extractionMessageData={extractionMessageData}\n setShowExtractionMessageModal={setShowExtractionMessageModal}\n onRefresh={refresh}\n onToggleExtraction={toggleExtraction}\n onDelete={onDelete}\n showImportModal={showImportModal}\n setShowImportModal={setShowImportModal}\n showDeleteModal={showDeleteModal}\n setShowDeleteModal={setShowDeleteModal}\n isTogglingExtraction={isTogglingExtraction}\n alert={renderAlert()}\n {...props}\n />\n );\n};\n"]}
|
|
@@ -2,6 +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 { ExtractionMessageData } from "./hooks/useMappingsOperations";
|
|
6
|
+
import type { ExtractionIconData } from "./hooks/useMappingsOperations";
|
|
5
7
|
export declare const mappingViewDefaultDisplayStrings: {
|
|
6
8
|
mappings: string;
|
|
7
9
|
iTwins: string;
|
|
@@ -15,6 +17,10 @@ export declare const mappingViewDefaultDisplayStrings: {
|
|
|
15
17
|
export interface MappingsViewProps {
|
|
16
18
|
mappings: Mapping[];
|
|
17
19
|
isLoading: boolean;
|
|
20
|
+
extractionIconData: ExtractionIconData;
|
|
21
|
+
showExtractionMessageModal: boolean;
|
|
22
|
+
extractionMessageData: ExtractionMessageData[];
|
|
23
|
+
setShowExtractionMessageModal: (show: boolean) => void;
|
|
18
24
|
isTogglingExtraction: boolean;
|
|
19
25
|
onRefresh: () => Promise<void>;
|
|
20
26
|
onToggleExtraction: (mapping: Mapping) => Promise<void>;
|
|
@@ -29,5 +35,5 @@ export interface MappingsViewProps {
|
|
|
29
35
|
onClickMappingModify?: (mapping: Mapping) => void;
|
|
30
36
|
alert?: React.ReactElement<typeof Alert>;
|
|
31
37
|
}
|
|
32
|
-
export declare const MappingsView: ({ mappings, isLoading, isTogglingExtraction, onRefresh, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }: MappingsViewProps) => JSX.Element;
|
|
38
|
+
export declare const MappingsView: ({ mappings, isLoading, extractionIconData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction, onRefresh, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }: MappingsViewProps) => JSX.Element;
|
|
33
39
|
//# sourceMappingURL=MappingsView.d.ts.map
|
|
@@ -12,6 +12,8 @@ import { MappingImportWizardModal } from "./MappingImportWizardModal";
|
|
|
12
12
|
import { HorizontalTile } from "./HorizontalTile";
|
|
13
13
|
import { BlockingOverlay } from "./BlockingOverlay";
|
|
14
14
|
import { MappingUIActionGroup } from "./MappingViewActionGroup";
|
|
15
|
+
import { ExtractionStatusIcon } from "./ExtractionStatusIcon";
|
|
16
|
+
import { ExtractionMessageModal } from "./ExtractionMessageModal";
|
|
15
17
|
export const mappingViewDefaultDisplayStrings = {
|
|
16
18
|
mappings: "Mappings",
|
|
17
19
|
iTwins: "iTwins",
|
|
@@ -22,7 +24,7 @@ export const mappingViewDefaultDisplayStrings = {
|
|
|
22
24
|
iModelName: "Name",
|
|
23
25
|
iModelDescription: "Description",
|
|
24
26
|
};
|
|
25
|
-
export const MappingsView = ({ mappings, isLoading, isTogglingExtraction, onRefresh, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }) => {
|
|
27
|
+
export const MappingsView = ({ mappings, isLoading, extractionIconData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, isTogglingExtraction, onRefresh, onToggleExtraction, onDelete, showDeleteModal, setShowDeleteModal, displayStrings: userDisplayStrings, showImportModal, setShowImportModal, onClickAddMapping, onClickMappingTitle, onClickMappingModify, alert, }) => {
|
|
26
28
|
const displayStrings = React.useMemo(() => ({ ...mappingViewDefaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
27
29
|
return (React.createElement(React.Fragment, null,
|
|
28
30
|
React.createElement(BlockingOverlay, { isVisible: isTogglingExtraction }),
|
|
@@ -33,11 +35,18 @@ export const MappingsView = ({ mappings, isLoading, isTogglingExtraction, onRefr
|
|
|
33
35
|
React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), onClick: onClickAddMapping, styleType: "high-visibility", title: "New Mapping" }, "New"),
|
|
34
36
|
showImportModal !== undefined && setShowImportModal && React.createElement(IconButton, { title: `Import ${displayStrings.mappings}`, onClick: () => setShowImportModal(true) },
|
|
35
37
|
React.createElement(SvgImport, null))),
|
|
36
|
-
React.createElement(
|
|
37
|
-
React.createElement(
|
|
38
|
+
React.createElement("div", { className: "gmw-button-spacing" },
|
|
39
|
+
React.createElement(ExtractionStatusIcon, { iconStatus: extractionIconData.iconStatus, onClick: () => {
|
|
40
|
+
if (extractionIconData.iconStatus === "negative") {
|
|
41
|
+
setShowExtractionMessageModal(true);
|
|
42
|
+
}
|
|
43
|
+
}, iconMessage: extractionIconData.iconMessage }),
|
|
44
|
+
React.createElement(IconButton, { title: "Refresh", onClick: onRefresh, disabled: isLoading, styleType: 'borderless' },
|
|
45
|
+
React.createElement(SvgRefresh, null)))),
|
|
38
46
|
alert,
|
|
39
47
|
React.createElement("div", { className: 'gmw-mappings-border' }),
|
|
40
48
|
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: onRefresh, onClickMappingModify: onClickMappingModify, setShowDeleteModal: setShowDeleteModal }) })))))),
|
|
49
|
+
React.createElement(ExtractionMessageModal, { isOpen: showExtractionMessageModal, onClose: () => setShowExtractionMessageModal(false), extractionMessageData: extractionMessageData, timestamp: extractionMessageData.length === 0 ? "" : extractionMessageData[0].date }),
|
|
41
50
|
showDeleteModal &&
|
|
42
51
|
React.createElement(DeleteModal, { entityName: showDeleteModal?.mappingName, onClose: () => setShowDeleteModal(undefined), onDelete: async () => {
|
|
43
52
|
await onDelete(showDeleteModal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingsView.js","sourceRoot":"","sources":["../../../../src/widget/components/MappingsView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACL,MAAM,EACN,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CA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AkB,GACtC,GAEJ,CACH,CAAC,CACE,CACP,CACG;QACL,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 {\n EmptyMessage,\n LoadingOverlay,\n} from \"./utils\";\nimport \"./MappingsView.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport { MappingImportWizardModal } from \"./MappingImportWizardModal\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { MappingUIActionGroup } from \"./MappingViewActionGroup\";\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 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 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 <IconButton\n title=\"Refresh\"\n onClick={onRefresh}\n disabled={isLoading}\n styleType='borderless'\n >\n <SvgRefresh />\n </IconButton>\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 {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/widget/components/MappingsView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACL,MAAM,EACN,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B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,EAAE,OAAO,CAAC,WAAW,EACjC,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EAClF,WAAW,EACT,oBAAC,oBAAoB,IACnB,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,SAAS,EACpB,oBAAoB,EAAE,oBAAoB,EAC1C,kBAAkB,EAAE,kBAAkB,GACtC,GAEJ,CACH,CAAC,CACE,CACP,CACG;QACN,oBAAC,sBAAsB,IACrB,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,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 {\n EmptyMessage,\n LoadingOverlay,\n} from \"./utils\";\nimport \"./MappingsView.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport { MappingImportWizardModal } from \"./MappingImportWizardModal\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { MappingUIActionGroup } from \"./MappingViewActionGroup\";\nimport type { ExtractionMessageData } from \"./hooks/useMappingsOperations\";\nimport type { ExtractionIconData } from \"./hooks/useMappingsOperations\";\nimport { ExtractionStatusIcon } from \"./ExtractionStatusIcon\";\nimport { ExtractionMessageModal } from \"./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 extractionIconData: ExtractionIconData;\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 extractionIconData,\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={extractionIconData.iconStatus}\n onClick={() => {\n if (extractionIconData.iconStatus === \"negative\") {\n setShowExtractionMessageModal(true);\n }\n }}\n iconMessage={extractionIconData.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"]}
|
|
@@ -5,6 +5,7 @@ declare const StatusIconMap: {
|
|
|
5
5
|
readonly error: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
6
6
|
readonly warning: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
7
7
|
readonly informational: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
8
|
+
readonly trace: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
8
9
|
};
|
|
9
10
|
export declare const StatusIcon: ({ status, className, ...rest }: {
|
|
10
11
|
status: keyof typeof StatusIconMap;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import React from "react";
|
|
6
6
|
import classnames from "classnames";
|
|
7
|
-
import { SvgInfoCircular, SvgStatusError, SvgStatusSuccess, SvgStatusWarning } from "@itwin/itwinui-icons-react";
|
|
7
|
+
import { SvgFlag, SvgInfoCircular, SvgStatusError, SvgStatusSuccess, SvgStatusWarning } from "@itwin/itwinui-icons-react";
|
|
8
8
|
import "./StatusIcon.scss";
|
|
9
9
|
const StatusIconMap = {
|
|
10
10
|
success: SvgStatusSuccess,
|
|
11
11
|
error: SvgStatusError,
|
|
12
12
|
warning: SvgStatusWarning,
|
|
13
13
|
informational: SvgInfoCircular,
|
|
14
|
+
trace: SvgFlag,
|
|
14
15
|
};
|
|
15
16
|
export const StatusIcon = ({ status, className, ...rest }) => {
|
|
16
17
|
const Element = StatusIconMap[status];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusIcon.js","sourceRoot":"","sources":["../../../../src/widget/components/StatusIcon.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"StatusIcon.js","sourceRoot":"","sources":["../../../../src/widget/components/StatusIcon.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC1H,OAAO,mBAAmB,CAAC;AAE3B,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,gBAAgB;IACzB,KAAK,EAAE,cAAc;IACrB,OAAO,EAAE,gBAAgB;IACzB,aAAa,EAAE,eAAe;IAC9B,KAAK,EAAE,OAAO;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,MAAM,EACN,SAAS,EACT,GAAG,IAAI,EAIR,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,oBAAC,OAAO,IAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,MAAM,EAAE,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AACjH,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 classnames from \"classnames\";\nimport { SvgFlag, SvgInfoCircular, SvgStatusError, SvgStatusSuccess, SvgStatusWarning } from \"@itwin/itwinui-icons-react\";\nimport \"./StatusIcon.scss\";\n\nconst StatusIconMap = {\n success: SvgStatusSuccess,\n error: SvgStatusError,\n warning: SvgStatusWarning,\n informational: SvgInfoCircular,\n trace: SvgFlag,\n} as const;\n\nexport const StatusIcon = ({\n status,\n className,\n ...rest\n}: {\n status: keyof typeof StatusIconMap;\n className?: string;\n}) => {\n const Element = StatusIconMap[status];\n return <Element className={classnames(\"gmw-status-icon\", `gmw-status-icon-${status}`, className)} {...rest} />;\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IExtractionClient } from "@itwin/insights-client";
|
|
3
|
+
import type { ClientPrefix } from "./GroupingApiConfigContext";
|
|
4
|
+
export declare const createDefaultExtractionClient: (prefix?: ClientPrefix) => IExtractionClient;
|
|
5
|
+
export declare const createExtractionClient: (clientProp: IExtractionClient | ClientPrefix) => IExtractionClient;
|
|
6
|
+
export declare const ExtractionClientContext: import("react").Context<IExtractionClient>;
|
|
7
|
+
export declare const useExtractionClient: () => IExtractionClient;
|
|
8
|
+
//# sourceMappingURL=ExtractionClientContext.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExtractionClient, REPORTING_BASE_PATH } from "@itwin/insights-client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const prefixUrl = (baseUrl, prefix) => {
|
|
4
|
+
if (prefix && baseUrl) {
|
|
5
|
+
return baseUrl.replace("api.bentley.com", `${prefix}-api.bentley.com`);
|
|
6
|
+
}
|
|
7
|
+
return baseUrl;
|
|
8
|
+
};
|
|
9
|
+
export const createDefaultExtractionClient = (prefix) => {
|
|
10
|
+
const url = prefixUrl(REPORTING_BASE_PATH, prefix);
|
|
11
|
+
return new ExtractionClient(url);
|
|
12
|
+
};
|
|
13
|
+
export const createExtractionClient = (clientProp) => {
|
|
14
|
+
if (undefined === clientProp || typeof clientProp === "string") {
|
|
15
|
+
return createDefaultExtractionClient(clientProp);
|
|
16
|
+
}
|
|
17
|
+
return clientProp;
|
|
18
|
+
};
|
|
19
|
+
export const ExtractionClientContext = createContext(createDefaultExtractionClient());
|
|
20
|
+
export const useExtractionClient = () => {
|
|
21
|
+
const context = useContext(ExtractionClientContext);
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error("useExtractionClient should be used within a ExtractionClientContext provider");
|
|
24
|
+
}
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=ExtractionClientContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtractionClientContext.js","sourceRoot":"","sources":["../../../../../src/widget/components/context/ExtractionClientContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGlD,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,MAAe,EAAE,EAAE;IACtD,IAAI,MAAM,IAAI,OAAO,EAAE;QACrB,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,MAAM,kBAAkB,CAAC,CAAC;KACxE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAAqB,EAAqB,EAAE;IACxF,MAAM,GAAG,GAAG,SAAS,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAA4C,EAAE,EAAE;IACrF,IAAI,SAAS,KAAK,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAC9D,OAAO,6BAA6B,CAAC,UAA0B,CAAC,CAAC;KAClE;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAoB,6BAA6B,EAAE,CAAC,CAAC;AAEzG,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,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 { ExtractionClient, REPORTING_BASE_PATH } from \"@itwin/insights-client\";\nimport { createContext, useContext } from \"react\";\nimport type { ClientPrefix } from \"./GroupingApiConfigContext\";\n\nconst prefixUrl = (baseUrl?: string, prefix?: string) => {\n if (prefix && baseUrl) {\n return baseUrl.replace(\"api.bentley.com\", `${prefix}-api.bentley.com`);\n }\n return baseUrl;\n};\n\nexport const createDefaultExtractionClient = (prefix?: ClientPrefix): IExtractionClient => {\n const url = prefixUrl(REPORTING_BASE_PATH, prefix);\n return new ExtractionClient(url);\n};\n\nexport const createExtractionClient = (clientProp: IExtractionClient | ClientPrefix) => {\n if (undefined === clientProp || typeof clientProp === \"string\") {\n return createDefaultExtractionClient(clientProp as ClientPrefix);\n }\n return clientProp;\n};\n\nexport const ExtractionClientContext = createContext<IExtractionClient>(createDefaultExtractionClient());\n\nexport const useExtractionClient = () => {\n const context = useContext(ExtractionClientContext);\n if (!context) {\n throw new Error(\n \"useExtractionClient should be used within a ExtractionClientContext provider\"\n );\n }\n return context;\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Group } from "@itwin/insights-client";
|
|
3
|
+
import type { ContextCustomUI, GroupingCustomUI } from "../customUI/GroupingMappingCustomUI";
|
|
4
|
+
export interface GroupsOperationsProps {
|
|
5
|
+
mappingId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGroupsOperations: ({ mappingId, }: GroupsOperationsProps) => {
|
|
8
|
+
groups: Group[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
refresh: () => Promise<void>;
|
|
11
|
+
onDeleteGroup: (group: Group) => Promise<void>;
|
|
12
|
+
setShowDeleteModal: import("react").Dispatch<import("react").SetStateAction<Group | undefined>>;
|
|
13
|
+
showDeleteModal: Group | undefined;
|
|
14
|
+
groupUIs: GroupingCustomUI[];
|
|
15
|
+
contextUIs: ContextCustomUI[];
|
|
16
|
+
numberOfVisualizedGroups: number;
|
|
17
|
+
errorMessage: string | undefined;
|
|
18
|
+
setErrorMessage: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useGroupsOperations.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { useCallback, useEffect, useState } from "react";
|
|
6
|
+
import { useGroupingMappingApiConfig } from "../context/GroupingApiConfigContext";
|
|
7
|
+
import { getErrorMessage } from "../utils";
|
|
8
|
+
import { GroupingMappingCustomUIType } from "../customUI/GroupingMappingCustomUI";
|
|
9
|
+
import { useGroupingMappingCustomUI } from "../context/GroupingMappingCustomUIContext";
|
|
10
|
+
import { useGroupHilitedElementsContext } from "../context/GroupHilitedElementsContext";
|
|
11
|
+
import { useMappingClient } from "../context/MappingClientContext";
|
|
12
|
+
const fetchGroups = async (setGroups, iModelId, mappingId, setIsLoading, getAccessToken, mappingsClient, setErrorMessage) => {
|
|
13
|
+
try {
|
|
14
|
+
setIsLoading(true);
|
|
15
|
+
const accessToken = await getAccessToken();
|
|
16
|
+
const groups = await mappingsClient.getGroups(accessToken, iModelId, mappingId);
|
|
17
|
+
setGroups(groups.sort((a, b) => a.groupName.localeCompare(b.groupName)));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
setErrorMessage(getErrorMessage(error.status));
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const useGroupsOperations = ({ mappingId, }) => {
|
|
27
|
+
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
28
|
+
const { groups, setGroups, numberOfVisualizedGroups } = useGroupHilitedElementsContext();
|
|
29
|
+
const mappingClient = useMappingClient();
|
|
30
|
+
const groupUIs = useGroupingMappingCustomUI().customUIs.filter((p) => p.type === GroupingMappingCustomUIType.Grouping);
|
|
31
|
+
const contextUIs = useGroupingMappingCustomUI().customUIs.filter((p) => p.type === GroupingMappingCustomUIType.Context);
|
|
32
|
+
const [showDeleteModal, setShowDeleteModal] = useState(undefined);
|
|
33
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
34
|
+
const [errorMessage, setErrorMessage] = useState(undefined);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const initialize = async () => {
|
|
37
|
+
await fetchGroups(setGroups, iModelId, mappingId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);
|
|
38
|
+
};
|
|
39
|
+
void initialize();
|
|
40
|
+
}, [getAccessToken, mappingClient, iModelId, mappingId, setGroups]);
|
|
41
|
+
const refresh = useCallback(async () => {
|
|
42
|
+
await fetchGroups(setGroups, iModelId, mappingId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);
|
|
43
|
+
}, [getAccessToken, mappingClient, iModelId, mappingId, setGroups]);
|
|
44
|
+
const onDeleteGroup = useCallback(async (group) => {
|
|
45
|
+
const accessToken = await getAccessToken();
|
|
46
|
+
await mappingClient.deleteGroup(accessToken, iModelId, mappingId, group.id);
|
|
47
|
+
await refresh();
|
|
48
|
+
}, [getAccessToken, iModelId, mappingClient, mappingId, refresh]);
|
|
49
|
+
return {
|
|
50
|
+
groups,
|
|
51
|
+
isLoading,
|
|
52
|
+
refresh,
|
|
53
|
+
onDeleteGroup,
|
|
54
|
+
setShowDeleteModal,
|
|
55
|
+
showDeleteModal,
|
|
56
|
+
groupUIs,
|
|
57
|
+
contextUIs,
|
|
58
|
+
numberOfVisualizedGroups,
|
|
59
|
+
errorMessage,
|
|
60
|
+
setErrorMessage,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=useGroupsOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGroupsOperations.js","sourceRoot":"","sources":["../../../../../src/widget/components/hooks/useGroupsOperations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,gBAAgB,E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QACN,SAAS;QACT,OAAO;QACP,aAAa;QACb,kBAAkB;QAClB,eAAe;QACf,QAAQ;QACR,UAAU;QACV,wBAAwB;QACxB,YAAY;QACZ,eAAe;KAChB,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 { useCallback, useEffect, useState } from \"react\";\nimport type { Group, IMappingsClient } from \"@itwin/insights-client\";\nimport type { GetAccessTokenFn } from \"../context/GroupingApiConfigContext\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport { getErrorMessage } from \"../utils\";\nimport type { ContextCustomUI, GroupingCustomUI } from \"../customUI/GroupingMappingCustomUI\";\nimport { GroupingMappingCustomUIType } from \"../customUI/GroupingMappingCustomUI\";\nimport { useGroupingMappingCustomUI } from \"../context/GroupingMappingCustomUIContext\";\nimport { useGroupHilitedElementsContext } from \"../context/GroupHilitedElementsContext\";\nimport { useMappingClient } from \"../context/MappingClientContext\";\n\nconst fetchGroups = async (\n setGroups: (groups: Group[]) => void,\n iModelId: string,\n mappingId: string,\n setIsLoading: (isLoading: boolean) => void,\n getAccessToken: GetAccessTokenFn,\n mappingsClient: IMappingsClient,\n setErrorMessage: (message: string | undefined) => void\n): Promise<void> => {\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const groups = await mappingsClient.getGroups(\n accessToken,\n iModelId,\n mappingId\n );\n setGroups(groups.sort((a, b) => a.groupName.localeCompare(b.groupName)));\n } catch (error: any) {\n setErrorMessage(getErrorMessage(error.status));\n } finally {\n setIsLoading(false);\n }\n};\n\nexport interface GroupsOperationsProps {\n mappingId: string;\n}\n\nexport const useGroupsOperations = ({\n mappingId,\n}: GroupsOperationsProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const { groups, setGroups, numberOfVisualizedGroups } = useGroupHilitedElementsContext();\n const mappingClient = useMappingClient();\n const groupUIs: GroupingCustomUI[] =\n useGroupingMappingCustomUI().customUIs.filter(\n (p) => p.type === GroupingMappingCustomUIType.Grouping\n ) as GroupingCustomUI[];\n const contextUIs: ContextCustomUI[] =\n useGroupingMappingCustomUI().customUIs.filter(\n (p) => p.type === GroupingMappingCustomUIType.Context\n ) as ContextCustomUI[];\n const [showDeleteModal, setShowDeleteModal] = useState<Group | undefined>(\n undefined\n );\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n const initialize = async () => {\n await fetchGroups(\n setGroups,\n iModelId,\n mappingId,\n setIsLoading,\n getAccessToken,\n mappingClient,\n setErrorMessage\n );\n };\n void initialize();\n }, [getAccessToken, mappingClient, iModelId, mappingId, setGroups]);\n\n const refresh = useCallback(async () => {\n await fetchGroups(\n setGroups,\n iModelId,\n mappingId,\n setIsLoading,\n getAccessToken,\n mappingClient,\n setErrorMessage\n );\n }, [getAccessToken, mappingClient, iModelId, mappingId, setGroups]);\n\n const onDeleteGroup = useCallback(async (group: Group) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteGroup(\n accessToken,\n iModelId,\n mappingId,\n group.id\n );\n await refresh();\n }, [getAccessToken, iModelId, mappingClient, mappingId, refresh]);\n\n return {\n groups,\n isLoading,\n refresh,\n onDeleteGroup,\n setShowDeleteModal,\n showDeleteModal,\n groupUIs,\n contextUIs,\n numberOfVisualizedGroups,\n errorMessage,\n setErrorMessage,\n };\n};\n"]}
|
|
@@ -4,9 +4,23 @@ import type { GroupingMappingApiConfig } from "../context/GroupingApiConfigConte
|
|
|
4
4
|
export interface MappingsOperationsProps extends GroupingMappingApiConfig {
|
|
5
5
|
mappingClient: IMappingsClient;
|
|
6
6
|
}
|
|
7
|
+
export interface ExtractionMessageData {
|
|
8
|
+
date: string;
|
|
9
|
+
category: string;
|
|
10
|
+
level: string;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExtractionIconData {
|
|
14
|
+
iconStatus: "negative" | "positive" | "warning";
|
|
15
|
+
iconMessage: string;
|
|
16
|
+
}
|
|
7
17
|
export declare const useMappingsOperations: ({ iModelId, getAccessToken, mappingClient }: MappingsOperationsProps) => {
|
|
8
18
|
mappings: Mapping[];
|
|
9
19
|
isLoading: boolean;
|
|
20
|
+
extractionIconData: ExtractionIconData;
|
|
21
|
+
showExtractionMessageModal: boolean;
|
|
22
|
+
extractionMessageData: ExtractionMessageData[];
|
|
23
|
+
setShowExtractionMessageModal: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
10
24
|
refresh: () => Promise<void>;
|
|
11
25
|
toggleExtraction: (mapping: Mapping) => Promise<void>;
|
|
12
26
|
onDelete: (mapping: Mapping) => Promise<void>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useCallback, useEffect, useState } from "react";
|
|
6
6
|
import { getErrorMessage, } from "../utils";
|
|
7
|
+
import { useExtractionClient } from "../context/ExtractionClientContext";
|
|
7
8
|
const fetchMappings = async (setMappings, iModelId, setIsLoading, getAccessToken, mappingsClient, setErrorMessage) => {
|
|
8
9
|
try {
|
|
9
10
|
setIsLoading(true);
|
|
@@ -18,16 +19,73 @@ const fetchMappings = async (setMappings, iModelId, setIsLoading, getAccessToken
|
|
|
18
19
|
setIsLoading(false);
|
|
19
20
|
}
|
|
20
21
|
};
|
|
22
|
+
const fetchExtractionStatus = async (iModelId, getAccessToken, extractionClient, setExtractionIconData, setExtractionMessageData) => {
|
|
23
|
+
setExtractionIconData({
|
|
24
|
+
iconStatus: "warning",
|
|
25
|
+
iconMessage: "Extraction status pending.",
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const accessToken = await getAccessToken();
|
|
29
|
+
const extractions = await extractionClient.getExtractionHistory(accessToken, iModelId, 1);
|
|
30
|
+
if (extractions.length === 0) {
|
|
31
|
+
setExtractionIconData({
|
|
32
|
+
iconStatus: "negative",
|
|
33
|
+
iconMessage: "No extraction found.",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const jobId = extractions[0].jobId;
|
|
38
|
+
const status = await extractionClient.getExtractionStatus(accessToken, jobId);
|
|
39
|
+
if (status.containsIssues) {
|
|
40
|
+
setExtractionIconData({
|
|
41
|
+
iconStatus: "negative",
|
|
42
|
+
iconMessage: "Extraction contains issues. Click to view extraction logs.",
|
|
43
|
+
});
|
|
44
|
+
const logs = await extractionClient.getExtractionLogs(accessToken, jobId);
|
|
45
|
+
const filteredLogs = logs.filter((log) => log.message !== null);
|
|
46
|
+
const extractionMessageData = filteredLogs.map((filteredLog) => ({
|
|
47
|
+
date: filteredLog.dateTime,
|
|
48
|
+
category: filteredLog.category,
|
|
49
|
+
level: filteredLog.level,
|
|
50
|
+
message: String(filteredLog.message),
|
|
51
|
+
}));
|
|
52
|
+
setExtractionMessageData(extractionMessageData);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setExtractionIconData({
|
|
56
|
+
iconStatus: "positive",
|
|
57
|
+
iconMessage: "Extraction successful.",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
setExtractionIconData({
|
|
64
|
+
iconStatus: "negative",
|
|
65
|
+
iconMessage: "Operation failed. Please try again.",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
21
69
|
export const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient }) => {
|
|
22
70
|
const [showImportModal, setShowImportModal] = useState(false);
|
|
23
71
|
const [showDeleteModal, setShowDeleteModal] = useState(undefined);
|
|
24
72
|
const [isLoading, setIsLoading] = useState(true);
|
|
25
73
|
const [mappings, setMappings] = useState([]);
|
|
74
|
+
const extractionClient = useExtractionClient();
|
|
26
75
|
const [errorMessage, setErrorMessage] = useState(undefined);
|
|
27
76
|
const [isTogglingExtraction, setIsTogglingExtraction] = useState(false);
|
|
77
|
+
const [extractionIconData, setExtractionIconData] = useState({
|
|
78
|
+
iconStatus: "warning",
|
|
79
|
+
iconMessage: "",
|
|
80
|
+
});
|
|
81
|
+
const [showExtractionMessageModal, setShowExtractionMessageModal] = useState(false);
|
|
82
|
+
const [extractionMessageData, setExtractionMessageData] = useState([]);
|
|
28
83
|
useEffect(() => {
|
|
29
84
|
void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);
|
|
30
85
|
}, [getAccessToken, mappingClient, iModelId]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
void fetchExtractionStatus(iModelId, getAccessToken, extractionClient, setExtractionIconData, setExtractionMessageData);
|
|
88
|
+
}, [iModelId, getAccessToken, extractionClient]);
|
|
31
89
|
const refresh = useCallback(async () => {
|
|
32
90
|
setMappings([]);
|
|
33
91
|
await fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);
|
|
@@ -53,6 +111,6 @@ export const useMappingsOperations = ({ iModelId, getAccessToken, mappingClient
|
|
|
53
111
|
await mappingClient.deleteMapping(accessToken, iModelId, mapping.id);
|
|
54
112
|
await refresh();
|
|
55
113
|
};
|
|
56
|
-
return { mappings, isLoading, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };
|
|
114
|
+
return { mappings, isLoading, extractionIconData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };
|
|
57
115
|
};
|
|
58
116
|
//# sourceMappingURL=useMappingsOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/widget/components/hooks/useMappingsOperations.ts"],"names":[],"mappings":"AAAA;;;+FAG+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AgB,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,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AACrM,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, useState } from \"react\";\nimport {\n getErrorMessage,\n} from \"../utils\";\nimport type { IMappingsClient, Mapping } from \"@itwin/insights-client\";\nimport type { GroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { GetAccessTokenFn } from \"../context/GroupingApiConfigContext\";\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\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 [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);\n const [isTogglingExtraction, setIsTogglingExtraction] = useState<boolean>(false);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);\n }, [getAccessToken, mappingClient, iModelId]);\n\n const refresh = useCallback(async () => {\n setMappings([]);\n await fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);\n }, [getAccessToken, mappingClient, iModelId]);\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, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useMappingsOperations.js","sourceRoot":"","sources":["../../../../../src/widget/components/hooks/useMappingsOperations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EACL,eAAe,GAChB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,aAAa,GAA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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, useState } from \"react\";\nimport {\n getErrorMessage,\n} from \"../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\";\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 setExtractionIconData: React.Dispatch<React.SetStateAction<ExtractionIconData>>,\n setExtractionMessageData: React.Dispatch<React.SetStateAction<ExtractionMessageData[]>>\n) => {\n setExtractionIconData({\n iconStatus: \"warning\",\n iconMessage: \"Extraction status pending.\",\n });\n try {\n const accessToken = await getAccessToken();\n const extractions = await extractionClient.getExtractionHistory(accessToken, iModelId, 1);\n if(extractions.length === 0){\n setExtractionIconData({\n iconStatus: \"negative\",\n iconMessage: \"No extraction found.\",\n });\n } else {\n const jobId = extractions[0].jobId;\n const status = await extractionClient.getExtractionStatus(accessToken, jobId);\n if (status.containsIssues) {\n setExtractionIconData({\n iconStatus: \"negative\",\n iconMessage: \"Extraction contains issues. Click to view extraction logs.\",\n });\n const logs = await extractionClient.getExtractionLogs(accessToken, jobId);\n const filteredLogs = logs.filter((log) => log.message !== null);\n const extractionMessageData = filteredLogs.map((filteredLog) =>\n (\n {\n date: filteredLog.dateTime,\n category: filteredLog.category,\n level: filteredLog.level,\n message: String(filteredLog.message),\n }\n ));\n setExtractionMessageData(extractionMessageData);\n } else {\n setExtractionIconData({\n iconStatus: \"positive\",\n iconMessage: \"Extraction successful.\",\n });\n }\n }\n } catch (error: any) {\n setExtractionIconData({\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 interface ExtractionMessageData {\n date: string;\n category: string;\n level: string;\n message: string;\n}\n\nexport interface ExtractionIconData {\n iconStatus: \"negative\" | \"positive\" | \"warning\";\n iconMessage: string;\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 [extractionIconData, setExtractionIconData] = useState<ExtractionIconData>({\n iconStatus: \"warning\",\n iconMessage: \"\",\n });\n const [showExtractionMessageModal, setShowExtractionMessageModal] = useState<boolean>(false);\n const [extractionMessageData, setExtractionMessageData] = useState<ExtractionMessageData[]>([]);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);\n }, [getAccessToken, mappingClient, iModelId]);\n\n useEffect(() => {\n void fetchExtractionStatus(\n iModelId,\n getAccessToken,\n extractionClient,\n setExtractionIconData,\n setExtractionMessageData\n );\n }, [iModelId, getAccessToken, extractionClient]);\n\n const refresh = useCallback(async () => {\n setMappings([]);\n await fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient, setErrorMessage);\n }, [getAccessToken, mappingClient, iModelId]);\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, extractionIconData, showExtractionMessageModal, extractionMessageData, setShowExtractionMessageModal, refresh, toggleExtraction, onDelete, setShowImportModal, showImportModal, setShowDeleteModal, showDeleteModal, isTogglingExtraction, errorMessage, setErrorMessage };\n};\n"]}
|
|
@@ -11,5 +11,6 @@ interface EmptyMessageProps {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const EmptyMessage: ({ message }: EmptyMessageProps) => JSX.Element;
|
|
13
13
|
export declare const LoadingSpinner: () => JSX.Element;
|
|
14
|
+
export declare const enableExperimentalFeatures: (iModelConnection: IModelConnection) => Promise<void>;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -78,4 +78,8 @@ export const LoadingSpinner = () => {
|
|
|
78
78
|
return (React.createElement("div", { className: "gmw-loading-spinner" },
|
|
79
79
|
React.createElement(ProgressRadial, { size: "small", indeterminate: true })));
|
|
80
80
|
};
|
|
81
|
+
export const enableExperimentalFeatures = async (iModelConnection) => {
|
|
82
|
+
const reader = iModelConnection.createQueryReader("PRAGMA experimental_features_enabled=true");
|
|
83
|
+
await reader.step();
|
|
84
|
+
};
|
|
81
85
|
//# sourceMappingURL=utils.js.map
|