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

Upgrade UI for Coordinates plugin #1138

Merged
merged 13 commits into from
Aug 29, 2022
2 changes: 1 addition & 1 deletion new-client/src/plugins/Coordinates/Coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Coordinates extends React.PureComponent {
icon: <ExploreIcon />,
title: "Visa koordinat",
description: "Visa koordinater för given plats",
height: "dynamic",
height: "auto",
width: 400,
onWindowShow: this.onWindowShow,
onWindowHide: this.onWindowHide,
Expand Down
46 changes: 29 additions & 17 deletions new-client/src/plugins/Coordinates/CoordinatesTransformRow.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import React from "react";
import { styled } from "@mui/material/styles";
import TableCell from "@mui/material/TableCell";
import TableRow from "@mui/material/TableRow";
import Typography from "@mui/material/Typography";
import TextField from "@mui/material/TextField";
import NumberFormat from "react-number-format";
import { transform } from "ol/proj";
import { withSnackbar } from "notistack";
import Grid from "@mui/material/Grid";

const StyledGridContainer = styled(Grid)(() => ({
borderBottom: "1px solid #e0e0e0",
}));

const StyledNumberFormat = styled(NumberFormat)(({ theme }) => ({
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
marginTop: theme.spacing(2),
marginLeft: theme.spacing(0.75),
marginRight: theme.spacing(0.75),
minWidth: 120,
}));

//Styled Grid that centers text to the left
const StyledGrid = styled(Grid)(({ theme }) => ({
textAlign: "left",
width: 120,
margin: theme.spacing(1.25),
}));

class CoordinatesTransformRow extends React.PureComponent {
Expand Down Expand Up @@ -183,16 +193,18 @@ class CoordinatesTransformRow extends React.PureComponent {

if (this.model.showFieldsOnStart || this.state.wasModified) {
return (
<TableRow key={this.props.transformation.code}>
<TableCell>
<Typography variant="body1" style={{ display: "flex" }}>
{this.props.transformation.title}
</Typography>
<Typography variant="body2" style={{ display: "flex" }}>
({this.props.transformation.code})
</Typography>
</TableCell>
<TableCell>
<StyledGridContainer container spacing={1} alignItems="center">
<Grid item>
<StyledGrid>
<Typography variant="body1">
{this.props.transformation.title}
</Typography>
<Typography variant="body2">
({this.props.transformation.code})
</Typography>
</StyledGrid>
</Grid>
<Grid item xs>
<StyledNumberFormat
label={this.props.transformation.xtitle}
margin="dense"
Expand Down Expand Up @@ -227,8 +239,8 @@ class CoordinatesTransformRow extends React.PureComponent {
thousandSeparator={this.model.thousandSeparator ? " " : false}
customInput={TextField}
/>
</TableCell>
</TableRow>
</Grid>
</StyledGridContainer>
);
} else {
return <></>;
Expand Down
140 changes: 82 additions & 58 deletions new-client/src/plugins/Coordinates/CoordinatesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,36 @@ import React from "react";
import Button from "@mui/material/Button";
import { styled } from "@mui/material/styles";
import Grid from "@mui/material/Grid";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import Paper from "@mui/material/Paper";
import CoordinatesTransformRow from "./CoordinatesTransformRow.js";
import { Tooltip } from "@mui/material";
import IconButton from "@mui/material/IconButton";
import ZoomInMapIcon from "@mui/icons-material/ZoomInMap";
import ZoomInIcon from "@mui/icons-material/ZoomIn";

import { withSnackbar } from "notistack";

const StyledPaper = styled(Paper)(() => ({
backgroundImage: "none",
const Root = styled("div")(() => ({
margin: -10,
display: "flex",
flexGrow: 1,
flexWrap: "wrap",
flexDirection: "column",
height: "100%",
overflowX: "hidden",
}));

const StyledButton = styled(Button)(({ theme }) => ({
minWidth: 64,
margin: 0,
margin: theme.spacing(0.5),
}));

const StyledGridContainer = styled(Grid)(() => ({
borderBottom: "1px solid #e0e0e0",
}));

//Styled Grid that centers text to the left
const StyledGrid = styled(Grid)(({ theme }) => ({
textAlign: "left",
width: 120,
margin: theme.spacing(1),
color: theme.palette.text.secondary,
}));

class CoordinatesView extends React.PureComponent {
Expand Down Expand Up @@ -81,53 +91,67 @@ class CoordinatesView extends React.PureComponent {

render() {
return (
<>
<StyledPaper>
<Table>
<TableHead>
<TableRow>
<TableCell>Projektion</TableCell>
<TableCell>Koordinater</TableCell>
</TableRow>
</TableHead>
<TableBody>{this.renderProjections()}</TableBody>
</Table>
<Grid container justifyContent="space-between">
<StyledButton
variant="text"
onClick={() => {
this.props.model.zoomOnMarker();
}}
>
Zooma
</StyledButton>
<StyledButton
variant="text"
onClick={() => {
this.props.model.centerOnMarker();
}}
>
Panorera
</StyledButton>
<StyledButton
variant="text"
onClick={() => {
this.props.model.goToUserLocation();
}}
>
Min position
</StyledButton>
<StyledButton
variant="text"
onClick={() => {
this.props.model.resetCoords();
}}
>
Rensa fält
</StyledButton>
<Root>
<StyledGridContainer container spacing={1}>
<Grid item>
<StyledGrid>Projektion</StyledGrid>
</Grid>
</StyledPaper>
</>
<Grid item xs>
<StyledGrid>Koordinater</StyledGrid>
</Grid>
</StyledGridContainer>
{this.renderProjections()}
<Grid container spacing={1}>
<Grid item>
<Tooltip title="Rensa fält">
<StyledButton
onClick={() => {
this.props.model.resetCoords();
}}
>
Rensa
</StyledButton>
</Tooltip>
<Tooltip title="Min position">
<StyledButton
onClick={() => {
this.props.model.goToUserLocation();
}}
>
Min position
</StyledButton>
</Tooltip>
</Grid>
<Grid item xs>
<Grid container direction="row-reverse">
<Grid item>
<Tooltip title="Centrera till markering">
<IconButton
aria-label="Centrera till markering"
component="label"
onClick={() => {
this.props.model.centerOnMarker();
}}
>
<ZoomInMapIcon />
</IconButton>
</Tooltip>
<Tooltip title="Zooma in till markering">
<IconButton
aria-label="Zooma in till markering"
component="label"
onClick={() => {
this.props.model.zoomOnMarker();
}}
>
<ZoomInIcon />
</IconButton>
</Tooltip>
</Grid>
</Grid>
</Grid>
</Grid>
</Root>
);
}
}
Expand Down