@itwin/reports-config-widget-react 0.2.1 → 0.4.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/.rush/temp/operation/rebuild/all.log +9 -0
- package/.rush/temp/operation/rebuild/state.json +3 -0
- package/.rush/temp/package-deps_rebuild.json +48 -44
- package/.rush/temp/shrinkwrap-deps.json +228 -207
- package/CHANGELOG.json +44 -0
- package/CHANGELOG.md +24 -1
- package/coverage/clover.xml +562 -542
- package/coverage/coverage-final.json +24 -20
- package/coverage/lcov-report/index.html +51 -51
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +22 -22
- package/coverage/lcov-report/src/index.html +21 -21
- package/coverage/lcov-report/src/test/index.html +11 -11
- package/coverage/lcov-report/src/test/test-utils.tsx.html +20 -140
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +14 -35
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +26 -20
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +94 -109
- package/coverage/lcov-report/src/widget/components/BulkExtractor.ts.html +55 -52
- package/coverage/lcov-report/src/widget/components/Constants.ts.html +1 -1
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +28 -46
- package/coverage/lcov-report/src/widget/components/ExtractionStates/FailedExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/QueuedExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/RunningExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/StartingExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/SucceededExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/index.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStatus.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionToast.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +3 -3
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +8 -8
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +36 -81
- package/coverage/lcov-report/src/widget/components/ReportHorizontalTile.tsx.html +38 -41
- package/coverage/lcov-report/src/widget/components/ReportMappingHorizontalTile.tsx.html +46 -46
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +127 -142
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +189 -312
- package/coverage/lcov-report/src/widget/components/ReportsConfigContext.tsx.html +370 -0
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +111 -33
- package/coverage/lcov-report/src/widget/components/ReportsHeader.tsx.html +166 -0
- package/coverage/lcov-report/src/widget/components/ReportsRouter.tsx.html +274 -0
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +22 -7
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +40 -94
- package/coverage/lcov-report/src/widget/components/index.html +142 -97
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +22 -19
- package/coverage/lcov-report/src/widget/context/{ReportsApiConfigContext.tsx.html → BulkExtractorContext.tsx.html} +23 -26
- package/coverage/lcov-report/src/widget/context/ReportsConfigApiContext.tsx.html +202 -0
- package/coverage/lcov-report/src/widget/context/index.html +30 -15
- package/coverage/lcov-report/src/widget/hooks/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +11 -11
- package/coverage/lcov-report/src/widget/index.html +13 -13
- package/coverage/lcov.info +1036 -1034
- package/jest.config.js +1 -0
- package/lib/cjs/ReportsConfigWidget.js +1 -1
- package/lib/cjs/ReportsConfigWidget.js.map +1 -1
- package/lib/cjs/reports-config-widget-react.d.ts +5 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -1
- package/lib/cjs/reports-config-widget-react.js +11 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -1
- package/lib/cjs/test/AddMappingModal.test.js +20 -34
- package/lib/cjs/test/AddMappingModal.test.js.map +1 -1
- package/lib/cjs/test/BulkExtractor.test.js +13 -19
- package/lib/cjs/test/BulkExtractor.test.js.map +1 -1
- package/lib/cjs/test/DeleteModal.test.d.ts.map +1 -1
- package/lib/cjs/test/DeleteModal.test.js +4 -62
- package/lib/cjs/test/DeleteModal.test.js.map +1 -1
- package/lib/cjs/test/ReportAction.test.js +14 -79
- package/lib/cjs/test/ReportAction.test.js.map +1 -1
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js +20 -54
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js.map +1 -1
- package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -1
- package/lib/cjs/test/ReportMappings.test.js +51 -106
- package/lib/cjs/test/ReportMappings.test.js.map +1 -1
- package/lib/cjs/test/Reports.test.js +41 -96
- package/lib/cjs/test/Reports.test.js.map +1 -1
- package/lib/cjs/test/WidgetHeader.test.js +9 -3
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -1
- package/lib/cjs/test/test-utils.d.ts +3 -8
- package/lib/cjs/test/test-utils.d.ts.map +1 -1
- package/lib/cjs/test/test-utils.js +6 -34
- package/lib/cjs/test/test-utils.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +3 -3
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -1
- package/lib/cjs/widget/ReportsConfigUiProvider.js +5 -7
- package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts +3 -3
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.js +4 -4
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.scss +2 -3
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +4 -4
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.js +39 -43
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.scss +1 -2
- package/lib/cjs/widget/components/BulkExtractor.d.ts +4 -4
- package/lib/cjs/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.js +8 -8
- package/lib/cjs/widget/components/BulkExtractor.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.d.ts +4 -5
- package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.js +11 -15
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.scss +2 -3
- package/lib/cjs/widget/components/ExtractionStatus.js +2 -2
- package/lib/cjs/widget/components/ExtractionStatus.js.map +1 -1
- package/lib/cjs/widget/components/ExtractionStatus.scss +6 -7
- package/lib/cjs/widget/components/HorizontalTile.js +2 -2
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/HorizontalTile.scss +11 -14
- package/lib/cjs/widget/components/LocalizedTablePaginator.js +2 -2
- package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -1
- package/lib/cjs/widget/components/ReportAction.d.ts +4 -5
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportAction.js +24 -26
- package/lib/cjs/widget/components/ReportAction.js.map +1 -1
- package/lib/cjs/widget/components/ReportAction.scss +1 -2
- package/lib/cjs/widget/components/ReportHorizontalTile.d.ts +4 -4
- package/lib/cjs/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportHorizontalTile.js +33 -20
- package/lib/cjs/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js +36 -21
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.d.ts +4 -6
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.js +50 -63
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.scss +10 -11
- package/lib/cjs/widget/components/Reports.d.ts +6 -1
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -1
- package/lib/cjs/widget/components/Reports.js +53 -94
- package/lib/cjs/widget/components/Reports.js.map +1 -1
- package/lib/cjs/widget/components/Reports.scss +15 -15
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts +18 -0
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsConfigContext.js +79 -0
- package/lib/cjs/widget/components/ReportsConfigContext.js.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts +14 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.js +27 -16
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.scss +1 -3
- package/lib/cjs/widget/components/ReportsHeader.d.ts +7 -0
- package/lib/cjs/widget/components/ReportsHeader.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsHeader.js +20 -0
- package/lib/cjs/widget/components/ReportsHeader.js.map +1 -0
- package/lib/cjs/widget/components/ReportsRouter.d.ts +8 -0
- package/lib/cjs/widget/components/ReportsRouter.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsRouter.js +51 -0
- package/lib/cjs/widget/components/ReportsRouter.js.map +1 -0
- package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -1
- package/lib/cjs/widget/components/SearchBar.js +4 -5
- package/lib/cjs/widget/components/SearchBar.js.map +1 -1
- package/lib/cjs/widget/components/SearchBar.scss +1 -2
- package/lib/cjs/widget/components/SelectIModel.d.ts +3 -3
- package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.js +10 -30
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.scss +2 -3
- package/lib/cjs/widget/components/utils.d.ts +1 -1
- package/lib/cjs/widget/components/utils.d.ts.map +1 -1
- package/lib/cjs/widget/components/utils.js +1 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +16 -8
- package/lib/cjs/widget/context/BulkExtractorContext.d.ts +10 -0
- package/lib/cjs/widget/context/BulkExtractorContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/{ReportsApiConfigContext.js → BulkExtractorContext.js} +7 -10
- package/lib/cjs/widget/context/BulkExtractorContext.js.map +1 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts +16 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.js +43 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.js.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.js +1 -1
- package/lib/cjs/widget/hooks/useValidator.js.map +1 -1
- package/lib/esm/ReportsConfigWidget.js +1 -1
- package/lib/esm/ReportsConfigWidget.js.map +1 -1
- package/lib/esm/reports-config-widget-react.d.ts +5 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -1
- package/lib/esm/reports-config-widget-react.js +5 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -1
- package/lib/esm/test/AddMappingModal.test.js +17 -31
- package/lib/esm/test/AddMappingModal.test.js.map +1 -1
- package/lib/esm/test/BulkExtractor.test.js +14 -17
- package/lib/esm/test/BulkExtractor.test.js.map +1 -1
- package/lib/esm/test/DeleteModal.test.d.ts.map +1 -1
- package/lib/esm/test/DeleteModal.test.js +5 -44
- package/lib/esm/test/DeleteModal.test.js.map +1 -1
- package/lib/esm/test/ReportAction.test.js +14 -60
- package/lib/esm/test/ReportAction.test.js.map +1 -1
- package/lib/esm/test/ReportMappingHorizontalTile.test.js +4 -38
- package/lib/esm/test/ReportMappingHorizontalTile.test.js.map +1 -1
- package/lib/esm/test/ReportMappings.test.d.ts.map +1 -1
- package/lib/esm/test/ReportMappings.test.js +43 -98
- package/lib/esm/test/ReportMappings.test.js.map +1 -1
- package/lib/esm/test/Reports.test.js +24 -60
- package/lib/esm/test/Reports.test.js.map +1 -1
- package/lib/esm/test/WidgetHeader.test.js +8 -2
- package/lib/esm/test/WidgetHeader.test.js.map +1 -1
- package/lib/esm/test/test-utils.d.ts +3 -8
- package/lib/esm/test/test-utils.d.ts.map +1 -1
- package/lib/esm/test/test-utils.js +4 -31
- package/lib/esm/test/test-utils.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts +3 -3
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -1
- package/lib/esm/widget/ReportsConfigUiProvider.js +2 -4
- package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts +3 -3
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/esm/widget/components/ActionPanel.js +4 -4
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/ActionPanel.scss +2 -3
- package/lib/esm/widget/components/AddMappingsModal.d.ts +4 -4
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.js +35 -39
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.scss +1 -2
- package/lib/esm/widget/components/BulkExtractor.d.ts +4 -4
- package/lib/esm/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.js +7 -8
- package/lib/esm/widget/components/BulkExtractor.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.d.ts +4 -5
- package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -1
- package/lib/esm/widget/components/DeleteModal.js +11 -15
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.scss +2 -3
- package/lib/esm/widget/components/ExtractionStatus.scss +6 -7
- package/lib/esm/widget/components/HorizontalTile.scss +11 -14
- package/lib/esm/widget/components/ReportAction.d.ts +4 -5
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportAction.js +17 -21
- package/lib/esm/widget/components/ReportAction.js.map +1 -1
- package/lib/esm/widget/components/ReportAction.scss +1 -2
- package/lib/esm/widget/components/ReportHorizontalTile.d.ts +4 -4
- package/lib/esm/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportHorizontalTile.js +6 -9
- package/lib/esm/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js +12 -13
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.d.ts +4 -6
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappings.js +43 -56
- package/lib/esm/widget/components/ReportMappings.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.scss +10 -11
- package/lib/esm/widget/components/Reports.d.ts +6 -1
- package/lib/esm/widget/components/Reports.d.ts.map +1 -1
- package/lib/esm/widget/components/Reports.js +46 -87
- package/lib/esm/widget/components/Reports.js.map +1 -1
- package/lib/esm/widget/components/Reports.scss +15 -15
- package/lib/esm/widget/components/ReportsConfigContext.d.ts +18 -0
- package/lib/esm/widget/components/ReportsConfigContext.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsConfigContext.js +56 -0
- package/lib/esm/widget/components/ReportsConfigContext.js.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts +14 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.js +27 -17
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.scss +1 -3
- package/lib/esm/widget/components/ReportsHeader.d.ts +7 -0
- package/lib/esm/widget/components/ReportsHeader.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsHeader.js +13 -0
- package/lib/esm/widget/components/ReportsHeader.js.map +1 -0
- package/lib/esm/widget/components/ReportsRouter.d.ts +8 -0
- package/lib/esm/widget/components/ReportsRouter.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsRouter.js +44 -0
- package/lib/esm/widget/components/ReportsRouter.js.map +1 -0
- package/lib/esm/widget/components/SearchBar.d.ts.map +1 -1
- package/lib/esm/widget/components/SearchBar.js +2 -3
- package/lib/esm/widget/components/SearchBar.js.map +1 -1
- package/lib/esm/widget/components/SearchBar.scss +1 -2
- package/lib/esm/widget/components/SelectIModel.d.ts +3 -3
- package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -1
- package/lib/esm/widget/components/SelectIModel.js +7 -27
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.scss +2 -3
- package/lib/esm/widget/components/utils.d.ts +1 -1
- package/lib/esm/widget/components/utils.d.ts.map +1 -1
- package/lib/esm/widget/components/utils.js +2 -2
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +16 -8
- package/lib/esm/widget/context/BulkExtractorContext.d.ts +10 -0
- package/lib/esm/widget/context/BulkExtractorContext.d.ts.map +1 -0
- package/lib/esm/widget/context/BulkExtractorContext.js +11 -0
- package/lib/esm/widget/context/BulkExtractorContext.js.map +1 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts +16 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts.map +1 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.js +20 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.js.map +1 -0
- package/lib/public/locales/en/ReportsConfigWidget.json +6 -1
- package/package.json +29 -29
- package/public/locales/en/ReportsConfigWidget.json +6 -1
- package/reports-config-widget-react.build.error.log +6 -6
- package/reports-config-widget-react.build.log +52 -49
- package/src/reports-config-widget-react.ts +6 -0
- package/src/test/AddMappingModal.test.tsx +20 -37
- package/src/test/BulkExtractor.test.ts +15 -17
- package/src/test/DeleteModal.test.tsx +4 -73
- package/src/test/ReportAction.test.tsx +17 -90
- package/src/test/ReportMappingHorizontalTile.test.tsx +3 -54
- package/src/test/ReportMappings.test.tsx +50 -135
- package/src/test/Reports.test.tsx +21 -80
- package/src/test/WidgetHeader.test.tsx +9 -2
- package/src/test/test-utils.tsx +9 -49
- package/src/widget/ReportsConfigUiProvider.tsx +7 -14
- package/src/widget/components/ActionPanel.scss +2 -3
- package/src/widget/components/ActionPanel.tsx +17 -15
- package/src/widget/components/AddMappingsModal.scss +1 -2
- package/src/widget/components/AddMappingsModal.tsx +55 -60
- package/src/widget/components/BulkExtractor.ts +11 -10
- package/src/widget/components/DeleteModal.scss +2 -3
- package/src/widget/components/DeleteModal.tsx +17 -23
- package/src/widget/components/ExtractionStatus.scss +6 -7
- package/src/widget/components/HorizontalTile.scss +11 -14
- package/src/widget/components/ReportAction.scss +1 -2
- package/src/widget/components/ReportAction.tsx +18 -33
- package/src/widget/components/ReportHorizontalTile.tsx +11 -12
- package/src/widget/components/ReportMappingHorizontalTile.tsx +30 -30
- package/src/widget/components/ReportMappings.scss +10 -11
- package/src/widget/components/ReportMappings.tsx +67 -72
- package/src/widget/components/Reports.scss +15 -15
- package/src/widget/components/Reports.tsx +140 -181
- package/src/widget/components/ReportsConfigContext.tsx +95 -0
- package/src/widget/components/ReportsContainer.scss +1 -3
- package/src/widget/components/ReportsContainer.tsx +47 -21
- package/src/widget/components/ReportsHeader.tsx +27 -0
- package/src/widget/components/ReportsRouter.tsx +63 -0
- package/src/widget/components/SearchBar.scss +1 -2
- package/src/widget/components/SearchBar.tsx +7 -2
- package/src/widget/components/SelectIModel.scss +2 -3
- package/src/widget/components/SelectIModel.tsx +11 -29
- package/src/widget/components/utils.scss +16 -8
- package/src/widget/components/utils.tsx +8 -7
- package/src/widget/context/{ReportsApiConfigContext.tsx → BulkExtractorContext.tsx} +9 -10
- package/src/widget/context/ReportsConfigApiContext.tsx +39 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +0 -9
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +0 -1
- package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +0 -1
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +0 -9
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +0 -1
- package/lib/esm/widget/context/ReportsApiConfigContext.js +0 -14
- package/lib/esm/widget/context/ReportsApiConfigContext.js.map +0 -1
|
@@ -2,48 +2,35 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { SvgAdd, SvgCopy, } from "@itwin/itwinui-icons-react";
|
|
6
|
-
import { Button, IconButton, LabeledInput,
|
|
5
|
+
import { SvgAdd, SvgCopy, SvgRefresh, } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { Button, IconButton, LabeledInput, Text, toaster, } from "@itwin/itwinui-react";
|
|
7
7
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { EmptyMessage, generateUrl, handleError, LoadingOverlay,
|
|
8
|
+
import { EmptyMessage, generateUrl, handleError, LoadingOverlay, LoadingSpinner, } from "./utils";
|
|
9
9
|
import "./ReportMappings.scss";
|
|
10
10
|
import DeleteModal from "./DeleteModal";
|
|
11
|
-
import {
|
|
11
|
+
import { REPORTING_BASE_PATH } from "@itwin/insights-client";
|
|
12
12
|
import { AddMappingsModal } from "./AddMappingsModal";
|
|
13
|
-
import { Constants, IModelsClient } from "@itwin/imodels-client-management";
|
|
14
13
|
import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
|
|
15
14
|
import { SearchBar } from "./SearchBar";
|
|
16
|
-
import {
|
|
15
|
+
import { useReportsConfigApi } from "../context/ReportsConfigApiContext";
|
|
17
16
|
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
18
17
|
import { ReportMappingHorizontalTile } from "./ReportMappingHorizontalTile";
|
|
19
18
|
import { BeEvent } from "@itwin/core-bentley";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
(function (ReportMappingsView) {
|
|
23
|
-
ReportMappingsView["REPORTMAPPINGS"] = "reportmappings";
|
|
24
|
-
ReportMappingsView["ADDING"] = "adding";
|
|
25
|
-
})(ReportMappingsView || (ReportMappingsView = {}));
|
|
26
|
-
const fetchReportMappings = async (setReportMappings, reportId, setIsLoading, apiContext) => {
|
|
27
|
-
var _a, _b;
|
|
19
|
+
import { useBulkExtractor } from "../context/BulkExtractorContext";
|
|
20
|
+
const fetchReportMappings = async (setReportMappings, reportId, setIsLoading, reportsClient, mappingsClient, iModelsClient, getAccessToken) => {
|
|
28
21
|
try {
|
|
29
22
|
setIsLoading(true);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const accessToken = await apiContext.getAccessToken();
|
|
33
|
-
const reportMappings = await reportsClientApi.getReportMappings(accessToken, reportId);
|
|
34
|
-
const iModelClientOptions = {
|
|
35
|
-
api: { baseUrl: generateUrl(Constants.api.baseUrl, apiContext.baseUrl) },
|
|
36
|
-
};
|
|
37
|
-
const iModelsClient = new IModelsClient(iModelClientOptions);
|
|
23
|
+
const accessToken = await getAccessToken();
|
|
24
|
+
const reportMappings = await reportsClient.getReportMappings(accessToken, reportId);
|
|
38
25
|
const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);
|
|
39
26
|
const iModelNames = new Map();
|
|
40
27
|
const reportMappingsAndMappings = [];
|
|
41
28
|
for (const reportMapping of reportMappings) {
|
|
42
29
|
const iModelId = reportMapping.imodelId;
|
|
43
30
|
let iModelName = "";
|
|
44
|
-
const mapping = await
|
|
31
|
+
const mapping = await mappingsClient.getMapping(accessToken, iModelId, reportMapping.mappingId);
|
|
45
32
|
if (iModelNames.has(iModelId)) {
|
|
46
|
-
iModelName =
|
|
33
|
+
iModelName = iModelNames.get(iModelId) ?? "";
|
|
47
34
|
}
|
|
48
35
|
else {
|
|
49
36
|
const getSingleParams = {
|
|
@@ -58,7 +45,7 @@ const fetchReportMappings = async (setReportMappings, reportId, setIsLoading, ap
|
|
|
58
45
|
...reportMapping,
|
|
59
46
|
iModelName,
|
|
60
47
|
mappingName: mapping.mappingName,
|
|
61
|
-
mappingDescription:
|
|
48
|
+
mappingDescription: mapping.description ?? "",
|
|
62
49
|
};
|
|
63
50
|
reportMappingsAndMappings.push(reportMappingAndMapping);
|
|
64
51
|
}
|
|
@@ -71,63 +58,63 @@ const fetchReportMappings = async (setReportMappings, reportId, setIsLoading, ap
|
|
|
71
58
|
setIsLoading(false);
|
|
72
59
|
}
|
|
73
60
|
};
|
|
74
|
-
export const ReportMappings = ({ report,
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const [
|
|
78
|
-
const
|
|
79
|
-
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
61
|
+
export const ReportMappings = ({ report, onClickClose, defaultIModelId }) => {
|
|
62
|
+
const { getAccessToken, reportsClient, iModelsClient, mappingsClient, baseUrl } = useReportsConfigApi();
|
|
63
|
+
const [showDeleteModal, setShowDeleteModal] = useState(undefined);
|
|
64
|
+
const [showAddMapping, setShowAddMapping] = useState(false);
|
|
65
|
+
const { bulkExtractor } = useBulkExtractor();
|
|
80
66
|
const [isLoading, setIsLoading] = useState(true);
|
|
81
67
|
const [searchValue, setSearchValue] = useState("");
|
|
82
68
|
const [reportMappings, setReportMappings] = useState([]);
|
|
83
69
|
const [jobRunning, setJobRunning] = useState(false);
|
|
84
70
|
const jobStartEvent = useMemo(() => new BeEvent(), []);
|
|
85
71
|
useEffect(() => {
|
|
86
|
-
void fetchReportMappings(setReportMappings, report.id, setIsLoading,
|
|
87
|
-
}, [
|
|
72
|
+
void fetchReportMappings(setReportMappings, report.id, setIsLoading, reportsClient, mappingsClient, iModelsClient, getAccessToken);
|
|
73
|
+
}, [getAccessToken, iModelsClient, mappingsClient, report.id, reportsClient, setIsLoading]);
|
|
88
74
|
useEffect(() => {
|
|
75
|
+
if (!bulkExtractor)
|
|
76
|
+
return;
|
|
89
77
|
bulkExtractor.setHook(setJobRunning, reportMappings.map((x) => x.imodelId));
|
|
90
78
|
}, [bulkExtractor, reportMappings]);
|
|
91
79
|
const refresh = useCallback(async () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const addMapping = () => {
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
const odataFeedUrl = `${generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)}/odata/${report.id}`;
|
|
80
|
+
await fetchReportMappings(setReportMappings, report.id, setIsLoading, reportsClient, mappingsClient, iModelsClient, getAccessToken);
|
|
81
|
+
}, [getAccessToken, iModelsClient, mappingsClient, report.id, reportsClient]);
|
|
82
|
+
const odataFeedUrl = `${generateUrl(REPORTING_BASE_PATH, baseUrl)}/odata/${report.id}`;
|
|
83
|
+
const addMapping = useCallback(() => {
|
|
84
|
+
setShowAddMapping(true);
|
|
85
|
+
}, []);
|
|
99
86
|
const filteredReportMappings = useMemo(() => reportMappings.filter((x) => [x.iModelName, x.mappingName, x.mappingDescription]
|
|
100
87
|
.join(" ")
|
|
101
88
|
.toLowerCase()
|
|
102
89
|
.includes(searchValue.toLowerCase())), [reportMappings, searchValue]);
|
|
90
|
+
const onAddMappingsModalClose = useCallback(async () => { await refresh(); setShowAddMapping(false); }, [refresh]);
|
|
91
|
+
if (!bulkExtractor)
|
|
92
|
+
return null;
|
|
103
93
|
return (React.createElement(React.Fragment, null,
|
|
104
|
-
React.createElement(
|
|
105
|
-
|
|
106
|
-
React.createElement(LabeledInput, { label: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ODataFeedURL"), className: "rcw-odata-url-input", readOnly: true, value: odataFeedUrl, svgIcon: React.createElement(IconButton, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Copy"), styleType: "borderless", onClick: async (_) => {
|
|
94
|
+
React.createElement("div", { className: "rcw-report-mappings-container" },
|
|
95
|
+
React.createElement(LabeledInput, { label: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ODataFeedURL"), className: "rcw-odata-url-input", readOnly: true, value: odataFeedUrl, svgIcon: React.createElement(IconButton, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Copy"), onClick: async (_) => {
|
|
107
96
|
await navigator.clipboard.writeText(odataFeedUrl);
|
|
108
97
|
toaster.positive(ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:CopiedToClipboard"));
|
|
109
98
|
} },
|
|
110
|
-
React.createElement(SvgCopy, null)), iconDisplayStyle: "inline" })
|
|
111
|
-
React.createElement(Surface, { className: "rcw-report-mappings-container" },
|
|
99
|
+
React.createElement(SvgCopy, null)), iconDisplayStyle: "inline" }),
|
|
112
100
|
React.createElement("div", { className: "rcw-toolbar" },
|
|
113
101
|
React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), onClick: () => addMapping(), styleType: "high-visibility" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:AddMapping")),
|
|
114
102
|
React.createElement("div", { className: "rcw-search-bar-container", "data-testid": "rcw-search-bar" },
|
|
103
|
+
React.createElement(IconButton, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Refresh"), onClick: refresh, disabled: isLoading, styleType: 'borderless' },
|
|
104
|
+
React.createElement(SvgRefresh, null)),
|
|
115
105
|
React.createElement(SearchBar, { searchValue: searchValue, setSearchValue: setSearchValue, disabled: isLoading }))),
|
|
116
106
|
isLoading ? (React.createElement(LoadingOverlay, null)) : reportMappings.length === 0 ? (React.createElement(EmptyMessage, null,
|
|
117
107
|
React.createElement(React.Fragment, null,
|
|
118
108
|
React.createElement(Text, null, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:NoReportMappings")),
|
|
119
109
|
React.createElement("div", null,
|
|
120
|
-
React.createElement(Button, { onClick:
|
|
121
|
-
|
|
122
|
-
setShowDeleteModal(true);
|
|
110
|
+
React.createElement(Button, { onClick: addMapping, styleType: "cta" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:LetsAddSomeMappingsCTA")))))) : (React.createElement("div", { className: "rcw-mapping-list" }, filteredReportMappings.map((mapping) => (React.createElement(ReportMappingHorizontalTile, { key: mapping.mappingId, bulkExtractor: bulkExtractor, mapping: mapping, onClickDelete: () => {
|
|
111
|
+
setShowDeleteModal(mapping);
|
|
123
112
|
}, odataFeedUrl: odataFeedUrl, jobStartEvent: jobStartEvent })))))),
|
|
124
|
-
React.createElement(AddMappingsModal, { show:
|
|
125
|
-
React.createElement(DeleteModal, { entityName:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
await reportsClientApi.deleteReportMapping(accessToken, report.id, (_a = selectedReportMapping === null || selectedReportMapping === void 0 ? void 0 : selectedReportMapping.mappingId) !== null && _a !== void 0 ? _a : "");
|
|
130
|
-
}, refresh: refresh }),
|
|
113
|
+
React.createElement(AddMappingsModal, { show: showAddMapping, reportId: report.id, existingMappings: reportMappings, onClose: onAddMappingsModalClose, defaultIModelId: defaultIModelId }),
|
|
114
|
+
React.createElement(DeleteModal, { entityName: showDeleteModal?.mappingName ?? "", onDelete: async () => {
|
|
115
|
+
const accessToken = await getAccessToken();
|
|
116
|
+
await reportsClient.deleteReportMapping(accessToken, report.id, showDeleteModal?.mappingId ?? "");
|
|
117
|
+
}, refresh: refresh, onClose: () => setShowDeleteModal(undefined) }),
|
|
131
118
|
React.createElement("div", { className: "rcw-action-panel" },
|
|
132
119
|
isLoading && React.createElement(LoadingSpinner, null),
|
|
133
120
|
React.createElement(Button, { disabled: isLoading || jobRunning || reportMappings.length === 0, styleType: "high-visibility", onClick: async () => {
|
|
@@ -138,6 +125,6 @@ export const ReportMappings = ({ report, bulkExtractor, goBack }) => {
|
|
|
138
125
|
jobStartEvent.raiseEvent(reportMapping.imodelId);
|
|
139
126
|
});
|
|
140
127
|
} }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:UpdateAllDatasets")),
|
|
141
|
-
React.createElement(Button, { styleType: "default", type: "button", onClick:
|
|
128
|
+
React.createElement(Button, { styleType: "default", type: "button", onClick: onClickClose, disabled: isLoading }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Close")))));
|
|
142
129
|
};
|
|
143
130
|
//# sourceMappingURL=ReportMappings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportMappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,UAAU,EACV,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5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ACD,OAAO,EAAE,OAAO,GAChB;QACF,6BAAK,SAAS,EAAC,kBAAkB;YAC9B,SAAS,IAAI,oBAAC,cAAc,OAAG;YAChC,oBAAC,MAAM,IACL,QAAQ,EAAE,SAAS,IAAI,UAAU,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAChE,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,KAAK,IAAI,EAAE;oBAClB,aAAa,CAAC,IAAI,CAAC,CAAC;oBACpB,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACjF,MAAM,aAAa,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;oBACxD,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;wBACvC,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;oBACnD,CAAC,CAAC,CAAC;gBACL,CAAC,IAEA,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,uCAAuC,CACxC,CACM;YACT,oBAAC,MAAM,IACL,SAAS,EAAC,SAAS,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,IAElB,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,2BAA2B,CAC5B,CACM,CACL,CACL,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 {\n SvgAdd,\n SvgCopy,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n IconButton,\n LabeledInput,\n Surface,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n generateUrl,\n handleError,\n LoadingOverlay,\n WidgetHeader,\n} from \"./utils\";\nimport \"./ReportMappings.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { Report, ReportMapping } from \"@itwin/insights-client\";\nimport { MappingsClient, REPORTING_BASE_PATH, ReportsClient } from \"@itwin/insights-client\";\nimport { AddMappingsModal } from \"./AddMappingsModal\";\nimport type {\n GetSingleIModelParams,\n IModelsClientOptions,\n} from \"@itwin/imodels-client-management\";\nimport { Constants, IModelsClient } from \"@itwin/imodels-client-management\";\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\nimport { SearchBar } from \"./SearchBar\";\nimport type { ReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { useReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { ReportMappingHorizontalTile } from \"./ReportMappingHorizontalTile\";\nimport type BulkExtractor from \"./BulkExtractor\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { LoadingSpinner } from \"./utils\";\n\nexport type ReportMappingType = CreateTypeFromInterface<ReportMapping>;\n\nexport type ReportMappingAndMapping = ReportMappingType & {\n mappingName: string;\n mappingDescription: string;\n iModelName: string;\n};\n\nenum ReportMappingsView {\n REPORTMAPPINGS = \"reportmappings\",\n ADDING = \"adding\",\n}\n\nconst fetchReportMappings = async (\n setReportMappings: (mappings: ReportMappingAndMapping[]) => void,\n reportId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: ReportsApiConfig\n) => {\n try {\n setIsLoading(true);\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const mappingsClientApi = new MappingsClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const accessToken = await apiContext.getAccessToken();\n const reportMappings = await reportsClientApi.getReportMappings(\n accessToken,\n reportId\n );\n const iModelClientOptions: IModelsClientOptions = {\n api: { baseUrl: generateUrl(Constants.api.baseUrl, apiContext.baseUrl) },\n };\n\n const iModelsClient: IModelsClient = new IModelsClient(iModelClientOptions);\n const authorization =\n AccessTokenAdapter.toAuthorizationCallback(accessToken);\n const iModelNames = new Map<string, string>();\n\n const reportMappingsAndMappings = [];\n for (const reportMapping of reportMappings) {\n const iModelId = reportMapping.imodelId;\n let iModelName = \"\";\n const mapping = await mappingsClientApi.getMapping(\n accessToken,\n iModelId,\n reportMapping.mappingId\n );\n if (iModelNames.has(iModelId)) {\n iModelName = iModelNames.get(iModelId) ?? \"\";\n } else {\n const getSingleParams: GetSingleIModelParams = {\n authorization,\n iModelId,\n };\n const iModel = await iModelsClient.iModels.getSingle(getSingleParams);\n iModelName = iModel.displayName;\n iModelNames.set(iModelId, iModelName);\n }\n const reportMappingAndMapping: ReportMappingAndMapping = {\n ...reportMapping,\n iModelName,\n mappingName: mapping.mappingName,\n mappingDescription: mapping.description ?? \"\",\n };\n reportMappingsAndMappings.push(reportMappingAndMapping);\n }\n\n setReportMappings(reportMappingsAndMappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\ninterface ReportMappingsProps {\n report: Report;\n bulkExtractor: BulkExtractor;\n goBack: () => Promise<void>;\n}\n\nexport const ReportMappings = ({ report, bulkExtractor, goBack }: ReportMappingsProps) => {\n const apiConfig = useReportsApiConfig();\n const [reportMappingsView, setReportMappingsView] =\n useState<ReportMappingsView>(ReportMappingsView.REPORTMAPPINGS);\n const [selectedReportMapping, setSelectedReportMapping] = useState<ReportMappingAndMapping | undefined>(undefined);\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reportMappings, setReportMappings] = useState<ReportMappingAndMapping[]>([]);\n const [jobRunning, setJobRunning] = useState<boolean>(false);\n\n const jobStartEvent = useMemo(\n () => new BeEvent<(iModelId: string) => void>(),\n []\n );\n\n useEffect(() => {\n void fetchReportMappings(\n setReportMappings,\n report.id,\n setIsLoading,\n apiConfig\n );\n }, [apiConfig, report.id, setIsLoading]);\n\n useEffect(() => {\n bulkExtractor.setHook(setJobRunning, reportMappings.map((x) => x.imodelId));\n }, [bulkExtractor, reportMappings]);\n\n const refresh = useCallback(async () => {\n setReportMappingsView(ReportMappingsView.REPORTMAPPINGS);\n await fetchReportMappings(\n setReportMappings,\n report.id,\n setIsLoading,\n apiConfig\n );\n }, [apiConfig, report.id, setReportMappings]);\n\n const addMapping = () => {\n setReportMappingsView(ReportMappingsView.ADDING);\n };\n\n const odataFeedUrl = `${generateUrl(\n REPORTING_BASE_PATH,\n apiConfig.baseUrl\n )}/odata/${report.id}`;\n\n const filteredReportMappings = useMemo(\n () =>\n reportMappings.filter((x) =>\n [x.iModelName, x.mappingName, x.mappingDescription]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reportMappings, searchValue]\n );\n\n return (\n <>\n <WidgetHeader title={report.displayName} returnFn={goBack} />\n <div className=\"rcw-report-mapping-misc\">\n <LabeledInput\n label={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ODataFeedURL\"\n )}\n className=\"rcw-odata-url-input\"\n readOnly={true}\n value={odataFeedUrl}\n svgIcon={\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Copy\"\n )}\n styleType=\"borderless\"\n onClick={async (_) => {\n await navigator.clipboard.writeText(odataFeedUrl);\n toaster.positive(\n ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CopiedToClipboard\"\n )\n );\n }}\n >\n <SvgCopy />\n </IconButton>\n }\n iconDisplayStyle=\"inline\"\n />\n </div>\n <Surface className=\"rcw-report-mappings-container\">\n <div className=\"rcw-toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={() => addMapping()}\n styleType=\"high-visibility\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:AddMapping\"\n )}\n </Button>\n <div className=\"rcw-search-bar-container\" data-testid=\"rcw-search-bar\">\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reportMappings.length === 0 ? (\n <EmptyMessage>\n <>\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReportMappings\"\n )}\n </Text>\n <div>\n <Button onClick={() => addMapping()} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:LetsAddSomeMappingsCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"rcw-mapping-list\">\n {filteredReportMappings.map((mapping) => (\n <ReportMappingHorizontalTile\n key={mapping.mappingId}\n bulkExtractor={bulkExtractor}\n mapping={mapping}\n onClickDelete={() => {\n setSelectedReportMapping(mapping);\n setShowDeleteModal(true);\n }}\n odataFeedUrl={odataFeedUrl}\n jobStartEvent={jobStartEvent}\n />\n ))}\n </div>\n )}\n </Surface>\n <AddMappingsModal\n show={reportMappingsView === ReportMappingsView.ADDING}\n reportId={report.id}\n existingMappings={reportMappings}\n returnFn={refresh}\n />\n <DeleteModal\n entityName={selectedReportMapping?.mappingName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)\n );\n const accessToken = await apiConfig.getAccessToken();\n await reportsClientApi.deleteReportMapping(\n accessToken,\n report.id,\n selectedReportMapping?.mappingId ?? \"\"\n );\n }}\n refresh={refresh}\n />\n <div className=\"rcw-action-panel\">\n {isLoading && <LoadingSpinner />}\n <Button\n disabled={isLoading || jobRunning || reportMappings.length === 0}\n styleType=\"high-visibility\"\n onClick={async () => {\n setJobRunning(true);\n const uniqueIModels = Array.from(new Set(reportMappings.map((x) => x.imodelId)));\n await bulkExtractor.runIModelExtractions(uniqueIModels);\n reportMappings.forEach((reportMapping) => {\n jobStartEvent.raiseEvent(reportMapping.imodelId);\n });\n }}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:UpdateAllDatasets\"\n )}\n </Button>\n <Button\n styleType=\"default\"\n type=\"button\"\n onClick={goBack}\n disabled={isLoading}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Close\"\n )}\n </Button>\n </div>\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ReportMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportMappings.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,OAAO,EACP,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,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MAAM,IACL,SAAS,EAAC,SAAS,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,SAAS,IAElB,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,2BAA2B,CAC5B,CACM,CACL,CACL,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 {\n SvgAdd,\n SvgCopy,\n SvgRefresh,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n IconButton,\n LabeledInput,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n generateUrl,\n handleError,\n LoadingOverlay,\n LoadingSpinner,\n} from \"./utils\";\nimport \"./ReportMappings.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { MappingsClient, Report, ReportMapping, ReportsClient } from \"@itwin/insights-client\";\nimport { REPORTING_BASE_PATH } from \"@itwin/insights-client\";\nimport { AddMappingsModal } from \"./AddMappingsModal\";\nimport type {\n GetSingleIModelParams,\n IModelsClient,\n} from \"@itwin/imodels-client-management\";\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\nimport { SearchBar } from \"./SearchBar\";\nimport { useReportsConfigApi } from \"../context/ReportsConfigApiContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { ReportMappingHorizontalTile } from \"./ReportMappingHorizontalTile\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { useBulkExtractor } from \"../context/BulkExtractorContext\";\n\nexport type ReportMappingType = CreateTypeFromInterface<ReportMapping>;\n\nexport type ReportMappingAndMapping = ReportMappingType & {\n mappingName: string;\n mappingDescription: string;\n iModelName: string;\n};\n\nconst fetchReportMappings = async (\n setReportMappings: (mappings: ReportMappingAndMapping[]) => void,\n reportId: string,\n setIsLoading: (isLoading: boolean) => void,\n reportsClient: ReportsClient,\n mappingsClient: MappingsClient,\n iModelsClient: IModelsClient,\n getAccessToken: () => Promise<AccessToken>\n) => {\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const reportMappings = await reportsClient.getReportMappings(\n accessToken,\n reportId\n );\n const authorization =\n AccessTokenAdapter.toAuthorizationCallback(accessToken);\n const iModelNames = new Map<string, string>();\n\n const reportMappingsAndMappings = [];\n for (const reportMapping of reportMappings) {\n const iModelId = reportMapping.imodelId;\n let iModelName = \"\";\n const mapping = await mappingsClient.getMapping(\n accessToken,\n iModelId,\n reportMapping.mappingId\n );\n if (iModelNames.has(iModelId)) {\n iModelName = iModelNames.get(iModelId) ?? \"\";\n } else {\n const getSingleParams: GetSingleIModelParams = {\n authorization,\n iModelId,\n };\n const iModel = await iModelsClient.iModels.getSingle(getSingleParams);\n iModelName = iModel.displayName;\n iModelNames.set(iModelId, iModelName);\n }\n const reportMappingAndMapping: ReportMappingAndMapping = {\n ...reportMapping,\n iModelName,\n mappingName: mapping.mappingName,\n mappingDescription: mapping.description ?? \"\",\n };\n reportMappingsAndMappings.push(reportMappingAndMapping);\n }\n\n setReportMappings(reportMappingsAndMappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport interface ReportMappingsProps {\n report: Report;\n onClickClose: () => void;\n defaultIModelId?: string;\n}\n\nexport const ReportMappings = ({ report, onClickClose, defaultIModelId }: ReportMappingsProps) => {\n const { getAccessToken, reportsClient, iModelsClient, mappingsClient, baseUrl } = useReportsConfigApi();\n const [showDeleteModal, setShowDeleteModal] = useState<ReportMappingAndMapping | undefined>(undefined);\n const [showAddMapping, setShowAddMapping] = useState<boolean>(false);\n const { bulkExtractor } = useBulkExtractor();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reportMappings, setReportMappings] = useState<ReportMappingAndMapping[]>([]);\n const [jobRunning, setJobRunning] = useState<boolean>(false);\n const jobStartEvent = useMemo(\n () => new BeEvent<(iModelId: string) => void>(),\n []\n );\n\n useEffect(() => {\n void fetchReportMappings(\n setReportMappings,\n report.id,\n setIsLoading,\n reportsClient,\n mappingsClient,\n iModelsClient,\n getAccessToken\n );\n }, [getAccessToken, iModelsClient, mappingsClient, report.id, reportsClient, setIsLoading]);\n\n useEffect(() => {\n if (!bulkExtractor) return;\n bulkExtractor.setHook(setJobRunning, reportMappings.map((x) => x.imodelId));\n }, [bulkExtractor, reportMappings]);\n\n const refresh = useCallback(async () => {\n await fetchReportMappings(\n setReportMappings,\n report.id,\n setIsLoading,\n reportsClient,\n mappingsClient,\n iModelsClient,\n getAccessToken\n );\n }, [getAccessToken, iModelsClient, mappingsClient, report.id, reportsClient]);\n\n const odataFeedUrl = `${generateUrl(\n REPORTING_BASE_PATH,\n baseUrl\n )}/odata/${report.id}`;\n\n const addMapping = useCallback(() => {\n setShowAddMapping(true);\n }, []);\n\n const filteredReportMappings = useMemo(\n () =>\n reportMappings.filter((x) =>\n [x.iModelName, x.mappingName, x.mappingDescription]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reportMappings, searchValue]\n );\n\n const onAddMappingsModalClose = useCallback(async () => { await refresh(); setShowAddMapping(false); }, [refresh]);\n\n if (!bulkExtractor) return null;\n\n return (\n <>\n <div className=\"rcw-report-mappings-container\">\n <LabeledInput\n label={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ODataFeedURL\"\n )}\n className=\"rcw-odata-url-input\"\n readOnly={true}\n value={odataFeedUrl}\n svgIcon={\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Copy\"\n )}\n onClick={async (_) => {\n await navigator.clipboard.writeText(odataFeedUrl);\n toaster.positive(\n ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CopiedToClipboard\"\n )\n );\n }}\n >\n <SvgCopy />\n </IconButton>\n }\n iconDisplayStyle=\"inline\"\n />\n <div className=\"rcw-toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={() => addMapping()}\n styleType=\"high-visibility\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:AddMapping\"\n )}\n </Button>\n <div className=\"rcw-search-bar-container\" data-testid=\"rcw-search-bar\">\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Refresh\"\n )}\n onClick={refresh}\n disabled={isLoading}\n styleType='borderless'\n >\n <SvgRefresh />\n </IconButton>\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reportMappings.length === 0 ? (\n <EmptyMessage>\n <>\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReportMappings\"\n )}\n </Text>\n <div>\n <Button onClick={addMapping} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:LetsAddSomeMappingsCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"rcw-mapping-list\">\n {filteredReportMappings.map((mapping) => (\n <ReportMappingHorizontalTile\n key={mapping.mappingId}\n bulkExtractor={bulkExtractor}\n mapping={mapping}\n onClickDelete={() => {\n setShowDeleteModal(mapping);\n }}\n odataFeedUrl={odataFeedUrl}\n jobStartEvent={jobStartEvent}\n />\n ))}\n </div>\n )}\n </div>\n <AddMappingsModal\n show={showAddMapping}\n reportId={report.id}\n existingMappings={reportMappings}\n onClose={onAddMappingsModalClose}\n defaultIModelId={defaultIModelId}\n />\n <DeleteModal\n entityName={showDeleteModal?.mappingName ?? \"\"}\n onDelete={async () => {\n const accessToken = await getAccessToken();\n await reportsClient.deleteReportMapping(\n accessToken,\n report.id,\n showDeleteModal?.mappingId ?? \"\"\n );\n }}\n refresh={refresh}\n onClose={() => setShowDeleteModal(undefined)}\n />\n <div className=\"rcw-action-panel\">\n {isLoading && <LoadingSpinner />}\n <Button\n disabled={isLoading || jobRunning || reportMappings.length === 0}\n styleType=\"high-visibility\"\n onClick={async () => {\n setJobRunning(true);\n const uniqueIModels = Array.from(new Set(reportMappings.map((x) => x.imodelId)));\n await bulkExtractor.runIModelExtractions(uniqueIModels);\n reportMappings.forEach((reportMapping) => {\n jobStartEvent.raiseEvent(reportMapping.imodelId);\n });\n }}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:UpdateAllDatasets\"\n )}\n </Button>\n <Button\n styleType=\"default\"\n type=\"button\"\n onClick={onClickClose}\n disabled={isLoading}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Close\"\n )}\n </Button>\n </div>\n </>\n );\n};\n"]}
|
|
@@ -2,31 +2,29 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
5
|
|
|
7
6
|
.rcw-report-mapping-misc {
|
|
8
7
|
display: flex;
|
|
9
8
|
flex-direction: column;
|
|
10
|
-
gap:
|
|
9
|
+
gap: var(--iui-size-s);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
.rcw-report-mappings-container {
|
|
14
13
|
display: flex;
|
|
15
14
|
flex-direction: column;
|
|
16
15
|
flex-grow: 1;
|
|
17
|
-
padding: $iui-baseline $iui-m;
|
|
18
16
|
min-height: 0;
|
|
19
17
|
|
|
20
18
|
.rcw-odata-url-input {
|
|
21
|
-
margin-bottom:
|
|
19
|
+
margin-bottom: calc(var(--iui-size-s) * 2);
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
.rcw-toolbar {
|
|
25
23
|
display: flex;
|
|
26
24
|
justify-content: space-between;
|
|
27
|
-
gap:
|
|
28
|
-
border-bottom: 1px solid var(--iui-color-
|
|
29
|
-
padding-bottom:
|
|
25
|
+
gap: var(--iui-size-xs);
|
|
26
|
+
border-bottom: 1px solid var(--iui-color-border-subtle);
|
|
27
|
+
padding-bottom: var(--iui-size-s);
|
|
30
28
|
flex-wrap: wrap;
|
|
31
29
|
}
|
|
32
30
|
|
|
@@ -34,13 +32,14 @@
|
|
|
34
32
|
display: flex;
|
|
35
33
|
flex-direction: column;
|
|
36
34
|
overflow-y: overlay;
|
|
37
|
-
gap:
|
|
38
|
-
margin-top:
|
|
35
|
+
gap: var(--iui-size-xs);
|
|
36
|
+
margin-top: var(--iui-size-xs);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
.rcw-search-bar-container {
|
|
42
|
-
flex-basis:
|
|
40
|
+
flex-basis: var(--iui-size-3xl);
|
|
43
41
|
flex-shrink: 1;
|
|
44
42
|
flex-grow: 1;
|
|
43
|
+
display: flex;
|
|
45
44
|
}
|
|
46
|
-
}
|
|
45
|
+
}
|
|
@@ -3,5 +3,10 @@ import type { CreateTypeFromInterface } from "./utils";
|
|
|
3
3
|
import "./Reports.scss";
|
|
4
4
|
import type { Report } from "@itwin/insights-client";
|
|
5
5
|
export declare type ReportType = CreateTypeFromInterface<Report>;
|
|
6
|
-
export
|
|
6
|
+
export interface ReportsProps {
|
|
7
|
+
onClickAddReport?: () => void;
|
|
8
|
+
onClickReportTitle?: (report: Report) => void;
|
|
9
|
+
onClickReportModify?: (report: Report) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const Reports: ({ onClickAddReport, onClickReportModify, onClickReportTitle, }: ReportsProps) => JSX.Element | null;
|
|
7
12
|
//# sourceMappingURL=Reports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reports.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Reports.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAMvD,OAAO,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,wBAAwB,CAAC;AASpE,oBAAY,UAAU,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAsBzD,MAAM,WAAW,YAAY;IAC3B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED,eAAO,MAAM,OAAO,mEAIjB,YAAY,uBAsKd,CAAC"}
|
|
@@ -1,40 +1,27 @@
|
|
|
1
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 { SvgAdd, SvgPlay, } from "@itwin/itwinui-icons-react";
|
|
6
|
-
import { Button, IconButton
|
|
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 { SvgAdd, SvgPlay, SvgRefresh } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { Button, IconButton } from "@itwin/itwinui-react";
|
|
7
7
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { EmptyMessage,
|
|
8
|
+
import { EmptyMessage, handleError, LoadingOverlay, } from "./utils";
|
|
9
9
|
import "./Reports.scss";
|
|
10
10
|
import DeleteModal from "./DeleteModal";
|
|
11
|
-
import { REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
12
|
-
import ReportAction from "./ReportAction";
|
|
13
|
-
import { ReportMappings } from "./ReportMappings";
|
|
14
11
|
import { ReportHorizontalTile } from "./ReportHorizontalTile";
|
|
15
12
|
import { SearchBar } from "./SearchBar";
|
|
16
|
-
import {
|
|
13
|
+
import { useReportsConfigApi } from "../context/ReportsConfigApiContext";
|
|
17
14
|
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
18
|
-
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
19
|
-
import BulkExtractor from "./BulkExtractor";
|
|
20
15
|
import { BeEvent } from "@itwin/core-bentley";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
(function (ReportsView) {
|
|
24
|
-
ReportsView["REPORTS"] = "reports";
|
|
25
|
-
ReportsView["REPORTSMAPPING"] = "reportsmapping";
|
|
26
|
-
ReportsView["ADDING"] = "adding";
|
|
27
|
-
ReportsView["MODIFYING"] = "modifying";
|
|
28
|
-
})(ReportsView || (ReportsView = {}));
|
|
29
|
-
const fetchReports = async (setReports, iTwinId, setIsLoading, apiContext) => {
|
|
16
|
+
import { useBulkExtractor } from "../context/BulkExtractorContext";
|
|
17
|
+
const fetchReports = async (setReports, iTwinId, setIsLoading, reportsClient, getAccessToken) => {
|
|
30
18
|
try {
|
|
31
19
|
if (!iTwinId)
|
|
32
20
|
return;
|
|
33
21
|
setIsLoading(true);
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
setReports(reports !== null && reports !== void 0 ? reports : []);
|
|
22
|
+
const accessToken = await getAccessToken();
|
|
23
|
+
const reports = await reportsClient.getReports(accessToken, iTwinId);
|
|
24
|
+
setReports(reports ?? []);
|
|
38
25
|
}
|
|
39
26
|
catch (error) {
|
|
40
27
|
handleError(error.status);
|
|
@@ -43,36 +30,21 @@ const fetchReports = async (setReports, iTwinId, setIsLoading, apiContext) => {
|
|
|
43
30
|
setIsLoading(false);
|
|
44
31
|
}
|
|
45
32
|
};
|
|
46
|
-
export const Reports = () => {
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
const failedExtractionToast = (iModelName) => {
|
|
52
|
-
toaster.negative(React.createElement(FailedExtractionToast, { iModelName: iModelName }));
|
|
53
|
-
};
|
|
54
|
-
const iTwinId = (_b = (_a = useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iTwinId) !== null && _b !== void 0 ? _b : "";
|
|
55
|
-
const apiConfig = useReportsApiConfig();
|
|
33
|
+
export const Reports = ({ onClickAddReport, onClickReportModify, onClickReportTitle, }) => {
|
|
34
|
+
const { iTwinId, getAccessToken, reportsClient } = useReportsConfigApi();
|
|
35
|
+
const { bulkExtractor } = useBulkExtractor();
|
|
36
|
+
const [showDeleteModal, setShowDeleteModal] = useState(undefined);
|
|
56
37
|
const [selectedReportIds, setSelectedReportIds] = useState([]);
|
|
57
|
-
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
58
|
-
const [reportsView, setReportsView] = useState(ReportsView.REPORTS);
|
|
59
|
-
const [selectedReport, setSelectedReport] = useState(undefined);
|
|
60
38
|
const [isLoading, setIsLoading] = useState(true);
|
|
61
39
|
const [searchValue, setSearchValue] = useState("");
|
|
62
40
|
const [reports, setReports] = useState([]);
|
|
63
|
-
const bulkExtractor = useMemo(() => new BulkExtractor(apiConfig, successfulExtractionToast, failedExtractionToast), [apiConfig]);
|
|
64
41
|
const jobStartEvent = useMemo(() => new BeEvent(), []);
|
|
65
42
|
useEffect(() => {
|
|
66
|
-
void fetchReports(setReports, iTwinId, setIsLoading,
|
|
67
|
-
}, [
|
|
43
|
+
void fetchReports(setReports, iTwinId, setIsLoading, reportsClient, getAccessToken);
|
|
44
|
+
}, [getAccessToken, iTwinId, reportsClient, setIsLoading]);
|
|
68
45
|
const refresh = useCallback(async () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);
|
|
72
|
-
}, [apiConfig, iTwinId, setReports]);
|
|
73
|
-
const addReport = () => {
|
|
74
|
-
setReportsView(ReportsView.ADDING);
|
|
75
|
-
};
|
|
46
|
+
await fetchReports(setReports, iTwinId, setIsLoading, reportsClient, getAccessToken);
|
|
47
|
+
}, [getAccessToken, iTwinId, reportsClient]);
|
|
76
48
|
const filteredReports = useMemo(() => reports.filter((x) => [x.displayName, x.description]
|
|
77
49
|
.join(" ")
|
|
78
50
|
.toLowerCase()
|
|
@@ -85,48 +57,35 @@ export const Reports = () => {
|
|
|
85
57
|
: [...sr, reportId]);
|
|
86
58
|
};
|
|
87
59
|
const updateDatasets = useCallback(async () => {
|
|
60
|
+
if (!bulkExtractor)
|
|
61
|
+
return;
|
|
88
62
|
await bulkExtractor.runReportExtractions(selectedReportIds);
|
|
89
63
|
selectedReportIds.map((reportId) => jobStartEvent.raiseEvent(reportId));
|
|
90
64
|
setSelectedReportIds([]);
|
|
91
65
|
}, [selectedReportIds, jobStartEvent, bulkExtractor]);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
React.createElement(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
setReportsView(ReportsView.REPORTSMAPPING);
|
|
117
|
-
}, jobStartEvent: jobStartEvent, bulkExtractor: bulkExtractor, onClickDelete: () => {
|
|
118
|
-
setSelectedReport(report);
|
|
119
|
-
setShowDeleteModal(true);
|
|
120
|
-
}, onClickModify: () => {
|
|
121
|
-
setSelectedReport(report);
|
|
122
|
-
setReportsView(ReportsView.MODIFYING);
|
|
123
|
-
}, onSelectionChange: onSelectionChange, selected: selectedReportIds.some((reportId) => report.id === reportId) })))))),
|
|
124
|
-
React.createElement(DeleteModal, { entityName: (_c = selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.displayName) !== null && _c !== void 0 ? _c : "", show: showDeleteModal, setShow: setShowDeleteModal, onDelete: async () => {
|
|
125
|
-
var _a;
|
|
126
|
-
const reportsClientApi = new ReportsClient(generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl));
|
|
127
|
-
const accessToken = await apiConfig.getAccessToken();
|
|
128
|
-
await reportsClientApi.deleteReport(accessToken, (_a = selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.id) !== null && _a !== void 0 ? _a : "");
|
|
129
|
-
}, refresh: refresh })));
|
|
130
|
-
}
|
|
66
|
+
if (!bulkExtractor)
|
|
67
|
+
return null;
|
|
68
|
+
return (React.createElement(React.Fragment, null,
|
|
69
|
+
React.createElement("div", { className: "rcw-reports-list-container" },
|
|
70
|
+
React.createElement("div", { className: "rcw-toolbar" },
|
|
71
|
+
React.createElement("div", { className: "rcw-button-spacing" },
|
|
72
|
+
onClickAddReport && (React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), onClick: onClickAddReport, styleType: "high-visibility", title: "New Report" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:New"))),
|
|
73
|
+
React.createElement(IconButton, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:UpdateDatasets"), onClick: updateDatasets, disabled: selectedReportIds.length === 0 },
|
|
74
|
+
React.createElement(SvgPlay, null))),
|
|
75
|
+
React.createElement("div", { className: "rcw-search-bar-container", "data-testid": "rcw-search-bar" },
|
|
76
|
+
React.createElement(IconButton, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Refresh"), onClick: refresh, disabled: isLoading, styleType: "borderless" },
|
|
77
|
+
React.createElement(SvgRefresh, null)),
|
|
78
|
+
React.createElement(SearchBar, { searchValue: searchValue, setSearchValue: setSearchValue, disabled: isLoading }))),
|
|
79
|
+
isLoading ? (React.createElement(LoadingOverlay, null)) : reports.length === 0 && onClickAddReport ? (React.createElement(EmptyMessage, null,
|
|
80
|
+
React.createElement(React.Fragment, null,
|
|
81
|
+
ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:NoReports"),
|
|
82
|
+
React.createElement("div", null,
|
|
83
|
+
React.createElement(Button, { onClick: onClickAddReport, styleType: "cta" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:CreateOneReportCTA")))))) : (React.createElement("div", { className: "rcw-reports-list" }, filteredReports.map((report) => (React.createElement(ReportHorizontalTile, { key: report.id, report: report, onClickTitle: onClickReportTitle, jobStartEvent: jobStartEvent, bulkExtractor: bulkExtractor, onClickDelete: () => {
|
|
84
|
+
setShowDeleteModal(report);
|
|
85
|
+
}, onClickModify: onClickReportModify, onSelectionChange: onSelectionChange, selected: selectedReportIds.some((reportId) => report.id === reportId) })))))),
|
|
86
|
+
React.createElement(DeleteModal, { entityName: showDeleteModal?.displayName, onClose: () => setShowDeleteModal(undefined), onDelete: async () => {
|
|
87
|
+
const accessToken = await getAccessToken();
|
|
88
|
+
await reportsClient.deleteReport(accessToken, showDeleteModal?.id ?? "");
|
|
89
|
+
}, refresh: refresh })));
|
|
131
90
|
};
|
|
132
91
|
//# sourceMappingURL=Reports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reports.js","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ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ACxC,WAAW,CAAC,mBAAmB,EAAE,SAAS,CAAC,OAAO,CAAC,CACpD,CAAC;wBACF,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,CAAC;wBACrD,MAAM,gBAAgB,CAAC,YAAY,CACjC,WAAW,EACX,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,EAAE,mCAAI,EAAE,CACzB,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;KACL;AACH,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 {\n SvgAdd,\n SvgPlay,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n IconButton,\n Surface,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n generateUrl,\n handleError,\n LoadingOverlay,\n WidgetHeader,\n} from \"./utils\";\nimport \"./Reports.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { Report } from \"@itwin/insights-client\";\nimport { REPORTING_BASE_PATH, ReportsClient } from \"@itwin/insights-client\";\nimport ReportAction from \"./ReportAction\";\nimport { ReportMappings } from \"./ReportMappings\";\nimport { ReportHorizontalTile } from \"./ReportHorizontalTile\";\nimport { SearchBar } from \"./SearchBar\";\nimport type { ReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { useReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport BulkExtractor from \"./BulkExtractor\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { FailedExtractionToast, SuccessfulExtractionToast } from \"./ExtractionToast\";\n\nexport type ReportType = CreateTypeFromInterface<Report>;\n\nenum ReportsView {\n REPORTS = \"reports\",\n REPORTSMAPPING = \"reportsmapping\",\n ADDING = \"adding\",\n MODIFYING = \"modifying\",\n}\n\nconst fetchReports = async (\n setReports: React.Dispatch<React.SetStateAction<Report[]>>,\n iTwinId: string | undefined,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: ReportsApiConfig\n) => {\n try {\n if (!iTwinId) return;\n setIsLoading(true);\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const accessToken = await apiContext.getAccessToken();\n const reports = await reportsClientApi.getReports(accessToken, iTwinId);\n setReports(reports ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport const Reports = () => {\n const successfulExtractionToast = (iModelName: string, odataFeedUrl: string) => {\n toaster.positive(<SuccessfulExtractionToast iModelName={iModelName} odataFeedUrl={odataFeedUrl} />);\n };\n\n const failedExtractionToast = (iModelName: string) => {\n toaster.negative(<FailedExtractionToast iModelName={iModelName} />);\n };\n\n const iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const apiConfig = useReportsApiConfig();\n const [selectedReportIds, setSelectedReportIds] = useState<string[]>([]);\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [reportsView, setReportsView] = useState<ReportsView>(\n ReportsView.REPORTS\n );\n const [selectedReport, setSelectedReport] = useState<Report | undefined>(\n undefined\n );\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reports, setReports] = useState<Report[]>([]);\n const bulkExtractor = useMemo(\n () => new BulkExtractor(apiConfig, successfulExtractionToast, failedExtractionToast),\n [apiConfig]\n );\n const jobStartEvent = useMemo(\n () => new BeEvent<(reportId: string) => void>(),\n []\n );\n\n useEffect(() => {\n void fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setIsLoading]);\n\n const refresh = useCallback(async () => {\n setReportsView(ReportsView.REPORTS);\n setSelectedReport(undefined);\n await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setReports]);\n\n const addReport = () => {\n setReportsView(ReportsView.ADDING);\n };\n\n const filteredReports = useMemo(\n () =>\n reports.filter((x) =>\n [x.displayName, x.description]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reports, searchValue]\n );\n\n const onSelectionChange = (reportId: string, control: boolean) => {\n if (!control)\n setSelectedReportIds([]);\n\n setSelectedReportIds((sr) =>\n sr.some((r) => reportId === r)\n ? sr.filter(\n (r) => reportId !== r\n )\n : [...sr, reportId]\n );\n };\n\n const updateDatasets = useCallback(async () => {\n await bulkExtractor.runReportExtractions(selectedReportIds);\n selectedReportIds.map((reportId) => jobStartEvent.raiseEvent(reportId));\n setSelectedReportIds([]);\n }, [selectedReportIds, jobStartEvent, bulkExtractor]);\n\n switch (reportsView) {\n case ReportsView.ADDING:\n return iTwinId ? (\n <ReportAction iTwinId={iTwinId ?? \"\"} returnFn={refresh} />\n ) : null;\n case ReportsView.MODIFYING:\n return iTwinId ? (\n <ReportAction\n iTwinId={iTwinId}\n report={selectedReport}\n returnFn={refresh}\n />\n ) : null;\n case ReportsView.REPORTSMAPPING:\n return selectedReport ? (\n <ReportMappings report={selectedReport} bulkExtractor={bulkExtractor} goBack={refresh} />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ITwinReports\"\n )}\n />\n <Surface className=\"rcw-reports-list-container\">\n <div className=\"rcw-toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={() => addReport()}\n styleType=\"high-visibility\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:New\"\n )}\n </Button>\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:UpdateDatasets\"\n )}\n onClick={updateDatasets}\n disabled={selectedReportIds.length === 0}\n >\n <SvgPlay />\n </IconButton>\n <div className=\"rcw-search-bar-container\" data-testid=\"rcw-search-bar\">\n <div className=\"rcw-search-button\">\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reports.length === 0 ? (\n <EmptyMessage>\n <>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReports\"\n )}\n <div>\n <Button onClick={addReport} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CreateOneReportCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"rcw-reports-list\">\n {filteredReports.map((report) => (\n <ReportHorizontalTile\n key={report.id}\n report={report}\n onClickTitle={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.REPORTSMAPPING);\n }}\n jobStartEvent={jobStartEvent}\n bulkExtractor={bulkExtractor}\n onClickDelete={() => {\n setSelectedReport(report);\n setShowDeleteModal(true);\n }}\n onClickModify={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.MODIFYING);\n }}\n onSelectionChange={onSelectionChange}\n selected={selectedReportIds.some((reportId) => report.id === reportId)}\n />\n ))}\n </div>\n )}\n </Surface>\n <DeleteModal\n entityName={selectedReport?.displayName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)\n );\n const accessToken = await apiConfig.getAccessToken();\n await reportsClientApi.deleteReport(\n accessToken,\n selectedReport?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Reports.js","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE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,EAAE,CAAC,CAC/B,oBAAC,oBAAoB,IACnB,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,kBAAkB,EAChC,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,GAAG,EAAE;oBAClB,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC,EACD,aAAa,EAAE,mBAAmB,EAClC,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,iBAAiB,CAAC,IAAI,CAC9B,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CACrC,GACD,CACH,CAAC,CACE,CACP,CACG;QACN,oBAAC,WAAW,IACV,UAAU,EAAE,eAAe,EAAE,WAAW,EACxC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAC5C,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;gBAC3C,MAAM,aAAa,CAAC,YAAY,CAC9B,WAAW,EACX,eAAe,EAAE,EAAE,IAAI,EAAE,CAC1B,CAAC;YACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,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 { SvgAdd, SvgPlay, SvgRefresh } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n handleError,\n LoadingOverlay,\n} from \"./utils\";\nimport \"./Reports.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { Report, ReportsClient } from \"@itwin/insights-client\";\nimport { ReportHorizontalTile } from \"./ReportHorizontalTile\";\nimport { SearchBar } from \"./SearchBar\";\nimport { useReportsConfigApi } from \"../context/ReportsConfigApiContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { useBulkExtractor } from \"../context/BulkExtractorContext\";\n\nexport type ReportType = CreateTypeFromInterface<Report>;\n\nconst fetchReports = async (\n setReports: (reports: Report[]) => void,\n iTwinId: string | undefined,\n setIsLoading: (isLoading: boolean) => void,\n reportsClient: ReportsClient,\n getAccessToken: () => Promise<AccessToken>\n) => {\n try {\n if (!iTwinId) return;\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const reports = await reportsClient.getReports(accessToken, iTwinId);\n setReports(reports ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport interface ReportsProps {\n onClickAddReport?: () => void;\n onClickReportTitle?: (report: Report) => void;\n onClickReportModify?: (report: Report) => void;\n}\n\nexport const Reports = ({\n onClickAddReport,\n onClickReportModify,\n onClickReportTitle,\n}: ReportsProps) => {\n const { iTwinId, getAccessToken, reportsClient } = useReportsConfigApi();\n const { bulkExtractor } = useBulkExtractor();\n const [showDeleteModal, setShowDeleteModal] = useState<Report | undefined>(\n undefined\n );\n const [selectedReportIds, setSelectedReportIds] = useState<string[]>([]);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reports, setReports] = useState<Report[]>([]);\n const jobStartEvent = useMemo(\n () => new BeEvent<(reportId: string) => void>(),\n []\n );\n\n useEffect(() => {\n void fetchReports(\n setReports,\n iTwinId,\n setIsLoading,\n reportsClient,\n getAccessToken\n );\n }, [getAccessToken, iTwinId, reportsClient, setIsLoading]);\n\n const refresh = useCallback(async () => {\n await fetchReports(\n setReports,\n iTwinId,\n setIsLoading,\n reportsClient,\n getAccessToken\n );\n }, [getAccessToken, iTwinId, reportsClient]);\n\n const filteredReports = useMemo(\n () =>\n reports.filter((x) =>\n [x.displayName, x.description]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reports, searchValue]\n );\n\n const onSelectionChange = (reportId: string, control: boolean) => {\n if (!control) setSelectedReportIds([]);\n\n setSelectedReportIds((sr) =>\n sr.some((r) => reportId === r)\n ? sr.filter((r) => reportId !== r)\n : [...sr, reportId]\n );\n };\n\n const updateDatasets = useCallback(async () => {\n if (!bulkExtractor) return;\n await bulkExtractor.runReportExtractions(selectedReportIds);\n selectedReportIds.map((reportId) => jobStartEvent.raiseEvent(reportId));\n setSelectedReportIds([]);\n }, [selectedReportIds, jobStartEvent, bulkExtractor]);\n\n if (!bulkExtractor) return null;\n\n return (\n <>\n <div className=\"rcw-reports-list-container\">\n <div className=\"rcw-toolbar\">\n <div className=\"rcw-button-spacing\">\n {onClickAddReport && (\n <Button\n startIcon={<SvgAdd />}\n onClick={onClickAddReport}\n styleType=\"high-visibility\"\n title=\"New Report\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:New\"\n )}\n </Button>\n )}\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:UpdateDatasets\"\n )}\n onClick={updateDatasets}\n disabled={selectedReportIds.length === 0}\n >\n <SvgPlay />\n </IconButton>\n </div>\n <div\n className=\"rcw-search-bar-container\"\n data-testid=\"rcw-search-bar\"\n >\n <IconButton\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Refresh\"\n )}\n onClick={refresh}\n disabled={isLoading}\n styleType=\"borderless\"\n >\n <SvgRefresh />\n </IconButton>\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reports.length === 0 && onClickAddReport ? (\n <EmptyMessage>\n <>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReports\"\n )}\n <div>\n <Button onClick={onClickAddReport} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CreateOneReportCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"rcw-reports-list\">\n {filteredReports.map((report) => (\n <ReportHorizontalTile\n key={report.id}\n report={report}\n onClickTitle={onClickReportTitle}\n jobStartEvent={jobStartEvent}\n bulkExtractor={bulkExtractor}\n onClickDelete={() => {\n setShowDeleteModal(report);\n }}\n onClickModify={onClickReportModify}\n onSelectionChange={onSelectionChange}\n selected={selectedReportIds.some(\n (reportId) => report.id === reportId\n )}\n />\n ))}\n </div>\n )}\n </div>\n <DeleteModal\n entityName={showDeleteModal?.displayName}\n onClose={() => setShowDeleteModal(undefined)}\n onDelete={async () => {\n const accessToken = await getAccessToken();\n await reportsClient.deleteReport(\n accessToken,\n showDeleteModal?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n </>\n );\n};\n"]}
|