diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js
index efd8bf7..21f7392 100644
--- a/src/components/Blockly/BlocklyWindow.js
+++ b/src/components/Blockly/BlocklyWindow.js
@@ -1,20 +1,18 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import { onChangeWorkspace, clearStats } from '../../actions/workspaceActions';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import { connect } from "react-redux";
+import { onChangeWorkspace, clearStats } from "../../actions/workspaceActions";
-import BlocklyComponent from './BlocklyComponent';
-import BlocklySvg from './BlocklySvg';
+import BlocklyComponent from "./BlocklyComponent";
+import BlocklySvg from "./BlocklySvg";
-import * as Blockly from 'blockly/core';
-import './blocks/index';
-import './generator/index';
-
-import { initialXml } from './initialXml.js';
+import * as Blockly from "blockly/core";
+import "./blocks/index";
+import "./generator/index";
+import { initialXml } from "./initialXml.js";
class BlocklyWindow extends Component {
-
constructor(props) {
super(props);
this.simpleWorkspace = React.createRef();
@@ -41,6 +39,7 @@ class BlocklyWindow extends Component {
Blockly.Events.disableOrphans(event);
}
});
+
Blockly.svgResize(workspace);
}
@@ -64,46 +63,65 @@ class BlocklyWindow extends Component {
// workspace.updateToolbox(toolbox.toolboxDef_);
}
Blockly.svgResize(workspace);
-
}
render() {
return (
-
-
- {this.props.svg && this.props.initialXml ? : null}
+ grid={
+ this.props.grid !== undefined && !this.props.grid
+ ? {}
+ : {
+ // https://developers.google.com/blockly/guides/configure/web/grid
+ spacing: 20,
+ length: 1,
+ colour: "#4EAF47", // senseBox-green
+ snap: false,
+ }
+ }
+ media={"/media/blockly/"}
+ move={
+ this.props.move !== undefined && !this.props.move
+ ? {}
+ : {
+ // https://developers.google.com/blockly/guides/configure/web/move
+ scrollbars: true,
+ drag: true,
+ wheel: false,
+ }
+ }
+ initialXml={
+ this.props.initialXml ? this.props.initialXml : initialXml
+ }
+ >
+ {this.props.svg && this.props.initialXml ? (
+
+ ) : null}
);
- };
+ }
}
BlocklyWindow.propTypes = {
@@ -114,10 +132,12 @@ BlocklyWindow.propTypes = {
workspaceXML: PropTypes.string.isRequired,
};
-const mapStateToProps = state => ({
+const mapStateToProps = (state) => ({
renderer: state.general.renderer,
language: state.general.language.Blockly,
workspaceXML: state.workspace.code.xml,
});
-export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(BlocklyWindow);
+export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(
+ BlocklyWindow
+);
diff --git a/src/components/Blockly/blocks/variables.js b/src/components/Blockly/blocks/variables.js
index 6984263..8e19984 100644
--- a/src/components/Blockly/blocks/variables.js
+++ b/src/components/Blockly/blocks/variables.js
@@ -1,43 +1,46 @@
-import Blockly from 'blockly/core';
-import { getColour } from '../helpers/colour';
-import { getCompatibleTypes } from '../helpers/types'
-
-
-Blockly.Blocks['variables_set_dynamic'] = {
- init: function () {
-
- // const type = myVar.type;
- this.setColour(getColour().variables);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.appendValueInput('VALUE')
- .appendField('set', 'set')
- .appendField('', 'type')
- .appendField(new Blockly.FieldVariable('VAR'), 'VAR')
- .appendField('to');
- },
- onchange: function (e) {
- let variableID = this.getFieldValue('VAR');
- let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
- this.getField('type').setValue(variable.type);
- this.getInput('VALUE').setCheck(getCompatibleTypes(variable.type));
+import Blockly from "blockly/core";
+import { getColour } from "../helpers/colour";
+import { getCompatibleTypes } from "../helpers/types";
+Blockly.Blocks["variables_set_dynamic"] = {
+ init: function () {
+ // const type = myVar.type;
+ this.setColour(getColour().variables);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.appendValueInput("VALUE")
+ .appendField("set", "set")
+ .appendField("", "type")
+ .appendField(new Blockly.FieldVariable("VAR"), "VAR")
+ .appendField("to");
+ },
+ onchange: function (e) {
+ let variableID = this.getFieldValue("VAR");
+ let variable = Blockly.getMainWorkspace()
+ .getVariableMap()
+ .getVariableById(variableID);
+ if (variable !== null) {
+ this.getField("type").setValue(variable.type);
+ this.getInput("VALUE").setCheck(getCompatibleTypes(variable.type));
}
-}
-
-Blockly.Blocks['variables_get_dynamic'] = {
- init: function () {
- this.setColour(getColour().variables);
- this.appendDummyInput()
- .appendField('', 'type')
- .appendField(new Blockly.FieldVariable('VAR'), 'VAR');
- this.setOutput(true);
- },
- onchange: function (e) {
- let variableID = this.getFieldValue('VAR');
- let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
- this.getField('type').setValue(variable.type);
+ },
+};
+Blockly.Blocks["variables_get_dynamic"] = {
+ init: function () {
+ this.setColour(getColour().variables);
+ this.appendDummyInput()
+ .appendField("", "type")
+ .appendField(new Blockly.FieldVariable("VAR"), "VAR");
+ this.setOutput(true);
+ },
+ onchange: function (e) {
+ let variableID = this.getFieldValue("VAR");
+ let variable = Blockly.getMainWorkspace()
+ .getVariableMap()
+ .getVariableById(variableID);
+ if (variable !== null) {
+ this.getField("type").setValue(variable.type);
}
-}
-
+ },
+};
diff --git a/src/components/Blockly/msg/de/ui.js b/src/components/Blockly/msg/de/ui.js
index 06b9f76..3c8b238 100644
--- a/src/components/Blockly/msg/de/ui.js
+++ b/src/components/Blockly/msg/de/ui.js
@@ -10,6 +10,16 @@ export const UI = {
toolbox_time: "Zeit",
toolbox_functions: "Funktionen",
toolbox_variables: "Variablen",
+ variable_NUMBER: "Zahl (int)",
+ variable_SHORT_NUMBER: "char",
+ variable_LONG: "große Zahl (long)",
+ variable_DECIMAL: "Kommazahl (float)",
+ variables_TEXT: "Text (string)",
+ variables_ARRAY: "Array (array)",
+ variables_CHARACTER: "char (char)",
+ variables_BOOLEAN: "Boolean (boolean)",
+ variables_NULL: "void (void)",
+ variables_UNDEF: "undefined",
/**
* Tooltips
diff --git a/src/components/Blockly/msg/en/ui.js b/src/components/Blockly/msg/en/ui.js
index 3428980..63089be 100644
--- a/src/components/Blockly/msg/en/ui.js
+++ b/src/components/Blockly/msg/en/ui.js
@@ -10,6 +10,16 @@ export const UI = {
toolbox_time: "Time",
toolbox_functions: "Functions",
toolbox_variables: "Variables",
+ variable_NUMBER: "Number (int)",
+ variable_SHORT_NUMBER: "char",
+ variable_LONG: " Zahl (long)",
+ variable_DECIMAL: "Decimal (float)",
+ variables_TEXT: "Text (string)",
+ variables_ARRAY: "Array (array)",
+ variables_CHARACTER: "char (char)",
+ variables_BOOLEAN: "Boolean (boolean)",
+ variables_NULL: "void (void)",
+ variables_UNDEF: "undefined",
/**
* Tooltips
diff --git a/src/components/Blockly/toolbox/Toolbox.js b/src/components/Blockly/toolbox/Toolbox.js
index 713bce3..9d65862 100644
--- a/src/components/Blockly/toolbox/Toolbox.js
+++ b/src/components/Blockly/toolbox/Toolbox.js
@@ -1,495 +1,557 @@
-import React from 'react';
-import { Block, Value, Field, Shadow, Category } from '../';
-import { getColour } from '../helpers/colour'
-import '@blockly/block-plus-minus';
-import { TypedVariableModal } from '@blockly/plugin-typed-variable-modal';
-import * as Blockly from 'blockly/core';
-
-
-
+import React from "react";
+import { Block, Value, Field, Shadow, Category } from "../";
+import { getColour } from "../helpers/colour";
+import "@blockly/block-plus-minus";
+import { TypedVariableModal } from "@blockly/plugin-typed-variable-modal";
+import * as Blockly from "blockly/core";
class Toolbox extends React.Component {
+ componentDidUpdate() {
+ this.props.workspace.registerToolboxCategoryCallback(
+ "CREATE_TYPED_VARIABLE",
+ this.createFlyout
+ );
- componentDidUpdate() {
- this.props.workspace.registerToolboxCategoryCallback('CREATE_TYPED_VARIABLE', this.createFlyout);
+ const typedVarModal = new TypedVariableModal(
+ this.props.workspace,
+ "callbackName",
+ [
+ [`${Blockly.Msg.variable_SHORT_NUMBER}`, "char"],
+ [`${Blockly.Msg.variable_NUMBER}`, "int"],
+ [`${Blockly.Msg.variable_LONG}`, "long"],
+ [`${Blockly.Msg.variable_DECIMAL}`, "float"],
+ [`${Blockly.Msg.variables_TEXT}`, "String"],
+ [`${Blockly.Msg.variables_ARRAY}`, "Array"],
+ [`${Blockly.Msg.variables_CHARACTER}`, "char"],
+ [`${Blockly.Msg.variables_BOOLEAN}`, "boolean"],
+ [`${Blockly.Msg.variables_NULL}`, "void"],
+ [`${Blockly.Msg.variables_UNDEF}`, "undefined"],
+ ]
+ );
+ typedVarModal.init();
+ }
- const typedVarModal = new TypedVariableModal(this.props.workspace, 'callbackName', [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'float'], ['TEXT', 'String'], ['ARRAY', 'Array'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]);
- typedVarModal.init();
- }
+ createFlyout(workspace) {
+ let xmlList = [];
- createFlyout(workspace) {
+ // Add your button and give it a callback name.
+ const button = document.createElement("button");
+ button.setAttribute("text", "Create Typed Variable");
+ button.setAttribute("callbackKey", "callbackName");
- let xmlList = [];
+ xmlList.push(button);
- // Add your button and give it a callback name.
- const button = document.createElement('button');
- button.setAttribute('text', 'Create Typed Variable');
- button.setAttribute('callbackKey', 'callbackName');
+ // This gets all the variables that the user creates and adds them to the
+ // flyout.
+ const blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace);
+ xmlList = xmlList.concat(blockList);
+ return xmlList;
+ }
- xmlList.push(button);
-
- // This gets all the variables that the user creates and adds them to the
- // flyout.
- const blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace);
- xmlList = xmlList.concat(blockList);
- return xmlList;
- };
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* */}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
- 30
-
-
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
-
-
-
-
- 100
-
-
-
-
- 50
-
-
-
-
- 0
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
-
-
- Title
-
-
-
-
- Unit
-
-
-
-
- Title
-
-
-
-
- Unit
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
- 15
-
-
-
-
- 0
-
-
-
-
- 50
-
-
-
-
- 5
-
-
-
-
- 0
-
-
-
-
- 15
-
-
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
- 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- latitude
-
-
-
-
- longitude
-
-
-
-
- altitude
-
-
-
-
- pDOP
-
-
-
-
- fixType
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* */}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10
-
-
-
-
-
-
-
- 1
-
-
-
-
- 10
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1000
-
-
-
-
-
-
- 100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
- 1
-
-
-
-
- 100
-
-
-
-
-
-
- 1
-
-
-
-
- 100
-
-
-
-
-
-
-
-
-
-
- 220
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 100
-
-
-
-
- {/* this block is the initial block of the workspace; not necessary
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ 30
+
+
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+ 50
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+
+
+ Title
+
+
+
+
+ Unit
+
+
+
+
+ Title
+
+
+
+
+ Unit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+ 15
+
+
+
+
+ 0
+
+
+
+
+ 50
+
+
+
+
+ 5
+
+
+
+
+ 0
+
+
+
+
+ 15
+
+
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ latitude
+
+
+
+
+ longitude
+
+
+
+
+ altitude
+
+
+
+
+ pDOP
+
+
+
+
+ fixType
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ 10
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1000
+
+
+
+
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+ 100
+
+
+
+
+
+
+ 1
+
+
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+ 220
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+ {/* this block is the initial block of the workspace; not necessary
to display, because it can only be used once anyway
*/}
-
- );
- };
+
+ );
+ }
}
export default Toolbox;
diff --git a/src/components/Tutorial/Assessment.js b/src/components/Tutorial/Assessment.js
index fa4d1c4..5dd24b7 100644
--- a/src/components/Tutorial/Assessment.js
+++ b/src/components/Tutorial/Assessment.js
@@ -1,20 +1,20 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import { workspaceName } from '../../actions/workspaceActions';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import { connect } from "react-redux";
+import { workspaceName } from "../../actions/workspaceActions";
-import BlocklyWindow from '../Blockly/BlocklyWindow';
-import CodeViewer from '../CodeViewer';
-import WorkspaceFunc from '../Workspace/WorkspaceFunc';
+import BlocklyWindow from "../Blockly/BlocklyWindow";
+import CodeViewer from "../CodeViewer";
+import WorkspaceFunc from "../Workspace/WorkspaceFunc";
-import withWidth, { isWidthDown } from '@material-ui/core/withWidth';
-import Grid from '@material-ui/core/Grid';
-import Card from '@material-ui/core/Card';
-import Typography from '@material-ui/core/Typography';
-import * as Blockly from 'blockly'
+import withWidth, { isWidthDown } from "@material-ui/core/withWidth";
+import Grid from "@material-ui/core/Grid";
+import Card from "@material-ui/core/Card";
+import Typography from "@material-ui/core/Typography";
+import * as Blockly from "blockly";
+import { initialXml } from "../Blockly/initialXml";
class Assessment extends Component {
-
componentDidMount() {
this.props.workspaceName(this.props.name);
}
@@ -28,48 +28,90 @@ class Assessment extends Component {
render() {
var tutorialId = this.props.tutorial._id;
var currentTask = this.props.step;
- var status = this.props.status.filter(status => status._id === tutorialId)[0];
- var taskIndex = status.tasks.findIndex(task => task._id === currentTask._id);
+ var status = this.props.status.filter(
+ (status) => status._id === tutorialId
+ )[0];
+ var taskIndex = status.tasks.findIndex(
+ (task) => task._id === currentTask._id
+ );
var statusTask = status.tasks[taskIndex];
return (
-
-
{currentTask.headline}
-
-
+
+
+ {currentTask.headline}
+
+
+
+
+
-
-
- {Blockly.Msg.tutorials_assessment_task}
+
+
+
+ {Blockly.Msg.tutorials_assessment_task}
+
{currentTask.text}
-
);
- };
+ }
}
Assessment.propTypes = {
status: PropTypes.array.isRequired,
change: PropTypes.number.isRequired,
workspaceName: PropTypes.func.isRequired,
- tutorial: PropTypes.object.isRequired
+ tutorial: PropTypes.object.isRequired,
};
-const mapStateToProps = state => ({
+const mapStateToProps = (state) => ({
change: state.tutorial.change,
status: state.tutorial.status,
- tutorial: state.tutorial.tutorials[0]
+ tutorial: state.tutorial.tutorials[0],
});
-export default connect(mapStateToProps, { workspaceName })(withWidth()(Assessment));
+export default connect(mapStateToProps, { workspaceName })(
+ withWidth()(Assessment)
+);
diff --git a/src/components/Tutorial/Instruction.js b/src/components/Tutorial/Instruction.js
index ade6dfb..fc72447 100644
--- a/src/components/Tutorial/Instruction.js
+++ b/src/components/Tutorial/Instruction.js
@@ -1,57 +1,95 @@
-import React, { Component } from 'react';
+import React, { Component } from "react";
-import Hardware from './Hardware';
-import Requirement from './Requirement';
-import BlocklyWindow from '../Blockly/BlocklyWindow';
-
-import Grid from '@material-ui/core/Grid';
-import Typography from '@material-ui/core/Typography';
-import ReactMarkdown from 'react-markdown'
+import Hardware from "./Hardware";
+import Requirement from "./Requirement";
+import BlocklyWindow from "../Blockly/BlocklyWindow";
+import Grid from "@material-ui/core/Grid";
+import Typography from "@material-ui/core/Typography";
+import ReactMarkdown from "react-markdown";
class Instruction extends Component {
-
render() {
var step = this.props.step;
var isHardware = step.hardware && step.hardware.length > 0;
var areRequirements = step.requirements && step.requirements.length > 0;
return (
-
{step.headline}
-
{step.text}
- {isHardware ?
-
: null}
- {areRequirements > 0 ?
-
: null}
- {step.media ?
- step.media.picture ?
-
-

-
- : step.media.youtube ?
- /*16:9; width: 800px; height: width/16*9=450px*/
-
- : null
- : null}
- {step.xml ?
-
-
-
+ {step.headline}
+
+
+
+ {step.text}
+
+
+ {isHardware ? : null}
+ {areRequirements > 0 ? (
+
+ ) : null}
+ {step.media ? (
+ step.media.picture ? (
+
+

+
+ ) : step.media.youtube ? (
+ /*16:9; width: 800px; height: width/16*9=450px*/
+
+ ) : null
+ ) : null}
+ {step.xml ? (
+
+
+
- : null}
+ ) : null}
);
- };
+ }
}
-
export default Instruction;
diff --git a/src/components/User/Login.js b/src/components/User/Login.js
index d667bf1..7119b22 100644
--- a/src/components/User/Login.js
+++ b/src/components/User/Login.js
@@ -1,76 +1,88 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import { login } from '../../actions/authActions'
-import { clearMessages } from '../../actions/messageActions'
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import { connect } from "react-redux";
+import { login } from "../../actions/authActions";
+import { clearMessages } from "../../actions/messageActions";
-import { withRouter } from 'react-router-dom';
+import { withRouter } from "react-router-dom";
-import Snackbar from '../Snackbar';
-import Alert from '../Alert';
-import Breadcrumbs from '../Breadcrumbs';
+import Snackbar from "../Snackbar";
+import Alert from "../Alert";
+import Breadcrumbs from "../Breadcrumbs";
-import Button from '@material-ui/core/Button';
-import IconButton from '@material-ui/core/IconButton';
+import Button from "@material-ui/core/Button";
+import IconButton from "@material-ui/core/IconButton";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
-import TextField from '@material-ui/core/TextField';
-import Divider from '@material-ui/core/Divider';
-import InputAdornment from '@material-ui/core/InputAdornment';
-import CircularProgress from '@material-ui/core/CircularProgress';
-import Link from '@material-ui/core/Link';
-import * as Blockly from 'blockly'
+import TextField from "@material-ui/core/TextField";
+import Divider from "@material-ui/core/Divider";
+import InputAdornment from "@material-ui/core/InputAdornment";
+import CircularProgress from "@material-ui/core/CircularProgress";
+import Link from "@material-ui/core/Link";
+import * as Blockly from "blockly";
export class Login extends Component {
-
constructor(props) {
super(props);
this.state = {
- redirect: props.location.state ? props.location.state.from.pathname : null,
- email: '',
- password: '',
+ redirect: props.location.state
+ ? props.location.state.from.pathname
+ : null,
+ email: "",
+ password: "",
snackbar: false,
- type: '',
- key: '',
- message: '',
- showPassword: false
+ type: "",
+ key: "",
+ message: "",
+ showPassword: false,
};
}
componentDidUpdate(props) {
const { message } = this.props;
if (message !== props.message) {
- if (message.id === 'LOGIN_SUCCESS') {
+ if (message.id === "LOGIN_SUCCESS") {
if (this.state.redirect) {
this.props.history.push(this.state.redirect);
- }
- else {
+ } else {
this.props.history.goBack();
}
}
// Check for login error
- else if (message.id === 'LOGIN_FAIL') {
- this.setState({ email: '', password: '', snackbar: true, key: Date.now(), message: Blockly.Msg.messages_LOGIN_FAIL, type: 'error' });
+ else if (message.id === "LOGIN_FAIL") {
+ this.setState({
+ email: "",
+ password: "",
+ snackbar: true,
+ key: Date.now(),
+ message: Blockly.Msg.messages_LOGIN_FAIL,
+ type: "error",
+ });
}
}
}
- onChange = e => {
+ onChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
- onSubmit = e => {
+ onSubmit = (e) => {
e.preventDefault();
const { email, password } = this.state;
- if (email !== '' && password !== '') {
+ if (email !== "" && password !== "") {
// create user object
const user = {
email,
- password
+ password,
};
this.props.login(user);
} else {
- this.setState({ snackbar: true, key: Date.now(), message: Blockly.Msg.messages_login_error, type: 'error' });
+ this.setState({
+ snackbar: true,
+ key: Date.now(),
+ message: Blockly.Msg.messages_login_error,
+ type: "error",
+ });
}
};
@@ -85,12 +97,25 @@ export class Login extends Component {
render() {
return (
-
+
-
+
{Blockly.Msg.login_head}
- {Blockly.Msg.login_osem_account_01} openSenseMap {Blockly.Msg.login_osem_account_02}.
+ {Blockly.Msg.login_osem_account_01}{" "}
+
+ openSenseMap
+ {" "}
+ {Blockly.Msg.login_osem_account_02}.
+ endAdornment: (
+
-
+
+ ),
}}
onChange={this.onChange}
fullWidth={true}
/>
-
-
- {Blockly.Msg.login_lostpassword}
+
+
+ {Blockly.Msg.login_lostpassword}
+
-
-
- {Blockly.Msg.login_createaccount}openSenseMap.
+
+
+ {Blockly.Msg.login_createaccount}
+
+ openSenseMap
+
+ .
@@ -155,12 +212,14 @@ Login.propTypes = {
message: PropTypes.object.isRequired,
login: PropTypes.func.isRequired,
clearMessages: PropTypes.func.isRequired,
- progress: PropTypes.bool.isRequired
+ progress: PropTypes.bool.isRequired,
};
-const mapStateToProps = state => ({
+const mapStateToProps = (state) => ({
message: state.message,
- progress: state.auth.progress
+ progress: state.auth.progress,
});
-export default connect(mapStateToProps, { login, clearMessages })(withRouter(Login));
+export default connect(mapStateToProps, { login, clearMessages })(
+ withRouter(Login)
+);