diff --git a/package.json b/package.json index 9ebe8f1..436e093 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "@blockly/zoom-to-fit": "^2.0.14", "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", - "@fortawesome/fontawesome-svg-core": "^1.2.36", - "@fortawesome/free-solid-svg-icons": "^5.15.4", - "@fortawesome/react-fontawesome": "^0.1.19", + "@fortawesome/fontawesome-svg-core": "^6.2.1", + "@fortawesome/free-solid-svg-icons": "^6.2.1", + "@fortawesome/react-fontawesome": "^0.2.0", "@monaco-editor/react": "^4.3.1", "@mui/lab": "^5.0.0-alpha.110", "@mui/material": "^5.10.16", diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index bbab82d..ffdb8f8 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -43,7 +43,7 @@ class BlocklyWindow extends Component { componentDidUpdate(props) { const workspace = Blockly.getMainWorkspace(); - var xml = this.props.initialXml; + var xml = localStorage.getItem("autoSaveXML"); if (props.selectedBoard !== this.props.selectedBoard) { // change board if(!xml) xml = initialXml; diff --git a/src/components/Navbar.js b/src/components/Navbar.js index 9b03d76..76105a6 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -37,10 +37,19 @@ import { faLightbulb, faCode, faPuzzlePiece, + faUser, + faMicrochip, + faEarthEurope, + faEarthAmericas, + faCaretDown } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import * as Blockly from "blockly"; import Tooltip from "@mui/material/Tooltip"; +import MenuItem from '@mui/material/MenuItem' +import Menu from '@mui/material/Menu' +import { setLanguage } from "../actions/generalActions"; +import { setBoard } from "../actions/boardAction"; const styles = (theme) => ({ drawerWidth: { @@ -60,9 +69,14 @@ const styles = (theme) => ({ class Navbar extends Component { constructor(props) { super(props); + this.langRef = React.createRef(); + this.mcuRef = React.createRef(); this.state = { open: false, isTourOpen: false, + anchorElLang: null, + anchorElBoard: null, + anchorElUser: null }; } @@ -80,7 +94,6 @@ class Navbar extends Component { render() { var isHome = /^\/(\/.*$|$)/g.test(this.props.location.pathname); - var isTutorial = /^\/tutorial(\/.*$|$)/g.test(this.props.location.pathname); var isAssessment = /^\/tutorial\/.{1,}$/g.test(this.props.location.pathname) && !this.props.tutorialIsLoading && @@ -127,55 +140,257 @@ class Navbar extends Component { senseBox-Logo - {isTutorial ? ( - +
+ { + this.props.selectedBoard === "mcu" ? + ( + + ) : ( + + + ) + } + { + this.setState({ anchorElBoard: null }); + }} + > + { + this.props.setBoard(event.currentTarget.getAttribute("value")); + this.setState({ anchorElBoard: null }); + }} + > + MCU + + { + this.props.setBoard(event.currentTarget.getAttribute("value")); + this.setState({ anchorElBoard: null }); + }} + > + mini + + +
+
+ { + this.props.language === "en_US" ? + ( + + ) : ( + + + ) + } + { + this.setState({ anchorElLang: null }); + }} + > + { + this.props.setLanguage(event.currentTarget.getAttribute("value")); + this.setState({ anchorElLang: null }); + }} + > + Deutsch + + { + this.props.setLanguage(event.currentTarget.getAttribute("value")); + this.setState({ anchorElLang: null }); + }} + > + English + + +
+ {isHome ? ( + + { + this.openTour(); + }} + size="large"> + + + + ) : null} + {isAssessment ? ( + + { + this.openTour(); + }} + size="large"> + + + + ) : null} + { + this.closeTour(); }} - > - - Tutorial - - - ) : null} - {isHome ? ( - - { - this.openTour(); - }} - style={{ margin: "0 30px 0 auto" }} - size="large"> - - - - ) : null} - {isAssessment ? ( - - { - this.openTour(); - }} - style={{ margin: "0 30px 0 auto" }} - size="large"> - - - - ) : null} - { - this.closeTour(); - }} - /> + /> + {this.props.user ? ( +
+ { this.setState({ anchorElUser: event.target }) }} + style={{ margin: "0 30px 0 auto" }} + size="large" + sx={{ display: { xs: 'none', md: 'block' } }} + > + + + { this.setState({ anchorElUser: null }); }} + > +
+

+ {this.props.user.name} +

+

+ {this.props.user.email} +

+
+
+ + + {Blockly.Msg.navbar_settings} + + + { + this.props.logout() + }} + > + {Blockly.Msg.navbar_logout} + +
+
+ ) + : + ( + + + + + ) + } + ({ @@ -378,8 +597,10 @@ const mapStateToProps = (state) => ({ user: state.auth.user, tutorial: state.tutorial.tutorials[0], activeStep: state.tutorial.activeStep, + language: state.general.language, + selectedBoard: state.board.board }); -export default connect(mapStateToProps, { logout })( +export default connect(mapStateToProps, { logout, setLanguage, setBoard })( withStyles(styles, { withTheme: true })(withRouter(Navbar)) );