Skip to content

Commit

Permalink
Merge branch 'main' into task/WG-422-poll-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfranklin committed Feb 13, 2025
2 parents 5fa2c00 + 6d52a02 commit 5abf3cd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 32 deletions.
14 changes: 2 additions & 12 deletions react/src/components/AssetsPanel/AssetsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useImportFeature,
useNotification,
} from '@hazmapper/hooks';
import { IMPORTABLE_FEATURE_TYPES } from '@hazmapper/utils/fileUtils';
import FileBrowserModal from '../FileBrowserModal/FileBrowserModal';

const getFilename = (projectName: string) => {
Expand Down Expand Up @@ -114,17 +115,6 @@ const AssetsPanel: React.FC<Props> = ({
);
};

const allowedFileExtensions = [
'shp',
'jpg',
'jpeg',
'json',
'geojson',
'gpx',
'rq',
'png',
];

const { Content, Header, Footer } = Layout;

return (
Expand Down Expand Up @@ -153,7 +143,7 @@ const AssetsPanel: React.FC<Props> = ({
isOpen={isModalOpen}
toggle={() => setIsModalOpen(false)}
onImported={handleFileImport}
allowedFileExtensions={allowedFileExtensions}
allowedFileExtensions={IMPORTABLE_FEATURE_TYPES}
/>
</>
);
Expand Down
47 changes: 27 additions & 20 deletions react/src/components/PointCloudsPanel/PointCloudPanelButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ interface DeletePointCloudButtonProps {
pointCloudId: number;
}

import React from 'react';
import React, { useState } from 'react';
import { Button } from 'antd';
import { UploadOutlined, DeleteOutlined } from '@ant-design/icons';

import { PointCloud } from '@hazmapper/types';
import { PointCloud, TapisFilePath } from '@hazmapper/types';
import FileBrowserModal from '../FileBrowserModal/FileBrowserModal';
import { useDeletePointCloud, useImportPointCloudFile } from '@hazmapper/hooks';
import { IMPORTABLE_POINT_CLOUD_TYPES } from '@hazmapper/utils/fileUtils';

interface UploadPointCloudButtonProps {
pointCloud: PointCloud;
Expand All @@ -17,31 +19,36 @@ interface UploadPointCloudButtonProps {
export const UploadPointCloudButton: React.FC<UploadPointCloudButtonProps> = ({
pointCloud,
}) => {
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
const { mutate: addPointCloudFile } = useImportPointCloudFile({
projectId: pointCloud.project_id,
pointCloudId: pointCloud.id,
});

const handleAddFile = () => {
console.log('TODO: Opening file browser for point cloud:', pointCloud.id);
addPointCloudFile({
files: [
{
system: 'project-4072868216578445806-242ac117-0001-012',
path: 'point_clouds_good/red-rocks.laz',
},
],
});
const handleFileImport = (files: TapisFilePath[]) => {
addPointCloudFile({ files });
setIsModalOpen(false);
};

return (
<Button
data-testid={`upload-point-cloud-${pointCloud.id}`}
size="small"
icon={<UploadOutlined />}
onClick={() => handleAddFile()}
>
Add las/laz
</Button>
<>
<Button
data-testid={`upload-point-cloud-${pointCloud.id}`}
size="small"
icon={<UploadOutlined />}
onClick={() => setIsModalOpen(true)}
>
Add las/laz
</Button>
{isModalOpen && (
<FileBrowserModal
isOpen={isModalOpen}
toggle={() => setIsModalOpen(false)}
onImported={handleFileImport}
allowedFileExtensions={IMPORTABLE_POINT_CLOUD_TYPES}
/>
)}
</>
);
};

Expand Down
22 changes: 22 additions & 0 deletions react/src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import { FileData } from 'chonky';
import { TapisFilePath, File } from '@hazmapper/types';

export const IMPORTABLE_FEATURE_TYPES = [
'shp',
'jpg',
'jpeg',
'json',
'geojson',
'gpx',
'rq',
];

export const IMPORTABLE_FEATURE_ASSET_TYPES = [
'jpeg',
'jpg',
'png',
'mp4',
'mov',
'mpeg4',
'webm',
];

export const IMPORTABLE_POINT_CLOUD_TYPES = ['las', 'laz'];

export const serializeToChonkyFile = (
file: File,
allowedFileExtensions: string[]
Expand Down

0 comments on commit 5abf3cd

Please sign in to comment.