@itwin/reports-config-widget-react 0.0.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/.rush/temp/package-deps_rebuild.json +48 -0
- package/.rush/temp/shrinkwrap-deps.json +868 -0
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +9 -0
- package/README.md +38 -0
- package/__mocks__/fileMock.js +5 -0
- package/coverage/clover.xml +612 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +191 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/test/index.html +116 -0
- package/coverage/lcov-report/src/test/test-utils.tsx.html +316 -0
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +286 -0
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +253 -0
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +610 -0
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +385 -0
- package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +1030 -0
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +256 -0
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +523 -0
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1135 -0
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +829 -0
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +193 -0
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +271 -0
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +391 -0
- package/coverage/lcov-report/src/widget/components/index.html +296 -0
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +562 -0
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +166 -0
- package/coverage/lcov-report/src/widget/context/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
- package/coverage/lcov-report/src/widget/index.html +116 -0
- package/coverage/lcov.info +1260 -0
- package/jest.config.js +19 -0
- package/lib/cjs/ReportsConfigWidget.d.ts +10 -0
- package/lib/cjs/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/cjs/ReportsConfigWidget.js +24 -0
- package/lib/cjs/ReportsConfigWidget.js.map +1 -0
- package/lib/cjs/reports-config-widget-react.d.ts +4 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -0
- package/lib/cjs/reports-config-widget-react.js +20 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -0
- package/lib/cjs/test/ReportAction.test.d.ts +2 -0
- package/lib/cjs/test/ReportAction.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportAction.test.js +194 -0
- package/lib/cjs/test/ReportAction.test.js.map +1 -0
- package/lib/cjs/test/ReportMappings.test.d.ts +2 -0
- package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportMappings.test.js +530 -0
- package/lib/cjs/test/ReportMappings.test.js.map +1 -0
- package/lib/cjs/test/Reports.test.d.ts +2 -0
- package/lib/cjs/test/Reports.test.d.ts.map +1 -0
- package/lib/cjs/test/Reports.test.js +232 -0
- package/lib/cjs/test/Reports.test.js.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.js +30 -0
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
- package/lib/cjs/test/test-utils.d.ts +69 -0
- package/lib/cjs/test/test-utils.d.ts.map +1 -0
- package/lib/cjs/test/test-utils.js +77 -0
- package/lib/cjs/test/test-utils.js.map +1 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js +55 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts +13 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.js +39 -0
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.scss +12 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.js +118 -0
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.scss +18 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.js +65 -0
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.scss +18 -0
- package/lib/cjs/widget/components/Extraction.d.ts +28 -0
- package/lib/cjs/widget/components/Extraction.d.ts.map +1 -0
- package/lib/cjs/widget/components/Extraction.js +193 -0
- package/lib/cjs/widget/components/Extraction.js.map +1 -0
- package/lib/cjs/widget/components/Extraction.scss +39 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.js +18 -0
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.scss +32 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js +41 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.d.ts +11 -0
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportAction.js +101 -0
- package/lib/cjs/widget/components/ReportAction.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.scss +16 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts +17 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.js +174 -0
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.scss +46 -0
- package/lib/cjs/widget/components/Reports.d.ts +7 -0
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -0
- package/lib/cjs/widget/components/Reports.js +143 -0
- package/lib/cjs/widget/components/Reports.js.map +1 -0
- package/lib/cjs/widget/components/Reports.scss +36 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.js +34 -0
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.scss +15 -0
- package/lib/cjs/widget/components/SearchBar.d.ts +10 -0
- package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/cjs/widget/components/SearchBar.js +50 -0
- package/lib/cjs/widget/components/SearchBar.js.map +1 -0
- package/lib/cjs/widget/components/SearchBar.scss +27 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts +9 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.js +82 -0
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.scss +15 -0
- package/lib/cjs/widget/components/utils.d.ts +23 -0
- package/lib/cjs/widget/components/utils.d.ts.map +1 -0
- package/lib/cjs/widget/components/utils.js +87 -0
- package/lib/cjs/widget/components/utils.js.map +1 -0
- package/lib/cjs/widget/components/utils.scss +39 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js +37 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts +8 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.js +56 -0
- package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
- package/lib/esm/ReportsConfigWidget.d.ts +10 -0
- package/lib/esm/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/esm/ReportsConfigWidget.js +20 -0
- package/lib/esm/ReportsConfigWidget.js.map +1 -0
- package/lib/esm/reports-config-widget-react.d.ts +4 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -0
- package/lib/esm/reports-config-widget-react.js +8 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -0
- package/lib/esm/test/ReportAction.test.d.ts +2 -0
- package/lib/esm/test/ReportAction.test.d.ts.map +1 -0
- package/lib/esm/test/ReportAction.test.js +170 -0
- package/lib/esm/test/ReportAction.test.js.map +1 -0
- package/lib/esm/test/ReportMappings.test.d.ts +2 -0
- package/lib/esm/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/esm/test/ReportMappings.test.js +506 -0
- package/lib/esm/test/ReportMappings.test.js.map +1 -0
- package/lib/esm/test/Reports.test.d.ts +2 -0
- package/lib/esm/test/Reports.test.d.ts.map +1 -0
- package/lib/esm/test/Reports.test.js +208 -0
- package/lib/esm/test/Reports.test.js.map +1 -0
- package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
- package/lib/esm/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/esm/test/WidgetHeader.test.js +25 -0
- package/lib/esm/test/WidgetHeader.test.js.map +1 -0
- package/lib/esm/test/test-utils.d.ts +69 -0
- package/lib/esm/test/test-utils.d.ts.map +1 -0
- package/lib/esm/test/test-utils.js +48 -0
- package/lib/esm/test/test-utils.js.map +1 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js +29 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.d.ts +13 -0
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/esm/widget/components/ActionPanel.js +18 -0
- package/lib/esm/widget/components/ActionPanel.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.scss +12 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.js +94 -0
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.scss +18 -0
- package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
- package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/esm/widget/components/DeleteModal.js +42 -0
- package/lib/esm/widget/components/DeleteModal.js.map +1 -0
- package/lib/esm/widget/components/DeleteModal.scss +18 -0
- package/lib/esm/widget/components/Extraction.d.ts +28 -0
- package/lib/esm/widget/components/Extraction.d.ts.map +1 -0
- package/lib/esm/widget/components/Extraction.js +169 -0
- package/lib/esm/widget/components/Extraction.js.map +1 -0
- package/lib/esm/widget/components/Extraction.scss +39 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.js +11 -0
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.scss +32 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js +18 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.d.ts +11 -0
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportAction.js +77 -0
- package/lib/esm/widget/components/ReportAction.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.scss +16 -0
- package/lib/esm/widget/components/ReportMappings.d.ts +17 -0
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportMappings.js +148 -0
- package/lib/esm/widget/components/ReportMappings.js.map +1 -0
- package/lib/esm/widget/components/ReportMappings.scss +46 -0
- package/lib/esm/widget/components/Reports.d.ts +7 -0
- package/lib/esm/widget/components/Reports.d.ts.map +1 -0
- package/lib/esm/widget/components/Reports.js +117 -0
- package/lib/esm/widget/components/Reports.js.map +1 -0
- package/lib/esm/widget/components/Reports.scss +36 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.js +13 -0
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.scss +15 -0
- package/lib/esm/widget/components/SearchBar.d.ts +10 -0
- package/lib/esm/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/esm/widget/components/SearchBar.js +27 -0
- package/lib/esm/widget/components/SearchBar.js.map +1 -0
- package/lib/esm/widget/components/SearchBar.scss +27 -0
- package/lib/esm/widget/components/SelectIModel.d.ts +9 -0
- package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/esm/widget/components/SelectIModel.js +59 -0
- package/lib/esm/widget/components/SelectIModel.js.map +1 -0
- package/lib/esm/widget/components/SelectIModel.scss +15 -0
- package/lib/esm/widget/components/utils.d.ts +23 -0
- package/lib/esm/widget/components/utils.d.ts.map +1 -0
- package/lib/esm/widget/components/utils.js +73 -0
- package/lib/esm/widget/components/utils.js.map +1 -0
- package/lib/esm/widget/components/utils.scss +39 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js +14 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/esm/widget/hooks/useValidator.d.ts +8 -0
- package/lib/esm/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/esm/widget/hooks/useValidator.js +50 -0
- package/lib/esm/widget/hooks/useValidator.js.map +1 -0
- package/lib/public/locales/en/ReportsConfigWidget.json +76 -0
- package/package.json +124 -0
- package/public/locales/en/ReportsConfigWidget.json +76 -0
- package/reports-config-widget-react.build.error.log +10 -0
- package/reports-config-widget-react.build.log +45 -0
- package/src/ReportsConfigWidget.ts +36 -0
- package/src/reports-config-widget-react.ts +7 -0
- package/src/test/ReportAction.test.tsx +258 -0
- package/src/test/ReportMappings.test.tsx +882 -0
- package/src/test/Reports.test.tsx +365 -0
- package/src/test/WidgetHeader.test.tsx +29 -0
- package/src/test/test-utils.tsx +77 -0
- package/src/widget/ReportsConfigUiProvider.tsx +67 -0
- package/src/widget/components/ActionPanel.scss +12 -0
- package/src/widget/components/ActionPanel.tsx +56 -0
- package/src/widget/components/AddMappingsModal.scss +18 -0
- package/src/widget/components/AddMappingsModal.tsx +175 -0
- package/src/widget/components/DeleteModal.scss +18 -0
- package/src/widget/components/DeleteModal.tsx +100 -0
- package/src/widget/components/Extraction.scss +39 -0
- package/src/widget/components/Extraction.tsx +315 -0
- package/src/widget/components/HorizontalTile.scss +32 -0
- package/src/widget/components/HorizontalTile.tsx +57 -0
- package/src/widget/components/LocalizedTablePaginator.tsx +59 -0
- package/src/widget/components/ReportAction.scss +16 -0
- package/src/widget/components/ReportAction.tsx +146 -0
- package/src/widget/components/ReportMappings.scss +46 -0
- package/src/widget/components/ReportMappings.tsx +350 -0
- package/src/widget/components/Reports.scss +36 -0
- package/src/widget/components/Reports.tsx +248 -0
- package/src/widget/components/ReportsContainer.scss +15 -0
- package/src/widget/components/ReportsContainer.tsx +36 -0
- package/src/widget/components/SearchBar.scss +27 -0
- package/src/widget/components/SearchBar.tsx +62 -0
- package/src/widget/components/SelectIModel.scss +15 -0
- package/src/widget/components/SelectIModel.tsx +102 -0
- package/src/widget/components/utils.scss +39 -0
- package/src/widget/components/utils.tsx +159 -0
- package/src/widget/context/ReportsApiConfigContext.tsx +27 -0
- package/src/widget/hooks/useValidator.ts +70 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,117 @@
|
|
|
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, SvgDelete, SvgEdit, SvgMore, } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { Button, DropdownMenu, IconButton, MenuItem, Surface, } from "@itwin/itwinui-react";
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { EmptyMessage, generateUrl, handleError, LoadingOverlay, WidgetHeader, } from "./utils";
|
|
9
|
+
import "./Reports.scss";
|
|
10
|
+
import DeleteModal from "./DeleteModal";
|
|
11
|
+
import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
|
|
12
|
+
import ReportAction from "./ReportAction";
|
|
13
|
+
import { ReportMappings } from "./ReportMappings";
|
|
14
|
+
import { HorizontalTile } from "./HorizontalTile";
|
|
15
|
+
import { SearchBar } from "./SearchBar";
|
|
16
|
+
import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
|
|
17
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
18
|
+
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
19
|
+
var ReportsView;
|
|
20
|
+
(function (ReportsView) {
|
|
21
|
+
ReportsView["REPORTS"] = "reports";
|
|
22
|
+
ReportsView["REPORTSMAPPING"] = "reportsmapping";
|
|
23
|
+
ReportsView["ADDING"] = "adding";
|
|
24
|
+
ReportsView["MODIFYING"] = "modifying";
|
|
25
|
+
})(ReportsView || (ReportsView = {}));
|
|
26
|
+
const fetchReports = async (setReports, iTwinId, setIsLoading, apiContext) => {
|
|
27
|
+
try {
|
|
28
|
+
if (!iTwinId)
|
|
29
|
+
return;
|
|
30
|
+
setIsLoading(true);
|
|
31
|
+
const reportingClientApi = new ReportingClient(generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl));
|
|
32
|
+
const accessToken = await apiContext.getAccessToken();
|
|
33
|
+
const reports = await reportingClientApi.getReports(accessToken, iTwinId);
|
|
34
|
+
setReports(reports !== null && reports !== void 0 ? reports : []);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
handleError(error.status);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export const Reports = () => {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
const iTwinId = (_b = (_a = useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iTwinId) !== null && _b !== void 0 ? _b : "";
|
|
46
|
+
const apiConfig = useReportsApiConfig();
|
|
47
|
+
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
48
|
+
const [reportsView, setReportsView] = useState(ReportsView.REPORTS);
|
|
49
|
+
const [selectedReport, setSelectedReport] = useState(undefined);
|
|
50
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
51
|
+
const [searchValue, setSearchValue] = useState("");
|
|
52
|
+
const [reports, setReports] = useState([]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
void fetchReports(setReports, iTwinId, setIsLoading, apiConfig);
|
|
55
|
+
}, [apiConfig, iTwinId, setIsLoading]);
|
|
56
|
+
const refresh = useCallback(async () => {
|
|
57
|
+
setReportsView(ReportsView.REPORTS);
|
|
58
|
+
setSelectedReport(undefined);
|
|
59
|
+
await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);
|
|
60
|
+
}, [apiConfig, iTwinId, setReports]);
|
|
61
|
+
const addReport = () => {
|
|
62
|
+
setReportsView(ReportsView.ADDING);
|
|
63
|
+
};
|
|
64
|
+
const filteredReports = useMemo(() => reports.filter((x) => [x.displayName, x.description]
|
|
65
|
+
.join(" ")
|
|
66
|
+
.toLowerCase()
|
|
67
|
+
.includes(searchValue.toLowerCase())), [reports, searchValue]);
|
|
68
|
+
switch (reportsView) {
|
|
69
|
+
case ReportsView.ADDING:
|
|
70
|
+
return iTwinId ? (React.createElement(ReportAction, { iTwinId: iTwinId !== null && iTwinId !== void 0 ? iTwinId : "", returnFn: refresh })) : null;
|
|
71
|
+
case ReportsView.MODIFYING:
|
|
72
|
+
return iTwinId ? (React.createElement(ReportAction, { iTwinId: iTwinId, report: selectedReport, returnFn: refresh })) : null;
|
|
73
|
+
case ReportsView.REPORTSMAPPING:
|
|
74
|
+
return selectedReport ? (React.createElement(ReportMappings, { report: selectedReport, goBack: refresh })) : null;
|
|
75
|
+
default:
|
|
76
|
+
return (React.createElement(React.Fragment, null,
|
|
77
|
+
React.createElement(WidgetHeader, { title: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ITwinReports") }),
|
|
78
|
+
React.createElement(Surface, { className: "reports-list-container" },
|
|
79
|
+
React.createElement("div", { className: "toolbar" },
|
|
80
|
+
React.createElement(Button, { startIcon: React.createElement(SvgAdd, null), onClick: () => addReport(), styleType: "high-visibility" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:New")),
|
|
81
|
+
React.createElement("div", { className: "search-bar-container", "data-testid": "search-bar" },
|
|
82
|
+
React.createElement(SearchBar, { searchValue: searchValue, setSearchValue: setSearchValue, disabled: isLoading }))),
|
|
83
|
+
isLoading ? (React.createElement(LoadingOverlay, null)) : reports.length === 0 ? (React.createElement(EmptyMessage, null,
|
|
84
|
+
React.createElement(React.Fragment, null,
|
|
85
|
+
ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:NoReports"),
|
|
86
|
+
React.createElement("div", null,
|
|
87
|
+
React.createElement(Button, { onClick: () => addReport(), styleType: "cta" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:CreateOneReportCTA")))))) : (React.createElement("div", { className: "reports-list" }, filteredReports.map((report) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
return (React.createElement(HorizontalTile, { key: report.id, title: (_a = report.displayName) !== null && _a !== void 0 ? _a : "", subText: (_b = report.description) !== null && _b !== void 0 ? _b : "", subtextToolTip: (_c = report.description) !== null && _c !== void 0 ? _c : "", titleTooltip: report.displayName, onClickTitle: () => {
|
|
90
|
+
setSelectedReport(report);
|
|
91
|
+
setReportsView(ReportsView.REPORTSMAPPING);
|
|
92
|
+
}, button: React.createElement(DropdownMenu, { menuItems: (close) => [
|
|
93
|
+
React.createElement(MenuItem, { key: 0, onClick: () => {
|
|
94
|
+
setSelectedReport(report);
|
|
95
|
+
setReportsView(ReportsView.MODIFYING);
|
|
96
|
+
}, icon: React.createElement(SvgEdit, null) }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Modify")),
|
|
97
|
+
React.createElement(MenuItem, { key: 1, onClick: () => {
|
|
98
|
+
setSelectedReport(report);
|
|
99
|
+
setShowDeleteModal(true);
|
|
100
|
+
close();
|
|
101
|
+
}, icon: React.createElement(SvgDelete, null) }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Remove")),
|
|
102
|
+
] },
|
|
103
|
+
React.createElement(IconButton, { styleType: "borderless" },
|
|
104
|
+
React.createElement(SvgMore, { style: {
|
|
105
|
+
width: "16px",
|
|
106
|
+
height: "16px",
|
|
107
|
+
} }))) }));
|
|
108
|
+
})))),
|
|
109
|
+
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 () => {
|
|
110
|
+
var _a;
|
|
111
|
+
const reportingClientApi = new ReportingClient(generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl));
|
|
112
|
+
const accessToken = await apiConfig.getAccessToken();
|
|
113
|
+
await reportingClientApi.deleteReport(accessToken, (_a = selectedReport === null || selectedReport === void 0 ? void 0 : selectedReport.id) !== null && _a !== void 0 ? _a : "");
|
|
114
|
+
}, refresh: refresh })));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=Reports.js.map
|
|
@@ -0,0 +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,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,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,gBAAgB,CAAC;AACxB,OAA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A,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 SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Surface,\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, ReportingClient } from \"@itwin/insights-client\";\nimport ReportAction from \"./ReportAction\";\nimport { ReportMappings } from \"./ReportMappings\";\nimport { HorizontalTile } from \"./HorizontalTile\";\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\";\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 reportingClientApi = new ReportingClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const accessToken = await apiContext.getAccessToken();\n const reports = await reportingClientApi.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 iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const apiConfig = useReportsApiConfig();\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\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 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} goBack={refresh} />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ITwinReports\"\n )}\n />\n <Surface className=\"reports-list-container\">\n <div className=\"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 <div className=\"search-bar-container\" data-testid=\"search-bar\">\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\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=\"reports-list\">\n {filteredReports.map((report) => (\n <HorizontalTile\n key={report.id}\n title={report.displayName ?? \"\"}\n subText={report.description ?? \"\"}\n subtextToolTip={report.description ?? \"\"}\n titleTooltip={report.displayName}\n onClickTitle={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.REPORTSMAPPING);\n }}\n button={\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.MODIFYING);\n }}\n icon={<SvgEdit />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Modify\"\n )}\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedReport(report);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Remove\"\n )}\n </MenuItem>,\n ]}\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n }\n />\n ))}\n </div>\n )}\n </Surface>\n <DeleteModal\n entityName={selectedReport?.displayName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const reportingClientApi = new ReportingClient(\n generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)\n );\n const accessToken = await apiConfig.getAccessToken();\n await reportingClientApi.deleteReport(\n accessToken,\n selectedReport?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
|
|
7
|
+
.reports-list-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
padding: $iui-baseline $iui-m;
|
|
12
|
+
min-height: 0;
|
|
13
|
+
|
|
14
|
+
.toolbar {
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
gap: $iui-s;
|
|
18
|
+
border-bottom: 1px solid var(--iui-color-background-4);
|
|
19
|
+
padding-bottom: $iui-baseline;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.search-bar-container {
|
|
24
|
+
flex-basis: $iui-3xl;
|
|
25
|
+
flex-shrink: 1;
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.reports-list {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
overflow-y: overlay;
|
|
33
|
+
gap: 7.5px;
|
|
34
|
+
margin-top: 7.5px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
3
|
+
import "./ReportsContainer.scss";
|
|
4
|
+
interface ReportsContainerProps {
|
|
5
|
+
getAccessToken?: () => Promise<AccessToken>;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
declare const ReportsContainer: ({ getAccessToken, baseUrl, }: ReportsContainerProps) => JSX.Element;
|
|
9
|
+
export default ReportsContainer;
|
|
10
|
+
//# sourceMappingURL=ReportsContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsContainer.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD,OAAO,yBAAyB,CAAC;AAEjC,UAAU,qBAAqB;IAC7B,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,gBAAgB,iCAGnB,qBAAqB,gBAcvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IModelApp } from "@itwin/core-frontend";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Reports } from "../components/Reports";
|
|
4
|
+
import { ReportsApiConfigContext } from "../context/ReportsApiConfigContext";
|
|
5
|
+
import "./ReportsContainer.scss";
|
|
6
|
+
const ReportsContainer = ({ getAccessToken, baseUrl, }) => (React.createElement(ReportsApiConfigContext.Provider, { value: {
|
|
7
|
+
getAccessToken: getAccessToken !== null && getAccessToken !== void 0 ? getAccessToken : (async () => { var _a, _b; return (_b = (await ((_a = IModelApp.authorizationClient) === null || _a === void 0 ? void 0 : _a.getAccessToken()))) !== null && _b !== void 0 ? _b : ""; }),
|
|
8
|
+
baseUrl,
|
|
9
|
+
} },
|
|
10
|
+
React.createElement("div", { className: "reports-container" },
|
|
11
|
+
React.createElement(Reports, null))));
|
|
12
|
+
export default ReportsContainer;
|
|
13
|
+
//# sourceMappingURL=ReportsContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsContainer.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,yBAAyB,CAAC;AAOjC,MAAM,gBAAgB,GAAG,CAAC,EACxB,cAAc,EACd,OAAO,GACe,EAAE,EAAE,CAAC,CAC3B,oBAAC,uBAAuB,CAAC,QAAQ,IAC/B,KAAK,EAAE;QACL,cAAc,EACZ,cAAc,aAAd,cAAc,cAAd,cAAc,GACd,CAAC,KAAK,IAAI,EAAE,eACV,OAAA,MAAA,CAAC,MAAM,CAAA,MAAA,SAAS,CAAC,mBAAmB,0CAAE,cAAc,EAAE,CAAA,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC;QAClE,OAAO;KACR;IAED,6BAAK,SAAS,EAAC,mBAAmB;QAChC,oBAAC,OAAO,OAAG,CACP,CAC2B,CACpC,CAAC;AAEF,eAAe,gBAAgB,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 { AccessToken } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport * as React from \"react\";\nimport { Reports } from \"../components/Reports\";\nimport { ReportsApiConfigContext } from \"../context/ReportsApiConfigContext\";\nimport \"./ReportsContainer.scss\";\n\ninterface ReportsContainerProps {\n getAccessToken?: () => Promise<AccessToken>;\n baseUrl: string;\n}\n\nconst ReportsContainer = ({\n getAccessToken,\n baseUrl,\n}: ReportsContainerProps) => (\n <ReportsApiConfigContext.Provider\n value={{\n getAccessToken:\n getAccessToken ??\n (async () =>\n (await IModelApp.authorizationClient?.getAccessToken()) ?? \"\"),\n baseUrl,\n }}\n >\n <div className=\"reports-container\">\n <Reports />\n </div>\n </ReportsApiConfigContext.Provider>\n);\n\nexport default ReportsContainer;\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
|
|
7
|
+
.reports-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
padding: $iui-baseline $iui-m;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
height: 100%;
|
|
13
|
+
overflow: auto;
|
|
14
|
+
gap: $iui-baseline;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./SearchBar.scss";
|
|
3
|
+
interface SearchBarProps {
|
|
4
|
+
searchValue: string;
|
|
5
|
+
setSearchValue: React.Dispatch<React.SetStateAction<string>>;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const SearchBar: ({ searchValue, setSearchValue, disabled, }: SearchBarProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=SearchBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/SearchBar.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,kBAAkB,CAAC;AAE1B,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,+CAInB,cAAc,gBAyChB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { SvgCloseSmall, SvgSearch } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { IconButton, LabeledInput } from "@itwin/itwinui-react";
|
|
7
|
+
import React, { useState } from "react";
|
|
8
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
9
|
+
import "./SearchBar.scss";
|
|
10
|
+
export const SearchBar = ({ searchValue, setSearchValue, disabled, }) => {
|
|
11
|
+
const [searchBarOpen, setSearchBarOpened] = useState(false);
|
|
12
|
+
const [searchBarClosing, setSearchBarClosing] = useState(false);
|
|
13
|
+
return searchBarOpen || searchValue ? (React.createElement("div", { style: {
|
|
14
|
+
animation: searchBarClosing ? "rcw-shrink .5s" : "rcw-expand .5s",
|
|
15
|
+
}, onAnimationEnd: () => {
|
|
16
|
+
if (searchBarClosing) {
|
|
17
|
+
setSearchBarClosing(false);
|
|
18
|
+
setSearchBarOpened(false);
|
|
19
|
+
setSearchValue("");
|
|
20
|
+
}
|
|
21
|
+
} },
|
|
22
|
+
React.createElement(LabeledInput, { "aria-label": "search-textbox", placeholder: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Search"), svgIcon: React.createElement(IconButton, { onClick: () => setSearchBarClosing(true), styleType: "borderless" },
|
|
23
|
+
React.createElement(SvgCloseSmall, null)), iconDisplayStyle: "inline", value: searchValue, onChange: (e) => setSearchValue(e.target.value), disabled: disabled }),
|
|
24
|
+
" ")) : (React.createElement(IconButton, { styleType: "borderless", onClick: () => setSearchBarOpened(true) },
|
|
25
|
+
React.createElement(SvgSearch, null)));
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=SearchBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.js","sourceRoot":"","sources":["../../../../src/widget/components/SearchBar.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,kBAAkB,CAAC;AAQ1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,WAAW,EACX,cAAc,EACd,QAAQ,GACO,EAAE,EAAE;IACnB,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACrE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEzE,OAAO,aAAa,IAAI,WAAW,CAAC,CAAC,CAAC,CACpC,6BACE,KAAK,EAAE;YACL,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB;SAClE,EACD,cAAc,EAAE,GAAG,EAAE;YACnB,IAAI,gBAAgB,EAAE;gBACpB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC3B,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC1B,cAAc,CAAC,EAAE,CAAC,CAAC;aACpB;QACH,CAAC;QAED,oBAAC,YAAY,kBACA,gBAAgB,EAC3B,WAAW,EAAE,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAC9D,4BAA4B,CAC7B,EACD,OAAO,EACL,oBAAC,UAAU,IACT,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EACxC,SAAS,EAAC,YAAY;gBAEtB,oBAAC,aAAa,OAAG,CACN,EAEf,gBAAgB,EAAC,QAAQ,EACzB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,QAAQ,EAAE,QAAQ,GAClB;QAAC,GAAG,CACF,CACP,CAAC,CAAC,CAAC,CACF,oBAAC,UAAU,IAAC,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACxE,oBAAC,SAAS,OAAG,CACF,CACd,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 { SvgCloseSmall, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { IconButton, LabeledInput } from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport \"./SearchBar.scss\";\n\ninterface SearchBarProps {\n searchValue: string;\n setSearchValue: React.Dispatch<React.SetStateAction<string>>;\n disabled?: boolean;\n}\n\nexport const SearchBar = ({\n searchValue,\n setSearchValue,\n disabled,\n}: SearchBarProps) => {\n const [searchBarOpen, setSearchBarOpened] = useState<boolean>(false);\n const [searchBarClosing, setSearchBarClosing] = useState<boolean>(false);\n\n return searchBarOpen || searchValue ? (\n <div\n style={{\n animation: searchBarClosing ? \"rcw-shrink .5s\" : \"rcw-expand .5s\",\n }}\n onAnimationEnd={() => {\n if (searchBarClosing) {\n setSearchBarClosing(false);\n setSearchBarOpened(false);\n setSearchValue(\"\");\n }\n }}\n >\n <LabeledInput\n aria-label=\"search-textbox\"\n placeholder={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Search\"\n )}\n svgIcon={\n <IconButton\n onClick={() => setSearchBarClosing(true)}\n styleType=\"borderless\"\n >\n <SvgCloseSmall />\n </IconButton>\n }\n iconDisplayStyle=\"inline\"\n value={searchValue}\n onChange={(e) => setSearchValue(e.target.value)}\n disabled={disabled}\n />{\" \"}\n </div>\n ) : (\n <IconButton styleType=\"borderless\" onClick={() => setSearchBarOpened(true)}>\n <SvgSearch />\n </IconButton>\n );\n};\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
|
|
7
|
+
@keyframes rcw-expand {
|
|
8
|
+
0% {
|
|
9
|
+
opacity: 0;
|
|
10
|
+
width: 20%;
|
|
11
|
+
}
|
|
12
|
+
100% {
|
|
13
|
+
opacity: 1;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@keyframes rcw-shrink {
|
|
19
|
+
100% {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
width: 20%;
|
|
22
|
+
}
|
|
23
|
+
0% {
|
|
24
|
+
opacity: 1;
|
|
25
|
+
width: 100%;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./SelectIModel.scss";
|
|
3
|
+
interface SelectedIModelProps {
|
|
4
|
+
selectedIModelId: string;
|
|
5
|
+
setSelectedIModelId: React.Dispatch<React.SetStateAction<string>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SelectIModel: ({ selectedIModelId, setSelectedIModelId, }: SelectedIModelProps) => JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=SelectIModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectIModel.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/SelectIModel.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAI5D,OAAO,qBAAqB,CAAC;AAyB7B,UAAU,mBAAmB;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CACnE;AAED,eAAO,MAAM,YAAY,+CAGtB,mBAAmB,gBA+CrB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { useActiveIModelConnection } from "@itwin/appui-react";
|
|
6
|
+
import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
|
|
7
|
+
import { Constants, IModelsClient, toArray, } from "@itwin/imodels-client-management";
|
|
8
|
+
import { ComboBox, Label } from "@itwin/itwinui-react";
|
|
9
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
10
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
11
|
+
import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
|
|
12
|
+
import "./SelectIModel.scss";
|
|
13
|
+
import { generateUrl } from "./utils";
|
|
14
|
+
const fetchIModels = async (setiModels, iTwinId, apiContext) => {
|
|
15
|
+
const iModelClientOptions = {
|
|
16
|
+
api: { baseUrl: generateUrl(Constants.api.baseUrl, apiContext.baseUrl) },
|
|
17
|
+
};
|
|
18
|
+
const iModelsClient = new IModelsClient(iModelClientOptions);
|
|
19
|
+
const accessToken = await apiContext.getAccessToken();
|
|
20
|
+
const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);
|
|
21
|
+
const getiModelListParams = {
|
|
22
|
+
urlParams: { projectId: iTwinId },
|
|
23
|
+
authorization,
|
|
24
|
+
};
|
|
25
|
+
const iModels = await toArray(iModelsClient.iModels.getMinimalList(getiModelListParams));
|
|
26
|
+
setiModels(iModels);
|
|
27
|
+
};
|
|
28
|
+
export const SelectIModel = ({ selectedIModelId, setSelectedIModelId, }) => {
|
|
29
|
+
var _a, _b, _c, _d;
|
|
30
|
+
const apiConfig = useReportsApiConfig();
|
|
31
|
+
const iModelId = (_b = (_a = useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iModelId) !== null && _b !== void 0 ? _b : "";
|
|
32
|
+
const iTwinId = (_d = (_c = useActiveIModelConnection()) === null || _c === void 0 ? void 0 : _c.iTwinId) !== null && _d !== void 0 ? _d : "";
|
|
33
|
+
const [iModels, setIModels] = useState([]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (iModelId && iTwinId) {
|
|
36
|
+
void fetchIModels(setIModels, iTwinId, apiConfig);
|
|
37
|
+
}
|
|
38
|
+
}, [apiConfig, setIModels, iModelId, iTwinId]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (iModelId && iModels.length > 0) {
|
|
41
|
+
setSelectedIModelId(iModelId);
|
|
42
|
+
}
|
|
43
|
+
}, [iModelId, iModels, setSelectedIModelId]);
|
|
44
|
+
const iModelOptions = useMemo(() => {
|
|
45
|
+
return iModels.map((iModel) => ({
|
|
46
|
+
label: iModel.displayName,
|
|
47
|
+
value: iModel.id,
|
|
48
|
+
}));
|
|
49
|
+
}, [iModels]);
|
|
50
|
+
return (React.createElement("div", { className: "reports-select-imodel" },
|
|
51
|
+
React.createElement(Label, { htmlFor: "combo-input" }, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:SelectIModel")),
|
|
52
|
+
React.createElement("div", { className: "combobox" },
|
|
53
|
+
React.createElement(ComboBox, { options: iModelOptions, value: selectedIModelId, onChange: (value) => {
|
|
54
|
+
setSelectedIModelId(value);
|
|
55
|
+
}, inputProps: {
|
|
56
|
+
id: "combo-input",
|
|
57
|
+
}, style: { flexGrow: 1, maxWidth: "395px" } }))));
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=SelectIModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectIModel.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectIModel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAMpE,OAAO,EACL,SAAS,EACT,aAAa,EACb,OAAO,GACR,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,YAAY,GAAG,KAAK,EACxB,UAAiE,EACjE,OAAe,EACf,UAA4B,EAC5B,EAAE;IACF,MAAM,mBAAmB,GAAyB;QAChD,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,GA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mB,CAAC,QAAQ,CAAC,CAAC;SAC/B;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,WAAW;YACzB,KAAK,EAAE,MAAM,CAAC,EAAE;SACjB,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,6BAAK,SAAS,EAAC,uBAAuB;QACpC,oBAAC,KAAK,IAAC,OAAO,EAAC,aAAa,IACzB,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,kCAAkC,CACnC,CACK;QACR,6BAAK,SAAS,EAAC,UAAU;YACvB,oBAAC,QAAQ,IACP,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC,EACD,UAAU,EAAE;oBACV,EAAE,EAAE,aAAa;iBAClB,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GACzC,CACE,CACF,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\nimport type {\n GetIModelListParams,\n IModelsClientOptions,\n MinimalIModel,\n} from \"@itwin/imodels-client-management\";\nimport {\n Constants,\n IModelsClient,\n toArray,\n} from \"@itwin/imodels-client-management\";\nimport { ComboBox, Label } from \"@itwin/itwinui-react\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport type { ReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { useReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport \"./SelectIModel.scss\";\nimport { generateUrl } from \"./utils\";\n\nconst fetchIModels = async (\n setiModels: React.Dispatch<React.SetStateAction<MinimalIModel[]>>,\n iTwinId: string,\n apiContext: ReportsApiConfig\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 accessToken = await apiContext.getAccessToken();\n const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);\n const getiModelListParams: GetIModelListParams = {\n urlParams: { projectId: iTwinId },\n authorization,\n };\n const iModels = await toArray(\n iModelsClient.iModels.getMinimalList(getiModelListParams)\n );\n setiModels(iModels);\n};\n\ninterface SelectedIModelProps {\n selectedIModelId: string;\n setSelectedIModelId: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport const SelectIModel = ({\n selectedIModelId,\n setSelectedIModelId,\n}: SelectedIModelProps) => {\n const apiConfig = useReportsApiConfig();\n const iModelId = useActiveIModelConnection()?.iModelId ?? \"\";\n const iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const [iModels, setIModels] = useState<MinimalIModel[]>([]);\n\n useEffect(() => {\n if (iModelId && iTwinId) {\n void fetchIModels(setIModels, iTwinId, apiConfig);\n }\n }, [apiConfig, setIModels, iModelId, iTwinId]);\n\n useEffect(() => {\n if (iModelId && iModels.length > 0) {\n setSelectedIModelId(iModelId);\n }\n }, [iModelId, iModels, setSelectedIModelId]);\n\n const iModelOptions = useMemo(() => {\n return iModels.map((iModel) => ({\n label: iModel.displayName,\n value: iModel.id,\n }));\n }, [iModels]);\n\n return (\n <div className=\"reports-select-imodel\">\n <Label htmlFor=\"combo-input\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:SelectIModel\"\n )}\n </Label>\n <div className=\"combobox\">\n <ComboBox<string>\n options={iModelOptions}\n value={selectedIModelId}\n onChange={(value) => {\n setSelectedIModelId(value);\n }}\n inputProps={{\n id: \"combo-input\",\n }}\n style={{ flexGrow: 1, maxWidth: \"395px\" }}\n />\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
|
|
7
|
+
.reports-select-imodel {
|
|
8
|
+
position: relative;
|
|
9
|
+
margin-bottom: $iui-baseline * 2;
|
|
10
|
+
.combobox {
|
|
11
|
+
display: flex;
|
|
12
|
+
gap: $iui-s;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./utils.scss";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface WidgetHeaderProps {
|
|
4
|
+
title: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
returnFn?: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeaderProps) => JSX.Element;
|
|
9
|
+
export declare const handleError: (errorStatus: number) => void;
|
|
10
|
+
export declare const LoadingOverlay: () => JSX.Element;
|
|
11
|
+
interface EmptyMessageProps {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const EmptyMessage: ({ children }: EmptyMessageProps) => JSX.Element;
|
|
15
|
+
export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElement>, values: T, setValues: React.Dispatch<React.SetStateAction<T>>) => void;
|
|
16
|
+
export declare const LoadingSpinner: () => JSX.Element;
|
|
17
|
+
export declare const SkeletonBlock: () => JSX.Element;
|
|
18
|
+
export declare const generateUrl: (baseUrl: string, newBaseUrl: string) => string;
|
|
19
|
+
export declare type CreateTypeFromInterface<Interface> = {
|
|
20
|
+
[Property in keyof Interface]: Interface[Property];
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAWA,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,YAAY,mCAItB,iBAAiB,gBAiBnB,CAAC;AAEF,eAAO,MAAM,WAAW,gBAAiB,MAAM,SAwD9C,CAAC;AAEF,eAAO,MAAM,cAAc,mBAc1B,CAAC;AACF,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AACD,eAAO,MAAM,YAAY,iBAAkB,iBAAiB,gBAE3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,SACzB,MAAM,WAAW,CAAC,gBAAgB,CAAC,wEAUvC,CAAC;AAEF,eAAO,MAAM,cAAc,mBAS1B,CAAC;AAEF,eAAO,MAAM,aAAa,mBAEzB,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,MAAM,cAAc,MAAM,WAE9D,CAAC;AAEF,oBAAY,uBAAuB,CAAC,SAAS,IAAI;KAC9C,QAAQ,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;CACnD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { SvgChevronLeft } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { IconButton, ProgressRadial, Text, toaster, } from "@itwin/itwinui-react";
|
|
7
|
+
import "./utils.scss";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
10
|
+
export const WidgetHeader = ({ title, disabled = false, returnFn, }) => {
|
|
11
|
+
return (React.createElement("div", { className: "rcw-widget-header-container" },
|
|
12
|
+
returnFn && (React.createElement(IconButton, { onClick: returnFn, disabled: disabled, styleType: "borderless" },
|
|
13
|
+
React.createElement(SvgChevronLeft, null))),
|
|
14
|
+
React.createElement(Text, { className: "title", variant: "title" }, title)));
|
|
15
|
+
};
|
|
16
|
+
export const handleError = (errorStatus) => {
|
|
17
|
+
let errorMessage = `${ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.Error")} `;
|
|
18
|
+
switch (errorStatus) {
|
|
19
|
+
case 401:
|
|
20
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.401");
|
|
21
|
+
break;
|
|
22
|
+
case 403:
|
|
23
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.403");
|
|
24
|
+
break;
|
|
25
|
+
case 404:
|
|
26
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.404");
|
|
27
|
+
break;
|
|
28
|
+
case 409:
|
|
29
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.409");
|
|
30
|
+
break;
|
|
31
|
+
case 422:
|
|
32
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.422");
|
|
33
|
+
break;
|
|
34
|
+
case 429:
|
|
35
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.429");
|
|
36
|
+
break;
|
|
37
|
+
case 500:
|
|
38
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.500");
|
|
39
|
+
break;
|
|
40
|
+
case 502:
|
|
41
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.502");
|
|
42
|
+
break;
|
|
43
|
+
case 503:
|
|
44
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.503");
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ErrorMessages.SomethingWentWrong");
|
|
48
|
+
}
|
|
49
|
+
toaster.negative(errorMessage);
|
|
50
|
+
};
|
|
51
|
+
export const LoadingOverlay = () => (React.createElement("div", { className: "rcw-center-overlay" },
|
|
52
|
+
React.createElement(Text, null, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Loading")),
|
|
53
|
+
React.createElement(ProgressRadial, { indeterminate: true }),
|
|
54
|
+
React.createElement(Text, null, ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:PleaseWait"))));
|
|
55
|
+
export const EmptyMessage = ({ children }) => {
|
|
56
|
+
return React.createElement("div", { className: "rcw-center-overlay" }, children);
|
|
57
|
+
};
|
|
58
|
+
export const handleInputChange = (e, values, setValues) => {
|
|
59
|
+
const { name, value } = e.target;
|
|
60
|
+
setValues({
|
|
61
|
+
...values,
|
|
62
|
+
[name]: value,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export const LoadingSpinner = () => {
|
|
66
|
+
return (React.createElement("div", { className: "rcw-loading-spinner", "data-testid": "rcw-action-loading-spinner" },
|
|
67
|
+
React.createElement(ProgressRadial, { size: "small", indeterminate: true })));
|
|
68
|
+
};
|
|
69
|
+
export const SkeletonBlock = () => (React.createElement("div", { className: "rcw-skeleton-block iui-skeleton" }));
|
|
70
|
+
export const generateUrl = (baseUrl, newBaseUrl) => {
|
|
71
|
+
return baseUrl.replace("https://api.bentley.com", newBaseUrl);
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,cAAc,EACd,IAAI,EACJ,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQhE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,QAAQ,GACU,EAAE,EAAE;IACtB,OAAO,CACL,6BAAK,SAAS,EAAC,6BAA6B;QACzC,QAAQ,IAAI,CACX,oBAAC,UAAU,IACT,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAC,YAAY;YAEtB,oBAAC,cAAc,OAAG,CACP,CACd;QACD,oBAAC,IAAI,IAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,IACpC,KAAK,CACD,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAE,EAAE;IACjD,IAAI,YAAY,GAAG,GAAG,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CACvE,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,EAAC,oBAAoB;IACjC,oBAAC,IAAI,QACF,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,6BAA6B,CAC9B,CACI;IACP,oBAAC,cAAc,IAAC,aAAa,SAAG;IAChC,oBAAC,IAAI,QACF,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,gCAAgC,CACjC,CACI,CACH,CACP,CAAC;AAIF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAqB,EAAE,EAAE;IAC9D,OAAO,6BAAK,SAAS,EAAC,oBAAoB,IAAE,QAAQ,CAAO,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,CAAsC,EACtC,MAAS,EACT,SAAkD,EAClD,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;IAEjC,SAAS,CAAC;QACR,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,6BACE,SAAS,EAAC,qBAAqB,iBACnB,4BAA4B;QAExC,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CACjC,6BAAK,SAAS,EAAC,iCAAiC,GAAG,CACpD,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAChE,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 { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport {\n IconButton,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => Promise<void>;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className=\"rcw-widget-header-container\">\n {returnFn && (\n <IconButton\n onClick={returnFn}\n disabled={disabled}\n styleType=\"borderless\"\n >\n <SvgChevronLeft />\n </IconButton>\n )}\n <Text className=\"title\" variant=\"title\">\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = `${ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.Error\"\n )} `;\n switch (errorStatus) {\n case 401:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.401\"\n );\n break;\n case 403:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.403\"\n );\n break;\n case 404:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.404\"\n );\n break;\n case 409:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.409\"\n );\n break;\n case 422:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.422\"\n );\n break;\n case 429:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.429\"\n );\n break;\n case 500:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.500\"\n );\n break;\n case 502:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.502\"\n );\n break;\n case 503:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.503\"\n );\n break;\n default:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.SomethingWentWrong\"\n );\n }\n toaster.negative(errorMessage);\n};\n\nexport const LoadingOverlay = () => (\n <div className=\"rcw-center-overlay\">\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Loading\"\n )}\n </Text>\n <ProgressRadial indeterminate />\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:PleaseWait\"\n )}\n </Text>\n </div>\n);\ninterface EmptyMessageProps {\n children?: React.ReactNode;\n}\nexport const EmptyMessage = ({ children }: EmptyMessageProps) => {\n return <div className=\"rcw-center-overlay\">{children}</div>;\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const LoadingSpinner = () => {\n return (\n <div\n className=\"rcw-loading-spinner\"\n data-testid=\"rcw-action-loading-spinner\"\n >\n <ProgressRadial size=\"small\" indeterminate />\n </div>\n );\n};\n\nexport const SkeletonBlock = () => (\n <div className=\"rcw-skeleton-block iui-skeleton\" />\n);\n\nexport const generateUrl = (baseUrl: string, newBaseUrl: string) => {\n return baseUrl.replace(\"https://api.bentley.com\", newBaseUrl);\n};\n\nexport type CreateTypeFromInterface<Interface> = {\n [Property in keyof Interface]: Interface[Property];\n};\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
@import "~@itwin/itwinui-css/scss/icon/index";
|
|
7
|
+
@import "~@itwin/itwinui-css/scss/button/index";
|
|
8
|
+
|
|
9
|
+
.rcw-widget-header-container {
|
|
10
|
+
display: flex;
|
|
11
|
+
margin-bottom: $iui-baseline;
|
|
12
|
+
align-items: center;
|
|
13
|
+
|
|
14
|
+
.title {
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
margin-bottom: 3px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.rcw-loading-spinner {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.rcw-center-overlay {
|
|
28
|
+
display: flex;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
align-items: center;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: $iui-baseline;
|
|
33
|
+
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.rcw-skeleton-block {
|
|
37
|
+
height: $iui-baseline * 3;
|
|
38
|
+
width: 100%;
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface ReportsApiConfig {
|
|
4
|
+
getAccessToken: () => Promise<AccessToken>;
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ReportsApiConfigContext: React.Context<ReportsApiConfig>;
|
|
8
|
+
export declare const useReportsApiConfig: () => ReportsApiConfig;
|
|
9
|
+
//# sourceMappingURL=ReportsApiConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsApiConfigContext.d.ts","sourceRoot":"","sources":["../../../../src/widget/context/ReportsApiConfigContext.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,uBAAuB,iCAGlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,wBAQ/B,CAAC"}
|