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
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
141 changes: 83 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,43 @@ 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 { 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,
[theme.breakpoints.down("md")]: {
minWidth: "100%",
},
[theme.breakpoints.up("md")]: {
minWidth: 136,
},
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,
}));

const StyledGridItem = styled(Grid)(({ theme }) => ({
margin: theme.spacing(0.5),
}));

class CoordinatesView extends React.PureComponent {
Expand Down Expand Up @@ -81,53 +98,61 @@ 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}>
<StyledGridItem item xs={12}>
<Tooltip title="Rensa fält">
<StyledButton
variant="contained"
onClick={() => {
this.props.model.resetCoords();
}}
>
Rensa fält
</StyledButton>
</Tooltip>
<Tooltip title="Min position">
<StyledButton
variant="contained"
onClick={() => {
this.props.model.goToUserLocation();
}}
>
Min position
</StyledButton>
</Tooltip>
<Tooltip title="Panorera till markering">
<StyledButton
variant="contained"
onClick={() => {
this.props.model.centerOnMarker();
}}
>
Panorera
</StyledButton>
</Tooltip>
<Tooltip title="Zooma till markering">
<StyledButton
variant="contained"
onClick={() => {
this.props.model.zoomOnMarker();
}}
>
Zooma
</StyledButton>
</Tooltip>
</StyledGridItem>
</Grid>
</Root>
);
}
}
Expand Down