add selected Board to settings and solve component rerender
This commit is contained in:
parent
b212316b0b
commit
4565b4e482
BIN
public/media/hardware/senseboxmcumini.png
Normal file
BIN
public/media/hardware/senseboxmcumini.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 KiB |
@ -43,8 +43,16 @@ class BlocklyWindow extends Component {
|
|||||||
|
|
||||||
componentDidUpdate(props) {
|
componentDidUpdate(props) {
|
||||||
const workspace = Blockly.getMainWorkspace();
|
const workspace = Blockly.getMainWorkspace();
|
||||||
|
|
||||||
var xml = this.props.initialXml;
|
var xml = this.props.initialXml;
|
||||||
|
if (props.selectedBoard !== this.props.selectedBoard) {
|
||||||
|
// change board
|
||||||
|
if(!xml) xml = initialXml;
|
||||||
|
var xmlDom = Blockly.Xml.textToDom(xml);
|
||||||
|
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
|
||||||
|
// var toolbox = workspace.getToolbox();
|
||||||
|
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||||
|
}
|
||||||
|
|
||||||
// if svg is true, then the update process is done in the BlocklySvg component
|
// if svg is true, then the update process is done in the BlocklySvg component
|
||||||
if (props.initialXml !== xml && !this.props.svg) {
|
if (props.initialXml !== xml && !this.props.svg) {
|
||||||
// guarantees that the current xml-code (this.props.initialXml) is rendered
|
// guarantees that the current xml-code (this.props.initialXml) is rendered
|
||||||
@ -55,7 +63,7 @@ class BlocklyWindow extends Component {
|
|||||||
if (props.language !== this.props.language) {
|
if (props.language !== this.props.language) {
|
||||||
// change language
|
// change language
|
||||||
if (!xml) xml = initialXml;
|
if (!xml) xml = initialXml;
|
||||||
var xmlDom = Blockly.Xml.textToDom(xml);
|
xmlDom = Blockly.Xml.textToDom(xml);
|
||||||
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
|
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
|
||||||
// var toolbox = workspace.getToolbox();
|
// var toolbox = workspace.getToolbox();
|
||||||
// workspace.updateToolbox(toolbox.toolboxDef_);
|
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||||
@ -130,12 +138,14 @@ BlocklyWindow.propTypes = {
|
|||||||
renderer: PropTypes.string.isRequired,
|
renderer: PropTypes.string.isRequired,
|
||||||
sounds: PropTypes.bool.isRequired,
|
sounds: PropTypes.bool.isRequired,
|
||||||
language: PropTypes.string.isRequired,
|
language: PropTypes.string.isRequired,
|
||||||
|
selectedBoard: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
renderer: state.general.renderer,
|
renderer: state.general.renderer,
|
||||||
sounds: state.general.sounds,
|
sounds: state.general.sounds,
|
||||||
language: state.general.language,
|
language: state.general.language,
|
||||||
|
selectedBoard: state.board.board,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(
|
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(
|
||||||
|
@ -45,15 +45,11 @@ Blockly.Blocks['sensebox_rgb_led'] = {
|
|||||||
|
|
||||||
Blockly.Blocks['sensebox_ws2818_led_init'] = {
|
Blockly.Blocks['sensebox_ws2818_led_init'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, '1'],
|
|
||||||
[Blockly.Msg.senseBox_ultrasonic_port_B, '3'], [Blockly.Msg.senseBox_ultrasonic_port_C, '5']];
|
|
||||||
|
|
||||||
this.setColour(getColour().sensebox);
|
this.setColour(getColour().sensebox);
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led_init)
|
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led_init)
|
||||||
.appendField("Port:")
|
.appendField("Port:")
|
||||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
|
||||||
this.appendValueInput("BRIGHTNESS", "brightness")
|
this.appendValueInput("BRIGHTNESS", "brightness")
|
||||||
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_brightness));
|
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_brightness));
|
||||||
this.appendValueInput("NUMBER", "number")
|
this.appendValueInput("NUMBER", "number")
|
||||||
@ -66,15 +62,11 @@ Blockly.Blocks['sensebox_ws2818_led_init'] = {
|
|||||||
|
|
||||||
Blockly.Blocks['sensebox_ws2818_led'] = {
|
Blockly.Blocks['sensebox_ws2818_led'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, '1'],
|
|
||||||
[Blockly.Msg.senseBox_ultrasonic_port_B, '3'], [Blockly.Msg.senseBox_ultrasonic_port_C, '5']];
|
|
||||||
|
|
||||||
this.setColour(getColour().sensebox);
|
this.setColour(getColour().sensebox);
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led)
|
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led)
|
||||||
.appendField("Port:")
|
.appendField("Port:")
|
||||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
|
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
|
||||||
this.appendValueInput("POSITION", "position")
|
this.appendValueInput("POSITION", "position")
|
||||||
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_position));
|
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_position));
|
||||||
this.appendValueInput("COLOR", 'Number')
|
this.appendValueInput("COLOR", 'Number')
|
||||||
|
@ -101,7 +101,6 @@ Blockly.Arduino.sensebox_phyphox_graph = function () {
|
|||||||
Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
|
Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
|
||||||
var branch = Blockly.Arduino.statementToCode(this, "sendValues");
|
var branch = Blockly.Arduino.statementToCode(this, "sendValues");
|
||||||
var blocks = this.getDescendants();
|
var blocks = this.getDescendants();
|
||||||
console.log(blocks);
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
if (blocks !== undefined) {
|
if (blocks !== undefined) {
|
||||||
for (var i = 0; i < blocks.length; i++) {
|
for (var i = 0; i < blocks.length; i++) {
|
||||||
@ -115,7 +114,6 @@ Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
|
|||||||
var string = "";
|
var string = "";
|
||||||
|
|
||||||
for (var j = 1; j <= count; j++) {
|
for (var j = 1; j <= count; j++) {
|
||||||
console.log("append");
|
|
||||||
if (string === "") {
|
if (string === "") {
|
||||||
string += `channel${j}`;
|
string += `channel${j}`;
|
||||||
} else if (string !== "") {
|
} else if (string !== "") {
|
||||||
|
@ -203,6 +203,5 @@ Blockly.Arduino.sensebox_sd_save_for_osem = function (block) {
|
|||||||
Blockly.Arduino.definitions_["SENSOR_ID" + id + ""] =
|
Blockly.Arduino.definitions_["SENSOR_ID" + id + ""] =
|
||||||
"const char SENSOR_ID" + id + '[] PROGMEM = "' + sensor_id + '";';
|
"const char SENSOR_ID" + id + '[] PROGMEM = "' + sensor_id + '";';
|
||||||
code += "addMeasurement(SENSOR_ID" + id + "," + sensor_value + ");\n";
|
code += "addMeasurement(SENSOR_ID" + id + "," + sensor_value + ");\n";
|
||||||
console.log(code);
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
import Blockly from "blockly";
|
import Blockly from "blockly";
|
||||||
|
//import store from "../../../store";
|
||||||
|
|
||||||
|
// preperations for the esp board
|
||||||
|
// var selectedBoard = store.getState().board.board;
|
||||||
|
// store.subscribe(() => {
|
||||||
|
// selectedBoard = store.getState().board.board;
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
/* Wifi connection and openSenseMap Blocks*/
|
/* Wifi connection and openSenseMap Blocks*/
|
||||||
Blockly.Arduino.sensebox_wifi = function (block) {
|
Blockly.Arduino.sensebox_wifi = function (block) {
|
||||||
@ -110,3 +118,5 @@ Blockly.Arduino.sensebox_ethernetIp = function () {
|
|||||||
var code = "Ethernet.localIP()";
|
var code = "Ethernet.localIP()";
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ const setVariableFunction = function (defaultValue) {
|
|||||||
.getVariableMap()
|
.getVariableMap()
|
||||||
.getAllVariables();
|
.getAllVariables();
|
||||||
const myVar = allVars.filter((v) => v.name === variableName)[0];
|
const myVar = allVars.filter((v) => v.name === variableName)[0];
|
||||||
console.log(myVar);
|
|
||||||
var code = "";
|
var code = "";
|
||||||
if (myVar !== undefined) {
|
if (myVar !== undefined) {
|
||||||
Blockly.Arduino.variables_[variableName + myVar.type] =
|
Blockly.Arduino.variables_[variableName + myVar.type] =
|
||||||
|
@ -23,6 +23,11 @@ const sensebox_mcu = {
|
|||||||
["C5", "5"],
|
["C5", "5"],
|
||||||
["C6", "6"],
|
["C6", "6"],
|
||||||
],
|
],
|
||||||
|
digitalPinsRGB: [
|
||||||
|
["A", "1"],
|
||||||
|
["B", "3"],
|
||||||
|
["C", "5"],
|
||||||
|
],
|
||||||
digitalPinsButton: [
|
digitalPinsButton: [
|
||||||
["on Board", "0"],
|
["on Board", "0"],
|
||||||
["A1", "1"],
|
["A1", "1"],
|
||||||
@ -131,7 +136,7 @@ const sensebox_mini = {
|
|||||||
description: "senseBox Mini",
|
description: "senseBox Mini",
|
||||||
compilerFlag: "arduino:samd",
|
compilerFlag: "arduino:samd",
|
||||||
digitalPins: [
|
digitalPins: [
|
||||||
["A1", "1"],
|
["Test", "1"],
|
||||||
["A2", "2"],
|
["A2", "2"],
|
||||||
["B3", "3"],
|
["B3", "3"],
|
||||||
["B4", "4"],
|
["B4", "4"],
|
||||||
@ -148,6 +153,11 @@ const sensebox_mini = {
|
|||||||
["C5", "5"],
|
["C5", "5"],
|
||||||
["C6", "6"],
|
["C6", "6"],
|
||||||
],
|
],
|
||||||
|
digitalPinsRGB: [
|
||||||
|
["on Board", "7"],
|
||||||
|
["B", "8"],
|
||||||
|
["C", "1"],
|
||||||
|
],
|
||||||
digitalPinsButton: [
|
digitalPinsButton: [
|
||||||
["on Board", "0"],
|
["on Board", "0"],
|
||||||
["A1", "1"],
|
["A1", "1"],
|
||||||
@ -247,7 +257,6 @@ const sensebox_mini = {
|
|||||||
var board = sensebox_mcu
|
var board = sensebox_mcu
|
||||||
|
|
||||||
export const setBoard = (selectedBoard) => {
|
export const setBoard = (selectedBoard) => {
|
||||||
console.log(board)
|
|
||||||
if (selectedBoard === "mini"){
|
if (selectedBoard === "mini"){
|
||||||
board = sensebox_mini
|
board = sensebox_mini
|
||||||
}
|
}
|
||||||
@ -258,6 +267,5 @@ export const setBoard = (selectedBoard) => {
|
|||||||
|
|
||||||
|
|
||||||
export const selectedBoard = () => {
|
export const selectedBoard = () => {
|
||||||
console.log(board)
|
|
||||||
return board;
|
return board;
|
||||||
};
|
};
|
||||||
|
@ -182,7 +182,8 @@ export const UI = {
|
|||||||
settings_sounds: "Töne",
|
settings_sounds: "Töne",
|
||||||
settings_sounds_text:
|
settings_sounds_text:
|
||||||
"Aktiviere oder Deaktiviere Töne beim hinzufügen und löschen von Blöcken. Standardmäßig deaktiviert",
|
"Aktiviere oder Deaktiviere Töne beim hinzufügen und löschen von Blöcken. Standardmäßig deaktiviert",
|
||||||
|
settings_board: "Board",
|
||||||
|
settings_board_text: "Wähle dein verwendetes Board aus",
|
||||||
/**
|
/**
|
||||||
* 404
|
* 404
|
||||||
*/
|
*/
|
||||||
|
@ -176,6 +176,8 @@ export const UI = {
|
|||||||
settings_sounds: "Sound",
|
settings_sounds: "Sound",
|
||||||
settings_sounds_text:
|
settings_sounds_text:
|
||||||
"Enable or disable sounds when adding and deleting blocks. Disabled by default",
|
"Enable or disable sounds when adding and deleting blocks. Disabled by default",
|
||||||
|
settings_board: "Board",
|
||||||
|
settings_board_text: "Choose your board",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 404
|
* 404
|
||||||
@ -296,4 +298,11 @@ export const UI = {
|
|||||||
codeeditor_blockly_code: "Load blockly code",
|
codeeditor_blockly_code: "Load blockly code",
|
||||||
codeeditor_compile_progress:
|
codeeditor_compile_progress:
|
||||||
"Your code will now be compiled and then downloaded to your computer",
|
"Your code will now be compiled and then downloaded to your computer",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device Selction
|
||||||
|
* */
|
||||||
|
deviceselection_head: "Which board are you using?",
|
||||||
|
deviceselection_keep_selection: "Save my choice",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,6 @@ const CodeEditor = (props) => {
|
|||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
|
||||||
if (data.code === "Internal Server Error") {
|
if (data.code === "Internal Server Error") {
|
||||||
setProgress(false);
|
setProgress(false);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
|
@ -89,7 +89,6 @@ class Compile extends Component {
|
|||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
|
||||||
if (data.code === "Internal Server Error") {
|
if (data.code === "Internal Server Error") {
|
||||||
this.setState({
|
this.setState({
|
||||||
progress: false,
|
progress: false,
|
||||||
|
@ -27,7 +27,6 @@ const SerialMonitor = () => {
|
|||||||
if (value) {
|
if (value) {
|
||||||
// byte array to string: https://stackoverflow.com/a/37542820
|
// byte array to string: https://stackoverflow.com/a/37542820
|
||||||
const text = String.fromCharCode.apply(null, value);
|
const text = String.fromCharCode.apply(null, value);
|
||||||
console.log(text);
|
|
||||||
setSerialPortContent((prevContent) => [
|
setSerialPortContent((prevContent) => [
|
||||||
...prevContent,
|
...prevContent,
|
||||||
[new Date(), text],
|
[new Date(), text],
|
||||||
|
@ -7,8 +7,7 @@ import { withStyles } from "@material-ui/core/styles";
|
|||||||
import Checkbox from "@material-ui/core/Checkbox";
|
import Checkbox from "@material-ui/core/Checkbox";
|
||||||
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
||||||
import * as Blockly from "blockly";
|
import * as Blockly from "blockly";
|
||||||
import ReactMarkdown from "react-markdown";
|
import { IconButton, Grid, Avatar, Typography } from "@material-ui/core";
|
||||||
import { IconButton, Grid, Avatar } from "@material-ui/core";
|
|
||||||
import { setBoard } from "../actions/boardAction";
|
import { setBoard } from "../actions/boardAction";
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
@ -65,7 +64,6 @@ class DeviceSeclection extends Component {
|
|||||||
this.setState({selectedBoard: value})
|
this.setState({selectedBoard: value})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -76,27 +74,27 @@ class DeviceSeclection extends Component {
|
|||||||
title={Blockly.Msg.deviceselection_head}
|
title={Blockly.Msg.deviceselection_head}
|
||||||
content={""}
|
content={""}
|
||||||
onClick={this.toggleDialog}
|
onClick={this.toggleDialog}
|
||||||
button={Blockly.Msg.button_save}
|
button={Blockly.Msg.button_accept}
|
||||||
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={4}>
|
<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
|
||||||
alt="Sensebox ESP"
|
alt="Sensebox ESP"
|
||||||
@ -109,20 +107,20 @@ class DeviceSeclection extends Component {
|
|||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<p>Sensebox ESP</p>
|
<p>Sensebox ESP</p>
|
||||||
</Grid>
|
</Grid> */}
|
||||||
<Grid item xs={4}>
|
<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/senseboxmcu.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 Mini</p>
|
<p>senseBox MCU:mini</p>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
@ -141,6 +139,9 @@ class DeviceSeclection extends Component {
|
|||||||
}
|
}
|
||||||
label={Blockly.Msg.deviceselection_keep_selection}
|
label={Blockly.Msg.deviceselection_keep_selection}
|
||||||
/>
|
/>
|
||||||
|
<Typography variant="body1" >
|
||||||
|
Hier kommst du zur alten Blockly Version für den <a href="https://sensebox.github.io/blockly/">Arduino UNO</a> oder die <a href="/">senseBox MCU</a>
|
||||||
|
</Typography>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ import BlocklyWindow from "./Blockly/BlocklyWindow";
|
|||||||
import CodeViewer from "./CodeViewer";
|
import CodeViewer from "./CodeViewer";
|
||||||
import TrashcanButtons from "./Workspace/TrashcanButtons";
|
import TrashcanButtons from "./Workspace/TrashcanButtons";
|
||||||
import HintTutorialExists from "./Tutorial/HintTutorialExists";
|
import HintTutorialExists from "./Tutorial/HintTutorialExists";
|
||||||
import DeviceSelction from "./DeviceSelction";
|
import DeviceSelection from "./DeviceSelection";
|
||||||
|
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from "@material-ui/core/Grid";
|
||||||
import IconButton from "@material-ui/core/IconButton";
|
import IconButton from "@material-ui/core/IconButton";
|
||||||
@ -187,7 +187,7 @@ class Home extends Component {
|
|||||||
</Grid>
|
</Grid>
|
||||||
) : null}
|
) : null}
|
||||||
</Grid>
|
</Grid>
|
||||||
<DeviceSelction />
|
<DeviceSelection />
|
||||||
<HintTutorialExists />
|
<HintTutorialExists />
|
||||||
{this.props.platform ? (
|
{this.props.platform ? (
|
||||||
<Dialog
|
<Dialog
|
||||||
|
55
src/components/Settings/DeviceSelector.js
Normal file
55
src/components/Settings/DeviceSelector.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { setBoard } from '../../actions/boardAction';
|
||||||
|
|
||||||
|
import * as Blockly from 'blockly/core';
|
||||||
|
|
||||||
|
import InputLabel from '@material-ui/core/InputLabel';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import FormControl from '@material-ui/core/FormControl';
|
||||||
|
import Select from '@material-ui/core/Select';
|
||||||
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||||
|
|
||||||
|
class DeviceSelector extends Component {
|
||||||
|
|
||||||
|
componentDidMount(){
|
||||||
|
// Ensure that Blockly.setLocale is adopted in the component.
|
||||||
|
// Otherwise, the text will not be displayed until the next update of the component.
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
render(){
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
<Typography style={{fontWeight: 'bold'}}>{Blockly.Msg.settings_board}</Typography>
|
||||||
|
<FormHelperText style={{color: 'black', lineHeight: 1.3, marginBottom: '8px'}}>{Blockly.Msg.settings_board_text}</FormHelperText>
|
||||||
|
<FormControl>
|
||||||
|
<InputLabel id="demo-simple-select-label">{Blockly.Msg.settings_board}</InputLabel>
|
||||||
|
<Select
|
||||||
|
labelId="demo-simple-select-label"
|
||||||
|
id="demo-simple-select"
|
||||||
|
value={this.props.selectedBoard}
|
||||||
|
onChange={(e) => this.props.setBoard(e.target.value)}
|
||||||
|
>
|
||||||
|
<MenuItem value="mcu">senseBox MCU</MenuItem>
|
||||||
|
<MenuItem value="mini">senseBox MCU mini</MenuItem>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceSelector.propTypes = {
|
||||||
|
setBoard: PropTypes.func.isRequired,
|
||||||
|
selectedBoard: PropTypes.string.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
selectedBoard: state.board.board
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, { setBoard })(DeviceSelector);
|
@ -12,6 +12,7 @@ import RenderSelector from "./RenderSelector";
|
|||||||
import StatsSelector from "./StatsSelector";
|
import StatsSelector from "./StatsSelector";
|
||||||
import OtaSelector from "./OtaSelector";
|
import OtaSelector from "./OtaSelector";
|
||||||
import SoundsSelector from "./SoundsSelector";
|
import SoundsSelector from "./SoundsSelector";
|
||||||
|
import DeviceSelector from "./DeviceSelector";
|
||||||
|
|
||||||
import Button from "@material-ui/core/Button";
|
import Button from "@material-ui/core/Button";
|
||||||
import Paper from "@material-ui/core/Paper";
|
import Paper from "@material-ui/core/Paper";
|
||||||
@ -52,6 +53,9 @@ class Settings extends Component {
|
|||||||
<Paper style={{ margin: "10px 0px", padding: "10px" }}>
|
<Paper style={{ margin: "10px 0px", padding: "10px" }}>
|
||||||
<SoundsSelector />
|
<SoundsSelector />
|
||||||
</Paper>
|
</Paper>
|
||||||
|
<Paper style={{ margin: "10px 0px", padding: "10px" }}>
|
||||||
|
<DeviceSelector />
|
||||||
|
</Paper>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style={{ marginTop: "10px" }}
|
style={{ marginTop: "10px" }}
|
||||||
|
@ -304,7 +304,6 @@ class Builder extends Component {
|
|||||||
newTutorial.append(`steps[${i}][xml]`, step.xml);
|
newTutorial.append(`steps[${i}][xml]`, step.xml);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(newTutorial);
|
|
||||||
return newTutorial;
|
return newTutorial;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -34,13 +34,11 @@ const styles = (theme) => ({
|
|||||||
|
|
||||||
class Difficulty extends Component {
|
class Difficulty extends Component {
|
||||||
ratingChanged = (newRating) => {
|
ratingChanged = (newRating) => {
|
||||||
console.log(newRating);
|
|
||||||
this.handleChange(newRating);
|
this.handleChange(newRating);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleChange = (e) => {
|
handleChange = (e) => {
|
||||||
var value = e;
|
var value = e;
|
||||||
console.log(value);
|
|
||||||
if (this.props.property === "difficulty") {
|
if (this.props.property === "difficulty") {
|
||||||
this.props.tutorialDifficulty(value);
|
this.props.tutorialDifficulty(value);
|
||||||
} else if (this.props.property === "json") {
|
} else if (this.props.property === "json") {
|
||||||
|
@ -44,7 +44,6 @@ const MarkdownEditor = (props) => {
|
|||||||
headers: { "Content-Type": "multipart/form-data" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
|
||||||
resolve(
|
resolve(
|
||||||
`${process.env.REACT_APP_BLOCKLY_API}/upload/` + res.data.filename
|
`${process.env.REACT_APP_BLOCKLY_API}/upload/` + res.data.filename
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,6 @@ const styles = (theme) => ({
|
|||||||
class Public extends Component {
|
class Public extends Component {
|
||||||
handleChange = (e) => {
|
handleChange = (e) => {
|
||||||
var value = e.target.checked;
|
var value = e.target.checked;
|
||||||
console.log(value);
|
|
||||||
if (this.props.property === "public") {
|
if (this.props.property === "public") {
|
||||||
this.props.tutorialPublic(value);
|
this.props.tutorialPublic(value);
|
||||||
} else if (this.props.property === "json") {
|
} else if (this.props.property === "json") {
|
||||||
|
@ -147,7 +147,6 @@ class TutorialHome extends Component {
|
|||||||
if (this.props.message.id === "GET_TUTORIALS_FAIL") {
|
if (this.props.message.id === "GET_TUTORIALS_FAIL") {
|
||||||
alert(this.props.message.msg);
|
alert(this.props.message.msg);
|
||||||
}
|
}
|
||||||
console.log(this.props.user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -50,7 +50,6 @@ export class Login extends Component {
|
|||||||
}
|
}
|
||||||
// Check for login error
|
// Check for login error
|
||||||
else if (message.id === "LOGIN_FAIL") {
|
else if (message.id === "LOGIN_FAIL") {
|
||||||
console.log("login fail");
|
|
||||||
this.setState({
|
this.setState({
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
@ -37,7 +37,6 @@ class AutoSave extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
console.log(this.props.xml);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
|
@ -89,7 +89,6 @@ class Compile extends Component {
|
|||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
|
||||||
if (data.code === "Internal Server Error") {
|
if (data.code === "Internal Server Error") {
|
||||||
this.setState({
|
this.setState({
|
||||||
progress: false,
|
progress: false,
|
||||||
|
@ -15,9 +15,6 @@ import DeleteProject from "./DeleteProject";
|
|||||||
import CopyCode from "./CopyCode";
|
import CopyCode from "./CopyCode";
|
||||||
import AutoSave from "./AutoSave";
|
import AutoSave from "./AutoSave";
|
||||||
class WorkspaceFunc extends Component {
|
class WorkspaceFunc extends Component {
|
||||||
componentDidUpdate() {
|
|
||||||
console.log(this.props.autosave);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
@ -2,9 +2,9 @@ import { BOARD } from '../actions/types';
|
|||||||
|
|
||||||
const initialValue = () => {
|
const initialValue = () => {
|
||||||
if (window.localStorage.getItem("board")) {
|
if (window.localStorage.getItem("board")) {
|
||||||
return window.localStorage.getItem("locale");
|
return window.localStorage.getItem("board");
|
||||||
}
|
}
|
||||||
return "";
|
return "bla";
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user