@terrestris/shogun-admin 16.1.0-next.1 → 17.0.0-next.10
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/README.md +4 -0
- package/package.json +116 -107
- package/dist/build/assets/App-BP74CNP_.js +0 -1258
- package/dist/build/assets/__federation_shared_react-CvClEUjg.js +0 -9
- package/dist/build/assets/__federation_shared_react-dom-BxqGBSTk.js +0 -24
- package/dist/build/assets/__federation_shared_react-i18next-MD_bYxcL.js +0 -1
- package/dist/build/assets/__federation_shared_react-router-dom-Vy7O6TNk.js +0 -2
- package/dist/build/assets/_commonjsHelpers-BosuxZz1.js +0 -1
- package/dist/build/assets/_virtual___federation_fn_import-PJHfB1tr.js +0 -1
- package/dist/build/assets/abap-DRC6TkPh.js +0 -6
- package/dist/build/assets/apex-BuapDI9Y.js +0 -6
- package/dist/build/assets/azcli-BypH-vXm.js +0 -6
- package/dist/build/assets/bat-BY6pwuIY.js +0 -6
- package/dist/build/assets/bicep-gRuQeaLk.js +0 -7
- package/dist/build/assets/cameligo-ul-Lp4lw.js +0 -6
- package/dist/build/assets/clojure-DeYg-96x.js +0 -6
- package/dist/build/assets/codicon-DCmgc-ay.ttf +0 -0
- package/dist/build/assets/coffee-CfnpWUYo.js +0 -6
- package/dist/build/assets/cpp-C9L3yaDO.js +0 -6
- package/dist/build/assets/csharp-DWGz5Zuj.js +0 -6
- package/dist/build/assets/csp-DrRCxMg5.js +0 -6
- package/dist/build/assets/css-BfLuTCmN.js +0 -8
- package/dist/build/assets/css.worker-BAJD-bzR.js +0 -83
- package/dist/build/assets/cssMode-Btzqpc23.js +0 -4
- package/dist/build/assets/cypher-DoFvH58O.js +0 -6
- package/dist/build/assets/dart-DIovg4uR.js +0 -6
- package/dist/build/assets/dockerfile-D2PfwrvU.js +0 -6
- package/dist/build/assets/ecl-C_scCXcs.js +0 -6
- package/dist/build/assets/editor.worker-MnaSPjGA.js +0 -11
- package/dist/build/assets/elixir-BRk-K-rg.js +0 -6
- package/dist/build/assets/favicon-CwZoocDV.ico +0 -0
- package/dist/build/assets/flow9-DLs3tTet.js +0 -6
- package/dist/build/assets/freemarker2-CoZuEXJi.js +0 -3
- package/dist/build/assets/fsharp-D0UiDa5C.js +0 -6
- package/dist/build/assets/go-CyVeKkvQ.js +0 -6
- package/dist/build/assets/graphql-BygKL3ZF.js +0 -6
- package/dist/build/assets/handlebars-BQ2vXFqT.js +0 -1
- package/dist/build/assets/hcl-D_OY6ada.js +0 -6
- package/dist/build/assets/html-S9BExIX4.js +0 -1
- package/dist/build/assets/html.worker-Bp7pNElH.js +0 -460
- package/dist/build/assets/htmlMode-D6oh_W-n.js +0 -4
- package/dist/build/assets/index-D5X_Cuhy.js +0 -139
- package/dist/build/assets/ini-BTpWsGps.js +0 -6
- package/dist/build/assets/java-3TATJI7h.js +0 -6
- package/dist/build/assets/javascript-C_BsKwTq.js +0 -1
- package/dist/build/assets/json.worker-BfIkrIax.js +0 -48
- package/dist/build/assets/jsonMode-CFQnTUoH.js +0 -10
- package/dist/build/assets/julia-DDpSJMW6.js +0 -6
- package/dist/build/assets/kotlin-DVYH6Lj_.js +0 -6
- package/dist/build/assets/less-CuFlys0T.js +0 -7
- package/dist/build/assets/lexon-m09vb5r-.js +0 -6
- package/dist/build/assets/liquid-CsJvQ-Gd.js +0 -1
- package/dist/build/assets/lua-D2Z7JJdl.js +0 -6
- package/dist/build/assets/m3-B2Cf9XSq.js +0 -6
- package/dist/build/assets/markdown-BXYnMxBe.js +0 -6
- package/dist/build/assets/mdx-CcsV6KQM.js +0 -1
- package/dist/build/assets/mips-Ckkbw-AO.js +0 -6
- package/dist/build/assets/msdax-B5uW3Zvf.js +0 -6
- package/dist/build/assets/mysql-B8ssZoUh.js +0 -6
- package/dist/build/assets/objective-c-CrrKwR0a.js +0 -6
- package/dist/build/assets/pascal-BWBTHuhh.js +0 -6
- package/dist/build/assets/pascaligo-BGLI1Hdo.js +0 -6
- package/dist/build/assets/perl-DDrv2Hr-.js +0 -6
- package/dist/build/assets/pgsql-DLPipH_Q.js +0 -6
- package/dist/build/assets/php-CTNlIIiR.js +0 -6
- package/dist/build/assets/pla-2oJWbEOo.js +0 -6
- package/dist/build/assets/postiats-DOk3G3cc.js +0 -6
- package/dist/build/assets/powerquery-Dgyr3wWZ.js +0 -6
- package/dist/build/assets/powershell-B_i9asfM.js +0 -6
- package/dist/build/assets/protobuf-CV9EbfTh.js +0 -7
- package/dist/build/assets/pug-CCBS_C5_.js +0 -6
- package/dist/build/assets/python-BNsLUA-F.js +0 -1
- package/dist/build/assets/qsharp-BLuZWbUW.js +0 -6
- package/dist/build/assets/r-CzF1MCbP.js +0 -6
- package/dist/build/assets/razor-CwLyy1uA.js +0 -1
- package/dist/build/assets/redis-C75U4IDy.js +0 -6
- package/dist/build/assets/redshift-Bc5xkKR1.js +0 -6
- package/dist/build/assets/restructuredtext-DmdQbaLT.js +0 -6
- package/dist/build/assets/ruby-DB0RB20n.js +0 -6
- package/dist/build/assets/rust-UMmp-gVE.js +0 -6
- package/dist/build/assets/sb-DVG02705.js +0 -6
- package/dist/build/assets/scala-DvSxYeG4.js +0 -6
- package/dist/build/assets/scheme-yf5bffbF.js +0 -6
- package/dist/build/assets/scss-Bzb7OGdO.js +0 -8
- package/dist/build/assets/shell-FNqbgIOG.js +0 -6
- package/dist/build/assets/shogun-spinner-BmOUi9Ar.gif +0 -0
- package/dist/build/assets/shogun_logo-B9ohJOpL.png +0 -0
- package/dist/build/assets/solidity-DyKutqhl.js +0 -6
- package/dist/build/assets/sophia-B4VqtPa2.js +0 -6
- package/dist/build/assets/sparql-B7alP455.js +0 -6
- package/dist/build/assets/sql-D7lU1fdU.js +0 -6
- package/dist/build/assets/st-VuadG5SK.js +0 -6
- package/dist/build/assets/style-CJpWC7V3.css +0 -1
- package/dist/build/assets/swift-BYtUz8ZP.js +0 -8
- package/dist/build/assets/systemverilog-DOAuugfS.js +0 -6
- package/dist/build/assets/tcl-CXKOl_mN.js +0 -6
- package/dist/build/assets/ts.worker-BBBnYv8q.js +0 -51333
- package/dist/build/assets/tsMode-meseu6bK.js +0 -11
- package/dist/build/assets/twig-D9yiNO04.js +0 -6
- package/dist/build/assets/typescript-BuOvk1sq.js +0 -1
- package/dist/build/assets/typespec-BupSXVCO.js +0 -6
- package/dist/build/assets/vb-ZlaFEk-P.js +0 -6
- package/dist/build/assets/wgsl-DrbANKle.js +0 -303
- package/dist/build/assets/xml-BXx9C-xA.js +0 -1
- package/dist/build/assets/yaml-CuMedh6B.js +0 -1
- package/dist/build/index.html +0 -24
- package/dist/lib/App.d.ts +0 -4
- package/dist/lib/App.js +0 -122
- package/dist/lib/Component/Dashboard/Dashboard.d.ts +0 -12
- package/dist/lib/Component/Dashboard/Dashboard.js +0 -10
- package/dist/lib/Component/Dashboard/DashboardCard/DashboardCard.d.ts +0 -13
- package/dist/lib/Component/Dashboard/DashboardCard/DashboardCard.js +0 -7
- package/dist/lib/Component/Dashboard/DashboardStatistics/DashboardStatistics.d.ts +0 -15
- package/dist/lib/Component/Dashboard/DashboardStatistics/DashboardStatistics.js +0 -30
- package/dist/lib/Component/EvictCache/EvictCache.d.ts +0 -6
- package/dist/lib/Component/EvictCache/EvictCache.js +0 -28
- package/dist/lib/Component/FormField/DisplayField/DisplayField.d.ts +0 -13
- package/dist/lib/Component/FormField/DisplayField/DisplayField.js +0 -32
- package/dist/lib/Component/FormField/JSONEditor/JSONEditor.d.ts +0 -13
- package/dist/lib/Component/FormField/JSONEditor/JSONEditor.js +0 -90
- package/dist/lib/Component/FormField/JSONEditor/UserWorker.d.ts +0 -1
- package/dist/lib/Component/FormField/JSONEditor/UserWorker.js +0 -26
- package/dist/lib/Component/FormField/LinkField/LinkField.d.ts +0 -11
- package/dist/lib/Component/FormField/LinkField/LinkField.js +0 -15
- package/dist/lib/Component/FormField/MarkdownEditor/MarkdownEditor.d.ts +0 -10
- package/dist/lib/Component/FormField/MarkdownEditor/MarkdownEditor.js +0 -23
- package/dist/lib/Component/FormField/Permission/GroupPermissionGrid/GroupPermissionGrid.d.ts +0 -7
- package/dist/lib/Component/FormField/Permission/GroupPermissionGrid/GroupPermissionGrid.js +0 -73
- package/dist/lib/Component/FormField/Permission/InstancePermissionGrid/InstancePermissionGrid.d.ts +0 -30
- package/dist/lib/Component/FormField/Permission/InstancePermissionGrid/InstancePermissionGrid.js +0 -151
- package/dist/lib/Component/FormField/Permission/PermissionModal/PermissionModal.d.ts +0 -28
- package/dist/lib/Component/FormField/Permission/PermissionModal/PermissionModal.js +0 -103
- package/dist/lib/Component/FormField/Permission/PermissionSelect/PermissionSelect.d.ts +0 -6
- package/dist/lib/Component/FormField/Permission/PermissionSelect/PermissionSelect.js +0 -21
- package/dist/lib/Component/FormField/Permission/RolePermissionGrid/RolePermissionGrid.d.ts +0 -7
- package/dist/lib/Component/FormField/Permission/RolePermissionGrid/RolePermissionGrid.js +0 -81
- package/dist/lib/Component/FormField/Permission/UserPermissionGrid/UserPermissionGrid.d.ts +0 -8
- package/dist/lib/Component/FormField/Permission/UserPermissionGrid/UserPermissionGrid.js +0 -87
- package/dist/lib/Component/FormField/VerifyProviderDetailsField/VerifyProviderDetailsField.d.ts +0 -13
- package/dist/lib/Component/FormField/VerifyProviderDetailsField/VerifyProviderDetailsField.js +0 -14
- package/dist/lib/Component/FormField/YesOrNoField/YesOrNoField.d.ts +0 -8
- package/dist/lib/Component/FormField/YesOrNoField/YesOrNoField.js +0 -10
- package/dist/lib/Component/FullscreenWrapper/FullscreenWrapper.d.ts +0 -4
- package/dist/lib/Component/FullscreenWrapper/FullscreenWrapper.js +0 -48
- package/dist/lib/Component/GeneralEntity/GeneralEntityForm/GeneralEntityForm.d.ts +0 -43
- package/dist/lib/Component/GeneralEntity/GeneralEntityForm/GeneralEntityForm.js +0 -145
- package/dist/lib/Component/GeneralEntity/GeneralEntityRoot/GeneralEntityRoot.d.ts +0 -22
- package/dist/lib/Component/GeneralEntity/GeneralEntityRoot/GeneralEntityRoot.js +0 -527
- package/dist/lib/Component/GeneralEntity/GeneralEntityTable/GeneralEntityTable.d.ts +0 -46
- package/dist/lib/Component/GeneralEntity/GeneralEntityTable/GeneralEntityTable.js +0 -179
- package/dist/lib/Component/GlobalSettings/GlobalSettingsRoot/GlobalSettingsRoot.d.ts +0 -5
- package/dist/lib/Component/GlobalSettings/GlobalSettingsRoot/GlobalSettingsRoot.js +0 -15
- package/dist/lib/Component/Header/Header.d.ts +0 -8
- package/dist/lib/Component/Header/Header.js +0 -16
- package/dist/lib/Component/ImageFile/ImageFileForm/ImageFileForm.d.ts +0 -7
- package/dist/lib/Component/ImageFile/ImageFileForm/ImageFileForm.js +0 -94
- package/dist/lib/Component/ImageFile/ImageFileRoot/ImageFileRoot.d.ts +0 -7
- package/dist/lib/Component/ImageFile/ImageFileRoot/ImageFileRoot.js +0 -44
- package/dist/lib/Component/ImageFile/ImageFileTable/ImageFileTable.d.ts +0 -9
- package/dist/lib/Component/ImageFile/ImageFileTable/ImageFileTable.js +0 -157
- package/dist/lib/Component/LanguageSelector/index.d.ts +0 -4
- package/dist/lib/Component/LanguageSelector/index.js +0 -15
- package/dist/lib/Component/Layer/LayerTypeSelect/LayerTypeSelect.d.ts +0 -11
- package/dist/lib/Component/Layer/LayerTypeSelect/LayerTypeSelect.js +0 -33
- package/dist/lib/Component/LayerPreview/LayerPreview.d.ts +0 -9
- package/dist/lib/Component/LayerPreview/LayerPreview.js +0 -159
- package/dist/lib/Component/LayerPreview/MapComponent/MapComponent.d.ts +0 -10
- package/dist/lib/Component/LayerPreview/MapComponent/MapComponent.js +0 -22
- package/dist/lib/Component/LogSettings/LogLevelSelect/LogLevelSelect.d.ts +0 -7
- package/dist/lib/Component/LogSettings/LogLevelSelect/LogLevelSelect.js +0 -20
- package/dist/lib/Component/LogSettings/LogLevelTable/LogLevelTable.d.ts +0 -12
- package/dist/lib/Component/LogSettings/LogLevelTable/LogLevelTable.js +0 -73
- package/dist/lib/Component/LogSettings/LogSettingsRoot/LogSettingsRoot.d.ts +0 -4
- package/dist/lib/Component/LogSettings/LogSettingsRoot/LogSettingsRoot.js +0 -11
- package/dist/lib/Component/Logs/Logs.d.ts +0 -5
- package/dist/lib/Component/Logs/Logs.js +0 -58
- package/dist/lib/Component/Menu/Navigation/Navigation.d.ts +0 -10
- package/dist/lib/Component/Menu/Navigation/Navigation.js +0 -96
- package/dist/lib/Component/Menu/User/User.d.ts +0 -7
- package/dist/lib/Component/Menu/User/User.js +0 -91
- package/dist/lib/Component/Metrics/JdbcConnectionsActive/JdbcConnectionsActive.d.ts +0 -6
- package/dist/lib/Component/Metrics/JdbcConnectionsActive/JdbcConnectionsActive.js +0 -7
- package/dist/lib/Component/Metrics/JvmMemoryUsed/JvmMemoryUsed.d.ts +0 -6
- package/dist/lib/Component/Metrics/JvmMemoryUsed/JvmMemoryUsed.js +0 -13
- package/dist/lib/Component/Metrics/JvmThreadsLive/JvmThreadsLive.d.ts +0 -6
- package/dist/lib/Component/Metrics/JvmThreadsLive/JvmThreadsLive.js +0 -7
- package/dist/lib/Component/Metrics/MetricEntry/MetricEntry.d.ts +0 -13
- package/dist/lib/Component/Metrics/MetricEntry/MetricEntry.js +0 -54
- package/dist/lib/Component/Metrics/MetricsRoot/MetricsRoot.d.ts +0 -12
- package/dist/lib/Component/Metrics/MetricsRoot/MetricsRoot.js +0 -28
- package/dist/lib/Component/Metrics/ProcessCpuUsage/ProcessCpuUsage.d.ts +0 -6
- package/dist/lib/Component/Metrics/ProcessCpuUsage/ProcessCpuUsage.js +0 -7
- package/dist/lib/Component/Metrics/ProcessStartTime/ProcessStartTime.d.ts +0 -6
- package/dist/lib/Component/Metrics/ProcessStartTime/ProcessStartTime.js +0 -12
- package/dist/lib/Component/Metrics/ProcessUptime/ProcessUptime.d.ts +0 -6
- package/dist/lib/Component/Metrics/ProcessUptime/ProcessUptime.js +0 -15
- package/dist/lib/Component/Metrics/SystemCpuCount/SystemCpuCount.d.ts +0 -6
- package/dist/lib/Component/Metrics/SystemCpuCount/SystemCpuCount.js +0 -7
- package/dist/lib/Component/Metrics/SystemCpuUsage/SystemCpuUsage.d.ts +0 -6
- package/dist/lib/Component/Metrics/SystemCpuUsage/SystemCpuUsage.js +0 -7
- package/dist/lib/Component/Metrics/SystemLoadAverage/SystemLoadAverage.d.ts +0 -6
- package/dist/lib/Component/Metrics/SystemLoadAverage/SystemLoadAverage.js +0 -7
- package/dist/lib/Component/Modal/ApplicationInfo/ApplicationInfo.d.ts +0 -7
- package/dist/lib/Component/Modal/ApplicationInfo/ApplicationInfo.js +0 -18
- package/dist/lib/Component/ShogunSpinner/ShogunSpinner.d.ts +0 -5
- package/dist/lib/Component/ShogunSpinner/ShogunSpinner.js +0 -7
- package/dist/lib/Component/UserAvatar/UserAvatar.d.ts +0 -9
- package/dist/lib/Component/UserAvatar/UserAvatar.js +0 -13
- package/dist/lib/Component/WelcomeDashboard/WelcomeDashboard.d.ts +0 -5
- package/dist/lib/Component/WelcomeDashboard/WelcomeDashboard.js +0 -35
- package/dist/lib/Context/PluginContext.d.ts +0 -9
- package/dist/lib/Context/PluginContext.js +0 -7
- package/dist/lib/Context/SHOGunAPIClientContext.d.ts +0 -9
- package/dist/lib/Context/SHOGunAPIClientContext.js +0 -7
- package/dist/lib/Controller/ControllerUtil.d.ts +0 -27
- package/dist/lib/Controller/ControllerUtil.js +0 -60
- package/dist/lib/Controller/GenericEntityController.d.ts +0 -169
- package/dist/lib/Controller/GenericEntityController.js +0 -368
- package/dist/lib/Hooks/useClientVersion.d.ts +0 -1
- package/dist/lib/Hooks/useClientVersion.js +0 -3
- package/dist/lib/Hooks/usePlugins.d.ts +0 -3
- package/dist/lib/Hooks/usePlugins.js +0 -6
- package/dist/lib/Hooks/useSHOGunAPIClient.d.ts +0 -3
- package/dist/lib/Hooks/useSHOGunAPIClient.js +0 -6
- package/dist/lib/Logger.d.ts +0 -2
- package/dist/lib/Logger.js +0 -23
- package/dist/lib/Page/Portal/Portal.d.ts +0 -7
- package/dist/lib/Page/Portal/Portal.js +0 -74
- package/dist/lib/Service/GenericServiceImpl/GenericServiceImpl.d.ts +0 -5
- package/dist/lib/Service/GenericServiceImpl/GenericServiceImpl.js +0 -7
- package/dist/lib/Service/LogService/LogService.d.ts +0 -18
- package/dist/lib/Service/LogService/LogService.js +0 -79
- package/dist/lib/Service/MetricService/MetricService.d.ts +0 -26
- package/dist/lib/Service/MetricService/MetricService.js +0 -25
- package/dist/lib/State/atoms.d.ts +0 -7
- package/dist/lib/State/atoms.js +0 -25
- package/dist/lib/State/static.d.ts +0 -3
- package/dist/lib/State/static.js +0 -10
- package/dist/lib/Util/FileUtil.d.ts +0 -3
- package/dist/lib/Util/FileUtil.js +0 -10
- package/dist/lib/Util/JsonUtil.d.ts +0 -11
- package/dist/lib/Util/JsonUtil.js +0 -22
- package/dist/lib/Util/OpenAPIUtil.d.ts +0 -25
- package/dist/lib/Util/OpenAPIUtil.js +0 -230
- package/dist/lib/Util/TableUtil.d.ts +0 -14
- package/dist/lib/Util/TableUtil.js +0 -71
- package/dist/lib/Util/TranslationUtil.d.ts +0 -3
- package/dist/lib/Util/TranslationUtil.js +0 -23
- package/dist/lib/Util/UserUtil.d.ts +0 -22
- package/dist/lib/Util/UserUtil.js +0 -32
- package/dist/lib/i18n/index.d.ts +0 -2
- package/dist/lib/i18n/index.js +0 -17
- package/dist/lib/i18n/translations.d.ts +0 -508
- package/dist/lib/i18n/translations.js +0 -512
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -172
- package/dist/lib/plugin/index.d.ts +0 -58
- package/dist/lib/plugin/index.js +0 -3
- package/dist/lib/test-util.d.ts +0 -6
- package/dist/lib/test-util.js +0 -16
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import './GeneralEntityRoot.less';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import BaseEntity from '@terrestris/shogun-util/dist/model/BaseEntity';
|
|
4
|
-
import { FormConfig } from '../GeneralEntityForm/GeneralEntityForm';
|
|
5
|
-
import { TableConfig } from '../GeneralEntityTable/GeneralEntityTable';
|
|
6
|
-
export type GeneralEntityConfigType<T extends BaseEntity> = {
|
|
7
|
-
i18n: FormTranslations;
|
|
8
|
-
endpoint: string;
|
|
9
|
-
entityType: string;
|
|
10
|
-
defaultSortField?: string;
|
|
11
|
-
entityName?: string;
|
|
12
|
-
navigationTitle?: string;
|
|
13
|
-
subTitle?: string;
|
|
14
|
-
formConfig: FormConfig;
|
|
15
|
-
tableConfig: TableConfig<T>;
|
|
16
|
-
onEntitiesLoaded?: (entities: T[], entityType: string) => void;
|
|
17
|
-
defaultEntity?: T;
|
|
18
|
-
};
|
|
19
|
-
type OwnProps<T extends BaseEntity> = GeneralEntityConfigType<T>;
|
|
20
|
-
export type GeneralEntityRootProps<T extends BaseEntity> = OwnProps<T> & React.HTMLAttributes<HTMLDivElement>;
|
|
21
|
-
export declare function GeneralEntityRoot<T extends BaseEntity>({ i18n, endpoint, entityType, defaultSortField, entityName, navigationTitle, subTitle, formConfig, tableConfig, defaultEntity, onEntitiesLoaded }: GeneralEntityRootProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export default GeneralEntityRoot;
|
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import './GeneralEntityRoot.less';
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { FormOutlined, SaveOutlined, UndoOutlined, UploadOutlined } from '@ant-design/icons';
|
|
5
|
-
import { PageHeader } from '@ant-design/pro-components';
|
|
6
|
-
import { Button, Form, notification, Upload } from 'antd';
|
|
7
|
-
import i18next from 'i18next';
|
|
8
|
-
import _isEmpty from 'lodash/isEmpty';
|
|
9
|
-
import _isNil from 'lodash/isNil';
|
|
10
|
-
import { useHotkeys } from 'react-hotkeys-hook';
|
|
11
|
-
import { useTranslation } from 'react-i18next';
|
|
12
|
-
import { Link, matchPath, useLocation, useNavigate } from 'react-router-dom';
|
|
13
|
-
import { Shapefile } from 'shapefile.js';
|
|
14
|
-
import config from 'shogunApplicationConfig';
|
|
15
|
-
import Logger from '@terrestris/base-util/dist/Logger';
|
|
16
|
-
import { getBearerTokenHeader } from '@terrestris/shogun-util/dist/security/getBearerTokenHeader';
|
|
17
|
-
import { ControllerUtil } from '../../../Controller/ControllerUtil';
|
|
18
|
-
import useSHOGunAPIClient from '../../../Hooks/useSHOGunAPIClient';
|
|
19
|
-
import TranslationUtil from '../../../Util/TranslationUtil';
|
|
20
|
-
import GeneralEntityForm from '../GeneralEntityForm/GeneralEntityForm';
|
|
21
|
-
import GeneralEntityTable from '../GeneralEntityTable/GeneralEntityTable';
|
|
22
|
-
export function GeneralEntityRoot({ i18n, endpoint, entityType, defaultSortField, entityName = 'Entität', navigationTitle = 'Entitäten', subTitle = '… mit denen man Dinge tun kann (aus Gründen bspw.)', formConfig, tableConfig = {}, defaultEntity, onEntitiesLoaded = () => { } }) {
|
|
23
|
-
const location = useLocation();
|
|
24
|
-
const navigate = useNavigate();
|
|
25
|
-
const match = matchPath({
|
|
26
|
-
path: `${config.appPrefix}/portal/${entityType}/:entityId`
|
|
27
|
-
}, location.pathname);
|
|
28
|
-
const entityId = match?.params?.entityId;
|
|
29
|
-
const [id, setId] = useState();
|
|
30
|
-
const [editEntity, setEditEntity] = useState();
|
|
31
|
-
const [allEntities, setEntities] = useState();
|
|
32
|
-
const [formIsDirty, setFormIsDirty] = useState(false);
|
|
33
|
-
const [formValid, setFormValid] = useState(true);
|
|
34
|
-
const [isGridLoading, setGridLoading] = useState(false);
|
|
35
|
-
const [isFormLoading, setFormLoading] = useState(false);
|
|
36
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
37
|
-
const [isUploadingFile, setIsUploadingFile] = useState(false);
|
|
38
|
-
const [pageTotal, setPageTotal] = useState();
|
|
39
|
-
const [pageSize, setPageSize] = useState(config.defaultPageSize || 10);
|
|
40
|
-
const [pageCurrent, setPageCurrent] = useState(1);
|
|
41
|
-
const [sortField, setSortField] = useState();
|
|
42
|
-
const [sortOrder, setSortOrder] = useState();
|
|
43
|
-
const [isFiltered, setFiltered] = useState(false);
|
|
44
|
-
const [form] = Form.useForm();
|
|
45
|
-
const client = useSHOGunAPIClient();
|
|
46
|
-
const { t } = useTranslation();
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
setSortField(defaultSortField ? defaultSortField : undefined);
|
|
49
|
-
setSortOrder('ascend');
|
|
50
|
-
setPageCurrent(1);
|
|
51
|
-
setFiltered(false); // to always obtain pagination when changing the entity
|
|
52
|
-
}, [entityType, defaultSortField]);
|
|
53
|
-
/**
|
|
54
|
-
* Validate form fields
|
|
55
|
-
*/
|
|
56
|
-
const validate = useCallback(async (nameList) => {
|
|
57
|
-
let valid;
|
|
58
|
-
try {
|
|
59
|
-
// TODO: check validation of JSON (and MarkDownEditor) if used for field
|
|
60
|
-
await form.validateFields(nameList || []);
|
|
61
|
-
valid = true;
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
if ('errorFields' in e) {
|
|
65
|
-
valid = false;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
throw e;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
setFormValid(valid);
|
|
72
|
-
}, [form]);
|
|
73
|
-
const updateForm = useCallback(async () => {
|
|
74
|
-
const nameList = formConfig?.fields.filter(field => field.required).map(field => field.dataField);
|
|
75
|
-
validate(nameList);
|
|
76
|
-
}, [formConfig?.fields, validate]);
|
|
77
|
-
const entityController = useMemo(() => ControllerUtil.createController({
|
|
78
|
-
endpoint,
|
|
79
|
-
keycloak: client?.getKeycloak(),
|
|
80
|
-
entityType,
|
|
81
|
-
formConfig,
|
|
82
|
-
updateForm
|
|
83
|
-
}), [endpoint, client, entityType, formConfig, updateForm]);
|
|
84
|
-
/**
|
|
85
|
-
* Fetch entity with given id
|
|
86
|
-
*/
|
|
87
|
-
const fetchEntity = useCallback(async (eId) => {
|
|
88
|
-
try {
|
|
89
|
-
setFormLoading(true);
|
|
90
|
-
const e = await entityController?.load(eId);
|
|
91
|
-
setEditEntity(e);
|
|
92
|
-
form.resetFields();
|
|
93
|
-
form.setFieldsValue(e);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
Logger.error(error);
|
|
97
|
-
}
|
|
98
|
-
finally {
|
|
99
|
-
setFormLoading(false);
|
|
100
|
-
}
|
|
101
|
-
}, [form, entityController]);
|
|
102
|
-
/**
|
|
103
|
-
* Fetch all entities shown in table
|
|
104
|
-
*/
|
|
105
|
-
const fetchEntities = useCallback(async () => {
|
|
106
|
-
try {
|
|
107
|
-
setGridLoading(true);
|
|
108
|
-
const pageOpts = isFiltered ? undefined : {
|
|
109
|
-
page: pageCurrent - 1,
|
|
110
|
-
size: pageSize,
|
|
111
|
-
sort: {
|
|
112
|
-
properties: _isNil(sortField) ? [] : [sortField],
|
|
113
|
-
order: sortOrder === 'ascend' ? 'asc' : sortOrder === 'descend' ? 'desc' : undefined
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const allEntries = await entityController?.findAll(pageOpts);
|
|
117
|
-
setPageTotal(allEntries.totalElements);
|
|
118
|
-
setEntities(allEntries.content || []);
|
|
119
|
-
onEntitiesLoaded(allEntries.content, entityType);
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
Logger.error(error);
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
setGridLoading(false);
|
|
126
|
-
}
|
|
127
|
-
}, [entityController, onEntitiesLoaded, entityType, pageCurrent, pageSize, sortField, sortOrder, isFiltered]);
|
|
128
|
-
/**
|
|
129
|
-
* Fetch entity or create new one
|
|
130
|
-
*/
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
if (id && id.toString() !== 'create' && id !== editEntity?.id) {
|
|
133
|
-
fetchEntity(parseInt(id.toString(), 10));
|
|
134
|
-
}
|
|
135
|
-
if (id && id.toString() === 'create' && editEntity === undefined) {
|
|
136
|
-
const e = entityController?.createEntity();
|
|
137
|
-
setEditEntity(e);
|
|
138
|
-
form.setFieldsValue(entityController?.getEntity());
|
|
139
|
-
}
|
|
140
|
-
}, [id, fetchEntity, editEntity, entityController, form]);
|
|
141
|
-
/**
|
|
142
|
-
* Set actual edited entity
|
|
143
|
-
*/
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
if (!entityId) {
|
|
146
|
-
setId(undefined);
|
|
147
|
-
setEditEntity(undefined);
|
|
148
|
-
setFormIsDirty(false);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (entityId === 'create') {
|
|
152
|
-
setId(entityId);
|
|
153
|
-
form.resetFields();
|
|
154
|
-
form.setFieldsValue(defaultEntity);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
setId(parseInt(entityId, 10));
|
|
158
|
-
setFormIsDirty(false);
|
|
159
|
-
}
|
|
160
|
-
}, [entityId, form, defaultEntity]);
|
|
161
|
-
// Once the controller is known we need to set the formUpdater so we can update
|
|
162
|
-
// a given form when the entity is updated via controller
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (entityController) {
|
|
165
|
-
entityController.setFormUpdater(updateForm);
|
|
166
|
-
}
|
|
167
|
-
}, [updateForm, entityController]);
|
|
168
|
-
/**
|
|
169
|
-
* Init data
|
|
170
|
-
*/
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
if (allEntities === undefined && !isGridLoading) {
|
|
173
|
-
fetchEntities();
|
|
174
|
-
}
|
|
175
|
-
}, [fetchEntities, allEntities, isGridLoading]);
|
|
176
|
-
/**
|
|
177
|
-
* Table updates when Entities change
|
|
178
|
-
*/
|
|
179
|
-
useEffect(() => {
|
|
180
|
-
if (entityType) {
|
|
181
|
-
fetchEntities();
|
|
182
|
-
}
|
|
183
|
-
}, [entityType, fetchEntities]);
|
|
184
|
-
const onValuesChange = async (changedValues) => {
|
|
185
|
-
setFormIsDirty(true);
|
|
186
|
-
if (id === 'create') {
|
|
187
|
-
await entityController.updateEntity({
|
|
188
|
-
...defaultEntity,
|
|
189
|
-
...changedValues
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
await entityController.updateEntity(changedValues);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const onResetForm = () => {
|
|
197
|
-
const oldValues = allEntities?.find((entity) => entity.id === id);
|
|
198
|
-
if (!oldValues) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
form.resetFields();
|
|
202
|
-
form.setFieldsValue(oldValues);
|
|
203
|
-
setFormIsDirty(false);
|
|
204
|
-
};
|
|
205
|
-
const onCreateForm = () => {
|
|
206
|
-
setEditEntity(undefined);
|
|
207
|
-
setId('create');
|
|
208
|
-
};
|
|
209
|
-
const onSaveClick = async () => {
|
|
210
|
-
setIsSaving(true);
|
|
211
|
-
try {
|
|
212
|
-
const updatedEntity = await entityController?.saveOrUpdate();
|
|
213
|
-
await fetchEntities();
|
|
214
|
-
await fetchEntity(updatedEntity.id);
|
|
215
|
-
navigate(`${config.appPrefix}/portal/${entityType}/${updatedEntity.id}`);
|
|
216
|
-
notification.success({
|
|
217
|
-
message: t('GeneralEntityRoot.saveSuccess', {
|
|
218
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
219
|
-
})
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
Logger.error(`Error saving ${entityName}:`, error);
|
|
224
|
-
notification.error({
|
|
225
|
-
message: t('GeneralEntityRoot.saveFail', {
|
|
226
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
227
|
-
})
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
finally {
|
|
231
|
-
setIsSaving(false);
|
|
232
|
-
setFormIsDirty(false);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
const onBeforeFileUpload = (file) => {
|
|
236
|
-
const maxSize = config.geoserver?.upload?.limit || '200000000';
|
|
237
|
-
const fileType = file.type;
|
|
238
|
-
const fileSize = file.size;
|
|
239
|
-
// 1. Check file size
|
|
240
|
-
if (fileSize > maxSize) {
|
|
241
|
-
notification.error({
|
|
242
|
-
message: t('GeneralEntityRoot.upload.error.message', {
|
|
243
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
244
|
-
}),
|
|
245
|
-
description: t('GeneralEntityRoot.upload.error.descriptionSize', {
|
|
246
|
-
maxSize: maxSize / 1000000
|
|
247
|
-
})
|
|
248
|
-
});
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
// 2. Check file format
|
|
252
|
-
const supportedFormats = ['application/zip', 'application/x-zip-compressed', 'image/tiff'];
|
|
253
|
-
if (!supportedFormats.includes(fileType)) {
|
|
254
|
-
notification.error({
|
|
255
|
-
message: t('GeneralEntityRoot.upload.error.message', {
|
|
256
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
257
|
-
}),
|
|
258
|
-
description: t('GeneralEntityRoot.upload.error.descriptionFormat', {
|
|
259
|
-
supportedFormats: supportedFormats.join(', ')
|
|
260
|
-
})
|
|
261
|
-
});
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
return true;
|
|
265
|
-
};
|
|
266
|
-
const uploadGeoTiff = async (options) => {
|
|
267
|
-
const { baseUrl, workspace, storeName, layerName, file } = options;
|
|
268
|
-
const url = `${baseUrl}/rest/workspaces/${workspace}/coveragestores/` +
|
|
269
|
-
`${storeName}/file.geotiff?coverageName=${layerName}`;
|
|
270
|
-
const response = await fetch(url, {
|
|
271
|
-
method: 'PUT',
|
|
272
|
-
headers: {
|
|
273
|
-
...getBearerTokenHeader(client?.getKeycloak()),
|
|
274
|
-
'Content-Type': 'image/tiff'
|
|
275
|
-
},
|
|
276
|
-
body: file
|
|
277
|
-
});
|
|
278
|
-
if (!response.ok) {
|
|
279
|
-
throw new Error('No successful response while uploading the file');
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
const uploadShapeZip = async (options) => {
|
|
283
|
-
const { baseUrl, workspace, storeName, layerName, file } = options;
|
|
284
|
-
const shp = await Shapefile.load(file);
|
|
285
|
-
let featureTypeName = '';
|
|
286
|
-
let featureTypeAttributes = {
|
|
287
|
-
attribute: []
|
|
288
|
-
};
|
|
289
|
-
if (Object.entries(shp).length !== 1) {
|
|
290
|
-
throw new Error(t('GeneralEntityRoot.upload.error.descriptionZipContent'));
|
|
291
|
-
}
|
|
292
|
-
Object.entries(shp).forEach(([k, v]) => {
|
|
293
|
-
featureTypeName = k;
|
|
294
|
-
const dbfContent = v.parse('dbf', {
|
|
295
|
-
properties: false
|
|
296
|
-
});
|
|
297
|
-
featureTypeAttributes.attribute = dbfContent.fields.map(field => ({
|
|
298
|
-
name: field.name,
|
|
299
|
-
minOccurs: 0,
|
|
300
|
-
maxOccurs: 1,
|
|
301
|
-
nillable: true,
|
|
302
|
-
binding: getAttributeType(field.type),
|
|
303
|
-
length: field.length
|
|
304
|
-
}));
|
|
305
|
-
const shxContent = v.parse('shx');
|
|
306
|
-
featureTypeAttributes.attribute.push({
|
|
307
|
-
name: 'the_geom',
|
|
308
|
-
minOccurs: 0,
|
|
309
|
-
maxOccurs: 1,
|
|
310
|
-
nillable: true,
|
|
311
|
-
binding: getGeometryType(shxContent.header.type)
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
const url = `${baseUrl}/rest/workspaces/${workspace}/datastores/` +
|
|
315
|
-
`${storeName}/file.shp?configure=none`;
|
|
316
|
-
const response = await fetch(url, {
|
|
317
|
-
method: 'PUT',
|
|
318
|
-
headers: {
|
|
319
|
-
...getBearerTokenHeader(client?.getKeycloak()),
|
|
320
|
-
'Content-Type': 'application/zip'
|
|
321
|
-
},
|
|
322
|
-
body: file
|
|
323
|
-
});
|
|
324
|
-
if (!response.ok) {
|
|
325
|
-
throw new Error('No successful response while uploading the file');
|
|
326
|
-
}
|
|
327
|
-
const featureTypeUrl = `${baseUrl}/rest/workspaces/${workspace}/datastores/${storeName}/featuretypes`;
|
|
328
|
-
const featureTypeResponse = await fetch(featureTypeUrl, {
|
|
329
|
-
method: 'POST',
|
|
330
|
-
headers: {
|
|
331
|
-
...getBearerTokenHeader(client?.getKeycloak()),
|
|
332
|
-
'Content-Type': 'application/json'
|
|
333
|
-
},
|
|
334
|
-
body: JSON.stringify({
|
|
335
|
-
featureType: {
|
|
336
|
-
enabled: true,
|
|
337
|
-
name: layerName,
|
|
338
|
-
nativeName: featureTypeName,
|
|
339
|
-
title: layerName,
|
|
340
|
-
attributes: featureTypeAttributes
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
});
|
|
344
|
-
if (!featureTypeResponse.ok) {
|
|
345
|
-
throw new Error('No successful response while creating the featuretype');
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
const getGeometryType = (geometryTypeNumber) => {
|
|
349
|
-
const allTypes = {
|
|
350
|
-
0: undefined, // Null
|
|
351
|
-
1: 'org.locationtech.jts.geom.Point', // Point
|
|
352
|
-
3: 'org.locationtech.jts.geom.LineString', // Polyline
|
|
353
|
-
5: 'org.locationtech.jts.geom.Polygon', // Polygon
|
|
354
|
-
8: 'org.locationtech.jts.geom.MultiPoint', // MultiPoint
|
|
355
|
-
11: 'org.locationtech.jts.geom.Point', // PointZ
|
|
356
|
-
13: 'org.locationtech.jts.geom.LineString', // PolylineZ
|
|
357
|
-
15: 'org.locationtech.jts.geom.Polygon', // PolygonZ
|
|
358
|
-
18: 'org.locationtech.jts.geom.MultiPoint', // MultiPointZ
|
|
359
|
-
21: 'org.locationtech.jts.geom.Point', // PointM
|
|
360
|
-
23: 'org.locationtech.jts.geom.LineString', // PolylineM
|
|
361
|
-
25: 'org.locationtech.jts.geom.Polygon', // PolygonM
|
|
362
|
-
28: 'org.locationtech.jts.geom.MultiPoint', // MultiPointM
|
|
363
|
-
31: undefined // MultiPatch
|
|
364
|
-
};
|
|
365
|
-
return allTypes[geometryTypeNumber];
|
|
366
|
-
};
|
|
367
|
-
const getAttributeType = (dbfFieldType) => {
|
|
368
|
-
switch (dbfFieldType) {
|
|
369
|
-
case 'C': // Character
|
|
370
|
-
return 'java.lang.String';
|
|
371
|
-
case 'D': // Date
|
|
372
|
-
return 'java.util.Date';
|
|
373
|
-
case 'N': // Numeric
|
|
374
|
-
return 'java.lang.Long';
|
|
375
|
-
case 'F': // Floating point
|
|
376
|
-
return 'java.lang.Double';
|
|
377
|
-
case 'L': // Logical
|
|
378
|
-
return 'java.lang.Boolean';
|
|
379
|
-
case 'M': // Memo
|
|
380
|
-
return undefined;
|
|
381
|
-
default:
|
|
382
|
-
return undefined;
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
const onFileUploadAction = async (options) => {
|
|
386
|
-
const { onError = () => undefined, onSuccess = () => undefined, file } = options;
|
|
387
|
-
const splittedFileName = file.name.split('.');
|
|
388
|
-
const fileType = file.type;
|
|
389
|
-
const geoServerBaseUrl = config.geoserver?.base || '/geoserver';
|
|
390
|
-
const workspace = config.geoserver?.upload?.workspace || 'SHOGUN';
|
|
391
|
-
const layerName = `${splittedFileName[0]}_${Date.now()}`.toUpperCase();
|
|
392
|
-
const uploadData = {
|
|
393
|
-
file: file,
|
|
394
|
-
baseUrl: geoServerBaseUrl,
|
|
395
|
-
workspace: workspace,
|
|
396
|
-
storeName: layerName,
|
|
397
|
-
layerName: layerName
|
|
398
|
-
};
|
|
399
|
-
try {
|
|
400
|
-
if (fileType === 'image/tiff') {
|
|
401
|
-
await uploadGeoTiff(uploadData);
|
|
402
|
-
}
|
|
403
|
-
if (fileType === 'application/zip' || fileType === 'application/x-zip-compressed') {
|
|
404
|
-
await uploadShapeZip(uploadData);
|
|
405
|
-
}
|
|
406
|
-
onSuccess({
|
|
407
|
-
baseUrl: geoServerBaseUrl,
|
|
408
|
-
workspace: workspace,
|
|
409
|
-
layerName: layerName
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
catch (error) {
|
|
413
|
-
onError({
|
|
414
|
-
name: 'UploadError',
|
|
415
|
-
message: error?.message
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
const onFileUploadChange = async (info) => {
|
|
420
|
-
const file = info.file;
|
|
421
|
-
if (file.status === 'uploading') {
|
|
422
|
-
setIsUploadingFile(true);
|
|
423
|
-
}
|
|
424
|
-
if (file.status === 'done') {
|
|
425
|
-
await client?.layer().add({
|
|
426
|
-
name: file.response?.layerName ?? 'LAYER-DEFAULT-NAME',
|
|
427
|
-
type: 'TILEWMS',
|
|
428
|
-
clientConfig: {
|
|
429
|
-
hoverable: false
|
|
430
|
-
},
|
|
431
|
-
sourceConfig: {
|
|
432
|
-
url: `${file.response?.baseUrl}/ows?`,
|
|
433
|
-
layerNames: `${file.response?.workspace}:${file.response?.layerName}`,
|
|
434
|
-
useBearerToken: true
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
// Refresh the list
|
|
438
|
-
await fetchEntities();
|
|
439
|
-
// Finally, show success message
|
|
440
|
-
setIsUploadingFile(false);
|
|
441
|
-
notification.success({
|
|
442
|
-
message: t('GeneralEntityRoot.upload.success.message', {
|
|
443
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
444
|
-
}),
|
|
445
|
-
description: t('GeneralEntityRoot.upload.success.description', {
|
|
446
|
-
fileName: file.fileName,
|
|
447
|
-
layerName: file.response?.layerName
|
|
448
|
-
}),
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
else if (file.status === 'error') {
|
|
452
|
-
setIsUploadingFile(false);
|
|
453
|
-
Logger.error(file.error);
|
|
454
|
-
notification.error({
|
|
455
|
-
message: t('GeneralEntityRoot.upload.error.message', {
|
|
456
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
457
|
-
}),
|
|
458
|
-
description: t('GeneralEntityRoot.upload.error.description', {
|
|
459
|
-
fileName: file.fileName
|
|
460
|
-
})
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
/**
|
|
465
|
-
* Shortcut: Save entity form when ctrl+s is pressed.
|
|
466
|
-
*/
|
|
467
|
-
const handleKeyboardSave = (event) => {
|
|
468
|
-
event.preventDefault();
|
|
469
|
-
onSaveClick();
|
|
470
|
-
};
|
|
471
|
-
useHotkeys('ctrl+s', handleKeyboardSave, {
|
|
472
|
-
enableOnFormTags: ['INPUT', 'TEXTAREA', 'SELECT'],
|
|
473
|
-
enabled: () => !saveReloadDisabled && formValid
|
|
474
|
-
});
|
|
475
|
-
const initialValues = useMemo(() => entityController?.getInitialFormValues(), [entityController]);
|
|
476
|
-
const saveReloadDisabled = useMemo(() => _isEmpty(editEntity) || !formIsDirty, [formIsDirty, editEntity]);
|
|
477
|
-
const onTableChange = (pagination, filters, sorter) => {
|
|
478
|
-
if (!Array.isArray(sorter)) {
|
|
479
|
-
setSortOrder(sorter.order);
|
|
480
|
-
setSortField(sorter.field);
|
|
481
|
-
}
|
|
482
|
-
const anyColumnIsFiltered = Object.keys(filters)
|
|
483
|
-
.some(attribute => !_isNil(filters[attribute]) || !_isEmpty(filters[attribute]));
|
|
484
|
-
setFiltered(anyColumnIsFiltered);
|
|
485
|
-
setPageCurrent(pagination.current);
|
|
486
|
-
setPageSize(pagination.pageSize);
|
|
487
|
-
};
|
|
488
|
-
const paginationConfig = {
|
|
489
|
-
total: pageTotal,
|
|
490
|
-
current: pageCurrent,
|
|
491
|
-
pageSize: pageSize,
|
|
492
|
-
showTotal: (total) => `${t('GeneralEntityTable.paging.total')}: ${total}`,
|
|
493
|
-
showSizeChanger: true,
|
|
494
|
-
showQuickJumper: true,
|
|
495
|
-
locale: {
|
|
496
|
-
// eslint-disable-next-line camelcase
|
|
497
|
-
next_page: t('GeneralEntityTable.paging.nextPage'),
|
|
498
|
-
// eslint-disable-next-line camelcase
|
|
499
|
-
prev_page: t('GeneralEntityTable.paging.prevPage'),
|
|
500
|
-
// eslint-disable-next-line camelcase
|
|
501
|
-
items_per_page: `/ ${t('GeneralEntityTable.paging.itemsPerPage')}`,
|
|
502
|
-
// eslint-disable-next-line camelcase
|
|
503
|
-
jump_to: t('GeneralEntityTable.paging.jumpTo'),
|
|
504
|
-
page: t('GeneralEntityTable.paging.page')
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
return (_jsxs("div", { className: "general-entity-root", children: [_jsx(PageHeader, { className: "header", onBack: () => navigate(-1), title: TranslationUtil.getTranslationFromConfig(navigationTitle, i18n), subTitle: subTitle, extra: [
|
|
508
|
-
_jsx(Button, { disabled: saveReloadDisabled || !formValid, icon: _jsx(SaveOutlined, {}), onClick: onSaveClick, type: "primary", loading: isSaving, children: t('GeneralEntityRoot.save', {
|
|
509
|
-
context: i18next.language,
|
|
510
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
511
|
-
}) }, "save"),
|
|
512
|
-
_jsx(Button, { disabled: saveReloadDisabled, icon: _jsx(UndoOutlined, {}), onClick: onResetForm, type: "primary", children: t('GeneralEntityRoot.reset', {
|
|
513
|
-
context: i18next.language,
|
|
514
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
515
|
-
}) }, "reset")
|
|
516
|
-
] }), _jsxs("div", { className: "left-container", children: [_jsxs("div", { className: "left-toolbar", children: [_jsx(Link, { to: `${config.appPrefix}/portal/${entityType}/create`, onClick: onCreateForm, children: _jsx(Button, { type: "primary", icon: _jsx(FormOutlined, {}), children: t('GeneralEntityRoot.create', {
|
|
517
|
-
context: i18next.language,
|
|
518
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
519
|
-
}) }, "create") }, "create"), entityType === 'layer' && (_jsx(Upload, { customRequest: onFileUploadAction, accept: 'image/tiff,application/zip', maxCount: 1, showUploadList: false, beforeUpload: onBeforeFileUpload, onChange: onFileUploadChange, children: _jsx(Button, { type: "primary", icon: _jsx(UploadOutlined, {}), loading: isUploadingFile, disabled: isUploadingFile, children: t('GeneralEntityRoot.upload.button', {
|
|
520
|
-
context: i18next.language,
|
|
521
|
-
entity: TranslationUtil.getTranslationFromConfig(entityName, i18n)
|
|
522
|
-
}) }, "upload") }))] }), _jsx(GeneralEntityTable, { bordered: true, controller: entityController, entities: allEntities ?? [], entityType: entityType, fetchEntities: fetchEntities, i18n: i18n, loading: isGridLoading, onChange: onTableChange, pagination: isFiltered ? false : paginationConfig, size: "small", tableConfig: tableConfig })] }), _jsx("div", { className: "right-container", children: id && !_isNil(entityId) && (_jsx(GeneralEntityForm, { loading: isFormLoading, i18n: i18n, entityId: parseInt(entityId, 10), entityName: entityName, entityType: entityType, formConfig: formConfig, form: form, formProps: {
|
|
523
|
-
initialValues,
|
|
524
|
-
onValuesChange
|
|
525
|
-
} })) })] }));
|
|
526
|
-
}
|
|
527
|
-
export default GeneralEntityRoot;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import './GeneralEntityTable.less';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ColumnType, TableProps } from 'antd/lib/table';
|
|
4
|
-
import { SortOrder } from 'antd/lib/table/interface';
|
|
5
|
-
import BaseEntity from '@terrestris/shogun-util/dist/model/BaseEntity';
|
|
6
|
-
import { GenericEntityController } from '../../../Controller/GenericEntityController';
|
|
7
|
-
export type TableConfig<T extends BaseEntity> = {
|
|
8
|
-
columnDefinition?: GeneralEntityTableColumn<T>[];
|
|
9
|
-
dataMapping?: DataMapping;
|
|
10
|
-
};
|
|
11
|
-
type DataMapping = {
|
|
12
|
-
[dataIndex: string]: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
type FilterConfig = {
|
|
17
|
-
isFilterable: boolean;
|
|
18
|
-
};
|
|
19
|
-
type SortConfig = {
|
|
20
|
-
customSorterName?: string;
|
|
21
|
-
isSortable: boolean;
|
|
22
|
-
sortOrder?: SortOrder;
|
|
23
|
-
};
|
|
24
|
-
export type EntityTableAction = 'delete' | 'edit';
|
|
25
|
-
type GeneralEntityTableColumnType = {
|
|
26
|
-
cellRenderComponentName?: string;
|
|
27
|
-
cellRenderComponentProps?: {
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
};
|
|
30
|
-
filterConfig?: FilterConfig;
|
|
31
|
-
sortConfig?: SortConfig;
|
|
32
|
-
};
|
|
33
|
-
export type GeneralEntityTableColumn<T extends BaseEntity> = ColumnType<T> & GeneralEntityTableColumnType;
|
|
34
|
-
type OwnProps<T extends BaseEntity> = {
|
|
35
|
-
actions?: EntityTableAction[];
|
|
36
|
-
controller: GenericEntityController<T>;
|
|
37
|
-
entities: T[];
|
|
38
|
-
entityType: string;
|
|
39
|
-
fetchEntities?: () => void;
|
|
40
|
-
i18n: FormTranslations;
|
|
41
|
-
onRowClick?: (record: T, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
42
|
-
tableConfig: TableConfig<T>;
|
|
43
|
-
};
|
|
44
|
-
type GeneralEntityTableProps<T extends BaseEntity> = OwnProps<T> & TableProps<T>;
|
|
45
|
-
export declare function GeneralEntityTable<T extends BaseEntity>({ actions, controller, entities, entityType, fetchEntities, i18n, tableConfig, ...tablePassThroughProps }: GeneralEntityTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
46
|
-
export default GeneralEntityTable;
|