Merge branch 'remove-senseboxmcu-lib' of https://github.com/sensebox/React-Ardublockly into remove-senseboxmcu-lib
This commit is contained in:
		
						commit
						e4fdb542bf
					
				| @ -1,4 +1,11 @@ | |||||||
| import { VISIT, LANGUAGE, RENDERER, STATISTICS, PLATFORM } from "./types"; | import { | ||||||
|  |   VISIT, | ||||||
|  |   LANGUAGE, | ||||||
|  |   RENDERER, | ||||||
|  |   SOUNDS, | ||||||
|  |   STATISTICS, | ||||||
|  |   PLATFORM, | ||||||
|  | } from "./types"; | ||||||
| 
 | 
 | ||||||
| export const visitPage = () => (dispatch) => { | export const visitPage = () => (dispatch) => { | ||||||
|   dispatch({ |   dispatch({ | ||||||
| @ -30,6 +37,13 @@ export const setRenderer = (renderer) => (dispatch) => { | |||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | export const setSounds = (sounds) => (dispatch) => { | ||||||
|  |   dispatch({ | ||||||
|  |     type: SOUNDS, | ||||||
|  |     payload: sounds, | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| export const setStatistics = (showStatistics) => (dispatch) => { | export const setStatistics = (showStatistics) => (dispatch) => { | ||||||
|   dispatch({ |   dispatch({ | ||||||
|     type: STATISTICS, |     type: STATISTICS, | ||||||
|  | |||||||
| @ -45,6 +45,7 @@ export const VISIT = "VISIT"; | |||||||
| export const LANGUAGE = "LANGUAGE"; | export const LANGUAGE = "LANGUAGE"; | ||||||
| export const PLATFORM = "PLATFORM"; | export const PLATFORM = "PLATFORM"; | ||||||
| export const RENDERER = "RENDERER"; | export const RENDERER = "RENDERER"; | ||||||
|  | export const SOUNDS = "SOUNDS"; | ||||||
| export const STATISTICS = "STATISTICS"; | export const STATISTICS = "STATISTICS"; | ||||||
| 
 | 
 | ||||||
| // messages
 | // messages
 | ||||||
|  | |||||||
| @ -72,6 +72,7 @@ class BlocklyWindow extends Component { | |||||||
|             this.props.trashcan !== undefined ? this.props.trashcan : true |             this.props.trashcan !== undefined ? this.props.trashcan : true | ||||||
|           } |           } | ||||||
|           renderer={this.props.renderer} |           renderer={this.props.renderer} | ||||||
|  |           sounds={this.props.sounds} | ||||||
|           maxInstances={getMaxInstances()} |           maxInstances={getMaxInstances()} | ||||||
|           zoom={{ |           zoom={{ | ||||||
|             // https://developers.google.com/blockly/guides/configure/web/zoom
 |             // https://developers.google.com/blockly/guides/configure/web/zoom
 | ||||||
| @ -123,11 +124,13 @@ BlocklyWindow.propTypes = { | |||||||
|   onChangeWorkspace: PropTypes.func.isRequired, |   onChangeWorkspace: PropTypes.func.isRequired, | ||||||
|   clearStats: PropTypes.func.isRequired, |   clearStats: PropTypes.func.isRequired, | ||||||
|   renderer: PropTypes.string.isRequired, |   renderer: PropTypes.string.isRequired, | ||||||
|  |   sounds: PropTypes.string.isRequired, | ||||||
|   language: PropTypes.string.isRequired, |   language: PropTypes.string.isRequired, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const mapStateToProps = (state) => ({ | const mapStateToProps = (state) => ({ | ||||||
|   renderer: state.general.renderer, |   renderer: state.general.renderer, | ||||||
|  |   sounds: state.general.sounds, | ||||||
|   language: state.general.language, |   language: state.general.language, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,8 +6,8 @@ Blockly.Arduino.sensebox_wifi = function (block) { | |||||||
|   var ssid = this.getFieldValue("SSID"); |   var ssid = this.getFieldValue("SSID"); | ||||||
|   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; |   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; | ||||||
|   Blockly.Arduino.libraries_["library_WiFi"] = "#include <WiFi101.h>"; |   Blockly.Arduino.libraries_["library_WiFi"] = "#include <WiFi101.h>"; | ||||||
|   Blockly.Arduino.variables_["ssid"] = `char ssid[] = ${ssid};`; |   Blockly.Arduino.variables_["ssid"] = `char ssid[] = "${ssid}";`; | ||||||
|   Blockly.Arduino.variables_["pass"] = `char pass[] = ${pw};`; |   Blockly.Arduino.variables_["pass"] = `char pass[] = "${pw}";`; | ||||||
|   Blockly.Arduino.variables_["wifi_Status"] = "int status = WL_IDLE_STATUS;"; |   Blockly.Arduino.variables_["wifi_Status"] = "int status = WL_IDLE_STATUS;"; | ||||||
|   if (pw === "") { |   if (pw === "") { | ||||||
|     Blockly.Arduino.setupCode_["wifi_begin"] = ` |     Blockly.Arduino.setupCode_["wifi_begin"] = ` | ||||||
| @ -53,6 +53,7 @@ Blockly.Arduino.sensebox_get_ip = function () { | |||||||
| Blockly.Arduino.sensebox_startap = function (block) { | Blockly.Arduino.sensebox_startap = function (block) { | ||||||
|   var ssid = this.getFieldValue("SSID"); |   var ssid = this.getFieldValue("SSID"); | ||||||
|   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; |   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; | ||||||
|  |   Blockly.Arduino.libraries_["library_WiFi"] = "#include <WiFi101.h>"; | ||||||
|   Blockly.Arduino.setupCode_["wifi_startAP"] = `WiFi.beginAP(${ssid});`; |   Blockly.Arduino.setupCode_["wifi_startAP"] = `WiFi.beginAP(${ssid});`; | ||||||
|   var code = ""; |   var code = ""; | ||||||
|   return code; |   return code; | ||||||
|  | |||||||
| @ -177,6 +177,9 @@ export const UI = { | |||||||
|     "Der Tablet Modus deaktiviert die Code anzeige und aktiviert die Möglichkeit den Programmcode über die senseBox Connect App zu übertragen. Weitere Informationen dazu findest du unter: ", |     "Der Tablet Modus deaktiviert die Code anzeige und aktiviert die Möglichkeit den Programmcode über die senseBox Connect App zu übertragen. Weitere Informationen dazu findest du unter: ", | ||||||
|   settings_ota_on: "Aktiviert", |   settings_ota_on: "Aktiviert", | ||||||
|   settings_ota_off: "Deaktiviert", |   settings_ota_off: "Deaktiviert", | ||||||
|  |   settings_sounds: "Töne", | ||||||
|  |   settings_sounds_text: | ||||||
|  |     "Aktiviere oder Deaktiviere Töne beim hinzufügen und löschen von Blöcken. Standardmäßig deaktiviert", | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * 404 |    * 404 | ||||||
|  | |||||||
| @ -167,11 +167,14 @@ export const UI = { | |||||||
|     "The display of statistics on the usage of the blocks above the workspace can be shown or hidden.", |     "The display of statistics on the usage of the blocks above the workspace can be shown or hidden.", | ||||||
|   settings_statistics_on: "On", |   settings_statistics_on: "On", | ||||||
|   settings_statistics_off: "Off", |   settings_statistics_off: "Off", | ||||||
|   settings_ota_head: "tablet mode", |   settings_ota_head: "Tablet mode", | ||||||
|   settings_ota_text: |   settings_ota_text: | ||||||
|     "Tablet mode disables the code display and enables the possibility to transfer the program code via the senseBox Connect app. You can find more information on: ", |     "Tablet mode disables the code display and enables the possibility to transfer the program code via the senseBox Connect app. You can find more information on: ", | ||||||
|   settings_ota_on: "Activated", |   settings_ota_on: "Activated", | ||||||
|   settings_ota_off: "Deactivated", |   settings_ota_off: "Deactivated", | ||||||
|  |   settings_sounds: "Sound", | ||||||
|  |   settings_sounds_text: | ||||||
|  |     "Enable or disable sounds when adding and deleting blocks. Disabled by default", | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * 404 |    * 404 | ||||||
|  | |||||||
| @ -601,11 +601,11 @@ class Toolbox extends React.Component { | |||||||
|           colour={getColour().variables} |           colour={getColour().variables} | ||||||
|           custom="CREATE_TYPED_VARIABLE" |           custom="CREATE_TYPED_VARIABLE" | ||||||
|         ></Category> |         ></Category> | ||||||
|         <Category name="Arrays" colour={getColour().arrays}> |         {/* <Category name="Arrays" colour={getColour().arrays}> | ||||||
|           <Block type="lists_create_empty" /> |           <Block type="lists_create_empty" /> | ||||||
|           <Block type="array_getIndex" /> |           <Block type="array_getIndex" /> | ||||||
|           <Block type="lists_length" /> |           <Block type="lists_length" /> | ||||||
|         </Category> |         </Category> */} | ||||||
|         <Category |         <Category | ||||||
|           name={Blockly.Msg.toolbox_functions} |           name={Blockly.Msg.toolbox_functions} | ||||||
|           colour={getColour().procedures} |           colour={getColour().procedures} | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ import LanguageSelector from "./LanguageSelector"; | |||||||
| import RenderSelector from "./RenderSelector"; | 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 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"; | ||||||
| @ -48,6 +49,9 @@ class Settings extends Component { | |||||||
|         <Paper style={{ margin: "10px 0px", padding: "10px" }}> |         <Paper style={{ margin: "10px 0px", padding: "10px" }}> | ||||||
|           <OtaSelector /> |           <OtaSelector /> | ||||||
|         </Paper> |         </Paper> | ||||||
|  |         <Paper style={{ margin: "10px 0px", padding: "10px" }}> | ||||||
|  |           <SoundsSelector /> | ||||||
|  |         </Paper> | ||||||
| 
 | 
 | ||||||
|         <Button |         <Button | ||||||
|           style={{ marginTop: "10px" }} |           style={{ marginTop: "10px" }} | ||||||
|  | |||||||
							
								
								
									
										63
									
								
								src/components/Settings/SoundsSelector.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/components/Settings/SoundsSelector.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | |||||||
|  | import React, { Component } from "react"; | ||||||
|  | import PropTypes from "prop-types"; | ||||||
|  | import { connect } from "react-redux"; | ||||||
|  | import { setSounds } from "../../actions/generalActions"; | ||||||
|  | 
 | ||||||
|  | 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 SoundsSelector 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_sounds} | ||||||
|  |         </Typography> | ||||||
|  |         <FormHelperText | ||||||
|  |           style={{ color: "black", lineHeight: 1.3, marginBottom: "8px" }} | ||||||
|  |         > | ||||||
|  |           {Blockly.Msg.settings_sounds_text} | ||||||
|  |         </FormHelperText> | ||||||
|  |         <FormControl> | ||||||
|  |           <InputLabel id="demo-simple-select-label"> | ||||||
|  |             {Blockly.Msg.settings_sounds} | ||||||
|  |           </InputLabel> | ||||||
|  |           <Select | ||||||
|  |             labelId="demo-simple-select-label" | ||||||
|  |             id="demo-simple-select" | ||||||
|  |             value={this.props.sounds} | ||||||
|  |             onChange={(e) => this.props.setSounds(e.target.value)} | ||||||
|  |           > | ||||||
|  |             <MenuItem value={false}>{Blockly.Msg.settings_ota_off}</MenuItem> | ||||||
|  |             <MenuItem value={true}>{Blockly.Msg.settings_ota_on}</MenuItem> | ||||||
|  |           </Select> | ||||||
|  |         </FormControl> | ||||||
|  |       </div> | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | SoundsSelector.propTypes = { | ||||||
|  |   setSounds: PropTypes.func.isRequired, | ||||||
|  |   language: PropTypes.string.isRequired, | ||||||
|  |   sounds: PropTypes.string.isRequired, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const mapStateToProps = (state) => ({ | ||||||
|  |   sounds: state.general.sounds, | ||||||
|  |   language: state.general.language, | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export default connect(mapStateToProps, { setSounds })(SoundsSelector); | ||||||
| @ -2,6 +2,7 @@ import { | |||||||
|   VISIT, |   VISIT, | ||||||
|   LANGUAGE, |   LANGUAGE, | ||||||
|   RENDERER, |   RENDERER, | ||||||
|  |   SOUNDS, | ||||||
|   STATISTICS, |   STATISTICS, | ||||||
|   PLATFORM, |   PLATFORM, | ||||||
| } from "../actions/types"; | } from "../actions/types"; | ||||||
| @ -20,6 +21,14 @@ const initialPlatform = () => { | |||||||
|   return getPlatform(); |   return getPlatform(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | const initialSounds = () => { | ||||||
|  |   if (window.localStorage.getItem("sounds")) { | ||||||
|  |     return window.localStorage.getItem("sounds"); | ||||||
|  |   } else { | ||||||
|  |     return "off"; | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| const getPlatform = () => { | const getPlatform = () => { | ||||||
|   if (window.localStorage.getItem("platform")) { |   if (window.localStorage.getItem("platform")) { | ||||||
|     return JSON.parse(window.localStorage.getItem("platform")); |     return JSON.parse(window.localStorage.getItem("platform")); | ||||||
| @ -62,6 +71,7 @@ const initialState = { | |||||||
|   pageVisits: 0, // detect if previous URL was
 |   pageVisits: 0, // detect if previous URL was
 | ||||||
|   language: initialLanguage(), |   language: initialLanguage(), | ||||||
|   renderer: initialRenderer(), |   renderer: initialRenderer(), | ||||||
|  |   sounds: initialSounds(), | ||||||
|   statistics: initialStatistics(), |   statistics: initialStatistics(), | ||||||
|   platform: initialPlatform(), |   platform: initialPlatform(), | ||||||
| }; | }; | ||||||
| @ -90,6 +100,12 @@ export default function foo(state = initialState, action) { | |||||||
|         ...state, |         ...state, | ||||||
|         renderer: action.payload, |         renderer: action.payload, | ||||||
|       }; |       }; | ||||||
|  |     case SOUNDS: | ||||||
|  |       window.localStorage.setItem("sounds", action.payload); | ||||||
|  |       return { | ||||||
|  |         ...state, | ||||||
|  |         sounds: action.payload, | ||||||
|  |       }; | ||||||
|     case STATISTICS: |     case STATISTICS: | ||||||
|       window.localStorage.setItem("statistics", action.payload); |       window.localStorage.setItem("statistics", action.payload); | ||||||
|       return { |       return { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user