Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend - Polishing up before release #364

Merged
merged 33 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e6fdfc8
Implemented simple 3D window
Corgam Jul 2, 2024
a90c1ca
Added leaflet map render
Corgam Jul 2, 2024
674a403
Fixed map not loading and camera
Corgam Jul 2, 2024
de76e8a
Further work on the controlls
Corgam Jul 2, 2024
96ecd27
Worked on the controls
Corgam Jul 2, 2024
29ab70f
The proper map is rendered instead
Corgam Jul 2, 2024
7709ab3
Merge branch 'sprint-release' into dev-eb
Corgam Jul 4, 2024
a89f8b7
Fixed popup for for marker on double click
Corgam Jul 4, 2024
ba7939c
Switching to new tab on add
Corgam Jul 4, 2024
e57d7e7
Reload button on tab switch
Corgam Jul 4, 2024
b088652
Started working on the polygon location data
Corgam Jul 4, 2024
c31430b
Worked on drawing polygons
Corgam Jul 4, 2024
657108a
Fixed not changing isDrawing
Corgam Jul 4, 2024
1742ff1
Removing old polygon when drawing a new one
Corgam Jul 4, 2024
a76058c
Disable draw polygon tooltips
Corgam Jul 4, 2024
7bba4d4
Finished the styling of the polygon
Corgam Jul 4, 2024
e49e4b4
Fixed display of coordinates in dataview
Corgam Jul 4, 2024
720a4c6
Created a selection type
Corgam Jul 6, 2024
d2a5beb
Added mapcontext reference for polygon event
Corgam Jul 6, 2024
f3a71e6
Fixed location endpoint calls
Corgam Jul 6, 2024
7416af6
Added working selections with search bar
Corgam Jul 6, 2024
505b816
Added ability to store marker names
Corgam Jul 6, 2024
59ca878
Fixed drawing of searched addresses + cleanup of last search
Corgam Jul 6, 2024
55330d7
Fixed location endpoint body
Corgam Jul 6, 2024
cfc092d
Cleanup
Corgam Jul 6, 2024
3f678e1
Implemented the open as a map functionality
Corgam Jul 6, 2024
c035d6c
Removed temp location values
Corgam Jul 6, 2024
dda4db7
Removed 3D
Corgam Jul 6, 2024
3772bca
Fixed styling issue with polygon drawing
Corgam Jul 6, 2024
eed1cc9
Uninstalled Three.js
Corgam Jul 6, 2024
e37254b
Small fixes
Corgam Jul 6, 2024
3a16353
Fixed data not loading at the start
Corgam Jul 6, 2024
38f6f55
fixed/added multipolygon handling
Lucas-Nan Jul 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"@phosphor-icons/react": "^2.1.5",
"@types/autosuggest-highlight": "^3.2.3",
"@types/geojson": "^7946.0.14",
"@types/leaflet-draw": "^1.0.11",
"@types/leaflet.markercluster": "^1.5.4",
"@types/proj4leaflet": "^1.0.10",
"autosuggest-highlight": "^3.3.4",
"axios": "^1.7.2",
"geojson": "^0.5.0",
"leaflet": "^1.9.4",
"leaflet-draw": "^1.0.4",
"leaflet-geosearch": "^4.0.0",
"leaflet.markercluster": "^1.5.3",
"proj4leaflet": "^1.0.2",
Expand Down
143 changes: 103 additions & 40 deletions frontend/src/components/DataView/DataPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,15 @@ import { CaretDown, MapTrifold } from "@phosphor-icons/react";
import "./DataPanel.css";
import { Tooltip } from "@mui/material";
import { GridToolbar, GridToolbarProps } from "@mui/x-data-grid";
import { useState } from "react";

// Returns a button if the "button" value is set to 1
const renderDetailsButton = (params: GridRenderCellParams) => {
const value = params.value;
if (value === 1) {
return (
<strong>
<Tooltip arrow title="Open as a map">
<IconButton aria-label="open as map" size="small">
<MapTrifold />
</IconButton>
</Tooltip>
</strong>
);
} else {
return null;
}
};

// Defines the columns of the Datagrid
const columns: GridColDef[] = [
{
field: "button",
headerName: "button",
width: 60,
renderCell: renderDetailsButton,
},
{ field: "key", headerName: "key", width: 250 },
{
field: "value",
headerName: "value",
type: "number",
width: 250,
getApplyQuickFilterFn: undefined,
},
];
import { useContext, useState } from "react";
import { DatasetItem } from "../../types/LocationDataTypes";
import { TabsContext } from "../../contexts/TabsContext";
import { fetchDatasets } from "../../services/datasetsService";
import { AlertContext } from "../../contexts/AlertContext";
import { Dataset } from "../../types/DatasetTypes";
import L from "leaflet";
import CustomSvgIcon from "../DatasetsList/CustomSvgIcon";
import { svgIconDefault } from "../DatasetsList/DatasetsList";

function MyCustomToolbar(props: GridToolbarProps) {
return <GridToolbar {...props} />;
Expand All @@ -50,9 +22,9 @@ function MyCustomToolbar(props: GridToolbarProps) {
interface DataPanelProps {
listTitle: string;
filterValue: string;
mapRows: object[];
genericRows: object[];
extraRows: object[];
mapRows: DatasetItem[];
genericRows: DatasetItem[];
extraRows: DatasetItem[];
}

/*
Expand All @@ -72,6 +44,88 @@ const DataPanel: React.FC<DataPanelProps> = ({
useState<boolean>(false);
const [ifExtraDataTabHidden, toggleExtraDataHidden] =
useState<boolean>(false);
const { currentAlertCache, setCurrentAlertCache } = useContext(AlertContext);

const { openNewTab } = useContext(TabsContext);

const openDatasetFromMapIcon = async (mapId: string) => {
const datasetsData = await fetchDatasets();
if (datasetsData) {
const datasetToOpen = datasetsData.find(
(dataset) => dataset.datasetId === mapId
);
if (datasetToOpen) {
const datasetToOpenTransformed: Dataset = {
id: datasetToOpen.datasetId,
displayName: datasetToOpen.name,
shortDescription: datasetToOpen.shortDescription,
datasetIcon: datasetToOpen.icon ? (
<CustomSvgIcon svgString={datasetToOpen.icon} size={24} />
) : (
<CustomSvgIcon svgString={svgIconDefault} size={24} />
),
metaData: undefined,
data: {
type: "FeatureCollection",
features: [],
},
lastDataRequestBounds: L.latLngBounds(L.latLng(0, 0), L.latLng(0, 0)),
};

openNewTab(datasetToOpenTransformed);
} else {
// Display alert
setCurrentAlertCache({
...currentAlertCache,
isAlertOpened: true,
text: "Dataset with provided ID does not exist.",
});
console.error("Dataset with provided ID does not exist.");
}
}
};

// Returns a button if the "button" value is set to 1
const renderDetailsButton = (params: GridRenderCellParams) => {
const dataObject = params.row as DatasetItem;
if (dataObject.mapId !== "") {
return (
<strong>
<Tooltip arrow title="Open a map ">
<IconButton
aria-label="open as map"
size="small"
onClick={() => {
openDatasetFromMapIcon(dataObject.mapId);
}}
>
<MapTrifold />
</IconButton>
</Tooltip>
</strong>
);
} else {
return null;
}
};

// Defines the columns of the Datagrid
const columns: GridColDef[] = [
{
field: "button",
headerName: "button",
width: 60,
renderCell: renderDetailsButton,
},
{ field: "key", headerName: "key", width: 250 },
{
field: "value",
headerName: "value",
type: "number",
width: 250,
getApplyQuickFilterFn: undefined,
},
];

return (
<div className="datapanels-container">
Expand Down Expand Up @@ -99,6 +153,9 @@ const DataPanel: React.FC<DataPanelProps> = ({
}`}
>
<DataGrid
getRowId={(row: DatasetItem) => {
return row.key + row.value;
}}
hideFooter={true}
disableColumnMenu
columnHeaderHeight={0}
Expand Down Expand Up @@ -161,6 +218,9 @@ const DataPanel: React.FC<DataPanelProps> = ({
}`}
>
<DataGrid
getRowId={(row: DatasetItem) => {
return row.key + row.value;
}}
hideFooter={true}
disableColumnMenu
columnHeaderHeight={0}
Expand Down Expand Up @@ -223,6 +283,9 @@ const DataPanel: React.FC<DataPanelProps> = ({
}`}
>
<DataGrid
getRowId={(row: DatasetItem) => {
return row.key + row.value;
}}
hideFooter={true}
disableColumnMenu
columnHeaderHeight={0}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/DataView/DataView.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@
width: 1rem;
height: 1rem;
}

.sub-text {
color: gray;
font-size: 0.6rem;
}
Loading
Loading