Merge pull request #216 from sensebox/development-deviceSelection
Development device selection
This commit is contained in:
commit
50b70b4ee3
@ -1,10 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
BOARD,
|
BOARD,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
import mini_opacity from "../data/mini_opacity.png"
|
||||||
|
import mcu_opacity from "../data/mcu_opacity.png"
|
||||||
|
|
||||||
export const setBoard = (board) => (dispatch) => {
|
export const setBoard = (board) => (dispatch) => {
|
||||||
dispatch({
|
window.sessionStorage.setItem("board", board);
|
||||||
type: BOARD,
|
const root = document.querySelector(':root');
|
||||||
payload: board,
|
root.style.setProperty('--url', `url(${board === "mcu" ? mcu_opacity : mini_opacity})`);
|
||||||
});
|
dispatch({
|
||||||
};
|
type: BOARD,
|
||||||
|
payload: board,
|
||||||
|
});
|
||||||
|
};
|
@ -11,6 +11,7 @@ import Sidebar from "./Sidebar";
|
|||||||
import Dialog from "../Dialog";
|
import Dialog from "../Dialog";
|
||||||
import SaveIcon from "./SaveIcon";
|
import SaveIcon from "./SaveIcon";
|
||||||
import store from "../../store";
|
import store from "../../store";
|
||||||
|
import DeviceSelection from "../DeviceSelection";
|
||||||
|
|
||||||
const CodeEditor = (props) => {
|
const CodeEditor = (props) => {
|
||||||
//const [filehandle, setFileHandle] = useState();
|
//const [filehandle, setFileHandle] = useState();
|
||||||
@ -192,6 +193,7 @@ void loop() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<DeviceSelection />
|
||||||
<Grid item lg={4} md={4}>
|
<Grid item lg={4} md={4}>
|
||||||
<Button
|
<Button
|
||||||
style={{ padding: "1rem", margin: "1rem" }}
|
style={{ padding: "1rem", margin: "1rem" }}
|
||||||
|
@ -7,8 +7,6 @@ import { withStyles } from "@material-ui/core/styles";
|
|||||||
import * as Blockly from "blockly";
|
import * as Blockly from "blockly";
|
||||||
import { IconButton, Grid, Avatar, Typography } from "@material-ui/core";
|
import { IconButton, Grid, Avatar, Typography } from "@material-ui/core";
|
||||||
import { setBoard } from "../actions/boardAction";
|
import { setBoard } from "../actions/boardAction";
|
||||||
import mini_opacity from "../data/mini_opacity.png"
|
|
||||||
import mcu_opacity from "../data/mcu_opacity.png"
|
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
link: {
|
link: {
|
||||||
@ -29,37 +27,29 @@ class DeviceSeclection extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
open: true,
|
open: props.selectedBoard ? false : true,
|
||||||
selectedBoard : "",
|
selectedBoard: "",
|
||||||
saveSettings: false,
|
saveSettings: false,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleDialog = () => {
|
toggleDialog = () => {
|
||||||
|
|
||||||
this.props.setBoard(this.state.selectedBoard)
|
this.props.setBoard(this.state.selectedBoard)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onChange = (e) => {
|
onChange = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
this.setState({ saveSettings: true});
|
this.setState({ saveSettings: true });
|
||||||
} else {
|
} else {
|
||||||
this.setState({ saveSettings: false});
|
this.setState({ saveSettings: false });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onclick = (e, value) => {
|
onclick = (e, value) => {
|
||||||
console.log(e, value)
|
this.setState({ selectedBoard: value })
|
||||||
const root = document.querySelector(':root');
|
|
||||||
root.style.setProperty('--url', `url(${value === "mcu" ? mcu_opacity : mini_opacity })`);
|
|
||||||
this.setState({selectedBoard: value})
|
|
||||||
this.props.setBoard(value)
|
this.props.setBoard(value)
|
||||||
this.setState({ open: !this.state });
|
this.setState({ open: !this.state });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -72,25 +62,24 @@ class DeviceSeclection extends Component {
|
|||||||
title={Blockly.Msg.deviceselection_head}
|
title={Blockly.Msg.deviceselection_head}
|
||||||
content={""}
|
content={""}
|
||||||
onClick={this.toggleDialog}
|
onClick={this.toggleDialog}
|
||||||
disabled={this.state.selectedBoard===""}
|
disabled={this.state.selectedBoard === ""}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<Grid container spacing={2} style={{ textAlign : "center" }}>
|
<Grid container spacing={2} style={{ textAlign: "center" }}>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<IconButton onClick={(e) => this.onclick(e, "mcu")}>
|
<IconButton onClick={(e) => this.onclick(e, "mcu")}>
|
||||||
<Avatar
|
<Avatar
|
||||||
alt="Sensebox MCU"
|
alt="Sensebox MCU"
|
||||||
src="/media/hardware/senseboxmcu.png"
|
src="/media/hardware/senseboxmcu.png"
|
||||||
style={{
|
style={{
|
||||||
border: this.state.selectedBoard === "mcu" ? 'medium solid DeepSkyBlue': "0.1px solid lightgray",
|
border: this.state.selectedBoard === "mcu" ? 'medium solid DeepSkyBlue' : "0.1px solid lightgray",
|
||||||
width:"20vw",
|
width: "20vw",
|
||||||
height: "20vw"
|
height: "20vw"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<p>senseBox MCU</p>
|
<p>senseBox MCU</p>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
{/* <Grid item xs={4}>
|
{/* <Grid item xs={4}>
|
||||||
<IconButton onClick={(e) => this.onclick(e, "esp")}>
|
<IconButton onClick={(e) => this.onclick(e, "esp")}>
|
||||||
<Avatar
|
<Avatar
|
||||||
@ -100,42 +89,27 @@ class DeviceSeclection extends Component {
|
|||||||
border: this.state.selectedBoard == "esp" ? 'medium solid DeepSkyBlue': "0.1px solid lightgray",
|
border: this.state.selectedBoard == "esp" ? 'medium solid DeepSkyBlue': "0.1px solid lightgray",
|
||||||
width:"20vw",
|
width:"20vw",
|
||||||
height: "20vw"
|
height: "20vw"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<p>Sensebox ESP</p>
|
<p>Sensebox ESP</p>
|
||||||
</Grid> */}
|
</Grid> */}
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<IconButton onClick={(e) => this.onclick(e, "mini")}>
|
<IconButton onClick={(e) => this.onclick(e, "mini")}>
|
||||||
<Avatar
|
<Avatar
|
||||||
alt="Sensebox Mini"
|
alt="Sensebox Mini"
|
||||||
src="/media/hardware/senseboxmcumini.png"
|
src="/media/hardware/senseboxmcumini.png"
|
||||||
style={{
|
style={{
|
||||||
border: this.state.selectedBoard === "mini" ? 'medium solid DeepSkyBlue': "0.1px solid lightgray",
|
border: this.state.selectedBoard === "mini" ? 'medium solid DeepSkyBlue' : "0.1px solid lightgray",
|
||||||
width:"20vw",
|
width: "20vw",
|
||||||
height: "20vw"
|
height: "20vw"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<p>senseBox MCU:mini</p>
|
<p>senseBox MCU:mini</p>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
{/* <FormControlLabel
|
|
||||||
style={{ marginTop: "20px" }}
|
|
||||||
classes={{ label: this.props.classes.label }}
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
size={"small"}
|
|
||||||
value={true}
|
|
||||||
checked={this.state.checked}
|
|
||||||
onChange={(e) => this.onChange(e)}
|
|
||||||
name="dialog"
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={Blockly.Msg.deviceselection_keep_selection}
|
|
||||||
/> */}
|
|
||||||
<Typography variant="body1" >
|
<Typography variant="body1" >
|
||||||
{Blockly.Msg.deviceselection_footnote} <a href="https://sensebox.github.io/blockly/">Arduino UNO</a> {Blockly.Msg.deviceselection_footnote_02} <a href="https://sensebox-blockly.netlify.app/ardublockly/?board=sensebox-mcu">senseBox MCU</a>
|
{Blockly.Msg.deviceselection_footnote} <a href="https://sensebox.github.io/blockly/">Arduino UNO</a> {Blockly.Msg.deviceselection_footnote_02} <a href="https://sensebox-blockly.netlify.app/ardublockly/?board=sensebox-mcu">senseBox MCU</a>
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -155,5 +129,5 @@ const mapStateToProps = (state) => ({
|
|||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
{setBoard}
|
{ setBoard }
|
||||||
)(withStyles(styles, { withTheme: true })(DeviceSeclection));
|
)(withStyles(styles, { withTheme: true })(DeviceSeclection));
|
||||||
|
@ -18,6 +18,7 @@ import Divider from "@material-ui/core/Divider";
|
|||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import Backdrop from "@material-ui/core/Backdrop";
|
import Backdrop from "@material-ui/core/Backdrop";
|
||||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||||
|
import DeviceSelection from "../DeviceSelection";
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
link: {
|
link: {
|
||||||
@ -60,9 +61,8 @@ class ProjectHome extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
snackbar: true,
|
snackbar: true,
|
||||||
key: Date.now(),
|
key: Date.now(),
|
||||||
message: `Dein angefragtes ${
|
message: `Dein angefragtes ${type === "gallery" ? "Galerie-" : ""
|
||||||
type === "gallery" ? "Galerie-" : ""
|
}Projekt konnte nicht gefunden werden.`,
|
||||||
}Projekt konnte nicht gefunden werden.`,
|
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -108,6 +108,7 @@ class ProjectHome extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<h1>{data}</h1>
|
<h1>{data}</h1>
|
||||||
|
<DeviceSelection />
|
||||||
{this.props.progress ? (
|
{this.props.progress ? (
|
||||||
<Backdrop open invisible>
|
<Backdrop open invisible>
|
||||||
<CircularProgress color="primary" />
|
<CircularProgress color="primary" />
|
||||||
@ -127,9 +128,8 @@ class ProjectHome extends Component {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
to={`/${
|
to={`/${data === "Projekte" ? "project" : "gallery"
|
||||||
data === "Projekte" ? "project" : "gallery"
|
}/${project._id}`}
|
||||||
}/${project._id}`}
|
|
||||||
style={{ textDecoration: "none", color: "inherit" }}
|
style={{ textDecoration: "none", color: "inherit" }}
|
||||||
>
|
>
|
||||||
<h3 style={{ marginTop: 0 }}>{project.title}</h3>
|
<h3 style={{ marginTop: 0 }}>{project.title}</h3>
|
||||||
@ -153,7 +153,7 @@ class ProjectHome extends Component {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Link>
|
</Link>
|
||||||
{this.props.user &&
|
{this.props.user &&
|
||||||
this.props.user.email === project.creator ? (
|
this.props.user.email === project.creator ? (
|
||||||
<div>
|
<div>
|
||||||
<Divider
|
<Divider
|
||||||
style={{
|
style={{
|
||||||
|
@ -37,6 +37,7 @@ import Tooltip from "@material-ui/core/Tooltip";
|
|||||||
import IconButton from "@material-ui/core/IconButton";
|
import IconButton from "@material-ui/core/IconButton";
|
||||||
import Snackbar from "../Snackbar";
|
import Snackbar from "../Snackbar";
|
||||||
import Divider from "@material-ui/core/Divider";
|
import Divider from "@material-ui/core/Divider";
|
||||||
|
import DeviceSelection from "../DeviceSelection";
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
outerDiv: {
|
outerDiv: {
|
||||||
@ -243,14 +244,11 @@ class TutorialHome extends Component {
|
|||||||
cy="50%"
|
cy="50%"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-width="10"
|
stroke-width="10"
|
||||||
stroke-dashoffset={`${
|
stroke-dashoffset={`${75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
||||||
75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
}`}
|
||||||
}`}
|
stroke-dasharray={`${75 * 2 * Math.PI * (1 - (50 / 100 - success / 2))
|
||||||
stroke-dasharray={`${
|
} ${75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
||||||
75 * 2 * Math.PI * (1 - (50 / 100 - success / 2))
|
}`}
|
||||||
} ${
|
|
||||||
75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
|
||||||
}`}
|
|
||||||
></circle>
|
></circle>
|
||||||
)}
|
)}
|
||||||
{success < 1 && !error ? (
|
{success < 1 && !error ? (
|
||||||
@ -265,9 +263,8 @@ class TutorialHome extends Component {
|
|||||||
cy="50%"
|
cy="50%"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-width="10"
|
stroke-width="10"
|
||||||
stroke-dashoffset={`${
|
stroke-dashoffset={`${75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
||||||
75 * 2 * Math.PI * (1 - (50 / 100 + success / 2))
|
}`}
|
||||||
}`}
|
|
||||||
stroke-dasharray={`${75 * 2 * Math.PI}`}
|
stroke-dasharray={`${75 * 2 * Math.PI}`}
|
||||||
></circle>
|
></circle>
|
||||||
) : null}
|
) : null}
|
||||||
@ -279,8 +276,8 @@ class TutorialHome extends Component {
|
|||||||
tutorialStatus === "Error"
|
tutorialStatus === "Error"
|
||||||
? this.props.classes.outerDivError
|
? this.props.classes.outerDivError
|
||||||
: tutorialStatus === "Success"
|
: tutorialStatus === "Success"
|
||||||
? this.props.classes.outerDivSuccess
|
? this.props.classes.outerDivSuccess
|
||||||
: null
|
: null
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={this.props.classes.innerDiv}>
|
<div className={this.props.classes.innerDiv}>
|
||||||
@ -311,6 +308,7 @@ class TutorialHome extends Component {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<DeviceSelection />
|
||||||
{this.props.user ? (
|
{this.props.user ? (
|
||||||
<div>
|
<div>
|
||||||
<h2>User Tutorials</h2>
|
<h2>User Tutorials</h2>
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
import { BOARD } from '../actions/types';
|
import { BOARD } from '../actions/types';
|
||||||
|
import mini_opacity from "../data/mini_opacity.png"
|
||||||
|
import mcu_opacity from "../data/mcu_opacity.png"
|
||||||
|
|
||||||
const initialValue = () => {
|
const initialValue = () => {
|
||||||
if (window.localStorage.getItem("board")) {
|
if (window.sessionStorage.getItem("board")) {
|
||||||
return window.localStorage.getItem("board");
|
setBackgroundImage(window.sessionStorage.getItem("board"));
|
||||||
|
return window.sessionStorage.getItem("board");
|
||||||
}
|
}
|
||||||
return "bla";
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setBackgroundImage = (board) => {
|
||||||
|
const root = document.querySelector(':root');
|
||||||
|
root.style.setProperty('--url', `url(${board === "mcu" ? mcu_opacity : mini_opacity})`);
|
||||||
|
}
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
board: initialValue()
|
board: initialValue()
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user