-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
24 changed files
with
1,507 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
apps/web/components/map/panels/toolbox/tools/InputLayer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import React from "react"; | ||
import { | ||
Typography, | ||
useTheme, | ||
Box, | ||
Select, | ||
FormControl, | ||
InputLabel, | ||
MenuItem, | ||
} from "@mui/material"; | ||
import { useProjectLayers } from "@/hooks/map/layersHooks"; | ||
import { v4 } from "uuid"; | ||
import { useTranslation } from "@/i18n/client"; | ||
|
||
import type { SelectChangeEvent } from "@mui/material"; | ||
|
||
interface PickLayerProps { | ||
multiple?: boolean; | ||
inputValues: string | string[]; | ||
setInputValues: (value: string | string[]) => void; | ||
layerTypes: string[]; | ||
} | ||
|
||
const InputLayer = (props: PickLayerProps) => { | ||
const { multiple = false, inputValues, setInputValues, layerTypes } = props; | ||
|
||
const theme = useTheme(); | ||
const { t } = useTranslation("maps"); | ||
|
||
const { projectLayers } = useProjectLayers(); | ||
|
||
const handleSingleChange = (event: SelectChangeEvent) => { | ||
setInputValues(event.target.value as string); | ||
}; | ||
|
||
const handleMultipleChange = (event: SelectChangeEvent, inputNr: number) => { | ||
const multipleValues = | ||
typeof inputValues !== "string" ? [...inputValues] : ["", ""]; | ||
multipleValues[inputNr] = event.target.value as string; | ||
|
||
setInputValues(multipleValues); | ||
}; | ||
|
||
return ( | ||
<Box> | ||
{multiple ? ( | ||
<> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
gap={theme.spacing(2)} | ||
marginBottom={theme.spacing(4)} | ||
> | ||
<Typography variant="body1" sx={{ color: "black" }}> | ||
{t("panels.tools.join.pick_target_layer")} | ||
</Typography> | ||
<Typography variant="body2" sx={{ fontStyle: "italic" }}> | ||
{t("panels.tools.join.target_layer_text")} | ||
</Typography> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="demo-simple-select-label"> | ||
{t("panels.tools.select_layer")} | ||
</InputLabel> | ||
<Select | ||
label={t("panels.tools.select_layer")} | ||
value={inputValues[0]} | ||
onChange={(event: SelectChangeEvent) => | ||
handleMultipleChange(event, 0) | ||
} | ||
> | ||
{projectLayers.map((layer) => ( | ||
<MenuItem value={layer.id} key={v4()}> | ||
{layer.name} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
gap={theme.spacing(2)} | ||
marginBottom={theme.spacing(4)} | ||
> | ||
<Typography | ||
variant="body1" | ||
sx={{ color: "black", marginBottom: theme.spacing(2) }} | ||
> | ||
{t("panels.tools.join.pick_join_layer")} | ||
</Typography> | ||
<Typography variant="body2" sx={{ fontStyle: "italic" }}> | ||
{t("panels.tools.join.join_layer_text")} | ||
</Typography> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="demo-simple-select-label"> | ||
{t("panels.tools.select_layer")} | ||
</InputLabel> | ||
<Select | ||
label={t("panels.tools.select_layer")} | ||
value={inputValues[1]} | ||
onChange={(event: SelectChangeEvent) => | ||
handleMultipleChange(event, 1) | ||
} | ||
> | ||
{projectLayers.map((layer) => ( | ||
<MenuItem value={layer.id} key={v4()}> | ||
{layer.name} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
</> | ||
) : ( | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
gap={theme.spacing(2)} | ||
marginBottom={theme.spacing(4)} | ||
> | ||
<Typography variant="body1" sx={{ color: "black" }}> | ||
{t("panels.tools.aggregate.pick_layer")} | ||
</Typography> | ||
<Typography variant="body2" sx={{ fontStyle: "italic" }}> | ||
{t("panels.tools.aggregate.pick_layer_text")} | ||
</Typography> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="demo-simple-select-label"> | ||
{" "} | ||
{t("panels.tools.select_layer")} | ||
</InputLabel> | ||
<Select | ||
label={t("panels.tools.select_layer")} | ||
value={inputValues} | ||
onChange={handleSingleChange} | ||
> | ||
{projectLayers.map((layer) => | ||
layerTypes.includes(layer.feature_layer_geometry_type) ? ( | ||
<MenuItem value={layer.id} key={v4()}> | ||
{layer.name} | ||
</MenuItem> | ||
) : null, | ||
)} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default InputLayer; |
122 changes: 122 additions & 0 deletions
122
apps/web/components/map/panels/toolbox/tools/SaveResult.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React from "react"; | ||
import { | ||
Box, | ||
Typography, | ||
Card, | ||
RadioGroup, | ||
FormControlLabel, | ||
Radio, | ||
useTheme, | ||
TextField, | ||
Select, | ||
FormControl, | ||
InputLabel, | ||
MenuItem, | ||
} from "@mui/material"; | ||
import { Icon, ICON_NAME } from "@p4b/ui/components/Icon"; | ||
import { useFolders } from "@/lib/api/folders"; | ||
import { v4 } from "uuid"; | ||
import { useTranslation } from "@/i18n/client"; | ||
|
||
import type { SelectChangeEvent } from "@mui/material"; | ||
|
||
interface SaveResultProps { | ||
outputName: string | undefined; | ||
setOutputName: (value: string) => void; | ||
folderSaveId: string | undefined; | ||
setFolderSaveID: (value: string) => void; | ||
} | ||
|
||
const SaveResult = (props: SaveResultProps) => { | ||
const { outputName, setOutputName, folderSaveId, setFolderSaveID } = props; | ||
|
||
const theme = useTheme(); | ||
const { t } = useTranslation("maps"); | ||
|
||
const { folders } = useFolders(); | ||
|
||
return ( | ||
<Box display="flex" flexDirection="column" gap={theme.spacing(2)}> | ||
<Typography variant="body1" sx={{ color: "black" }}> | ||
{t("panels.tools.result")} | ||
</Typography> | ||
<Card | ||
sx={{ | ||
paddingLeft: theme.spacing(2), | ||
backgroundColor: `${theme.palette.background.default}80`, | ||
}} | ||
> | ||
<RadioGroup aria-label="options" name="options"> | ||
<FormControlLabel | ||
value={outputName} | ||
sx={{ | ||
span: { | ||
fontSize: "12px", | ||
fontStyle: "italic", | ||
}, | ||
}} | ||
control={ | ||
<Radio | ||
color="default" | ||
icon={ | ||
<Icon | ||
iconName={ICON_NAME.STAR} | ||
htmlColor={theme.palette.primary.dark} | ||
sx={{ fontSize: "18px" }} | ||
/> | ||
} | ||
checkedIcon={ | ||
<Icon | ||
iconName={ICON_NAME.STAR} | ||
htmlColor={theme.palette.primary.main} | ||
sx={{ fontSize: "18px" }} | ||
/> | ||
} | ||
/> | ||
} | ||
label={outputName} | ||
/> | ||
</RadioGroup> | ||
</Card> | ||
<Typography variant="body1" sx={{ color: "black", marginTop: theme.spacing(5)}}> | ||
{t("panels.tools.output_name")} | ||
</Typography> | ||
<Box> | ||
<TextField | ||
fullWidth | ||
value={outputName ? outputName : ""} | ||
label="Name" | ||
size="small" | ||
onChange={(event: React.ChangeEvent<HTMLInputElement>) => | ||
setOutputName(event.target.value as string) | ||
} | ||
/> | ||
</Box> | ||
<Typography variant="body1" sx={{ color: "black" }}> | ||
{t("panels.tools.save_in_folder")} | ||
</Typography> | ||
<Box> | ||
<FormControl fullWidth size="small"> | ||
<InputLabel id="demo-simple-select-label">{t("panels.tools.select_option")}</InputLabel> | ||
<Select | ||
label={t("panels.tools.select_option")} | ||
value={folderSaveId} | ||
onChange={(event: SelectChangeEvent) => | ||
setFolderSaveID(event.target.value as string) | ||
} | ||
> | ||
{folders | ||
? folders.map((folder) => ( | ||
<MenuItem value={folder.id} key={v4()}> | ||
{folder.name} | ||
</MenuItem> | ||
)) | ||
: null} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default SaveResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, { useState } from "react"; | ||
import { Box, useTheme, Typography } from "@mui/material"; | ||
import { v4 } from "uuid"; | ||
import Join from "@/components/map/panels/toolbox/tools/join/Join"; | ||
import { Icon, ICON_NAME } from "@p4b/ui/components/Icon"; | ||
import Aggregate from "@/components/map/panels/toolbox/tools/aggregate/Aggregate"; | ||
import { useParams } from "next/navigation"; | ||
|
||
interface ToolTabType { | ||
name: string; | ||
tooltip: string; | ||
value: string; | ||
element: React.ReactNode; | ||
} | ||
|
||
const ToolTabs = () => { | ||
const [value, setValue] = useState<ToolTabType | undefined>(undefined); | ||
|
||
const theme = useTheme(); | ||
const params = useParams(); | ||
|
||
const tabs: ToolTabType[] = [ | ||
{ | ||
name: "Join", | ||
tooltip: | ||
"Utilize join tool to merge columns from different layers. Apply functions like count, sum, min, etc., for desired results.", | ||
value: "join", | ||
element: <Join projectId={typeof params.projectId === "string" ? params.projectId : ""}/>, | ||
}, | ||
{ | ||
name: "Aggregate features", | ||
tooltip: | ||
"Utilize join tool to merge columns from different layers. Apply functions like count, sum, min, etc., for desired results.", | ||
value: "aggregate_features", | ||
element: <Aggregate projectId={typeof params.projectId === "string" ? params.projectId : ""}/>, | ||
}, | ||
{ | ||
name: "Summarize features", | ||
tooltip: | ||
"Utilize join tool to merge columns from different layers. Apply functions like count, sum, min, etc., for desired results.", | ||
value: "summarize_features", | ||
element: <p>summarize</p>, | ||
}, | ||
{ | ||
name: "Origin to destination", | ||
tooltip: | ||
"Utilize join tool to merge columns from different layers. Apply functions like count, sum, min, etc., for desired results.", | ||
value: "origin_to_destination", | ||
element: <p>origin</p>, | ||
}, | ||
]; | ||
|
||
const handleChange = (newValue: ToolTabType | undefined) => { | ||
setValue(newValue); | ||
}; | ||
|
||
return ( | ||
<Box sx={{maxHeight: "100%"}}> | ||
{!value && | ||
tabs.map((tab) => ( | ||
<Box | ||
key={v4()} | ||
sx={{ | ||
padding: "12px 0", | ||
borderBottom: `1px solid ${theme.palette.primary.main}80`, | ||
display: "flex", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
cursor: "pointer", | ||
transition: "all 0.3s ease-in-out", | ||
"&:hover": { | ||
backgroundColor: `${theme.palette.secondary.light}40` | ||
} | ||
}} | ||
onClick={() => handleChange(tab)} | ||
> | ||
<Box sx={{ display: "flex", alignItems: "center", gap: theme.spacing(2) }}> | ||
<Icon iconName={ICON_NAME.CIRCLEINFO} htmlColor={theme.palette.secondary.light} sx={{ fontSize: "12px" }} /> | ||
<Typography variant="body1">{tab.name}</Typography> | ||
</Box> | ||
<Icon | ||
iconName={ICON_NAME.CHEVRON_RIGHT} | ||
sx={{ fontSize: "12px" }} | ||
/> | ||
</Box> | ||
))} | ||
{value ? ( | ||
<> | ||
{/* <Box onClick={() => handleChange(undefined)}>Back</Box> */} | ||
{value.element} | ||
</> | ||
) : null} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default ToolTabs; |
Oops, something went wrong.