@collabdt/core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.d.ts +3 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js +46 -10
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/ViewerContextMenu.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/ViewerContextMenu.js +28 -20
- package/dist/core/components/ui/FilesManager/src/ViewerContextMenu.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/fileType.d.ts +2 -0
- package/dist/core/components/ui/FilesManager/src/fileType.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/fileType.js +2 -0
- package/dist/core/components/ui/FilesManager/src/fileType.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/ifcGeoreference.d.ts +13 -0
- package/dist/core/components/ui/FilesManager/src/ifcGeoreference.d.ts.map +1 -0
- package/dist/core/components/ui/FilesManager/src/ifcGeoreference.js +76 -0
- package/dist/core/components/ui/FilesManager/src/ifcGeoreference.js.map +1 -0
- package/dist/core/components/ui/FilesManager/src/useFileUploadHandler.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadHandler.js +4 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadHandler.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.d.ts +3 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.js +3 -2
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.js.map +1 -1
- package/dist/core/components/ui/uploadFile.d.ts +4 -1
- package/dist/core/components/ui/uploadFile.d.ts.map +1 -1
- package/dist/core/components/ui/uploadFile.js +13 -3
- package/dist/core/components/ui/uploadFile.js.map +1 -1
- package/dist/core/components/viewers/Data/ActiveFilterChips.d.ts +12 -0
- package/dist/core/components/viewers/Data/ActiveFilterChips.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/ActiveFilterChips.js +54 -0
- package/dist/core/components/viewers/Data/ActiveFilterChips.js.map +1 -0
- package/dist/core/components/viewers/Data/DataMenu.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/DataMenu.js +98 -49
- package/dist/core/components/viewers/Data/DataMenu.js.map +1 -1
- package/dist/core/components/viewers/Data/FilterButtons.d.ts +2 -1
- package/dist/core/components/viewers/Data/FilterButtons.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/FilterButtons.js +87 -401
- package/dist/core/components/viewers/Data/FilterButtons.js.map +1 -1
- package/dist/core/components/viewers/Data/MoreOptions.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/MoreOptions.js +28 -20
- package/dist/core/components/viewers/Data/MoreOptions.js.map +1 -1
- package/dist/core/components/viewers/Data/PageActions.d.ts +13 -0
- package/dist/core/components/viewers/Data/PageActions.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/PageActions.js +81 -0
- package/dist/core/components/viewers/Data/PageActions.js.map +1 -0
- package/dist/core/components/viewers/Data/ResultActions.d.ts +16 -0
- package/dist/core/components/viewers/Data/ResultActions.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/ResultActions.js +106 -0
- package/dist/core/components/viewers/Data/ResultActions.js.map +1 -0
- package/dist/core/components/viewers/Data/buildingDetails/DeleteBuildingDialog.d.ts +11 -0
- package/dist/core/components/viewers/Data/buildingDetails/DeleteBuildingDialog.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/buildingDetails/DeleteBuildingDialog.js +91 -0
- package/dist/core/components/viewers/Data/buildingDetails/DeleteBuildingDialog.js.map +1 -0
- package/dist/core/components/viewers/Data/details/DetailActions.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/details/DetailActions.js +2 -1
- package/dist/core/components/viewers/Data/details/DetailActions.js.map +1 -1
- package/dist/core/components/viewers/Data/utils/filterFieldNames.d.ts +13 -0
- package/dist/core/components/viewers/Data/utils/filterFieldNames.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/utils/filterFieldNames.js +31 -0
- package/dist/core/components/viewers/Data/utils/filterFieldNames.js.map +1 -0
- package/dist/core/components/viewers/Data/utils/filterHelper.d.ts +3 -0
- package/dist/core/components/viewers/Data/utils/filterHelper.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/utils/filterHelper.js +10 -1
- package/dist/core/components/viewers/Data/utils/filterHelper.js.map +1 -1
- package/dist/core/components/viewers/Data/utils/useFilterChipLabels.d.ts +13 -0
- package/dist/core/components/viewers/Data/utils/useFilterChipLabels.d.ts.map +1 -0
- package/dist/core/components/viewers/Data/utils/useFilterChipLabels.js +42 -0
- package/dist/core/components/viewers/Data/utils/useFilterChipLabels.js.map +1 -0
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/sceneSeed.d.ts +4 -3
- package/dist/core/components/viewers/bim/src/lib/sceneSeed.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/sceneSeed.js +2 -1
- package/dist/core/components/viewers/bim/src/lib/sceneSeed.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +2 -0
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js +7 -27
- package/dist/core/components/viewers/map/datasets/DatasetManager/index.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/DatasetLayerActions.d.ts +10 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/DatasetLayerActions.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/DatasetLayerActions.js +50 -0
- package/dist/core/components/viewers/map/datasets/DatasetManager/src/DatasetLayerActions.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/RowActions.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/RowActions.js +11 -8
- package/dist/core/components/viewers/map/datasets/RowActions.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/datasetExtent.d.ts +8 -0
- package/dist/core/components/viewers/map/datasets/src/datasetExtent.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/datasetExtent.js +20 -0
- package/dist/core/components/viewers/map/datasets/src/datasetExtent.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/orgDatasetFiles.d.ts +25 -0
- package/dist/core/components/viewers/map/datasets/src/orgDatasetFiles.d.ts.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/orgDatasetFiles.js +64 -0
- package/dist/core/components/viewers/map/datasets/src/orgDatasetFiles.js.map +1 -0
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.js +51 -10
- package/dist/core/components/viewers/map/datasets/src/orgFileDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/urlSources.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/urlSources.js +2 -1
- package/dist/core/components/viewers/map/datasets/src/urlSources.js.map +1 -1
- package/dist/core/components/viewers/map/src/BuildingFocus/useBuildingFocus.d.ts +13 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useBuildingFocus.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useBuildingFocus.js +61 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useBuildingFocus.js.map +1 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useClearBuildingFocus.d.ts +2 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useClearBuildingFocus.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useClearBuildingFocus.js +33 -0
- package/dist/core/components/viewers/map/src/BuildingFocus/useClearBuildingFocus.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/ifcOriginOffset.d.ts +5 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/ifcOriginOffset.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/ifcOriginOffset.js +9 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/ifcOriginOffset.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js +10 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts +8 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js +9 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +8 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.js +13 -5
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +9 -5
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/useCameraSubdivision.d.ts +5 -4
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/useCameraSubdivision.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/useCameraSubdivision.js +17 -9
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/useCameraSubdivision.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.js +7 -2
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/PlaceOnMap.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/PlaceOnMap.js +4 -10
- package/dist/core/components/viewers/map/src/MapLayers/src/PlaceOnMap.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.js +6 -14
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.d.ts +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js +2 -29
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AppliedDatasetsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AppliedDatasetsSection.js +4 -50
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AppliedDatasetsSection.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AvailableDatasetsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AvailableDatasetsSection.js +32 -12
- package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/src/AvailableDatasetsSection.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/useLinkFileToBuilding.d.ts +4 -0
- package/dist/core/components/viewers/map/src/Placement/useLinkFileToBuilding.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/Placement/useLinkFileToBuilding.js +16 -0
- package/dist/core/components/viewers/map/src/Placement/useLinkFileToBuilding.js.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.d.ts +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js +48 -54
- package/dist/core/components/viewers/map/src/tools/AddTools/AddDataset/DatasetAdder.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js +23 -29
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddToMap.js +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddToMap.js.map +1 -1
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js +10 -0
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js.map +1 -1
- package/dist/core/components/viewers/shared/intake/useFileIntake.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/intake/useFileIntake.js +6 -3
- package/dist/core/components/viewers/shared/intake/useFileIntake.js.map +1 -1
- package/dist/core/components/viewers/shared/placement/GeolocationDialog.d.ts +10 -0
- package/dist/core/components/viewers/shared/placement/GeolocationDialog.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/placement/GeolocationDialog.js +182 -0
- package/dist/core/components/viewers/shared/placement/GeolocationDialog.js.map +1 -0
- package/dist/core/hooks/buildings/buildings.d.ts +11 -0
- package/dist/core/hooks/buildings/buildings.d.ts.map +1 -1
- package/dist/core/hooks/buildings/buildings.js +5 -1
- package/dist/core/hooks/buildings/buildings.js.map +1 -1
- package/dist/core/hooks/buildings/createBuildingHooks.d.ts +12 -1
- package/dist/core/hooks/buildings/createBuildingHooks.d.ts.map +1 -1
- package/dist/core/hooks/buildings/createBuildingHooks.js +28 -1
- package/dist/core/hooks/buildings/createBuildingHooks.js.map +1 -1
- package/dist/core/hooks/ports/apiAdapter.d.ts +5 -1
- package/dist/core/hooks/ports/apiAdapter.d.ts.map +1 -1
- package/dist/core/i18n/messages/en.json +58 -10
- package/dist/core/i18n/messages/es.json +58 -10
- package/dist/core/i18n/messages/fr.json +58 -10
- package/dist/core/store/Map/context.d.ts.map +1 -1
- package/dist/core/store/Map/context.js +2 -1
- package/dist/core/store/Map/context.js.map +1 -1
- package/dist/core/store/Map/reducer.d.ts +3 -0
- package/dist/core/store/Map/reducer.d.ts.map +1 -1
- package/dist/core/store/Map/reducer.js +4 -3
- package/dist/core/store/Map/reducer.js.map +1 -1
- package/dist/core/types/dbTypes.d.ts +11 -0
- package/dist/core/types/dbTypes.d.ts.map +1 -1
- package/dist/core/types/dbTypes.js.map +1 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/utils/buildingDisplayName.d.ts +4 -0
- package/dist/core/utils/buildingDisplayName.d.ts.map +1 -0
- package/dist/core/utils/buildingDisplayName.js +5 -0
- package/dist/core/utils/buildingDisplayName.js.map +1 -0
- package/dist/core/utils/escapeGuard.d.ts +3 -0
- package/dist/core/utils/escapeGuard.d.ts.map +1 -0
- package/dist/core/utils/escapeGuard.js +10 -0
- package/dist/core/utils/escapeGuard.js.map +1 -0
- package/dist/core/utils/geo/crsDefinitions.d.ts +9 -0
- package/dist/core/utils/geo/crsDefinitions.d.ts.map +1 -0
- package/dist/core/utils/geo/crsDefinitions.js +60 -0
- package/dist/core/utils/geo/crsDefinitions.js.map +1 -0
- package/dist/core/utils/geo/georeference.d.ts +24 -0
- package/dist/core/utils/geo/georeference.d.ts.map +1 -0
- package/dist/core/utils/geo/georeference.js +85 -0
- package/dist/core/utils/geo/georeference.js.map +1 -0
- package/dist/core/utils/geo/reprojectGeometry.d.ts.map +1 -1
- package/dist/core/utils/geo/reprojectGeometry.js +1 -1
- package/dist/core/utils/geo/reprojectGeometry.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/components/viewers/Data/HeaderButtons.d.ts +0 -20
- package/dist/core/components/viewers/Data/HeaderButtons.d.ts.map +0 -1
- package/dist/core/components/viewers/Data/HeaderButtons.js +0 -237
- package/dist/core/components/viewers/Data/HeaderButtons.js.map +0 -1
- package/dist/core/components/viewers/map/src/Placement/useBuildingLinkConfirm.d.ts +0 -9
- package/dist/core/components/viewers/map/src/Placement/useBuildingLinkConfirm.d.ts.map +0 -1
- package/dist/core/components/viewers/map/src/Placement/useBuildingLinkConfirm.js +0 -50
- package/dist/core/components/viewers/map/src/Placement/useBuildingLinkConfirm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/ui/FilesManager/src/useFileUploadWithProgress.ts"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { mutate } from 'swr'\n\nimport { useFileIntake } from '../../../viewers/shared/intake/useFileIntake'\n\nimport { useUploadTasks } from './uploadProgress'\n\nexport interface UseFileUploadWithProgressProps {\n acceptedFileTypes?: string\n onUploadSuccess?: () => void\n onUploadError?: (error: Error) => void\n /** Names already taken, so a clash is stored with a numeric suffix rather than shadowing. */\n existingNames?: string[]\n}\n\nexport interface UploadState {\n uploading: boolean\n progress: number\n}\n\nconst IDLE: UploadState = { uploading: false, progress: 0 }\n\n/**\n * The sidebar's add-file button, on the shared intake: one task store drives the toast, the\n * section's progress bar and the marker ring, so no surface tracks progress of its own.\n */\nexport function useFileUploadWithProgress({\n acceptedFileTypes = '*',\n onUploadSuccess,\n onUploadError,\n existingNames = [],\n}: UseFileUploadWithProgressProps = {}) {\n const [pendingName, setPendingName] = React.useState<string | null>(null)\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n const tasks = useUploadTasks()\n\n const createFile = React.useCallback(async ({ fileData }: { fileData: unknown }) => {\n const response = await fetch('/api/files/create', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(fileData),\n })\n if (!response.ok) throw new Error(`Failed to upload file: ${response.statusText}`)\n return response.json()\n }, [])\n\n const intake = useFileIntake({ existingNames, uploadFile: createFile })\n\n const uploadState: UploadState = React.useMemo(() => {\n if (!pendingName) return IDLE\n const task = tasks.find(item => item.name === pendingName)\n return { uploading: true, progress: task?.progress ?? 0 }\n }, [pendingName, tasks])\n\n const handleFileUpload = React.useCallback(async (file: File) => {\n setPendingName(file.name)\n try {\n const created = await intake.submit(file)\n if (!created) throw new Error(`Failed to upload file: ${file.name}`)\n void mutate(['files'])\n onUploadSuccess?.()\n }\n catch (error) {\n console.error('Error uploading file:', error)\n onUploadError?.(error as Error)\n }\n finally {\n setPendingName(null)\n }\n }, [intake, onUploadSuccess, onUploadError])\n\n const handleAddFile = React.useCallback(() => {\n if (pendingName) return\n\n if (!inputRef.current) {\n const input = document.createElement('input')\n input.type = 'file'\n input.accept = acceptedFileTypes\n input.style.display = 'none'\n\n input.addEventListener('change', (e) => {\n const file = (e.target as HTMLInputElement).files?.[0]\n if (!file) return\n void handleFileUpload(file)\n })\n\n inputRef.current = input\n document.body.appendChild(input)\n }\n else {\n inputRef.current.accept = acceptedFileTypes\n }\n\n inputRef.current.click()\n }, [acceptedFileTypes, handleFileUpload, pendingName])\n\n React.useEffect(() => {\n return () => {\n if (inputRef.current && document.body.contains(inputRef.current)) {\n document.body.removeChild(inputRef.current)\n }\n }\n }, [])\n\n return {\n handleAddFile,\n handleFileUpload,\n uploadState,\n }\n}\n"],"mappings":";AAKA,YAAY,WAAW;AACvB,SAAS,cAAc;AAEvB,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/ui/FilesManager/src/useFileUploadWithProgress.ts"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { mutate } from 'swr'\n\nimport { useFileIntake } from '../../../viewers/shared/intake/useFileIntake'\n\nimport { useUploadTasks } from './uploadProgress'\n\nexport interface UseFileUploadWithProgressProps {\n acceptedFileTypes?: string\n onUploadSuccess?: () => void\n onUploadError?: (error: Error) => void\n /** Names already taken, so a clash is stored with a numeric suffix rather than shadowing. */\n existingNames?: string[]\n /** Attaches every upload to this building, so the BIM viewer lists it. */\n buildingId?: number\n}\n\nexport interface UploadState {\n uploading: boolean\n progress: number\n}\n\nconst IDLE: UploadState = { uploading: false, progress: 0 }\n\n/**\n * The sidebar's add-file button, on the shared intake: one task store drives the toast, the\n * section's progress bar and the marker ring, so no surface tracks progress of its own.\n */\nexport function useFileUploadWithProgress({\n acceptedFileTypes = '*',\n onUploadSuccess,\n onUploadError,\n existingNames = [],\n buildingId,\n}: UseFileUploadWithProgressProps = {}) {\n const [pendingName, setPendingName] = React.useState<string | null>(null)\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n const tasks = useUploadTasks()\n\n const createFile = React.useCallback(async ({ fileData }: { fileData: unknown }) => {\n const response = await fetch('/api/files/create', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(fileData),\n })\n if (!response.ok) throw new Error(`Failed to upload file: ${response.statusText}`)\n return response.json()\n }, [])\n\n const intake = useFileIntake({ buildingId, existingNames, uploadFile: createFile })\n\n const uploadState: UploadState = React.useMemo(() => {\n if (!pendingName) return IDLE\n const task = tasks.find(item => item.name === pendingName)\n return { uploading: true, progress: task?.progress ?? 0 }\n }, [pendingName, tasks])\n\n const handleFileUpload = React.useCallback(async (file: File) => {\n setPendingName(file.name)\n try {\n const created = await intake.submit(file)\n if (!created) throw new Error(`Failed to upload file: ${file.name}`)\n void mutate(['files'])\n onUploadSuccess?.()\n }\n catch (error) {\n console.error('Error uploading file:', error)\n onUploadError?.(error as Error)\n }\n finally {\n setPendingName(null)\n }\n }, [intake, onUploadSuccess, onUploadError])\n\n const handleAddFile = React.useCallback(() => {\n if (pendingName) return\n\n if (!inputRef.current) {\n const input = document.createElement('input')\n input.type = 'file'\n input.accept = acceptedFileTypes\n input.style.display = 'none'\n\n input.addEventListener('change', (e) => {\n const file = (e.target as HTMLInputElement).files?.[0]\n if (!file) return\n void handleFileUpload(file)\n })\n\n inputRef.current = input\n document.body.appendChild(input)\n }\n else {\n inputRef.current.accept = acceptedFileTypes\n }\n\n inputRef.current.click()\n }, [acceptedFileTypes, handleFileUpload, pendingName])\n\n React.useEffect(() => {\n return () => {\n if (inputRef.current && document.body.contains(inputRef.current)) {\n document.body.removeChild(inputRef.current)\n }\n }\n }, [])\n\n return {\n handleAddFile,\n handleFileUpload,\n uploadState,\n }\n}\n"],"mappings":";AAKA,YAAY,WAAW;AACvB,SAAS,cAAc;AAEvB,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB;AAiB/B,MAAM,OAAoB,EAAE,WAAW,OAAO,UAAU,EAAE;AAMnD,SAAS,0BAA0B;AAAA,EACxC,oBAAoB;AAAA,EACpB;AAAA,EACA;AAAA,EACA,gBAAgB,CAAC;AAAA,EACjB;AACF,IAAoC,CAAC,GAAG;AACtC,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAwB,IAAI;AACxE,QAAM,WAAW,MAAM,OAAgC,IAAI;AAC3D,QAAM,QAAQ,eAAe;AAE7B,QAAM,aAAa,MAAM,YAAY,OAAO,EAAE,SAAS,MAA6B;AAClF,UAAM,WAAW,MAAM,MAAM,qBAAqB;AAAA,MAChD,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,QAAQ;AAAA,IAC/B,CAAC;AACD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,0BAA0B,SAAS,UAAU,EAAE;AACjF,WAAO,SAAS,KAAK;AAAA,EACvB,GAAG,CAAC,CAAC;AAEL,QAAM,SAAS,cAAc,EAAE,YAAY,eAAe,YAAY,WAAW,CAAC;AAElF,QAAM,cAA2B,MAAM,QAAQ,MAAM;AAxDvD;AAyDI,QAAI,CAAC,YAAa,QAAO;AACzB,UAAM,OAAO,MAAM,KAAK,UAAQ,KAAK,SAAS,WAAW;AACzD,WAAO,EAAE,WAAW,MAAM,WAAU,kCAAM,aAAN,YAAkB,EAAE;AAAA,EAC1D,GAAG,CAAC,aAAa,KAAK,CAAC;AAEvB,QAAM,mBAAmB,MAAM,YAAY,OAAO,SAAe;AAC/D,mBAAe,KAAK,IAAI;AACxB,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,OAAO,IAAI;AACxC,UAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B,KAAK,IAAI,EAAE;AACnE,WAAK,OAAO,CAAC,OAAO,CAAC;AACrB;AAAA,IACF,SACO,OAAO;AACZ,cAAQ,MAAM,yBAAyB,KAAK;AAC5C,qDAAgB;AAAA,IAClB,UACA;AACE,qBAAe,IAAI;AAAA,IACrB;AAAA,EACF,GAAG,CAAC,QAAQ,iBAAiB,aAAa,CAAC;AAE3C,QAAM,gBAAgB,MAAM,YAAY,MAAM;AAC5C,QAAI,YAAa;AAEjB,QAAI,CAAC,SAAS,SAAS;AACrB,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,OAAO;AACb,YAAM,SAAS;AACf,YAAM,MAAM,UAAU;AAEtB,YAAM,iBAAiB,UAAU,CAAC,MAAM;AAxF9C;AAyFQ,cAAM,QAAQ,OAAE,OAA4B,UAA9B,mBAAsC;AACpD,YAAI,CAAC,KAAM;AACX,aAAK,iBAAiB,IAAI;AAAA,MAC5B,CAAC;AAED,eAAS,UAAU;AACnB,eAAS,KAAK,YAAY,KAAK;AAAA,IACjC,OACK;AACH,eAAS,QAAQ,SAAS;AAAA,IAC5B;AAEA,aAAS,QAAQ,MAAM;AAAA,EACzB,GAAG,CAAC,mBAAmB,kBAAkB,WAAW,CAAC;AAErD,QAAM,UAAU,MAAM;AACpB,WAAO,MAAM;AACX,UAAI,SAAS,WAAW,SAAS,KAAK,SAAS,SAAS,OAAO,GAAG;AAChE,iBAAS,KAAK,YAAY,SAAS,OAAO;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GeoreferenceColumns } from '../../utils/geo/georeference';
|
|
1
2
|
import type { SourceUpAxis } from '../../types/dbTypes';
|
|
2
3
|
interface UploadFileArgs {
|
|
3
4
|
file?: File;
|
|
@@ -31,7 +32,9 @@ interface UploadFileArgs {
|
|
|
31
32
|
onProgress?: (percent: number) => void;
|
|
32
33
|
existingNames?: string[];
|
|
33
34
|
sourceUp?: SourceUpAxis;
|
|
35
|
+
/** A georeferenced file stands where its source puts it, whatever position the caller passed. */
|
|
36
|
+
georeference?: GeoreferenceColumns | null;
|
|
34
37
|
}
|
|
35
|
-
export declare function uploadFile({ file, files, buildingId, tag, isVisible, user, uploadFile, position, x, y, z, lat, lng, elevation, rotation, scale, recordType, onProgress, existingNames, sourceUp, }: UploadFileArgs): Promise<any[]>;
|
|
38
|
+
export declare function uploadFile({ file, files, buildingId, tag, isVisible, user, uploadFile, position, x, y, z, lat, lng, elevation, rotation, scale, recordType, onProgress, existingNames, sourceUp, georeference, }: UploadFileArgs): Promise<any[]>;
|
|
36
39
|
export {};
|
|
37
40
|
//# sourceMappingURL=uploadFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../src/core/components/ui/uploadFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../../src/core/components/ui/uploadFile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAM7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,UAAU,cAAc;IAEtB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,GAAG,CAAA;IACT,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,QAAQ,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IACrG,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,iGAAiG;IACjG,YAAY,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAC1C;AAYD,wBAAsB,UAAU,CAAC,EAC/B,IAAI,EACJ,KAAK,EACL,UAAU,EACV,GAAG,EACH,SAAS,EACT,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,CAAC,EACD,CAAC,EACD,CAAC,EACD,GAAG,EACH,GAAG,EACH,SAAS,EACT,QAAQ,EACR,KAAK,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,kBAgEhB"}
|
|
@@ -17,10 +17,19 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { sourcePlacementPatch } from "../../utils/geo/georeference";
|
|
20
21
|
import { uniqueFileName } from "../../utils/uniqueFileName";
|
|
21
22
|
import { getFileExtension } from "../../utils/utils";
|
|
22
23
|
import { getAttachmentFieldName } from "../viewers/Data/details/getAttachmentFileName";
|
|
23
24
|
import { uploadFileWithProgress } from "../viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS";
|
|
25
|
+
function safeSourcePlacement(georeference) {
|
|
26
|
+
try {
|
|
27
|
+
return sourcePlacementPatch(georeference);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn("uploadFile: the georeference could not be converted; the file keeps the caller position", error);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
async function uploadFile({
|
|
25
34
|
file,
|
|
26
35
|
files,
|
|
@@ -41,7 +50,8 @@ async function uploadFile({
|
|
|
41
50
|
recordType,
|
|
42
51
|
onProgress,
|
|
43
52
|
existingNames,
|
|
44
|
-
sourceUp
|
|
53
|
+
sourceUp,
|
|
54
|
+
georeference
|
|
45
55
|
}) {
|
|
46
56
|
if (!file && (!files || files.length === 0)) return null;
|
|
47
57
|
const filesToProcess = files != null ? files : file ? [file] : [];
|
|
@@ -65,7 +75,7 @@ async function uploadFile({
|
|
|
65
75
|
const name = uniqueFileName(currentFile.name, [...taken]);
|
|
66
76
|
taken.add(name);
|
|
67
77
|
const attachment = buildingId === void 0 ? {} : { [getAttachmentFieldName(tag)]: buildingId };
|
|
68
|
-
const fileData = __spreadProps(__spreadValues({
|
|
78
|
+
const fileData = __spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
69
79
|
name,
|
|
70
80
|
type: recordType != null ? recordType : "system",
|
|
71
81
|
mimeType: currentFile.type,
|
|
@@ -89,7 +99,7 @@ async function uploadFile({
|
|
|
89
99
|
fileScale: scale,
|
|
90
100
|
fileSourceUp: sourceUp,
|
|
91
101
|
isVisible: isVisible != null ? isVisible : false
|
|
92
|
-
});
|
|
102
|
+
}), georeference), georeference ? safeSourcePlacement(georeference) : null);
|
|
93
103
|
const result = await uploadFile2({ fileData, buildingId });
|
|
94
104
|
uploadResults.push(result);
|
|
95
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/components/ui/uploadFile.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { uniqueFileName } from '../../utils/uniqueFileName'\nimport { getFileExtension } from '../../utils/utils'\nimport { getAttachmentFieldName } from '../viewers/Data/details/getAttachmentFileName'\nimport { uploadFileWithProgress } from '../viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS'\n\nimport type { SourceUpAxis } from '../../types/dbTypes'\n\ninterface UploadFileArgs {\n // Support both single and multiple files; prefer `files` when passing many\n file?: File\n files?: File[]\n /** Omitted for a map file that belongs to no building. */\n buildingId?: number\n tag?: string\n user: any\n isVisible?: boolean\n uploadFile: (args: { fileData: any, buildingId?: number }) => Promise<any>\n position?: { lng?: number, lat?: number, rotation?: number, elevation?: number, isVisible?: boolean }\n x?: number\n y?: number\n z?: number\n lat?: number\n lng?: number\n elevation?: number\n rotation?: number\n scale?: number\n /** The File record's `type`. Defaults to 'system'; a buildingless map file is a 'map-file'. */\n recordType?: string\n onProgress?: (percent: number) => void\n existingNames?: string[]\n sourceUp?: SourceUpAxis\n}\n\nexport async function uploadFile({\n file,\n files,\n buildingId,\n tag,\n isVisible,\n user,\n uploadFile,\n position,\n x,\n y,\n z,\n lat,\n lng,\n elevation,\n rotation,\n scale,\n recordType,\n onProgress,\n existingNames,\n sourceUp,\n}: UploadFileArgs) {\n if (!file && (!files || files.length === 0)) return null\n\n const filesToProcess: File[] = files ?? (file ? [file] : [])\n\n const uploadResults: any[] = []\n const taken = new Set(existingNames ?? [])\n\n for (const currentFile of filesToProcess) {\n const fileId = crypto.randomUUID()\n const presignedResponse = await fetch(`/api/presigned-url-upload?asset=${fileId}`)\n if (!presignedResponse.ok) throw new Error('Failed to fetch presigned URL')\n const { presignedUrl } = await presignedResponse.json()\n\n if (onProgress) {\n await uploadFileWithProgress(presignedUrl, currentFile, percent => onProgress(percent))\n }\n else {\n const uploadResponse = await fetch(presignedUrl, {\n method: 'PUT',\n body: currentFile,\n headers: { 'Content-Type': currentFile.type },\n })\n if (!uploadResponse.ok) throw new Error(`Failed to upload file to storage: ${uploadResponse.status}`)\n }\n\n const name = uniqueFileName(currentFile.name, [...taken])\n taken.add(name)\n const attachment = buildingId === undefined\n ? {}\n : { [getAttachmentFieldName(tag as string)]: buildingId }\n const fileData = {\n name,\n type: recordType ?? 'system',\n mimeType: currentFile.type,\n extension: getFileExtension(currentFile),\n sizeBytes: currentFile.size,\n tag,\n uploadedAt: new Date().toISOString(),\n url: '',\n assetId: fileId,\n description: '',\n ...attachment,\n fileOrganizationId: user?.organizationId || null,\n position: JSON.stringify(position) || null,\n fileTransformX: x,\n fileTransformY: y,\n fileTransformZ: z,\n lat,\n lng,\n elevation,\n rotation,\n fileScale: scale,\n fileSourceUp: sourceUp,\n isVisible: isVisible ?? false,\n }\n\n const result = await uploadFile({ fileData, buildingId })\n uploadResults.push(result)\n }\n\n return uploadResults\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/components/ui/uploadFile.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { sourcePlacementPatch, type GeoreferenceColumns } from '../../utils/geo/georeference'\nimport { uniqueFileName } from '../../utils/uniqueFileName'\nimport { getFileExtension } from '../../utils/utils'\nimport { getAttachmentFieldName } from '../viewers/Data/details/getAttachmentFileName'\nimport { uploadFileWithProgress } from '../viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS'\n\nimport type { SourceUpAxis } from '../../types/dbTypes'\n\ninterface UploadFileArgs {\n // Support both single and multiple files; prefer `files` when passing many\n file?: File\n files?: File[]\n /** Omitted for a map file that belongs to no building. */\n buildingId?: number\n tag?: string\n user: any\n isVisible?: boolean\n uploadFile: (args: { fileData: any, buildingId?: number }) => Promise<any>\n position?: { lng?: number, lat?: number, rotation?: number, elevation?: number, isVisible?: boolean }\n x?: number\n y?: number\n z?: number\n lat?: number\n lng?: number\n elevation?: number\n rotation?: number\n scale?: number\n /** The File record's `type`. Defaults to 'system'; a buildingless map file is a 'map-file'. */\n recordType?: string\n onProgress?: (percent: number) => void\n existingNames?: string[]\n sourceUp?: SourceUpAxis\n /** A georeferenced file stands where its source puts it, whatever position the caller passed. */\n georeference?: GeoreferenceColumns | null\n}\n\nfunction safeSourcePlacement(georeference: GeoreferenceColumns) {\n try {\n return sourcePlacementPatch(georeference)\n }\n catch (error) {\n console.warn('uploadFile: the georeference could not be converted; the file keeps the caller position', error)\n return null\n }\n}\n\nexport async function uploadFile({\n file,\n files,\n buildingId,\n tag,\n isVisible,\n user,\n uploadFile,\n position,\n x,\n y,\n z,\n lat,\n lng,\n elevation,\n rotation,\n scale,\n recordType,\n onProgress,\n existingNames,\n sourceUp,\n georeference,\n}: UploadFileArgs) {\n if (!file && (!files || files.length === 0)) return null\n\n const filesToProcess: File[] = files ?? (file ? [file] : [])\n\n const uploadResults: any[] = []\n const taken = new Set(existingNames ?? [])\n\n for (const currentFile of filesToProcess) {\n const fileId = crypto.randomUUID()\n const presignedResponse = await fetch(`/api/presigned-url-upload?asset=${fileId}`)\n if (!presignedResponse.ok) throw new Error('Failed to fetch presigned URL')\n const { presignedUrl } = await presignedResponse.json()\n\n if (onProgress) {\n await uploadFileWithProgress(presignedUrl, currentFile, percent => onProgress(percent))\n }\n else {\n const uploadResponse = await fetch(presignedUrl, {\n method: 'PUT',\n body: currentFile,\n headers: { 'Content-Type': currentFile.type },\n })\n if (!uploadResponse.ok) throw new Error(`Failed to upload file to storage: ${uploadResponse.status}`)\n }\n\n const name = uniqueFileName(currentFile.name, [...taken])\n taken.add(name)\n const attachment = buildingId === undefined\n ? {}\n : { [getAttachmentFieldName(tag as string)]: buildingId }\n const fileData = {\n name,\n type: recordType ?? 'system',\n mimeType: currentFile.type,\n extension: getFileExtension(currentFile),\n sizeBytes: currentFile.size,\n tag,\n uploadedAt: new Date().toISOString(),\n url: '',\n assetId: fileId,\n description: '',\n ...attachment,\n fileOrganizationId: user?.organizationId || null,\n position: JSON.stringify(position) || null,\n fileTransformX: x,\n fileTransformY: y,\n fileTransformZ: z,\n lat,\n lng,\n elevation,\n rotation,\n fileScale: scale,\n fileSourceUp: sourceUp,\n isVisible: isVisible ?? false,\n ...georeference,\n ...(georeference ? safeSourcePlacement(georeference) : null),\n }\n\n const result = await uploadFile({ fileData, buildingId })\n uploadResults.push(result)\n }\n\n return uploadResults\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,SAAS,4BAAsD;AAC/D,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AAgCvC,SAAS,oBAAoB,cAAmC;AAC9D,MAAI;AACF,WAAO,qBAAqB,YAAY;AAAA,EAC1C,SACO,OAAO;AACZ,YAAQ,KAAK,2FAA2F,KAAK;AAC7G,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,WAAW;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmB;AACjB,MAAI,CAAC,SAAS,CAAC,SAAS,MAAM,WAAW,GAAI,QAAO;AAEpD,QAAM,iBAAyB,wBAAU,OAAO,CAAC,IAAI,IAAI,CAAC;AAE1D,QAAM,gBAAuB,CAAC;AAC9B,QAAM,QAAQ,IAAI,IAAI,wCAAiB,CAAC,CAAC;AAEzC,aAAW,eAAe,gBAAgB;AACxC,UAAM,SAAS,OAAO,WAAW;AACjC,UAAM,oBAAoB,MAAM,MAAM,mCAAmC,MAAM,EAAE;AACjF,QAAI,CAAC,kBAAkB,GAAI,OAAM,IAAI,MAAM,+BAA+B;AAC1E,UAAM,EAAE,aAAa,IAAI,MAAM,kBAAkB,KAAK;AAEtD,QAAI,YAAY;AACd,YAAM,uBAAuB,cAAc,aAAa,aAAW,WAAW,OAAO,CAAC;AAAA,IACxF,OACK;AACH,YAAM,iBAAiB,MAAM,MAAM,cAAc;AAAA,QAC/C,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS,EAAE,gBAAgB,YAAY,KAAK;AAAA,MAC9C,CAAC;AACD,UAAI,CAAC,eAAe,GAAI,OAAM,IAAI,MAAM,qCAAqC,eAAe,MAAM,EAAE;AAAA,IACtG;AAEA,UAAM,OAAO,eAAe,YAAY,MAAM,CAAC,GAAG,KAAK,CAAC;AACxD,UAAM,IAAI,IAAI;AACd,UAAM,aAAa,eAAe,SAC9B,CAAC,IACD,EAAE,CAAC,uBAAuB,GAAa,CAAC,GAAG,WAAW;AAC1D,UAAM,WAAW;AAAA,MACf;AAAA,MACA,MAAM,kCAAc;AAAA,MACpB,UAAU,YAAY;AAAA,MACtB,WAAW,iBAAiB,WAAW;AAAA,MACvC,WAAW,YAAY;AAAA,MACvB;AAAA,MACA,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,MACnC,KAAK;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,OACV,aAXY;AAAA,MAYf,qBAAoB,6BAAM,mBAAkB;AAAA,MAC5C,UAAU,KAAK,UAAU,QAAQ,KAAK;AAAA,MACtC,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAW,gCAAa;AAAA,QACrB,eACC,eAAe,oBAAoB,YAAY,IAAI;AAGzD,UAAM,SAAS,MAAMA,YAAW,EAAE,UAAU,WAAW,CAAC;AACxD,kBAAc,KAAK,MAAM;AAAA,EAC3B;AAEA,SAAO;AACT;","names":["uploadFile"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FilterState } from '../../../types/global';
|
|
2
|
+
type ActiveFilterChipsProps = {
|
|
3
|
+
activeFilters: FilterState[];
|
|
4
|
+
onRemove: (id: number, value?: string) => void;
|
|
5
|
+
onClearAll: () => void;
|
|
6
|
+
fieldLabel?: (field: string) => string;
|
|
7
|
+
valueLabel?: (field: string, value: string) => string;
|
|
8
|
+
};
|
|
9
|
+
/** Removable chips for the filters applied to a data table, with a Clear all action. */
|
|
10
|
+
export default function ActiveFilterChips({ activeFilters, onRemove, onClearAll, fieldLabel, valueLabel, }: ActiveFilterChipsProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=ActiveFilterChips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActiveFilterChips.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/Data/ActiveFilterChips.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,KAAK,sBAAsB,GAAG;IAC5B,aAAa,EAAE,WAAW,EAAE,CAAA;IAC5B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACtC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;CACtD,CAAA;AAwBD,wFAAwF;AACxF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAA2B,EAC3B,UAAqB,GACtB,EAAE,sBAAsB,+BAyBxB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import * as LR from "lucide-react";
|
|
6
|
+
import { useTranslations } from "next-intl";
|
|
7
|
+
import { Badge } from "../../ui/Badge";
|
|
8
|
+
import { Button } from "../../ui/Button";
|
|
9
|
+
const formatValue = (value) => value instanceof Date ? value.toLocaleDateString() : String(value);
|
|
10
|
+
const identity = (_field, value) => value;
|
|
11
|
+
function toChips(activeFilters, fieldLabel, valueLabel) {
|
|
12
|
+
return activeFilters.flatMap(({ id, field, value, secondValue }) => {
|
|
13
|
+
const label = fieldLabel(field);
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.map((item) => ({ id, value: item, text: `${label}: ${valueLabel(field, item)}` }));
|
|
16
|
+
}
|
|
17
|
+
const range = secondValue == null ? formatValue(value) : `${formatValue(value)} \u2013 ${formatValue(secondValue)}`;
|
|
18
|
+
return [{ id, text: `${label}: ${valueLabel(field, range)}` }];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function ActiveFilterChips({
|
|
22
|
+
activeFilters,
|
|
23
|
+
onRemove,
|
|
24
|
+
onClearAll,
|
|
25
|
+
fieldLabel = (field) => field,
|
|
26
|
+
valueLabel = identity
|
|
27
|
+
}) {
|
|
28
|
+
const t = useTranslations("HeaderButtons");
|
|
29
|
+
const chips = toChips(activeFilters, fieldLabel, valueLabel);
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
31
|
+
chips.map((chip) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "gap-1 pr-1 font-normal", children: [
|
|
34
|
+
/* @__PURE__ */ jsx("span", { children: chip.text }),
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Button,
|
|
37
|
+
{
|
|
38
|
+
variant: "ghost",
|
|
39
|
+
size: "icon",
|
|
40
|
+
className: "h-4 w-4 rounded-full hover:bg-transparent",
|
|
41
|
+
"aria-label": t("removeFilter", { label: chip.text }),
|
|
42
|
+
onClick: () => onRemove(chip.id, chip.value),
|
|
43
|
+
children: /* @__PURE__ */ jsx(LR.X, { className: "h-3 w-3" })
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] }, `${chip.id}:${(_a = chip.value) != null ? _a : ""}`);
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx(Button, { variant: "link", size: "sm", className: "h-auto px-1 text-muted-foreground", onClick: onClearAll, children: t("clearAll") })
|
|
49
|
+
] });
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
ActiveFilterChips as default
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=ActiveFilterChips.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/viewers/Data/ActiveFilterChips.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\n\nimport { Badge } from '../../ui/Badge'\nimport { Button } from '../../ui/Button'\n\nimport type { FilterState } from '../../../types/global'\n\ntype ActiveFilterChipsProps = {\n activeFilters: FilterState[]\n onRemove: (id: number, value?: string) => void\n onClearAll: () => void\n fieldLabel?: (field: string) => string\n valueLabel?: (field: string, value: string) => string\n}\n\ntype Chip = { id: number; value?: string; text: string }\n\nconst formatValue = (value: FilterState['value'] | FilterState['secondValue']) =>\n value instanceof Date ? value.toLocaleDateString() : String(value)\n\nconst identity = (_field: string, value: string) => value\n\nfunction toChips(\n activeFilters: FilterState[],\n fieldLabel: (field: string) => string,\n valueLabel: (field: string, value: string) => string,\n): Chip[] {\n return activeFilters.flatMap(({ id, field, value, secondValue }) => {\n const label = fieldLabel(field)\n if (Array.isArray(value)) {\n return value.map(item => ({ id, value: item, text: `${label}: ${valueLabel(field, item)}` }))\n }\n const range = secondValue == null ? formatValue(value) : `${formatValue(value)} – ${formatValue(secondValue)}`\n return [{ id, text: `${label}: ${valueLabel(field, range)}` }]\n })\n}\n\n/** Removable chips for the filters applied to a data table, with a Clear all action. */\nexport default function ActiveFilterChips({\n activeFilters,\n onRemove,\n onClearAll,\n fieldLabel = field => field,\n valueLabel = identity,\n}: ActiveFilterChipsProps) {\n const t = useTranslations('HeaderButtons')\n const chips = toChips(activeFilters, fieldLabel, valueLabel)\n\n return (\n <div className=\"flex flex-wrap items-center gap-2\">\n {chips.map(chip => (\n <Badge key={`${chip.id}:${chip.value ?? ''}`} variant=\"secondary\" className=\"gap-1 pr-1 font-normal\">\n <span>{chip.text}</span>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-4 w-4 rounded-full hover:bg-transparent\"\n aria-label={t('removeFilter', { label: chip.text })}\n onClick={() => onRemove(chip.id, chip.value)}\n >\n <LR.X className=\"h-3 w-3\" />\n </Button>\n </Badge>\n ))}\n <Button variant=\"link\" size=\"sm\" className=\"h-auto px-1 text-muted-foreground\" onClick={onClearAll}>\n {t('clearAll')}\n </Button>\n </div>\n )\n}\n"],"mappings":";AAyDQ,SACE,KADF;AApDR,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAEhC,SAAS,aAAa;AACtB,SAAS,cAAc;AAcvB,MAAM,cAAc,CAAC,UACnB,iBAAiB,OAAO,MAAM,mBAAmB,IAAI,OAAO,KAAK;AAEnE,MAAM,WAAW,CAAC,QAAgB,UAAkB;AAEpD,SAAS,QACP,eACA,YACA,YACQ;AACR,SAAO,cAAc,QAAQ,CAAC,EAAE,IAAI,OAAO,OAAO,YAAY,MAAM;AAClE,UAAM,QAAQ,WAAW,KAAK;AAC9B,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,aAAO,MAAM,IAAI,WAAS,EAAE,IAAI,OAAO,MAAM,MAAM,GAAG,KAAK,KAAK,WAAW,OAAO,IAAI,CAAC,GAAG,EAAE;AAAA,IAC9F;AACA,UAAM,QAAQ,eAAe,OAAO,YAAY,KAAK,IAAI,GAAG,YAAY,KAAK,CAAC,WAAM,YAAY,WAAW,CAAC;AAC5G,WAAO,CAAC,EAAE,IAAI,MAAM,GAAG,KAAK,KAAK,WAAW,OAAO,KAAK,CAAC,GAAG,CAAC;AAAA,EAC/D,CAAC;AACH;AAGe,SAAR,kBAAmC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa,WAAS;AAAA,EACtB,aAAa;AACf,GAA2B;AACzB,QAAM,IAAI,gBAAgB,eAAe;AACzC,QAAM,QAAQ,QAAQ,eAAe,YAAY,UAAU;AAE3D,SACE,qBAAC,SAAI,WAAU,qCACZ;AAAA,UAAM,IAAI,UAAK;AAxDtB;AAyDQ,kCAAC,SAA6C,SAAQ,aAAY,WAAU,0BAC1E;AAAA,4BAAC,UAAM,eAAK,MAAK;AAAA,QACjB;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,EAAE,gBAAgB,EAAE,OAAO,KAAK,KAAK,CAAC;AAAA,YAClD,SAAS,MAAM,SAAS,KAAK,IAAI,KAAK,KAAK;AAAA,YAE3C,8BAAC,GAAG,GAAH,EAAK,WAAU,WAAU;AAAA;AAAA,QAC5B;AAAA,WAVU,GAAG,KAAK,EAAE,KAAI,UAAK,UAAL,YAAc,EAAE,EAW1C;AAAA,KACD;AAAA,IACD,oBAAC,UAAO,SAAQ,QAAO,MAAK,MAAK,WAAU,qCAAoC,SAAS,YACrF,YAAE,UAAU,GACf;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataMenu.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/Data/DataMenu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"DataMenu.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/Data/DataMenu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,EAAkB,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAqC5D,OAAO,KAAK,EAAwC,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAMhG,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,WAAW,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,wBAAgB,QAAQ,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,aAAa,qBAgnBlJ"}
|
|
@@ -21,6 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
23
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
import * as LR from "lucide-react";
|
|
24
25
|
import { useSession } from "next-auth/react";
|
|
25
26
|
import { useTranslations } from "next-intl";
|
|
26
27
|
import * as React from "react";
|
|
@@ -29,13 +30,14 @@ import { useBuildings, useCreateBuilding } from "../../../hooks/buildings/buildi
|
|
|
29
30
|
import { useFiles } from "../../../hooks/files/files";
|
|
30
31
|
import { useCreateInfrastructure, useInfrastructures } from "../../../hooks/infrastructures/infrastructures";
|
|
31
32
|
import { useCreateSite, useSites } from "../../../hooks/sites/sites";
|
|
33
|
+
import { useIsMobile } from "../../../hooks/ui/use-mobile";
|
|
32
34
|
import { useUsers } from "../../../hooks/users/users";
|
|
33
35
|
import { useMenusContext } from "../../../store";
|
|
34
36
|
import { useBuildingsContext } from "../../../store";
|
|
35
37
|
import { useFilesContext } from "../../../store";
|
|
36
38
|
import { DataTypesNames, ViewerNames } from "../../../types";
|
|
37
39
|
import { handleApiError } from "../../../utils/errorHandler";
|
|
38
|
-
import { Button, Checkbox, DataTable, Input, Separator } from "../../ui/";
|
|
40
|
+
import { Badge, Button, Checkbox, DataTable, Input, Separator } from "../../ui/";
|
|
39
41
|
import {
|
|
40
42
|
Breadcrumb,
|
|
41
43
|
BreadcrumbItem,
|
|
@@ -44,23 +46,32 @@ import {
|
|
|
44
46
|
BreadcrumbPage,
|
|
45
47
|
BreadcrumbSeparator
|
|
46
48
|
} from "../../ui/Breadcrumb";
|
|
49
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/Popover";
|
|
50
|
+
import ActiveFilterChips from "./ActiveFilterChips";
|
|
47
51
|
import BuildingDetails from "./buildingDetails/BuildingDetails";
|
|
48
52
|
import DetailActions from "./details/DetailActions";
|
|
49
53
|
import DetailHeader from "./details/DetailHeader";
|
|
50
54
|
import { FileDetails } from "./files/FileDetails";
|
|
51
55
|
import FilterButtons from "./FilterButtons";
|
|
52
|
-
import HeaderButtons from "./HeaderButtons";
|
|
53
56
|
import InfrastructureDetails from "./infrastructureDetails/InfrastructureDetails";
|
|
54
57
|
import MoreOptions from "./MoreOptions";
|
|
58
|
+
import PageActions from "./PageActions";
|
|
59
|
+
import ResultActions from "./ResultActions";
|
|
55
60
|
import SiteDetails from "./siteDetails/SiteDetails";
|
|
56
61
|
import UserDetails from "./userDetails/UserDetails";
|
|
57
62
|
import { useColumns, useUserColumns } from "./utils/Columns";
|
|
63
|
+
import { hasFilterButtons } from "./utils/filterFieldNames";
|
|
64
|
+
import { removeFilterValue } from "./utils/filterHelper";
|
|
58
65
|
import { useBuildingHeaders, useInfrastructureHeaders, useSiteHeaders } from "./utils/Headers";
|
|
66
|
+
import { useFilterChipLabels } from "./utils/useFilterChipLabels";
|
|
59
67
|
import { useViewerData } from "./utils/useViewerData";
|
|
60
68
|
import { VIEWER_CONFIG } from "./utils/viewerConfig";
|
|
69
|
+
const EMPTY_FILTER_ROW = { id: 1, field: "", fieldType: null, operator: null, value: null, secondValue: null };
|
|
61
70
|
function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, organization, geocodeEarthApiKey, geocoderUrl }) {
|
|
62
71
|
var _a, _b, _c;
|
|
63
72
|
const t = useTranslations("DataMenu");
|
|
73
|
+
const tHeader = useTranslations("HeaderButtons");
|
|
74
|
+
const isMobile = useIsMobile();
|
|
64
75
|
const { view, setView } = useMenusContext();
|
|
65
76
|
const { selectedItem, setSelectedItem } = useMenusContext();
|
|
66
77
|
const { selectedSite, setSelectedSite } = useMenusContext();
|
|
@@ -71,9 +82,18 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
71
82
|
const { currentFile } = fileState.files;
|
|
72
83
|
const [searchTerm, setSearchTerm] = React.useState("");
|
|
73
84
|
const [activeFilters, setActiveFilters] = React.useState([]);
|
|
74
|
-
const [filters, setFilters] = React.useState([
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
const [filters, setFilters] = React.useState([EMPTY_FILTER_ROW]);
|
|
86
|
+
const removeFilter = (id, value) => {
|
|
87
|
+
setActiveFilters((prev) => removeFilterValue(prev, id, value));
|
|
88
|
+
setFilters((prev) => {
|
|
89
|
+
const remaining = removeFilterValue(prev, id, value);
|
|
90
|
+
return remaining.length > 0 ? remaining : [EMPTY_FILTER_ROW];
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const clearAllFilters = () => {
|
|
94
|
+
setActiveFilters([]);
|
|
95
|
+
setFilters([EMPTY_FILTER_ROW]);
|
|
96
|
+
};
|
|
77
97
|
const [dataType, setDataType] = React.useState(DataTypesNames.building);
|
|
78
98
|
const [editing, setEditing] = React.useState(false);
|
|
79
99
|
const [activeChanges, setActiveChanges] = React.useState(false);
|
|
@@ -108,7 +128,6 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
108
128
|
prevInfrastructureId.current = selectedInfrastructure == null ? void 0 : selectedInfrastructure.id;
|
|
109
129
|
}
|
|
110
130
|
}, [selectedItem == null ? void 0 : selectedItem.id, selectedInfrastructure == null ? void 0 : selectedInfrastructure.id, currentViewer]);
|
|
111
|
-
const [newItemName, setNewItemName] = React.useState("");
|
|
112
131
|
const {
|
|
113
132
|
compareItems,
|
|
114
133
|
setCompareItems,
|
|
@@ -131,6 +150,7 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
131
150
|
React.useEffect(() => {
|
|
132
151
|
setComparing(false);
|
|
133
152
|
setCompareItems([]);
|
|
153
|
+
clearAllFilters();
|
|
134
154
|
}, [currentViewer, setComparing, setCompareItems]);
|
|
135
155
|
const { buildings, isLoading: buildingsLoading, isError: buildingsError } = useBuildings();
|
|
136
156
|
const { sites, isLoading: sitesLoading, isError: sitesError } = useSites();
|
|
@@ -150,6 +170,7 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
150
170
|
handleApiError(createBuildingError);
|
|
151
171
|
handleApiError(createInfrastructureError);
|
|
152
172
|
}, [buildingsError, sitesError, infrastructuresError, filesError, usersError, createSiteError, createBuildingError, createInfrastructureError]);
|
|
173
|
+
const filterChipLabels = useFilterChipLabels({ buildings, sites, infrastructures });
|
|
153
174
|
const tableColumns = useColumns(buildings || []);
|
|
154
175
|
const userColumns = useUserColumns();
|
|
155
176
|
const { user } = useSession().data;
|
|
@@ -175,6 +196,7 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
175
196
|
filters,
|
|
176
197
|
userEmail: (user == null ? void 0 : user.email) || ""
|
|
177
198
|
});
|
|
199
|
+
const collectionData = currentViewer === ViewerNames.buildings || currentViewer === ViewerNames.sites || currentViewer === ViewerNames.infrastructure ? filteredData : void 0;
|
|
178
200
|
const openedCurrentFileIdRef = React.useRef(null);
|
|
179
201
|
React.useEffect(() => {
|
|
180
202
|
if (currentViewer !== ViewerNames.files || !currentFile) return;
|
|
@@ -290,6 +312,29 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
290
312
|
}
|
|
291
313
|
};
|
|
292
314
|
const isNewItem = !!(selectedSite && selectedSite.id < 0 || selectedItem && selectedItem.id < 0 || selectedInfrastructure && selectedInfrastructure.id < 0);
|
|
315
|
+
const pageActions = /* @__PURE__ */ jsx(
|
|
316
|
+
PageActions,
|
|
317
|
+
{
|
|
318
|
+
currentViewer,
|
|
319
|
+
users: currentViewer === ViewerNames.users ? users : void 0,
|
|
320
|
+
geocodeEarthApiKey,
|
|
321
|
+
geocoderUrl,
|
|
322
|
+
filteredData: collectionData
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
const filterButtons = /* @__PURE__ */ jsx(
|
|
326
|
+
FilterButtons,
|
|
327
|
+
{
|
|
328
|
+
currentViewer,
|
|
329
|
+
filters,
|
|
330
|
+
activeFilters,
|
|
331
|
+
filterFields: filtersOptions,
|
|
332
|
+
data,
|
|
333
|
+
setFilters,
|
|
334
|
+
setActiveFilters,
|
|
335
|
+
collapsed: isMobile
|
|
336
|
+
}
|
|
337
|
+
);
|
|
293
338
|
return /* @__PURE__ */ jsx("div", { className: `${hideFrame ? "" : "sm:p-2"} overflow-hidden ${hideFrame ? "" : "bg-[#fafafa]"} ${height ? height : "h-full"}`, children: /* @__PURE__ */ jsx("div", { className: `${hideFrame ? "" : "bg-background rounded-xl shadow"} h-full min-h-0`, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full min-h-0", children: [
|
|
294
339
|
/* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
295
340
|
/* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 justify-start items-center px-3 py-4 relative", children: /* @__PURE__ */ jsx(Breadcrumb, { className: "px-3", children: /* @__PURE__ */ jsxs(BreadcrumbList, { children: [
|
|
@@ -300,19 +345,22 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
300
345
|
] })
|
|
301
346
|
] }) }) }),
|
|
302
347
|
view === "table" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
303
|
-
!hideTitle && /* @__PURE__ */
|
|
304
|
-
/* @__PURE__ */ jsxs("div", { className: "flex
|
|
305
|
-
/* @__PURE__ */
|
|
306
|
-
|
|
348
|
+
!hideTitle && /* @__PURE__ */ jsxs("div", { className: "flex flex-row justify-between items-start gap-3 px-3 sm:px-6 py-6", children: [
|
|
349
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 min-w-0", children: [
|
|
350
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
351
|
+
/* @__PURE__ */ jsx(MenuIcon, { className: "h-8 w-8 shrink-0" }),
|
|
352
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl text-foreground", children: headerTitle })
|
|
353
|
+
] }),
|
|
354
|
+
comparing && /* @__PURE__ */ jsxs("h2", { className: "text-sm text-muted-foreground font-normal", children: [
|
|
355
|
+
"Choose up to 3 ",
|
|
356
|
+
headerTitle.toLowerCase(),
|
|
357
|
+
" to compare."
|
|
358
|
+
] })
|
|
307
359
|
] }),
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
] })
|
|
313
|
-
] }) }),
|
|
314
|
-
/* @__PURE__ */ jsxs("div", { className: `flex flex-col sm:flex-row ${hideTitle ? "sm:justify-between" : "sm:justify-end"} items-stretch sm:items-center px-3 sm:px-6 py-4 gap-3 sm:gap-4`, children: [
|
|
315
|
-
/* @__PURE__ */ jsx("div", { className: `w-full ${hideTitle ? "sm:w-64" : "sm:w-96"}`, children: /* @__PURE__ */ jsx(
|
|
360
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-end gap-2", children: pageActions })
|
|
361
|
+
] }),
|
|
362
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 px-3 sm:px-6 py-4", children: [
|
|
363
|
+
/* @__PURE__ */ jsx("div", { className: "w-full sm:w-80", children: /* @__PURE__ */ jsx(
|
|
316
364
|
Input,
|
|
317
365
|
{
|
|
318
366
|
placeholder: `${t("searchPlaceholder")} ${headerTitle}...`,
|
|
@@ -320,38 +368,39 @@ function DataMenu({ currentViewer, height, hideTitle, hideActions, hideFrame, or
|
|
|
320
368
|
onChange: (e) => setSearchTerm(e.target.value)
|
|
321
369
|
}
|
|
322
370
|
) }),
|
|
323
|
-
/* @__PURE__ */ jsxs(
|
|
324
|
-
/* @__PURE__ */ jsx(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
newItemName,
|
|
346
|
-
setNewItemName,
|
|
347
|
-
filteredData: currentViewer === ViewerNames.buildings || currentViewer === ViewerNames.sites || currentViewer === ViewerNames.infrastructure ? filteredData : void 0,
|
|
348
|
-
users: currentViewer === ViewerNames.users ? users : void 0,
|
|
349
|
-
geocodeEarthApiKey,
|
|
350
|
-
geocoderUrl
|
|
351
|
-
}
|
|
352
|
-
)
|
|
353
|
-
] })
|
|
371
|
+
isMobile && hasFilterButtons(currentViewer) ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
372
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "border-dashed", children: [
|
|
373
|
+
/* @__PURE__ */ jsx(LR.ListFilter, {}),
|
|
374
|
+
tHeader("filters"),
|
|
375
|
+
activeFilters.length > 0 && /* @__PURE__ */ jsx(Badge, { children: activeFilters.length })
|
|
376
|
+
] }) }),
|
|
377
|
+
/* @__PURE__ */ jsx(PopoverContent, { align: "start", className: "flex w-auto flex-col items-stretch gap-2 p-2", children: filterButtons })
|
|
378
|
+
] }) : filterButtons,
|
|
379
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
380
|
+
/* @__PURE__ */ jsx(
|
|
381
|
+
ResultActions,
|
|
382
|
+
{
|
|
383
|
+
headerTitle,
|
|
384
|
+
currentViewer,
|
|
385
|
+
filteredData: collectionData,
|
|
386
|
+
compareItems,
|
|
387
|
+
setCompareItems,
|
|
388
|
+
comparing,
|
|
389
|
+
setComparing
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
hideTitle && pageActions
|
|
354
393
|
] }),
|
|
394
|
+
activeFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "px-3 sm:px-6 pb-3", children: /* @__PURE__ */ jsx(
|
|
395
|
+
ActiveFilterChips,
|
|
396
|
+
{
|
|
397
|
+
activeFilters,
|
|
398
|
+
onRemove: removeFilter,
|
|
399
|
+
onClearAll: clearAllFilters,
|
|
400
|
+
fieldLabel: filterChipLabels.fieldLabel,
|
|
401
|
+
valueLabel: filterChipLabels.valueLabel
|
|
402
|
+
}
|
|
403
|
+
) }),
|
|
355
404
|
/* @__PURE__ */ jsx(Separator, {})
|
|
356
405
|
] }) : (
|
|
357
406
|
// Detail View Header
|