Compare commits

..

4 Commits

Author SHA1 Message Date
Bjoern Luig
0388e5c627 change order of phenomenons 2023-06-09 11:03:28 +02:00
Bjoern Luig
9c33bc4c0d small bugfix to use multiple sensors 2022-11-16 14:18:27 +01:00
Bjoern
32372bc222 finished english language and testing of compiling 2022-10-28 01:37:16 +02:00
Bjoern Luig
dbc7fdc7ab added rainsensor 2022-08-28 16:25:52 +02:00
156 changed files with 46286 additions and 6765 deletions

2
.env
View File

@ -2,7 +2,5 @@ REACT_APP_COMPILER_URL=https://compiler.sensebox.de
REACT_APP_BOARD=sensebox-mcu
REACT_APP_BLOCKLY_API=https://api.blockly.sensebox.de
GENERATE_SOURCEMAP=false
# in days
REACT_APP_SHARE_LINK_EXPIRES=30

View File

@ -1,41 +0,0 @@
name: Build and push image
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
#defaults:
# run:
# working-directory: /repo
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # all history for all branches and tags
- name: Login to gitea.simonzeyer.de Repo
uses: docker/login-action@v2
with:
registry: gitea.simonzeyer.de
username: ${{ secrets.DOCKER_REPO_USER }}
password: ${{ secrets.DOCKER_REPO_PASSWD }}
- name: Get Meta
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --always | sed 's/^v//') >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
env:
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
with:
context: .
file: ./Dockerfile
push: true
tags: |
gitea.simonzeyer.de/schuelerlabor-cleverlab/smarti:${{ steps.meta.outputs.REPO_VERSION }}

View File

@ -1,38 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -1,14 +0,0 @@
---
name: Short Issue
about: Template for Short Issues
title: ''
labels: ''
assignees: ''
---
### Current behaviour
Describe the current behaviour
### Expected behaviour
Describe how it is supposed to work

2
.gitignore vendored
View File

@ -22,4 +22,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
package-lock.json

View File

@ -1,12 +0,0 @@
# specify the node base image with your desired version node:<version>
FROM node:16 as build
WORKDIR /app
copy ./ /app
RUN npm install --verbose
RUN npm run build --verbose
FROM nginx:alpine
COPY --from=build /app/build/ /usr/share/nginx/html
RUN chmod 755 /usr/share/nginx/html/ -R
EXPOSE 80
ENTRYPOINT ["sh", "-c", "cd /usr/share/nginx/html/ && nginx -g 'daemon off;'"]

View File

@ -1,11 +0,0 @@
# docker-compose.yml
services:
smarti:
mem_limit: 2048m
mem_reservation: 128M
cpus: 2
build:
dockerfile: Dockerfile
ports:
- "80"

44160
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,45 @@
{
"name": "blockly-react",
"version": "1.0.0",
"version": "0.1.0",
"private": true,
"dependencies": {
"@blockly/block-plus-minus": "^4.0.4",
"@blockly/field-grid-dropdown": "^2.0.4",
"@blockly/field-slider": "4.0.4",
"@blockly/plugin-scroll-options": "^3.0.5",
"@blockly/plugin-typed-variable-modal": "^5.0.6",
"@blockly/workspace-backpack": "^3.0.4",
"@blockly/zoom-to-fit": "^3.0.4",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@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",
"@mui/styles": "^5.10.16",
"@blockly/block-plus-minus": "^2.0.10",
"@blockly/field-grid-dropdown": "^1.0.25",
"@blockly/field-slider": "^2.1.1",
"@blockly/plugin-scroll-options": "^1.0.2",
"@blockly/plugin-typed-variable-modal": "^3.1.26",
"@blockly/zoom-to-fit": "^2.0.7",
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@fortawesome/react-fontawesome": "^0.1.11",
"@material-ui/core": "^4.11.0",
"@sentry/react": "^6.0.0",
"@sentry/tracing": "^6.0.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.22.0",
"blockly": "^9.2.0",
"file-saver": "^2.0.5",
"markdown-it": "^12.3.2",
"blockly": "^6.20210701.0",
"file-saver": "^2.0.2",
"mnemonic-id": "^3.2.7",
"moment": "^2.29.4",
"moment": "^2.28.0",
"prismjs": "^1.27.0",
"qrcode.react": "^3.1.0",
"react": "^17.0.2",
"react-cookie-consent": "^7.2.1",
"react-cookie-consent": "^7.0.0",
"react-dom": "^17.0.2",
"react-markdown": "^8.0.0",
"react-markdown-editor-lite": "^1.3.3",
"react-markdown": "^5.0.2",
"react-mde": "^11.5.0",
"react-rating-stars-component": "^2.2.0",
"react-redux": "^7.2.9",
"react-router-dom": "^5.3.3",
"react-scripts": "^5.0.1",
"react-share": "^4.4.0",
"react-spinners": "^0.13.3",
"reactour": "^1.18.7",
"redux": "^4.2.0",
"redux-thunk": "^2.4.1",
"rehype-raw": "^6.1.1",
"remark-gemoji": "^7.0.1",
"remark-gfm": "^3.0.1",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"reactour": "^1.18.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"styled-components": "^4.4.1",
"uuid": "^8.3.1",
"watchpack": "^2.3.1"
},
"resolutions": {
"//": "See https://github.com/facebook/create-react-app/issues/11773",
"react-error-overlay": "6.0.9"
"uuid": "^8.3.1"
},
"scripts": {
"start": "node_modules/react-scripts/bin/react-scripts.js start",
"start": "react-scripts start",
"dev": "set \"REACT_APP_BLOCKLY_API=http://localhost:8080\" && npm start",
"build": "react-scripts build",
"test": "react-scripts test",
@ -66,12 +48,16 @@
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "7.21.11"
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

View File

@ -1,17 +1,16 @@
.wrapper {
min-height: calc(
100vh - 60px
); /* will cover the 100% of viewport - height of footer (padding-bottom) */
min-height: calc(100vh - 60px); /* will cover the 100% of viewport - height of footer (padding-bottom) */
overflow: hidden;
display: block;
position: relative;
padding-bottom: 60px; /* height of your footer + 30px*/
}
.tutorial img{
display: flex;
align-items: center;
max-height: 40vh;
max-height: 40vH;
max-width: 100%;
margin: auto;
}
@ -19,7 +18,7 @@
.news img{
display: flex;
align-items: center;
max-height: 40vh;
max-height: 40vH;
max-width: 100%;
margin: auto;
}
@ -32,7 +31,7 @@
quotes: "\201C""\201D""\2018""\2019";
}
blockquote:before {
color: #4eaf47;
color:#4EAF47;
content: open-quote;
font-size: 4em;
line-height: 0.1em;
@ -43,32 +42,10 @@ blockquote p {
display: inline;
}
.tutorial table,
th,
td {
border: 1px solid #ddd;
}
.tutorial th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
border-color: #4eaf47;
color: white;
}
.overlay {
display: flex;
flex-direction: column;
align-items: center;
}
:root {
--url: url('./data/mcu_opacity.png');
}
.blocklySvg {
background-image: var(--url);
background-position: center;
background-repeat: no-repeat;
}

View File

@ -1,34 +1,35 @@
import React, { Component } from "react";
import React, { Component } from 'react';
import { Router } from "react-router-dom";
import { BrowserRouter as Router } from 'react-router-dom';
import { createBrowserHistory } from "history";
import { Provider } from "react-redux";
import store from "./store";
import { loadUser } from "./actions/authActions";
import { Provider } from 'react-redux';
import store from './store';
import { loadUser } from './actions/authActions';
import "./App.css";
import './App.css';
import { ThemeProvider, StyledEngineProvider, createTheme } from "@mui/material/styles";
import { ThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import Content from "./components/Content";
import Content from './components/Content';
const theme = createTheme({
const theme = createMuiTheme({
palette: {
primary: {
main: "#4EAF47",
contrastText: "#ffffff",
main: '#4EAF47',
contrastText: '#ffffff'
},
secondary: {
main: "#DDDDDD",
main: '#DDDDDD'
},
button: {
compile: "#e27136",
},
},
compile: '#e27136'
}
}
});
class App extends Component {
componentDidMount() {
store.dispatch(loadUser());
}
@ -36,7 +37,6 @@ class App extends Component {
render() {
const customHistory = createBrowserHistory();
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<Provider store={store}>
<Router history={customHistory}>
@ -44,7 +44,6 @@ class App extends Component {
</Router>
</Provider>
</ThemeProvider>
</StyledEngineProvider>
);
}
}

View File

@ -63,6 +63,9 @@ export const loadUser = () => (dispatch) => {
});
};
var logoutTimerId;
const timeToLogout = 14.9 * 60 * 1000; // nearly 15 minutes corresponding to the API
// Login user
export const login =
({ email, password }) =>
@ -81,6 +84,10 @@ export const login =
axios
.post(`${process.env.REACT_APP_BLOCKLY_API}/user`, body, config)
.then((res) => {
// Logout automatically if refreshToken "expired"
const logoutTimer = () =>
setTimeout(() => dispatch(logout()), timeToLogout);
logoutTimerId = logoutTimer();
dispatch(setLanguage(res.data.user.language));
dispatch({
type: LOGIN_SUCCESS,
@ -137,6 +144,7 @@ export const logout = () => (dispatch) => {
}
dispatch(setLanguage(locale));
dispatch(returnSuccess(res.data.message, res.status, "LOGOUT_SUCCESS"));
clearTimeout(logoutTimerId);
},
error: (err) => {
dispatch(
@ -157,6 +165,7 @@ export const logout = () => (dispatch) => {
type: GET_STATUS,
payload: status,
});
clearTimeout(logoutTimerId);
},
};
axios
@ -213,6 +222,10 @@ export const authInterceptor = () => (dispatch, getState) => {
})
.then((res) => {
if (res.status === 200) {
clearTimeout(logoutTimerId);
const logoutTimer = () =>
setTimeout(() => dispatch(logout()), timeToLogout);
logoutTimerId = logoutTimer();
dispatch({
type: REFRESH_TOKEN_SUCCESS,
payload: res.data,

View File

@ -1,15 +0,0 @@
import {
BOARD,
} from "./types";
import mini_opacity from "../data/mini_opacity.png"
import mcu_opacity from "../data/mcu_opacity.png"
export const setBoard = (board) => (dispatch) => {
window.sessionStorage.setItem("board", board);
const root = document.querySelector(':root');
root.style.setProperty('--url', `url(${board === "mcu" ? mcu_opacity : mini_opacity})`);
dispatch({
type: BOARD,
payload: board,
});
};

View File

@ -1,18 +0,0 @@
import axios from 'axios'
const fetchSensorWikiSuccess = sensors => ({
type: 'FETCH_SENSORWIKI_SUCCESS',
payload: { sensors }
})
export const fetchSensors = () => {
return async dispatch => {
try {
let sensors = await axios.get('https://api.sensors.wiki/sensors/all')
dispatch(fetchSensorWikiSuccess(sensors.data))
}
catch(e){
console.log(e)
}
}
}

View File

@ -84,77 +84,6 @@ export const getTutorials = () => (dispatch, getState) => {
});
};
export const getAllTutorials = () => (dispatch, getState) => {
axios
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/getAllTutorials`)
.then((res) => {
var tutorials = res.data.tutorials;
existingTutorials(tutorials, getState().tutorial.status).then(
(status) => {
dispatch({
type: TUTORIAL_SUCCESS,
payload: status,
});
dispatch(updateStatus(status));
dispatch({
type: GET_TUTORIALS,
payload: tutorials,
});
dispatch({ type: TUTORIAL_PROGRESS });
dispatch(returnSuccess(res.data.message, res.status));
}
);
})
.catch((err) => {
if (err.response) {
dispatch(
returnErrors(
err.response.data.message,
err.response.status,
"GET_TUTORIALS_FAIL"
)
);
}
dispatch({ type: TUTORIAL_PROGRESS });
});
};
export const getUserTutorials = () => (dispatch, getState) => {
axios
.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/getUserTutorials`)
.then((res) => {
var tutorials = res.data.tutorials;
existingTutorials(tutorials, getState().tutorial.status).then(
(status) => {
dispatch({
type: TUTORIAL_SUCCESS,
payload: status,
});
dispatch(updateStatus(status));
dispatch({
type: GET_TUTORIALS,
payload: tutorials,
});
dispatch({ type: TUTORIAL_PROGRESS });
dispatch(returnSuccess(res.data.message, res.status));
}
);
})
.catch((err) => {
console.log(err);
if (err.response) {
dispatch(
returnErrors(
err.response.data.message,
err.response.status,
"GET_TUTORIALS_FAIL"
)
);
}
dispatch({ type: TUTORIAL_PROGRESS });
});
};
export const updateStatus = (status) => (dispatch, getState) => {
if (getState().auth.isAuthenticated) {
// update user account in database - sync with redux store

View File

@ -4,9 +4,6 @@ import {
BUILDER_CHANGE,
BUILDER_ERROR,
BUILDER_TITLE,
BUILDER_PUBLIC,
BUILDER_DIFFICULTY,
BUILDER_REVIEW,
BUILDER_ID,
BUILDER_ADD_STEP,
BUILDER_DELETE_STEP,
@ -38,30 +35,6 @@ export const tutorialTitle = (title) => (dispatch) => {
dispatch(changeTutorialBuilder());
};
export const tutorialPublic = (pub) => (dispatch) => {
dispatch({
type: BUILDER_PUBLIC,
payload: pub,
});
dispatch(changeTutorialBuilder());
};
export const tutorialDifficulty = (difficulty) => (dispatch) => {
dispatch({
type: BUILDER_DIFFICULTY,
payload: difficulty,
});
dispatch(changeTutorialBuilder());
};
export const tutorialReview = (review) => (dispatch) => {
dispatch({
type: BUILDER_REVIEW,
payload: review,
});
dispatch(changeTutorialBuilder());
};
export const tutorialSteps = (steps) => (dispatch) => {
dispatch({
type: BUILDER_ADD_STEP,
@ -347,7 +320,6 @@ export const readJSON = (json) => (dispatch, getState) => {
return object;
});
dispatch(tutorialTitle(json.title));
dispatch(tutorialDifficulty(json.difficulty));
dispatch(tutorialSteps(steps));
dispatch(setSubmitError());
dispatch(progress(false));

View File

@ -21,7 +21,6 @@ export const NAME = "NAME";
export const TUTORIAL_PROGRESS = "TUTORIAL_PROGRESS";
export const GET_TUTORIAL = "GET_TUTORIAL";
export const GET_TUTORIALS = "GET_TUTORIALS";
export const GET_USERTUTORIALS = "GET_USERTUTORIALS";
export const GET_STATUS = "GET_STATUS";
export const TUTORIAL_SUCCESS = "TUTORIAL_SUCCESS";
export const TUTORIAL_ERROR = "TUTORIAL_ERROR";
@ -33,9 +32,6 @@ export const JSON_STRING = "JSON_STRING";
export const BUILDER_CHANGE = "BUILDER_CHANGE";
export const BUILDER_TITLE = "BUILDER_TITLE";
export const BUILDER_DIFFICULTY = "BUILDER_DIFFICULTY";
export const BUILDER_PUBLIC = "BUILDER_PUBLIC";
export const BUILDER_REVIEW = "BUILDER_REVIEW";
export const BUILDER_ID = "BUILDER_ID";
export const BUILDER_ADD_STEP = "BUILDER_ADD_STEP";
export const BUILDER_DELETE_STEP = "BUILDER_DELETE_STEP";
@ -63,6 +59,3 @@ export const GET_PROJECT = "GET_PROJECT";
export const GET_PROJECTS = "GET_PROJECTS";
export const PROJECT_TYPE = "PROJECT_TYPE";
export const PROJECT_DESCRIPTION = "PROJECT_DESCRIPTION";
//board
export const BOARD = "BOARD";

View File

@ -16,19 +16,13 @@ export const onChangeCode = () => (dispatch, getState) => {
code.arduino = Blockly.Arduino.workspaceToCode(workspace);
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
code.xml = Blockly.Xml.domToPrettyText(xmlDom);
var selectedBlock = Blockly.getSelected();
var selectedBlock = Blockly.selected
if (selectedBlock !== null) {
code.helpurl = selectedBlock.helpUrl
code.tooltip = selectedBlock.tooltip
if (selectedBlock.data) {
code.data = selectedBlock.data
} else {
code.data = null
}
} else if (selectedBlock === null) {
code.tooltip = Blockly.Msg.tooltip_hint
code.helpurl = ''
code.data = null
}

View File

@ -1,29 +1,34 @@
import React, { Component } from "react";
import React, { Component } from 'react';
import withStyles from '@mui/styles/withStyles';
import { alpha } from "@mui/material/styles";
import { withStyles } from '@material-ui/core/styles';
import { fade } from '@material-ui/core/styles/colorManipulator';
import Typography from "@mui/material/Typography";
import Typography from '@material-ui/core/Typography';
const styles = (theme) => ({
alert: {
marginBottom: "20px",
marginBottom: '20px',
border: `1px solid ${theme.palette.primary.main}`,
padding: "10px 20px",
borderRadius: "4px",
background: alpha(theme.palette.primary.main, 0.3),
color: "rgb(70,70,70)",
},
padding: '10px 20px',
borderRadius: '4px',
background: fade(theme.palette.primary.main, 0.3),
color: 'rgb(70,70,70)'
}
});
export class Alert extends Component {
render(){
return(
<div className={this.props.classes.alert}>
<Typography>{this.props.children}</Typography>
<Typography>
{this.props.children}
</Typography>
</div>
);
}
}
export default withStyles(styles, { withTheme: true })(Alert);

View File

@ -27,7 +27,7 @@ import Blockly from "blockly/core";
import "blockly/blocks";
import Toolbox from "./toolbox/Toolbox";
import { Card } from "@mui/material";
import { Card } from "@material-ui/core";
import {
ScrollOptions,
ScrollBlockDragger,

View File

@ -12,7 +12,6 @@ import "./generator/index";
import { ZoomToFitControl } from "@blockly/zoom-to-fit";
import { initialXml } from "./initialXml.js";
import { getMaxInstances } from "./helpers/maxInstances";
import { Backpack } from "@blockly/workspace-backpack";
class BlocklyWindow extends Component {
constructor(props) {
@ -36,24 +35,12 @@ class BlocklyWindow extends Component {
Blockly.svgResize(workspace);
const zoomToFit = new ZoomToFitControl(workspace);
zoomToFit.init();
// Initialize plugin.
const backpack = new Backpack(workspace);
backpack.init();
}
componentDidUpdate(props) {
const workspace = Blockly.getMainWorkspace();
var xml = this.props.initialXml;
if (props.selectedBoard !== this.props.selectedBoard) {
xml = localStorage.getItem("autoSaveXML");
// 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_);
}
var xml = this.props.initialXml;
// if svg is true, then the update process is done in the BlocklySvg component
if (props.initialXml !== xml && !this.props.svg) {
// guarantees that the current xml-code (this.props.initialXml) is rendered
@ -63,9 +50,8 @@ class BlocklyWindow extends Component {
}
if (props.language !== this.props.language) {
// change language
xml = localStorage.getItem("autoSaveXML");
if (!xml) xml = initialXml;
xmlDom = Blockly.Xml.textToDom(xml);
var xmlDom = Blockly.Xml.textToDom(xml);
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
// var toolbox = workspace.getToolbox();
// workspace.updateToolbox(toolbox.toolboxDef_);
@ -138,16 +124,14 @@ BlocklyWindow.propTypes = {
onChangeWorkspace: PropTypes.func.isRequired,
clearStats: PropTypes.func.isRequired,
renderer: PropTypes.string.isRequired,
sounds: PropTypes.bool.isRequired,
sounds: PropTypes.string.isRequired,
language: PropTypes.string.isRequired,
selectedBoard: PropTypes.string.isRequired,
};
const mapStateToProps = (state) => ({
renderer: state.general.renderer,
sounds: state.general.sounds,
language: state.general.language,
selectedBoard: state.board.board,
});
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(

View File

@ -1,88 +0,0 @@
import Blockly from "blockly";
import { getColour } from "../helpers/colour";
import * as Types from "../helpers/types";
import { selectedBoard } from "../helpers/board";
import { FieldGridDropdown } from "@blockly/field-grid-dropdown";
/**
* DS18B20 Temperatursonde
*
*/
Blockly.Blocks["CleVerLab_dummy1"] = {
init: function () {
this.setColour(getColour().cleverlab);
this.appendDummyInput()
.appendField("tut nichts")
this.setOutput(true, Types.NUMBER.typeName);
this.data = {name: "empty"};
},
};
Blockly.Blocks["CleVerLab_temperature"] = {
init: function () {
this.setColour(getColour().cleverlab);
this.appendDummyInput()
.appendField("Temperatur")
.appendField("Digital Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "DigitalPin");
this.setOutput(true, Types.NUMBER.typeName);
this.data = {name: "ds18b20"};
},
};
/**
* PH Wert
*
*/
Blockly.Blocks["CleVerLab_pH"] = {
init: function () {
this.setColour(getColour().cleverlab);
this.appendDummyInput()
.appendField("pH Wert")
.appendField("Digital Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "DigitalPin");
this.setOutput(true, Types.NUMBER.typeName);
this.data = {name: "phoderso"};
},
};
Blockly.Blocks["CleVerLab_cali1"] = {
init: function () {
this.appendDummyInput()
.appendField("Kalibriere pH Sensor");
this.appendValueInput("VAR1", "Number")
.appendField("Referenzlösung pH 4.00 =")
.setAlign(Blockly.ALIGN_RIGHT);
this.appendValueInput("VAR2", "Number2")
.appendField("Referenzlösung pH 7.00 =")
.setAlign(Blockly.ALIGN_RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().cleverlab);
this.setOutput(true, Types.NUMBER.typeName);
this.data = {name: "dsasda"};
},
};
/**
* Pump
*
*/
Blockly.Blocks['CleVerLab_pump'] = {
init: function() {
this.setColour(getColour().cleverlab);
var dropdown = new Blockly.FieldDropdown([
[ 'START','HIGH'],
[ 'STOPP','LOW']
]);
this.appendDummyInput()
.appendField(dropdown, "Mode")
.appendField(" Pumpe ")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "DigitalPin");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
//this.setOutput(true, "Number");
this.setTooltip('');
this.setHelpUrl('');
}
};

View File

@ -6,11 +6,9 @@ import "./sensebox-telegram";
import "./sensebox-osem";
import "./sensebox-web";
import "./sensebox-display";
import "./sensebox-motors";
import "./sensebox-lora";
import "./sensebox-led";
import "./sensebox-rtc";
import "./sensebox-ntp";
import "./sensebox-ble";
import "./sensebox-sd";
import "./mqtt";
@ -26,6 +24,5 @@ import "./variables";
import "./lists";
import "./watchdog";
import "./webserver";
import "./CleVerLab"
import "../helpers/types";

View File

@ -45,11 +45,15 @@ Blockly.Blocks['sensebox_rgb_led'] = {
Blockly.Blocks['sensebox_ws2818_led_init'] = {
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.appendDummyInput()
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led_init)
.appendField("Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
this.appendValueInput("BRIGHTNESS", "brightness")
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_brightness));
this.appendValueInput("NUMBER", "number")
@ -62,11 +66,15 @@ Blockly.Blocks['sensebox_ws2818_led_init'] = {
Blockly.Blocks['sensebox_ws2818_led'] = {
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.appendDummyInput()
.appendField(Blockly.Msg.senseBox_ws2818_rgb_led)
.appendField("Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPinsRGB), "Port")
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port")
this.appendValueInput("POSITION", "position")
.appendField((Blockly.Msg.senseBox_ws2818_rgb_led_position));
this.appendValueInput("COLOR", 'Number')

View File

@ -1,144 +0,0 @@
import * as Blockly from "blockly/core";
import { getColour } from "../helpers/colour";
import { selectedBoard } from "../helpers/board";
import { FieldSlider } from "@blockly/field-slider";
/**
* Servo Motor
*
*/
Blockly.Blocks["sensebox_motors_beginServoMotor"] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_beginServoMotor);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_beginServoMotor_pin)
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "pin")
.setAlign(Blockly.ALIGN_RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_beginServoMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_beginServoMotor_helpurl);
},
};
Blockly.Blocks["sensebox_motors_moveServoMotor"] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor_pin)
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "pin")
.setAlign(Blockly.ALIGN_RIGHT);
this.appendValueInput("degrees", "Number")
.appendField(Blockly.Msg.sensebox_motors_moveServoMotor_degrees)
.setAlign(Blockly.ALIGN_RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_moveServoMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_moveServoMotor_helpurl);
},
};
/**
* I2C Motor Board
*
*/
Blockly.Blocks["sensebox_motors_I2CMotorBoard_begin"] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_begin_helpurl);
},
};
Blockly.Blocks["sensebox_motors_I2CMotorBoard_moveDCMotor"] = {
init: function () {
var dropdownOptions = [[Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_left, '1'],
[Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_right, '2']];
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor)
.appendField(new Blockly.FieldDropdown(dropdownOptions), "motor")
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_motor);
this.appendValueInput("speed", "Number")
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_speed)
.setAlign(Blockly.ALIGN_RIGHT);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_moveDCMotor_helpurl);
},
};
Blockly.Blocks["sensebox_motors_I2CMotorBoard_stopDCMotor"] = {
init: function () {
var dropdownOptions = [[Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_left, '1'],
[Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_right, '2']];
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor)
.appendField(new Blockly.FieldDropdown(dropdownOptions), "motor")
.appendField(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_motor)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_I2CMotorBoard_stopDCMotor_helpurl);
},
};
/**
* Stepper Motor
*
*/
Blockly.Blocks["sensebox_motors_beginStepperMotor"] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor_pins);
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in1")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in2")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in3")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPins), "in4");
this.setFieldValue("1", "in1");
this.setFieldValue("2", "in2");
this.setFieldValue("3", "in3");
this.setFieldValue("4", "in4");
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_beginStepperMotor_rpm)
.appendField(new FieldSlider(3, 1, 3), "rpm");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_beginStepperMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_beginStepperMotor_helpurl);
},
};
Blockly.Blocks["sensebox_motors_moveStepperMotor"] = {
init: function () {
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_motors_moveStepperMotor);
this.appendValueInput("steps", "Number")
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.sensebox_motors_moveStepperMotor_step);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(getColour().motors);
this.setTooltip(Blockly.Msg.sensebox_motors_moveStepperMotor_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_motors_moveStepperMotor_helpurl);
},
};

View File

@ -1,42 +0,0 @@
import * as Blockly from "blockly";
import { getColour } from "../helpers/colour";
import * as Types from "../helpers/types";
Blockly.Blocks["sensebox_ntp_init"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_ntp_helpurl);
this.setColour(getColour().time);
this.appendDummyInput().appendField(Blockly.Msg.sensebox_ntp_init);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.sensebox_ntp_tooltip);
},
};
Blockly.Blocks["sensebox_ntp_get"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_ntp_get_helpurl);
this.setColour(getColour().time);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_ntp_get)
.appendField(
new Blockly.FieldDropdown([
[Blockly.Msg.sensebox_ntp_epochTime, "getEpochTime"],
[Blockly.Msg.sensebox_ntp_formattedTimeStamp, "getFormattedTime"],
]),
"dropdown"
);
this.setOutput(true, Types.LARGE_NUMBER.typeName);
this.setTooltip(Blockly.Msg.sensebox_rtc_get_tooltip);
},
};
Blockly.Blocks["sensebox_ntp_get_timestamp"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
this.setColour(getColour().time);
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_get_timestamp);
this.setOutput(true);
this.setTooltip(Blockly.Msg.sensebox_rtc_get_timestamp_tooltip);
},
};

View File

@ -76,67 +76,3 @@ Blockly.Blocks["sensebox_rtc_get_timestamp"] = {
this.setTooltip(Blockly.Msg.sensebox_rtc_get_timestamp_tooltip);
},
};
/**
* Internal RTC
*
*/
Blockly.Blocks["sensebox_internal_rtc_init"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_internal_rtc_helpurl);
this.setColour(getColour().time);
this.appendDummyInput().appendField(Blockly.Msg.sensebox_internal_rtc_init);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_init_tooltip);
},
};
Blockly.Blocks["sensebox_internal_rtc_set"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
this.setColour(getColour().time);
this.appendValueInput("time").appendField(
Blockly.Msg.sensebox_internal_rtc_set
);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_set_tooltip);
},
};
Blockly.Blocks["sensebox_internal_rtc_get"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
this.setColour(getColour().time);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_internal_rtc_get)
.appendField(
new Blockly.FieldDropdown([
[Blockly.Msg.sensebox_internal_rtc_epoch, "Epoch"],
[Blockly.Msg.sensebox_internal_rtc_year, "Year"],
[Blockly.Msg.sensebox_internal_rtc_month, "Month"],
[Blockly.Msg.sensebox_internal_rtc_day, "Day"],
[Blockly.Msg.sensebox_internal_rtc_hour, "Hours"],
[Blockly.Msg.sensebox_internal_rtc_minutes, "Minutes"],
[Blockly.Msg.sensebox_internal_rtc_seconds, "Seconds"],
]),
"dropdown"
);
this.setOutput(true, Types.LARGE_NUMBER.typeName);
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_get_tooltip);
},
};
Blockly.Blocks["sensebox_internal_rtc_get_timestamp"] = {
init: function () {
this.setHelpUrl(Blockly.Msg.sensebox_internal_rtc_helpurl);
this.setColour(getColour().time);
this.appendDummyInput().appendField(
Blockly.Msg.sensebox_internal_rtc_get_timestamp
);
this.setOutput(true);
this.setTooltip(Blockly.Msg.sensebox_internal_rtc_get_timestamp_tooltip);
},
};

View File

@ -26,7 +26,6 @@ Blockly.Blocks["sensebox_sensor_temp_hum"] = {
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_temp_hum_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_temp_hum_helpurl);
this.data = {name: "hdc1080", connection: "I2C"};
},
};
@ -52,7 +51,6 @@ Blockly.Blocks["sensebox_sensor_uv_light"] = {
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_uv_light_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_uv_light_helpurl);
this.data = {name: "veml6070"};
},
};
@ -93,7 +91,6 @@ Blockly.Blocks["sensebox_sensor_bmx055_accelerometer"] = {
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_bmx055_accelerometer_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_bmx055_helpurl);
this.data = {name: "bmx055"};
},
};
@ -117,15 +114,16 @@ Blockly.Blocks["sensebox_sensor_sds011"] = {
)
.appendField(Blockly.Msg.senseBox_sds011_dimension)
.appendField(
new Blockly.FieldDropdown(
selectedBoard().serialSensors),
new Blockly.FieldDropdown([
[Blockly.Msg.senseBox_sds011_serial1, "Serial1"],
[Blockly.Msg.senseBox_sds011_serial2, "Serial2"],
]),
"SERIAL"
);
this.setOutput(true, Types.DECIMAL.typeName);
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_sds011_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_sds011_helpurl);
this.data = {name: "sds011"};
},
};
@ -159,7 +157,6 @@ Blockly.Blocks["sensebox_sensor_pressure"] = {
this.setOutput(true, Types.DECIMAL.typeName);
this.setTooltip(Blockly.Msg.senseBox_pressure_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_pressure_helpurl);
this.data = {name: "bmp280"};
this.getField("NAME").setValidator(
function (val) {
this.updateShape_(val === "Altitude");
@ -191,7 +188,7 @@ Blockly.Blocks["sensebox_sensor_bme680_bsec"] = {
var dropdownOptions = [
[Blockly.Msg.senseBox_temp, "temperature"],
[Blockly.Msg.senseBox_hum, "humidity"],
[Blockly.Msg.senseBox_bme_pressure, "pressure"],
[Blockly.Msg.senseBox_pressure, "pressure"],
[Blockly.Msg.senseBox_bme_iaq, "IAQ"],
[Blockly.Msg.senseBox_bme_iaq_accuracy, "IAQAccuracy"],
[Blockly.Msg.senseBox_bme_co2, "CO2"],
@ -206,7 +203,6 @@ Blockly.Blocks["sensebox_sensor_bme680_bsec"] = {
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_bme_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_bme680_helpurl);
this.data = {name: "bme680"};
},
};
@ -218,7 +214,12 @@ Blockly.Blocks["sensebox_sensor_bme680_bsec"] = {
Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
init: function () {
var dropdown = new FieldGridDropdown(selectedBoard().digitalPorts, function (option) {
var dropdownOptions = [
[Blockly.Msg.senseBox_ultrasonic_port_A, "A"],
[Blockly.Msg.senseBox_ultrasonic_port_B, "B"],
[Blockly.Msg.senseBox_ultrasonic_port_C, "C"],
];
var dropdown = new FieldGridDropdown(dropdownOptions, function (option) {
var input = option === "A" || option === "B" || option === "C";
this.sourceBlock_.updateShape_(input);
});
@ -246,7 +247,6 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = {
this.setOutput(true, Types.NUMBER.typeName);
this.setTooltip(Blockly.Msg.senseBox_ultrasonic_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_ultrasonic_helpurl);
this.data = {name: "hc-sr04"};
},
/**
* Parse XML to restore the number of pins available.
@ -331,7 +331,6 @@ Blockly.Blocks["sensebox_button"] = {
[Blockly.Msg.senseBox_button_isPressed, "isPressed"],
[Blockly.Msg.senseBox_button_wasPressed, "wasPressed"],
[Blockly.Msg.senseBox_button_longPress, "longPress"],
[Blockly.Msg.senseBox_button_switch,"toggleButton"]
]),
"FUNCTION"
)
@ -385,7 +384,6 @@ Blockly.Blocks["sensebox_scd30"] = {
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_scd_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_scd_helpurl);
this.data = {name: "scd30"};
},
onchange: function (e) {
var dropdown = this.getFieldValue("dropdown");
@ -430,11 +428,16 @@ Blockly.Blocks["sensebox_gps"] = {
Blockly.Blocks["sensebox_sensor_truebner_smt50"] = {
init: function () {
var dropdownOptions = [
[Blockly.Msg.senseBox_ultrasonic_port_A, "A"],
[Blockly.Msg.senseBox_ultrasonic_port_B, "B"],
[Blockly.Msg.senseBox_ultrasonic_port_C, "C"],
];
this.setColour(getColour().sensebox);
this.appendDummyInput().appendField(Blockly.Msg.senseBox_smt50);
this.appendDummyInput()
.appendField("Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port");
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_value)
.appendField(
@ -447,7 +450,6 @@ Blockly.Blocks["sensebox_sensor_truebner_smt50"] = {
this.setOutput(true, Types.NUMBER.typeName);
this.setTooltip(Blockly.Msg.senseBox_smt50_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_smt50_helpurl);
this.data = {name: "smt50"};
},
};
@ -458,15 +460,18 @@ Blockly.Blocks["sensebox_sensor_truebner_smt50"] = {
Blockly.Blocks["sensebox_sensor_watertemperature"] = {
init: function () {
var dropdownOptions = [
[Blockly.Msg.senseBox_ultrasonic_port_A, "A"],
[Blockly.Msg.senseBox_ultrasonic_port_B, "B"],
[Blockly.Msg.senseBox_ultrasonic_port_C, "C"],
];
this.setColour(getColour().sensebox);
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_watertemperature)
.appendField("Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port");
this.setOutput(true, Types.NUMBER.typeName);
this.setTooltip(Blockly.Msg.senseBox_watertemperature_tip);
this.data = {name: "ds18b20"};
},
};
@ -493,17 +498,56 @@ Blockly.Blocks['sensebox_windspeed'] = {
Blockly.Blocks["sensebox_soundsensor_dfrobot"] = {
init: function () {
var dropdownOptions = [
[Blockly.Msg.senseBox_ultrasonic_port_A, "A"],
[Blockly.Msg.senseBox_ultrasonic_port_B, "B"],
[Blockly.Msg.senseBox_ultrasonic_port_C, "C"],
];
this.setColour(getColour().sensebox);
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_soundsensor_dfrobot)
.appendField("Port:")
.appendField(new Blockly.FieldDropdown(selectedBoard().digitalPorts), "Port");
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port");
this.setOutput(true, Types.DECIMAL.typeName);
this.setTooltip(Blockly.Msg.senseBox_soundsensor_dfrobot_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_soundsensor_dfrobot_helpurl);
},
};
/**
* rainsensor hydreon rg-15
*/
Blockly.Blocks["sensebox_rainsensor_hydreon_rg15"] = {
init: function () {
var dropdownOptionsPorts = [
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_serial1, "Serial1"],
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_serial2, "Serial2"],
];
var dropdownOptionsValues = [
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_acc, "getAccumulation"],
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_totalAcc, "getTotalAccumulation"],
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_eventAcc, "getEventAccumulation"],
[Blockly.Msg.sensebox_rainsensor_hydreon_rg15_rainInt, "getRainfallIntensity"],
];
this.setColour(getColour().sensebox);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15);
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_port)
.appendField(new Blockly.FieldDropdown(dropdownOptionsPorts), "SERIAL");
this.appendDummyInput()
.appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_value)
.appendField(new Blockly.FieldDropdown(dropdownOptionsValues), "VALUE");
this.setOutput(true, Types.DECIMAL.typeName);
this.setTooltip(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_tooltip);
this.setHelpUrl(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_helpurl);
},
};
/**
* Infineon DPS310 Pressure Sensor
*
@ -534,7 +578,6 @@ Blockly.Blocks["sensebox_sensor_dps310"] = {
this.setOutput(true, Types.DECIMAL.typeName);
this.setTooltip(Blockly.Msg.senseBox_sensor_dps310_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_sensor_dps310_helpurl);
this.data = {name: "dps310"};
this.getField("NAME").setValidator(
function (val) {
this.updateShape_(val === "Altitude");
@ -555,31 +598,3 @@ Blockly.Blocks["sensebox_sensor_dps310"] = {
}
},
};
/**
* Sensirion SPS30 Fine Particular Matter Sensor
* added 02.12.2022
*/
Blockly.Blocks["sensebox_sensor_sps30"] = {
init: function () {
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sps30);
this.appendDummyInput()
.setAlign(Blockly.ALIGN_LEFT)
.appendField(Blockly.Msg.senseBox_value)
.appendField(
new Blockly.FieldDropdown([
[Blockly.Msg.senseBox_sps30_1p0, "1p0"],
[Blockly.Msg.senseBox_sps30_2p5, "2p5"],
[Blockly.Msg.senseBox_sps30_4p0, "4p0"],
[Blockly.Msg.senseBox_sps30_10p0, "10p0"],
]),
"value"
)
.appendField(Blockly.Msg.senseBox_sps30_dimension);
this.setOutput(true, Types.DECIMAL.typeName);
this.setColour(getColour().sensebox);
this.setTooltip(Blockly.Msg.senseBox_sps30_tooltip);
this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl);
},
};

View File

@ -9,10 +9,10 @@ Blockly.Blocks["variables_set_dynamic"] = {
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.appendValueInput("VALUE")
.appendField(Blockly.Msg.variables_set, Blockly.Msg.variables_set)
.appendField("set", "set")
.appendField("", "type")
.appendField(new Blockly.FieldVariable("VAR"), "VAR")
.appendField(Blockly.Msg.variables_to);
.appendField("to");
},
onchange: function (e) {
let variableID = this.getFieldValue("VAR");

View File

@ -1,61 +0,0 @@
import Blockly from "blockly";
/**
* starte/stoppe Pumpe
*
*/
Blockly.Arduino.CleVerLab_pump = function (block) {
var pin = block.getFieldValue('DigitalPin');
var state = block.getFieldValue("Mode");
Blockly['Arduino'].setupCode_['pinMode'] = 'pinMode(' + pin + ', OUTPUT);';
var code = 'digitalWrite(' + pin + ', ' + state + ');\n';
return code;
};
/**
* PH wert
*
*/
Blockly.Arduino.CleVerLab_temperature = function () {
var dropdown_pin = this.getFieldValue("DigitalPort");
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_["library_oneWire"] =
"#include <OneWire.h> // http://librarymanager/All#OneWire";
Blockly.Arduino.libraries_["library_oneDallasTemperature"] =
"#include <DallasTemperature.h> // http://librarymanager/All#DallasTemperature";
Blockly.Arduino.definitions_["define_OneWire"] =
"#define ONE_WIRE_BUS " +
dropdown_pin +
"\nOneWire oneWire(ONE_WIRE_BUS);\nDallasTemperature sensors(&oneWire);";
Blockly.Arduino.setupCode_["sensebox_oneWireSetup"] = "sensors.begin();";
Blockly.Arduino.codeFunctions_["sensebox_requestTemp"] =
"float getWaterTemp(){\nsensors.requestTemperatures();\nsensors.getTempCByIndex(0);\n}";
var code = "getWaterTemp()";
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
Blockly.Arduino.CleVerLab_pH = function () {
var dropdown_pin = this.getFieldValue("DigitalPin");
Blockly.Arduino.definitions_["define_pHgetter"] =
"#define SensorPin " + dropdown_pin +"\n#define samplingInterval 20\n#define printInterval 800\n#define ArrayLenth 40 //times of collection\nint pHArray[ArrayLenth]; //Store the average value of the sensor feedback\nint pHArrayIndex=0;\nfloat slope = 1.00;\nfloat b =0.00;";
Blockly.Arduino.codeFunctions_["sensebox_requestpH"] =
"float getpH(){\nstatic unsigned long samplingTime = millis();\nstatic unsigned long printTime = millis();\nstatic float pHValue,voltage;\n//nif(millis()-samplingTime > samplingInterval){\n//pHArray[pHArrayIndex++]=analogRead(SensorPin);\nfor (int i = 1; i <= 10; i += 1) {\nvoltage = voltage + analogRead(SensorPin);\n}\n voltage = (voltage / 10)*5.0/1024; \nsamplingTime=millis();\n\nreturn pHValue = 3.5*voltage*slope+b;\n}\n";
Blockly.Arduino.codeFunctions_["avergearraypH"] =
"double avergearray(int* arr, int number) {\n int i;\n int max, min;\n double avg;\n long amount = 0;\n if (number <= 0) {\n return 0;\n }\n if (number < 5) {\n for (i = 0; i < number; i++) {\n amount += arr[i];\n }\n avg = amount / number;\n return avg;\n }\n else {\n if (arr[0] < arr[1]) {\n min = arr[0];\n max = arr[1];\n }\n else {\n min = arr[1];\n max = arr[0];\n }\n for (i = 2; i < number; i++) {\n if (arr[i] < min) {\n amount += min;\n min = arr[i];\n }\n else {\n if (arr[i] > max) {\n amount += max;\n max = arr[i];\n }\n else {\n amount += arr[i];\n }\n }\n }\n avg = (double)amount / (number - 2);\n }\n return avg;\n}";
var code = "getpH()";
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
Blockly.Arduino.CleVerLab_cali1 = function () {
var var1 = Blockly.Arduino.valueToCode(this, 'VAR1', Blockly.Arduino.ORDER_ATOMIC) || "4.00";
var var2 = Blockly.Arduino.valueToCode(this, 'VAR2', Blockly.Arduino.ORDER_ATOMIC) || "7.00";
//var var1 = this.getFieldValue("VAR1");
//var var2 = this.getFieldValue("VAR2");
Blockly.Arduino.definitions_["define_pHKali"] = "#define pH4 4.00\n#define pH7 7.00\nfloat pH4is = "+ var1+";\nfloat pH7is = "+ var2 +";";
Blockly.Arduino.setupCode_["asdsadsa"] ="slope = (2.00-(4.00/3.50))/(pH7is/3.50 - pH4is/3.50);\n b = 7 - (pH7is * slope);";
var code = "0";
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

View File

@ -148,7 +148,53 @@ Blockly["Arduino"].init = function (workspace) {
// Blockly.Names.DEVELOPER_VARIABLE_TYPE));
// }
const doubleVariables = workspace.getVariablesOfType("Number");
let i = 0;
let variableCode = "";
for (i = 0; i < doubleVariables.length; i += 1) {
variableCode +=
"double " +
Blockly["Arduino"].nameDB_.getName(
doubleVariables[i].getId(),
Blockly.Variables.NAME_TYPE
) +
" = 0; \n\n";
}
const stringVariables = workspace.getVariablesOfType("String");
for (i = 0; i < stringVariables.length; i += 1) {
variableCode +=
"String " +
Blockly["Arduino"].nameDB_.getName(
stringVariables[i].getId(),
Blockly.Variables.NAME_TYPE
) +
' = ""; \n\n';
}
const booleanVariables = workspace.getVariablesOfType("Boolean");
for (i = 0; i < booleanVariables.length; i += 1) {
variableCode +=
"boolean " +
Blockly["Arduino"].nameDB_.getDistinctName(
booleanVariables[i].getId(),
Blockly.Variables.NAME_TYPE
) +
" = false; \n\n";
}
const colourVariables = workspace.getVariablesOfType("Colour");
for (i = 0; i < colourVariables.length; i += 1) {
variableCode +=
"RGB " +
Blockly["Arduino"].nameDB_.getName(
colourVariables[i].getId(),
Blockly.Variables.NAME_TYPE
) +
" = {0, 0, 0}; \n\n";
}
Blockly["Arduino"].variablesInitCode_ = variableCode;
};
/**

View File

@ -5,12 +5,10 @@ import "./sensebox-telegram";
import "./sensebox-osem";
import "./sensebox-web";
import "./sensebox-display";
import "./sensebox-motors";
import "./sensebox-lora";
import "./sensebox-led";
import "./sensebox";
import "./sensebox-rtc";
import "./sensebox-ntp";
import "./sensebox-ble";
import "./sensebox-sd";
import "./mqtt";
@ -27,4 +25,3 @@ import "./variables";
import "./lists";
import "./watchdog";
import "./webserver";
import "./CleVerLab"

View File

@ -275,15 +275,10 @@ Blockly.Arduino["math_change"] = function (block) {
"DELTA",
Blockly.Arduino.ORDER_ADDITIVE
) || "0";
var id = block.getFieldValue("VAR")
const varName = Blockly.Variables.getVariable(
Blockly.getMainWorkspace(),
id
).name;
// var varName = Blockly.Arduino.nameDB_.getName(
// block.getFieldValue("VAR"),
// Blockly.Variables.NAME_TYPE
// );
var varName = Blockly.Arduino.nameDB_.getName(
block.getFieldValue("VAR"),
Blockly.Variables.NAME_TYPE
);
return varName + " += " + argument0 + ";\n";
};

View File

@ -101,6 +101,7 @@ Blockly.Arduino.sensebox_phyphox_graph = function () {
Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
var branch = Blockly.Arduino.statementToCode(this, "sendValues");
var blocks = this.getDescendants();
console.log(blocks);
var count = 0;
if (blocks !== undefined) {
for (var i = 0; i < blocks.length; i++) {
@ -114,6 +115,7 @@ Blockly.Arduino.sensebox_phyphox_experiment_send = function () {
var string = "";
for (var j = 1; j <= count; j++) {
console.log("append");
if (string === "") {
string += `channel${j}`;
} else if (string !== "") {

View File

@ -1,77 +0,0 @@
import * as Blockly from "blockly/core";
/**
* Servo Motor
*
*/
Blockly.Arduino.sensebox_motors_beginServoMotor = function () {
var pin = this.getFieldValue("pin");
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_["include_servo_motor"] = "#include <Servo.h>";
Blockly.Arduino.definitions_[`define_servo_motor_${pin}`] = `Servo servo_motor_${pin}; // servo Motor`;
Blockly.Arduino.setupCode_[`setup_servo_motor_${pin}`] = `servo_motor_${pin}.attach(${pin}); // attach servo motor to pin ${pin}`;
var code = "";
return code;
};
Blockly.Arduino.sensebox_motors_moveServoMotor = function () {
var pin = this.getFieldValue("pin");
var degrees = Blockly.Arduino.valueToCode(this, 'degrees', Blockly.Arduino.ORDER_ATOMIC) || "90";
var code = `servo_motor_${pin}.write(${degrees}); // move servo motor to ${degrees} degrees\n`;
return code;
};
/**
* I2C Motor Board
*
*/
Blockly.Arduino.sensebox_motors_I2CMotorBoard_begin = function () {
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_["include_i2c_motor_board"] = "#include <Grove_I2C_Motor_Driver.h>";
Blockly.Arduino.definitions_["define_i2c_motor_board"] = `
#define I2C_MOTOR_BOARD_ADDRESS 0x0f // default I2C address of I2C Motor Board`;
Blockly.Arduino.setupCode_["setup_i2c_motor_board"] = `
Motor.begin(I2C_MOTOR_BOARD_ADDRESS); // Initialize I2C Motor Board`;
var code = "";
return code;
};
Blockly.Arduino.sensebox_motors_I2CMotorBoard_moveDCMotor = function () {
var motor = this.getFieldValue("motor");
var speed = Blockly.Arduino.valueToCode(this, 'speed', Blockly.Arduino.ORDER_ATOMIC) || "50";
var code = `Motor.speed(MOTOR${motor}, ${speed}); // set speed of motor\n`;
return code;
};
Blockly.Arduino.sensebox_motors_I2CMotorBoard_stopDCMotor = function () {
var motor = this.getFieldValue("motor");
var code = `Motor.stop(MOTOR${motor}); // stop motor\n`;
return code;
};
/**
* Stepper Motor
*/
Blockly.Arduino.sensebox_motors_beginStepperMotor = function () {
var in1 = this.getFieldValue("in1");
var in2 = this.getFieldValue("in2");
var in3 = this.getFieldValue("in3");
var in4 = this.getFieldValue("in4");
var rpm = this.getFieldValue("rpm");
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_["include_stepper_motor"] = "#include <Stepper.h>";
Blockly.Arduino.definitions_["define_stepper_motor"] = `
Stepper stepper_motor(2048, ${in1}, ${in2}, ${in3}, ${in4}); // stepper Motor with 2048 steps per rotation`;
Blockly.Arduino.setupCode_["setup_stepper_motor"] =
`stepper_motor.setSpeed(${rpm}); // speed in rotations per minute`;
var code = "";
return code;
};
Blockly.Arduino.sensebox_motors_moveStepperMotor = function () {
var steps = Blockly.Arduino.valueToCode(this, 'steps', Blockly.Arduino.ORDER_ATOMIC) || '2048';
var code = `stepper_motor.step(${steps}); // 2048 steps correspond to one rotation\n`;
return code;
};

View File

@ -1,19 +0,0 @@
import Blockly from "blockly";
Blockly.Arduino.sensebox_ntp_init = function () {
Blockly.Arduino.libraries_["WiFiUdp"] = `#include <WiFiUdp.h>`;
Blockly.Arduino.libraries_["NTPClient"] = `#include <NTPClient.h>`;
Blockly.Arduino.definitions_["WiFiUDP"] = `WiFiUDP ntpUDP;`;
Blockly.Arduino.definitions_["NTPClient"] = `NTPClient timeClient(ntpUDP);`;
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.setupCode_["timeclient.begin"] = `timeClient.begin();`;
Blockly.Arduino.setupCode_["timeclient.update"] = `timeClient.update();`;
var code = ``;
return code;
};
Blockly.Arduino.sensebox_ntp_get = function () {
var format = this.getFieldValue("dropdown");
var code = `timeClient.${format}()`;
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

View File

@ -94,46 +94,3 @@ uint8_t sec, min, hour, day, month;
var code = `getTimeStamp()`;
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
Blockly.Arduino.sensebox_internal_rtc_init = function () {
Blockly.Arduino.libraries_["RTClib"] = `#include <RTCZero.h>`;
Blockly.Arduino.definitions_["RTC"] = `RTCZero rtc;`;
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.setupCode_["rtc.begin"] = `rtc.begin();`;
return "";
};
Blockly.Arduino.sensebox_internal_rtc_set = function () {
var branch =
Blockly.Arduino.valueToCode(this, "time", Blockly.Arduino.ORDER_ATOMIC) ||
"0";
Blockly.Arduino.setupCode_["rtc.setEpoch"] = `rtc.setEpoch(${branch});`;
var code = ``;
return code;
};
Blockly.Arduino.sensebox_internal_rtc_get = function () {
var dropdown = this.getFieldValue("dropdown");
var code = `rtc.get${dropdown}()`;
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
Blockly.Arduino.sensebox_internal_rtc_get_timestamp = function () {
Blockly.Arduino.variables_["rtc_timestamp"] = `char timestamp[20];`;
Blockly.Arduino.codeFunctions_["getTimeStamp"] = `
char* getTimeStamp() {
uint8_t sec, min, hour, day, month;
uint16_t year;
sec = rtc.getSeconds();
min = rtc.getMinutes();
hour = rtc.getHours();
day = rtc.getDay();
month = rtc.getMonth();
year = rtc.getYear();
sprintf(timestamp, "%02d-%02d-%02dT%02d:%02d:%02dZ", year, month, day, hour, min, sec);
return timestamp;
}
`;
var code = `getTimeStamp()`;
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

View File

@ -203,5 +203,6 @@ Blockly.Arduino.sensebox_sd_save_for_osem = function (block) {
Blockly.Arduino.definitions_["SENSOR_ID" + id + ""] =
"const char SENSOR_ID" + id + '[] PROGMEM = "' + sensor_id + '";';
code += "addMeasurement(SENSOR_ID" + id + "," + sensor_value + ");\n";
console.log(code);
return code;
};

View File

@ -399,7 +399,6 @@ Blockly.Arduino.sensebox_button = function () {
Blockly.Arduino.libraries_[
"library_jcButtons"
] = `#include <JC_Button.h> // http://librarymanager/All#JC_Button`;
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
"Button button_" + dropdown_pin + "(" + dropdown_pin + ");";
Blockly.Arduino.setupCode_["setup_button" + dropdown_pin + ""] =
@ -414,10 +413,6 @@ Blockly.Arduino.sensebox_button = function () {
} else if (dropown_function === "longPress") {
var time = this.getFieldValue("time");
code = "button_" + dropdown_pin + ".pressedFor(" + time + ")";
} else if (dropown_function === "toggleButton") {
code = "button_" + dropdown_pin + ".toggleState()";
Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] =
"ToggleButton button_" + dropdown_pin + "(" + dropdown_pin + ");";
}
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
@ -439,8 +434,6 @@ if (airSensor.begin() == false)
while (1)
;
}`;
Blockly.Arduino.setupCode_["scd30_staleData"] =
"airSensor.useStaleData(true);";
var code = "";
switch (dropdown) {
case "temperature":
@ -661,6 +654,23 @@ float getSoundValue(){
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
/**
* rainsensor hydreon rg-15
*/
Blockly.Arduino.sensebox_rainsensor_hydreon_rg15 = function () {
var port = this.getFieldValue("SERIAL");
var value = this.getFieldValue("VALUE");
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_["library_rainsensor_rg15"] = "#include <hydreon.h>";
Blockly.Arduino.definitions_["def_rainsensor_rg15_" + port] = "HYDREON rainsensor_" + port + "(" + port + ");";
Blockly.Arduino.setupCode_["setup_rainsensor_rg15_" + port] = "rainsensor_" + port + ".begin();";
Blockly.Arduino.loopCodeOnce_["loop_rainsensor_rg15_" + port] = "rainsensor_" + port + ".readAllData();"
var code = "rainsensor_" + port + "." + value + "()";
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
/**
* Infineon DPS310 Pressure Sensor
*
@ -699,57 +709,3 @@ Blockly.Arduino.sensebox_sensor_dps310 = function () {
}
return [code, Blockly.Arduino.ORDER_ATOMIC];
};
/**
* Sensirion SPS30 Fine Particlar Matter
*
*/
Blockly.Arduino.sensebox_sensor_sps30 = function () {
var dropdown_name = this.getFieldValue("value");
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
Blockly.Arduino.libraries_[
"sps30"
] = `#include <sps30.h> // http://librarymanager/All#`;
Blockly.Arduino.variables_["sps30_measurement"] =
"struct sps30_measurement m;";
Blockly.Arduino.variables_["sps30_auto_clean_days"] =
"uint32_t auto_clean_days = 4;";
Blockly.Arduino.variables_["sps30_interval_intervalsps"] =
"const long intervalsps = 1000;";
Blockly.Arduino.variables_["sps30_time_startsps"] =
"unsigned long time_startsps = 0;";
Blockly.Arduino.variables_["sps30_time_actualsps"] =
"unsigned long time_actualsps = 0;";
Blockly.Arduino.codeFunctions_["sps30_getData"] = `
void getSPS30Data(){
uint16_t data_ready;
int16_t ret;
do {
ret = sps30_read_data_ready(&data_ready);
if (ret < 0) {
} else if (!data_ready) {}
else
break;
delay(100); /* retry in 100ms */
} while (1);
ret = sps30_read_measurement(&m);
}
`;
Blockly.Arduino.setupCode_["sps30_begin"] = "sensirion_i2c_init();";
Blockly.Arduino.setupCode_["sps30_setFanCleaningInterval"] =
"sps30_set_fan_auto_cleaning_interval_days(auto_clean_days);";
Blockly.Arduino.setupCode_["sps30_startMeasurement"] =
"sps30_start_measurement();";
Blockly.Arduino.loopCodeOnce_["getSPS30Data();"] = `
time_startsps = millis();
if (time_startsps > time_actualsps + intervalsps) {
time_actualsps = millis();
getSPS30Data();
}`;
var code = `m.mc_${dropdown_name}`;
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

View File

@ -1,12 +1,4 @@
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*/
Blockly.Arduino.sensebox_wifi = function (block) {
@ -118,5 +110,3 @@ Blockly.Arduino.sensebox_ethernetIp = function () {
var code = "Ethernet.localIP()";
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

View File

@ -2,17 +2,10 @@ import Blockly from "blockly";
const setVariableFunction = function (defaultValue) {
return function (block) {
var id = block.getFieldValue("VAR");
const variableName = Blockly.Variables.getVariable(
Blockly.getMainWorkspace(),
id
).name;
// const variableName = Blockly["Arduino"].nameDB_.getName(
// id,
// Blockly.Variables.NAME_TYPE
// );
const variableName = Blockly["Arduino"].nameDB_.getName(
block.getFieldValue("VAR"),
Blockly.Variables.NAME_TYPE
);
const variableValue = Blockly["Arduino"].valueToCode(
block,
"VALUE",
@ -24,32 +17,42 @@ const setVariableFunction = function (defaultValue) {
.getAllVariables();
const myVar = allVars.filter((v) => v.name === variableName)[0];
var code = "";
if (myVar !== undefined) {
switch (myVar.type) {
default:
Blockly.Arduino.variables_[variableName + myVar.type] =
myVar.type + " " + myVar.name + ";\n";
code = variableName + " = " + (variableValue || defaultValue) + ";\n";
break;
case "Array":
var arrayType;
var number;
if (this.getChildren().length > 0) {
if (this.getChildren()[0].type === "lists_create_empty") {
arrayType = this.getChildren()[0].getFieldValue("type");
number = Blockly.Arduino.valueToCode(
this.getChildren()[0],
"NUMBER",
Blockly["Arduino"].ORDER_ATOMIC
);
Blockly.Arduino.variables_[
myVar + myVar.type
] = `${arrayType} ${myVar.name} [${number}];\n`;
}
}
break;
}
return code;
};
};
const getVariableFunction = function (block) {
var id = block.getFieldValue("VAR");
const variableName = Blockly.Variables.getVariable(
Blockly.getMainWorkspace(),
id
).name;
const allVars = Blockly.getMainWorkspace()
.getVariableMap()
.getAllVariables();
const myVar = allVars.filter((v) => v.name === variableName)[0];
// const variableName = Blockly["Arduino"].nameDB_.getName(
// block.getFieldValue("VAR"),
// Blockly.Variables.NAME_TYPE
// );
var code = myVar.name;
const variableName = Blockly["Arduino"].nameDB_.getName(
block.getFieldValue("VAR"),
Blockly.Variables.NAME_TYPE
);
var code = variableName;
return [code, Blockly["Arduino"].ORDER_ATOMIC];
};

View File

@ -13,11 +13,6 @@ const sensebox_mcu = {
["C5", "5"],
["C6", "6"],
],
digitalPorts: [
["A", "A"],
["B", "B"],
["C", "C"],
],
digitalPinsLED: [
["BUILTIN_1", "7"],
["BUILTIN_2", "8"],
@ -28,11 +23,6 @@ const sensebox_mcu = {
["C5", "5"],
["C6", "6"],
],
digitalPinsRGB: [
["A", "1"],
["B", "3"],
["C", "5"],
],
digitalPinsButton: [
["on Board", "0"],
["A1", "1"],
@ -51,13 +41,9 @@ const sensebox_mcu = {
["C6", "6"],
],
serial: [
["SerialUSB", "SerialUSB"],
["Serial1", "Serial1"],
["Serial2", "Serial2"],
],
serialSensors: [
["Serial1", "Serial1"],
["Serial2", "Serial2"],
["serial", "SerialUSB"],
["serial_1", "Serial1"],
["serial_2", "Serial2"],
],
serialPins: {
SerialUSB: [
@ -140,129 +126,6 @@ const sensebox_mcu = {
parseKey: "_*_",
};
//senseBox MCU mini
const sensebox_mini = {
description: "senseBox Mini",
compilerFlag: "arduino:samd",
digitalPins: [
["IO1", "1"],
["IO2", "2"],
],
digitalPorts: [
["IO1-2", "A"],
],
digitalPinsLED: [
["BUILTIN_1", "7"],
["BUILTIN_2", "8"],
["IO1", "1"],
["IO2", "2"],
],
digitalPinsRGB: [
["on Board", "6"],
["IO1-2", "1"],
],
digitalPinsButton: [
["on Board", "0"],
["IO1", "1"],
["IO2", "2"],
],
pwmPins: [
["IO1", "1"],
["IO2", "2"],
],
serial: [
["SerialUSB", "SerialUSB"],
["Serial1", "Serial1"],
],
serialSensors: [
["Serial1", "Serial1"],
],
serialPins: {
SerialUSB: [
["RX", ""],
["TX", ""],
],
Serial1: [
["RX", "11"],
["TX", "10"],
],
Serial2: [
["RX", "13"],
["TX", "12"],
],
},
serialSpeed: [
["300", "300"],
["600", "600"],
["1200", "1200"],
["2400", "2400"],
["4800", "4800"],
["9600", "9600"],
["14400", "14400"],
["19200", "19200"],
["28800", "28800"],
["31250", "31250"],
["38400", "38400"],
["57600", "57600"],
["115200", "115200"],
],
spi: [["SPI", "SPI"]],
spiPins: {
SPI: [
["MOSI", "19"],
["MISO", "21"],
["SCK", "20"],
],
},
spiClockDivide: [
["2 (8MHz)", "SPI_CLOCK_DIV2"],
["4 (4MHz)", "SPI_CLOCK_DIV4"],
["8 (2MHz)", "SPI_CLOCK_DIV8"],
["16 (1MHz)", "SPI_CLOCK_DIV16"],
["32 (500KHz)", "SPI_CLOCK_DIV32"],
["64 (250KHz)", "SPI_CLOCK_DIV64"],
["128 (125KHz)", "SPI_CLOCK_DIV128"],
],
i2c: [["I2C", "Wire"]],
i2cPins: {
Wire: [
["SDA", "17"],
["SCL", "16"],
],
},
i2cSpeed: [
["100kHz", "100000L"],
["400kHz", "400000L"],
],
builtinLed: [
["BUILTIN_1", "7"],
["BUILTIN_2", "8"],
],
interrupt: [
["interrupt1", "1"],
["interrupt2", "2"],
],
analogPins: [
["A1", "A1"],
["A2", "A2"],
],
serial_baud_rate: 9600,
parseKey: "_*_",
};
var board = sensebox_mcu
export const setBoard = (selectedBoard) => {
if (selectedBoard === "mini"){
board = sensebox_mini
}
else {
board = sensebox_mcu
}
}
export const selectedBoard = () => {
return board;
return sensebox_mcu;
};

View File

@ -14,8 +14,6 @@ const colours = {
serial: 230,
webserver: 40,
phyphox: 25,
motors: 190,
cleverlab: 185 ,
};
export const getColour = () => {

View File

@ -13,8 +13,6 @@ const maxInstances = {
sensebox_lora_initialize_otaa: 1,
sensebox_lora_initialize_abp: 1,
sensebox_phyphox_init: 1,
sensebox_phyphox_experiment: 1,
sensebox_phyphox_experiment_send: 1,
sensebox_ethernet: 1,
};

View File

@ -21,8 +21,8 @@
* @author samelh@google.com (Sam El-Husseini)
*/
import React from "react";
import BlocklyComponent from "./BlocklyComponent";
import React from 'react';
import BlocklyComponent from './BlocklyComponent';
export default BlocklyComponent;
@ -56,16 +56,4 @@ const Shadow = (p) => {
return React.createElement("shadow", props, children);
};
const Sep = (p) => {
const { children, ...props } = p;
props.is = "blockly";
return React.createElement("sep", props, children);
};
const Label = (p) => {
const { children, ...props } = p;
props.is = "blockly";
return React.createElement("label", props, children);
};
export { Block, Category, Value, Field, Shadow, Sep, Label };
export { Block, Category, Value, Field, Shadow }

View File

@ -7,12 +7,10 @@ import { LOOPS } from "./de/loops";
import { MATH } from "./de/math";
import { MQTT } from "./de/mqtt";
import { DISPLAY } from "./de/sensebox-display";
import { MOTORS } from "./de/sensebox-motors";
import { LED } from "./de/sensebox-led";
import { LORA } from "./de/sensebox-lora";
import { OSEM } from "./de/sensebox-osem";
import { RTC } from "./de/sensebox-rtc";
import { NTP } from "./de/sensebox-ntp";
import { SD } from "./de/sensebox-sd";
import { SENSORS } from "./de/sensebox-sensors";
import { SENSEBOX } from "./de/sensebox";
@ -36,12 +34,10 @@ export const De = {
...MATH,
...MQTT,
...DISPLAY,
...MOTORS,
...LED,
...LORA,
...OSEM,
...RTC,
...NTP,
...SD,
...SENSORS,
...SENSEBOX,

View File

@ -1,48 +0,0 @@
export const MOTORS = {
/**
* Motors
*/
sensebox_motors_beginServoMotor: "Initialisiere Servomotor",
sensebox_motors_beginServoMotor_pin: "Pin:",
sensebox_motors_beginServoMotor_tooltip: "Verbinde einen digitalen Pin mit dem orangen Kabel des Servomotrors. Verbinde zusätzlich GND mit GND (schwarzes und braunes Kabel) und 5V mit 5V (rotes Kabel).",
sensebox_motors_beginServoMotor_helpurl: "https://de.wikipedia.org/wiki/Servomotor",
sensebox_motors_moveServoMotor: "Bewege Servomotor",
sensebox_motors_moveServoMotor_pin: "Pin:",
sensebox_motors_moveServoMotor_degrees: "Winkel in Grad:",
sensebox_motors_moveServoMotor_tooltip: "Der Servomotor kann zwischen 0 und 180 Grad bewegt werden.",
sensebox_motors_moveServoMotor_helpurl: "https://de.wikipedia.org/wiki/Servomotor",
sensebox_motors_I2CMotorBoard_begin: "Initialize I2C Motor Board",
sensebox_motors_I2CMotorBoard_begin_tooltip: "Connect the I2C Moztor Board with the two DC Motors to one of the five I2C-Ports. Use this Block inside the setup()-function.",
sensebox_motors_I2CMotorBoard_begin_helpurl: "TODO",
sensebox_motors_I2CMotorBoard_moveDCMotor: "Move",
sensebox_motors_I2CMotorBoard_moveDCMotor_left: "left",
sensebox_motors_I2CMotorBoard_moveDCMotor_right: "right",
sensebox_motors_I2CMotorBoard_moveDCMotor_motor: "DC Motor at I2C Motor Board",
sensebox_motors_I2CMotorBoard_moveDCMotor_speed: "Speed:",
sensebox_motors_I2CMotorBoard_moveDCMotor_tooltip: "You can set the Speed between -100 and 100.",
sensebox_motors_I2CMotorBoard_moveDCMotor_helpurl: "TODO",
sensebox_motors_I2CMotorBoard_stopDCMotor: "Stop ",
sensebox_motors_I2CMotorBoard_stopDCMotor_left: "left",
sensebox_motors_I2CMotorBoard_stopDCMotor_right: "right",
sensebox_motors_I2CMotorBoard_stopDCMotor_motor: "DC Motor at I2C Motor Board",
sensebox_motors_I2CMotorBoard_stopDCMotor_tooltip: "TODO",
sensebox_motors_I2CMotorBoard_stopDCMotor_helpurl: "TODO",
sensebox_motors_beginStepperMotor: "Initialize Stepper Motor (28BYJ-48)",
sensebox_motors_beginStepperMotor_rpm: "Rotations per Minute:",
sensebox_motors_beginStepperMotor_pins: "Input Pins (IN1-IN4):",
sensebox_motors_beginStepperMotor_tooltip: "Connect four of the the digital pins in the right order to the inputs IN1-IN4 on the stepper motor board. Connect a GND pin (black wire) to the minus pin and a 5V pin (red wire) to the plus pin on the board. Also connect the stepper motor to this Board. Use this Block inside the setup()-function.",
sensebox_motors_beginStepperMotor_helpurl: "TODO",
sensebox_motors_moveStepperMotor: "Move Stepper Motor (28BYJ-48)",
sensebox_motors_moveStepperMotor_step: "Steps:",
sensebox_motors_moveStepperMotor_tooltip: "Move stepper motor. 2048 steps equal a full rotation.",
sensebox_motors_moveStepperMotor_helpurl: "TODO",
};

View File

@ -1,11 +0,0 @@
export const NTP = {
sensebox_ntp_init: "Initialisiere NTP",
sensebox_ntp_init_tooltip: "Initialisiere den NTP Server.",
sensebox_ntp_get: "Hole Zeit von NTP Server: ",
sensebox_ntp_get_timestamp_tooltip:
"Gibt dir einen in ISO 8601 formatierten Zeitstempel zurück. Bsp: 2021-12-24T18:21Z",
sensebox_ntp_get_tooltip:
"Gibt dir den ausgewählten Wert zurück. Unix Zeit entspricht der Anzahl der Sekunden seit dem 1.1.1970",
sensebox_ntp_epochTime: "Unix Zeit",
sensebox_ntp_formattedTimeStamp: "Zeitstempel (hh:mm:ss)",
};

View File

@ -1,14 +1,14 @@
export const RTC = {
sensebox_rtc_init: "Initialisiere externe RTC",
sensebox_rtc_init: "Initialisiere RTC",
sensebox_rtc_init_tooltip:
"Initialisiere die RTC. Schließe diese an einen der 5 I2C/Wire Anschlüsse an und lege die Batterie ein. Bevor du die Uhrzeit auslesen kannst muss diese zunächst einmal gesetzt werden. Dieser Schritt muss normalerweise nur einmalig durchgeführt werden.",
sensebox_rtc_set: "Setze Uhrzeit/Datum der externen RTC",
sensebox_rtc_set: "Setze Uhrzeit/Datum der RTC",
sensebox_rtc_set_tooltip:
"Stellt die Uhrzeit der RTC ein. Beachte, dass du diesen Block im Setup ausführst.",
sensebox_rtc_get_timestamp: "Zeitstempel externe RTC (RFC 3339)",
sensebox_rtc_get_timestamp: "Zeitstempel (RFC 3339)",
sensebox_rtc_get_timestamp_tooltip:
"Gibt dir einen in ISO 8601 formatierten Zeitstempel zurück. Bsp: 2021-12-24T18:21Z",
sensebox_rtc_get: "Wert (externe RTC): ",
sensebox_rtc_get: "Wert: ",
sensebox_rtc_get_tooltip: "Gibt dir den ausgewählten Wert zurück.",
sensebox_rtc_second: "Sekunden",
sensebox_rtc_minutes: "Minuten",
@ -16,22 +16,4 @@ export const RTC = {
sensebox_rtc_day: "Tag",
sensebox_rtc_month: "Monat",
sensebox_rtc_year: "Jahr",
sensebox_internal_rtc_init: "Initialisiere interne RTC",
sensebox_internal_rtc_init_tooltip:
"Initialisieren der internen RTC. Diese RTC ist nicht batteriegepuffert und wird bei jedem Einschaltvorgang zurückgesetzt",
sensebox_internal_rtc_set: "Setze interne RTC Zeit/Datum (Unix Time)",
sensebox_internal_rtc_set_tooltip:
"Setzt die Zeit der internen RTC. Führe den Block einmalig im Setup aus und setzte die Uhrzeit über die Unix Zeit.",
sensebox_internal_rtc_get: "Wert (interne RTC): ",
sensebox_internal_rtc_get_timestamp: "Zeitstempel interne RTC (RFC 3339)",
sensebox_internal_rtc_get_timestamp_tooltip:
"Returns a timestamp formatted in ISO 8601. Ex: 2021-12-24T18:21Z",
sensebox_internal_rtc_get_tooltip: "Gibt den ausgewählten Wert zurück",
sensebox_internal_rtc_epoch: "Unix Zeit",
sensebox_internal_rtc_year: "Jahr",
sensebox_internal_rtc_month: "Monat",
sensebox_internal_rtc_day: "Tag",
sensebox_internal_rtc_hour: "Stunde",
sensebox_internal_rtc_minutes: "Minute",
sensebox_internal_rtc_seconds: "Sekunde",
};

View File

@ -132,15 +132,29 @@ Wenn die maximale Distanz überschritten wird, wird ein Wert von **O** ausgegebe
"Schließe den Sensor an einen der 3 **digital/analog Ports** an. Der Sensor gibt dir den Messwert in dB mit einer Nachkommastelle",
senseBox_soundsensor_dfrobot_helpurl:
"https://docs.sensebox.de/hardware/sensoren-lautstaerke/",
/*
* rainsensor hydreon rg-15
*/
sensebox_rainsensor_hydreon_rg15: "Regensensor (RG-15)",
sensebox_rainsensor_hydreon_rg15_port: "Serieller Port:",
sensebox_rainsensor_hydreon_rg15_serial1: "Serial1",
sensebox_rainsensor_hydreon_rg15_serial2: "Serial2",
sensebox_rainsensor_hydreon_rg15_value: "Messwert:",
sensebox_rainsensor_hydreon_rg15_totalAcc: "gesamter Niederschlag in mm",
sensebox_rainsensor_hydreon_rg15_rainInt: "Niederschlagsintensität in mm/h",
sensebox_rainsensor_hydreon_rg15_eventAcc: "Niederschlag pro Event in mm",
sensebox_rainsensor_hydreon_rg15_acc: "Niederschlag seit letzter Messung in mm",
sensebox_rainsensor_hydreon_rg15_tooltip: "Regensensor (RG-15) an einen der Seriellen Ports anschließen.",
sensebox_rainsensor_hydreon_rg15_helpurl: "https://rainsensors.com/products/rg-15/",
/*
* BME680
*/
senseBox_bme680: "Umweltsensor (BME680)",
senseBox_bme_iaq: "Innenraumluftqualität (IAQ)",
senseBox_bme_iaq_accuracy: "Kalibrierungswert",
senseBox_bme_co2: "CO2 Äquivalent",
senseBox_bme_pressure: "Luftdruck in Pa",
senseBox_bme_breatheVocEquivalent: "Atemluft VOC Äquivalent",
senseBox_bme_tooltip: `Schließe den Umweltsensor an einen der 5 **I2C-Anschlüsse** an. **Beachte:** Der Sensor benöigt eine gewisse Zeit zum kalibrieren.
Den Status der Kalibrierung kann über den Kalibrierungswert abgelesen werden. Er ist entweder 0, 1, 2 oder 3 und sagt folgendes aus:
@ -176,7 +190,7 @@ Die Messwerte für Temperatur, Luftfeuchtigkeit und Luftdruck können direkt ver
* Feinstaubsensor (SDS011)
*/
senseBox_sds011: "Feinstaubsensor SDS011",
senseBox_sds011: "Feinstaubsensor",
senseBox_sds011_dimension: "in µg/m³ an",
senseBox_sds011_pm25: "PM2.5",
senseBox_sds011_pm10: "PM10",
@ -201,23 +215,4 @@ Die Messwerte für Temperatur, Luftfeuchtigkeit und Luftdruck können direkt ver
- "wurde gedrückt": Mit diesem Modus kannst du abfragen ob der Block gedrückt wurde. Erst wenn der Knopf gedrückt und wieder losgelassen wurde erhältst du TRUE zurück
- "als Schalter": Wenn du diesen Block verwendest kannst du den Knopf wie ein Lichtschalter verwenden. Der Status wird gespeichert bis der Button erneut gedrückt wird`,
senseBox_button_helpurl: "",
/**
* Feinstaubsensor Sensirion SPS30
*/
senseBox_sps30: "Feinstaubsensor Sensirion SPS30",
senseBox_sps30_dimension: "in µg/m³",
senseBox_sps30_1p0: "PM1.0",
senseBox_sps30_2p5: "PM2.5",
senseBox_sps30_4p0: "PM4.0",
senseBox_sps30_10p0: "PM10",
senseBox_sps30_tooltip:"Dieser Block gibt dir den Messwert des Sensirion SPS30 Feinstaubsensor. Schließe den Feinstaubsensor an einen der 5 **I2C** Anschlüssen an. Im Dropdown Menü zwischen PM1.0, PM2.5, PM4.0 und PM10 auswählen. Der Messwert wird dir als **Kommazahl** in µg/m3",
senseBox_sps30_helpurl:
"https://docs.sensebox.de/hardware/sensoren-feinstaub/",
};

View File

@ -8,27 +8,20 @@ export const UI = {
toolbox_math: "Mathematik",
toolbox_io: "Eingang/Ausgang",
toolbox_time: "Zeit",
toolbox_rtc: "RTC",
toolbox_ntp: "NTP",
toolbox_functions: "Funktionen",
toolbox_variables: "Variablen",
toolbox_serial: "Seriell",
toolbox_advanced: "Erweitert",
toolbox_motors: "Motoren",
toolbox_label_externalRTC: "Externe RTC",
toolbox_label_internalRTC: "Interne RTC",
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: "Buchstabe (char)",
variables_CHARACTER: "char (char)",
variables_BOOLEAN: "Boolean (boolean)",
variables_NULL: "void (void)",
variables_UNDEF: "undefined",
variables_set: "Schreibe",
variables_to: "",
/**
* Tooltips
@ -148,7 +141,6 @@ export const UI = {
button_cancel: "Abbrechen",
button_close: "Schließen",
button_save: "Speichern",
button_accept: "Bestätigen",
button_compile: "Kompilieren",
button_create_variableCreate: "Erstelle Variable",
@ -156,7 +148,6 @@ export const UI = {
button_next: "nächster Schritt",
button_tutorial_overview: "Tutorial Übersicht",
button_login: "Anmelden",
button_createVariable: "Typisierte Variable erstellen",
/**
*
@ -190,8 +181,7 @@ export const UI = {
settings_sounds: "Töne",
settings_sounds_text:
"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
*/
@ -238,12 +228,6 @@ export const UI = {
builder_requirements_head: "Voraussetzungen",
builder_requirements_order:
"Beachte, dass die Reihenfolge des Anhakens maßgebend ist.",
builder_difficulty: "Schwierigkeitsgrad",
builder_public_head: "Tutorial veröffentlichen",
builder_public_label: "Tutorial für alle Nutzer:innen veröffentlichen",
builder_review_head: "Tutorial veröffentlichen",
builder_review_text:
"Du kannst dein Tutorial direkt über den Link mit anderen Personen teilen. Wenn du dein Tutorial für alle Nutzer:innen in der Überischt veröffenltichen wollen kannst du es hier aktivieren. Ein Administrator wird dein Tutorial ansehen und anschließend freischalten.",
/**
* Login
@ -257,7 +241,7 @@ export const UI = {
/**
* Navbar
*/
navbar_blockly: "Blockly",
navbar_tutorials: "Tutorials",
navbar_tutorialbuilder: "Tutorial erstellen",
navbar_gallery: "Galerie",
@ -298,36 +282,4 @@ export const UI = {
drawer_ideerror_head: "Hoppla da ist was schief gegangen.",
drawer_ideerror_text:
"Beim kompilieren ist ein Fehler aufgetreten, überprüfe deine Blöcke.",
/**
* Code Editor
* */
codeeditor_libraries_head: "Installierte Arduino Libraries",
codeeditor_libraries_text:
"Für die Dokumentation sehen Sie sich die installierten Bibliotheken und deren Beispiele an",
codeeditor_save_code: "Code herunterladen",
codeeditor_open_code: "Code öffnen",
codeeditor_reset_code: "Code zurücksetzen",
codeeditor_blockly_code: "Lade Blockly Code",
codeeditor_compile_progress:
"Dein Code wird nun kompiliert und anschließend auf deinen Computer heruntergeladen",
/**
* Device Selction
* */
deviceselection_head: "Welches Board benutzt du?",
deviceselection_keep_selection:
"Speichere meine Auswahl fürs nächste Mal (Du kannst das Board später in den Einstellungen wechseln)",
deviceselection_footnote: "Hier kommst du zur alten Blockly Version für den ",
deviceselection_footnote_02: "oder die",
/**
* Sensor Markdown Information
*/
sensorinfo_info: "Informationen zum Sensor",
sensorinfo_description: "Beschreibung",
sensorinfo_measurable_phenos: "Messbare Phänomene",
sensorinfo_manufacturer: "Hersteller",
sensorinfo_lifetime: "Lebensdauer",
sensorinfo_explanation: "Diese Informationen wurden aus [sensors.wiki](https://sensors.wiki) entnommen. Für weitere Informationen besuchen Sie den Abschnitt über diesen Sensor "
};

View File

@ -8,12 +8,10 @@ import { MATH } from "./en/math";
import { MQTT } from "./en/mqtt";
import { SENSEBOX } from "./en/sensebox";
import { DISPLAY } from "./en/sensebox-display";
import { MOTORS } from "./en/sensebox-motors";
import { LED } from "./en/sensebox-led";
import { LORA } from "./en/sensebox-lora";
import { OSEM } from "./en/sensebox-osem";
import { RTC } from "./en/sensebox-rtc";
import { NTP } from "./en/sensebox-ntp";
import { SD } from "./en/sensebox-sd";
import { SENSORS } from "./en/sensebox-sensors";
import { TELEGRAM } from "./en/sensebox-telegram";
@ -36,12 +34,10 @@ export const En = {
...MATH,
...MQTT,
...DISPLAY,
...MOTORS,
...LED,
...LORA,
...OSEM,
...RTC,
...NTP,
...SD,
...SENSORS,
...SENSEBOX,

View File

@ -1,3 +0,0 @@
export const CLEVERLAB = {
}

View File

@ -1,48 +0,0 @@
export const MOTORS = {
/**
* Motors
*/
sensebox_motors_beginServoMotor: "Initialize Servo Motor",
sensebox_motors_beginServoMotor_pin: "Pin:",
sensebox_motors_beginServoMotor_tooltip: "Connect one of the the digital pins to the orange wire of the Servo Motor. Also Connect GND to GND (black and brown wire) and 5V to 5V (red wire).",
sensebox_motors_beginServoMotor_helpurl: "https://en.wikipedia.org/wiki/Servomotor",
sensebox_motors_moveServoMotor: "Move Servo Motor",
sensebox_motors_moveServoMotor_pin: "Pin:",
sensebox_motors_moveServoMotor_degrees: "Degrees:",
sensebox_motors_moveServoMotor_tooltip: "The Servo Motor can be moved to a spezific angle between 0 and 180 degrees.",
sensebox_motors_moveServoMotor_helpurl: "https://en.wikipedia.org/wiki/Servomotor",
sensebox_motors_I2CMotorBoard_begin: "Initialize I2C Motor Board",
sensebox_motors_I2CMotorBoard_begin_tooltip: "Connect the I2C Moztor Board with the two DC Motors to one of the five I2C-Ports. Use this Block inside the setup()-function.",
sensebox_motors_I2CMotorBoard_begin_helpurl: "TODO",
sensebox_motors_I2CMotorBoard_moveDCMotor: "Move",
sensebox_motors_I2CMotorBoard_moveDCMotor_left: "left",
sensebox_motors_I2CMotorBoard_moveDCMotor_right: "right",
sensebox_motors_I2CMotorBoard_moveDCMotor_motor: "DC Motor at I2C Motor Board",
sensebox_motors_I2CMotorBoard_moveDCMotor_speed: "Speed:",
sensebox_motors_I2CMotorBoard_moveDCMotor_tooltip: "You can set the Speed between -100 and 100.",
sensebox_motors_I2CMotorBoard_moveDCMotor_helpurl: "TODO",
sensebox_motors_I2CMotorBoard_stopDCMotor: "Stop ",
sensebox_motors_I2CMotorBoard_stopDCMotor_left: "left",
sensebox_motors_I2CMotorBoard_stopDCMotor_right: "right",
sensebox_motors_I2CMotorBoard_stopDCMotor_motor: "DC Motor at I2C Motor Board",
sensebox_motors_I2CMotorBoard_stopDCMotor_tooltip: "TODO",
sensebox_motors_I2CMotorBoard_stopDCMotor_helpurl: "TODO",
sensebox_motors_beginStepperMotor: "Initialize Stepper Motor (28BYJ-48)",
sensebox_motors_beginStepperMotor_rpm: "Rotations per Minute:",
sensebox_motors_beginStepperMotor_pins: "Input Pins (IN1-IN4):",
sensebox_motors_beginStepperMotor_tooltip: "Connect four of the the digital pins in the right order to the inputs IN1-IN4 on the stepper motor board. Connect a GND pin (black wire) to the minus pin and a 5V pin (red wire) to the plus pin on the board. Also connect the stepper motor to this Board. Use this Block inside the setup()-function.",
sensebox_motors_beginStepperMotor_helpurl: "TODO",
sensebox_motors_moveStepperMotor: "Move Stepper Motor (28BYJ-48)",
sensebox_motors_moveStepperMotor_step: "Steps:",
sensebox_motors_moveStepperMotor_tooltip: "Move stepper motor. 2048 steps equal a full rotation.",
sensebox_motors_moveStepperMotor_helpurl: "TODO",
};

View File

@ -1,10 +0,0 @@
export const NTP = {
sensebox_ntp_init: "Initialise NTP",
sensebox_ntp_init_tooltip:
"Initialisiere die RTC. Schließe diese an einen der 5 I2C/Wire Anschlüsse an und lege die Batterie ein. Bevor du die Uhrzeit auslesen kannst muss diese zunächst einmal gesetzt werden. Dieser Schritt muss normalerweise nur einmalig durchgeführt werden.",
sensebox_ntp_get: "Get time from NTP Server: ",
sensebox_ntp_get_tooltip:
"Gibt dir den ausgewählten Wert zurück. Unix Zeit entspricht der Anzahl der Sekunden seit dem 1.1.1970",
sensebox_ntp_epochTime: "Unix time",
sensebox_ntp_formattedTimeStamp: "Timestamp (hh:mm:ss)",
};

View File

@ -1,11 +1,11 @@
export const RTC = {
sensebox_rtc_init: "Initialise external RTC",
sensebox_rtc_init: "Initialise RTC",
sensebox_rtc_init_tooltip:
"Initialise the RTC. Connect it to one of the 5 I2C/Wire connections and insert the battery. Before you can read out the time, it must first be set. This step usually only needs to be done once.",
sensebox_rtc_set: "Set RTC time/date:",
sensebox_rtc_set_tooltip:
"Sets the time of the RTC. Note that you execute this block in the setup.",
sensebox_rtc_get_timestamp: "Timestamp external RTC (RFC 3339)",
sensebox_rtc_get_timestamp: "Get timestamp",
sensebox_rtc_get_timestamp_tooltip:
"Returns a timestamp formatted in ISO 8601. Ex: 2021-12-24T18:21Z",
sensebox_rtc_get_tooltip: "Returns the selected value",
@ -17,22 +17,4 @@ export const RTC = {
sensebox_rtc_day: "day",
sensebox_rtc_month: "month",
sensebox_rtc_year: "year",
sensebox_internal_rtc_init: "Initialise internal RTC",
sensebox_internal_rtc_init_tooltip:
"Initialise the internal RTC. This RTC is not battery backed and will be reset on every power cycle.",
sensebox_internal_rtc_set: "Set internal RTC time/date:",
sensebox_internal_rtc_set_tooltip:
"Sets the time of the internal RTC. Note that you execute this block in the setup.",
sensebox_internal_rtc_get: "Get: ",
sensebox_internal_rtc_get_timestamp: "Timestamp internal RTC (RFC 3339)",
sensebox_internal_rtc_get_timestamp_tooltip:
"Returns a timestamp formatted in ISO 8601. Ex: 2021-12-24T18:21Z",
sensebox_internal_rtc_get_tooltip: "Returns the selected value",
sensebox_internal_rtc_epoch: "Unix Time",
sensebox_internal_rtc_year: "year",
sensebox_internal_rtc_month: "month",
sensebox_internal_rtc_day: "day",
sensebox_internal_rtc_hour: "hour",
sensebox_internal_rtc_minutes: "minutes",
sensebox_internal_rtc_seconds: "seconds",
};

View File

@ -134,6 +134,21 @@ If the max distance is reached the a value of **O** will be returned`,
senseBox_soundsensor_dfrobot_helpurl:
"https://en.docs.sensebox.de/hardware/sensoren-lautstaerke/",
/*
* rainsensor hydreon rg-15
*/
sensebox_rainsensor_hydreon_rg15: "Rainsensor (RG-15)",
sensebox_rainsensor_hydreon_rg15_port: "Serial Port:",
sensebox_rainsensor_hydreon_rg15_serial1: "Serial1",
sensebox_rainsensor_hydreon_rg15_serial2: "Serial2",
sensebox_rainsensor_hydreon_rg15_value: "value:",
sensebox_rainsensor_hydreon_rg15_totalAcc: "total Accumulation in mm",
sensebox_rainsensor_hydreon_rg15_rainInt: "Rainfall Intensity in mm/h",
sensebox_rainsensor_hydreon_rg15_eventAcc: "Accumulation per Event in mm",
sensebox_rainsensor_hydreon_rg15_acc: "Accumulation since last loop in mm",
sensebox_rainsensor_hydreon_rg15_tooltip: "Connect Rainsensor (RG-15) to one of the Serial ports.",
sensebox_rainsensor_hydreon_rg15_helpurl: "https://rainsensors.com/products/rg-15/",
/*
* BME680
*/
@ -141,7 +156,6 @@ If the max distance is reached the a value of **O** will be returned`,
senseBox_bme680: "Environmental sensor (BME680)",
senseBox_bme_iaq: "Indoor Air Quality (IAQ)",
senseBox_bme_iaq_accuracy: "Calibration Value",
senseBox_bme_pressure: "Airpressure in Pa",
senseBox_bme_co2: "CO2 Equivalent",
senseBox_bme_breatheVocEquivalent: "Breathe VOC Equivalent",
senseBox_bme_tooltip: `Connect the environmental sensor to one of the 5 **I2C ports**. **Note:** The sensor needs some time to calibrate.
@ -206,23 +220,4 @@ The measured values for temperature, humidity and air pressure can be used direc
*
*/
senseBox_watertemperature: "Water Temperature",
/**
* Feinstaubsensor Sensirion SPS30
*/
senseBox_sps30: "Particulate Matter Sensor (Sensirion SPS30)",
senseBox_sps30_dimension: "in µg/m³",
senseBox_sps30_1p0: "PM1.0",
senseBox_sps30_2p5: "PM2.5",
senseBox_sps30_4p0: "PM4.0",
senseBox_sps30_10p0: "PM10",
senseBox_sps30_tooltip:
"This block gives you the measured value of the Sensirion SPS30 fine dust sensor. Connect the fine dust sensor to one of the 5 **I2C** connectors. Select between PM1.0, PM2.5, PM4.0 and PM10 in the dropdown menu. The measured value will be displayed as **decimal** in µg/m3",
senseBox_sps30_helpurl:
"https://docs.sensebox.de/hardware/sensoren-feinstaub/",
};

View File

@ -8,27 +8,20 @@ export const UI = {
toolbox_math: "Math",
toolbox_io: "Input/Output",
toolbox_time: "Time",
toolbox_rtc: "RTC",
toolbox_ntp: "NTP",
toolbox_functions: "Functions",
toolbox_variables: "Variables",
toolbox_serial: "Serial",
toolbox_advanced: "Erweitert",
toolbox_motors: "Motors",
toolbox_label_externalRTC: "External RTC",
toolbox_label_internalRTC: "Internal RTC",
variable_NUMBER: "Number (int)",
variable_SHORT_NUMBER: "char",
variable_LONG: "Big number (long)",
variable_LONG: " Zahl (long)",
variable_DECIMAL: "Decimal (float)",
variables_TEXT: "Text (string)",
variables_ARRAY: "Array (array)",
variables_CHARACTER: "Character (char)",
variables_CHARACTER: "char (char)",
variables_BOOLEAN: "Boolean (boolean)",
variables_NULL: "void (void)",
variables_UNDEF: "undefined",
variables_set: "set",
variables_to: "to",
/**
* Tooltips
@ -151,7 +144,6 @@ export const UI = {
button_next: "Next step",
button_tutorial_overview: "Tutorial overview",
button_login: "Login",
button_createVariable: "Create Typed Variable",
/**
*
@ -184,8 +176,6 @@ export const UI = {
settings_sounds: "Sound",
settings_sounds_text:
"Enable or disable sounds when adding and deleting blocks. Disabled by default",
settings_board: "Board",
settings_board_text: "Choose your board",
/**
* 404
@ -232,12 +222,6 @@ export const UI = {
builder_requirements_head: "Requirements.",
builder_requirements_order:
"Note that the order of ticking is authoritative.",
builder_difficulty: "Difficulty level",
builder_public_head: "Publish tutorial",
builder_public_label: "Publish tutorial for all users",
builder_review_head: "Publish tutorial",
builder_review_text:
"You can share your tutorial with other people directly from the link. If you want to publish your tutorial for all users in the overview you can activate it here. An administrator will view your tutorial and then activate it.",
/**
* Login
@ -253,7 +237,7 @@ export const UI = {
/**
* Navbar
*/
navbar_blockly: "Blockly",
navbar_tutorials: "Tutorials",
navbar_tutorialbuilder: "Create tutorial",
navbar_gallery: "Gallery",
@ -293,38 +277,4 @@ export const UI = {
*/
drawer_ideerror_head: "Oops something went wrong",
drawer_ideerror_text: "An error occurred while compiling, check your blocks",
/**
* Code Editor
* */
codeeditor_libraries_head: "Installed Arduino Libraries",
codeeditor_libraries_text:
"For documentation, view the installed libraries and their examples",
codeeditor_save_code: "Download code",
codeeditor_open_code: "Open code",
codeeditor_reset_code: "Reset code",
codeeditor_blockly_code: "Load blockly code",
codeeditor_compile_progress:
"Your code will now be compiled and then downloaded to your computer",
/**
* Device Selection
* */
deviceselection_head: "Which board are you using?",
deviceselection_keep_selection:
"Save my choice (You can change the board later in the settings)",
deviceselection_footnote:
"Here you can access the old blockly Version for the",
deviceselection_footnote_02: "or the",
/**
* Sensor Markdown Information
* */
sensorinfo_info: "Informationen regarding the Sensor",
sensorinfo_description: "Description",
sensorinfo_measurable_phenos: "Measurable Phenomena",
sensorinfo_manufacturer: "Manufacturer",
sensorinfo_lifetime: "Lifetime",
sensorinfo_explanation: "This information was fetched from [sensors.wiki](https://sensors.wiki). For more information visit the section on this sensor ",
};

View File

@ -1,5 +1,5 @@
import React from "react";
import { Block, Value, Field, Shadow, Category, Sep, Label } from "../";
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";
@ -16,12 +16,16 @@ class Toolbox extends React.Component {
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();
@ -32,7 +36,7 @@ class Toolbox extends React.Component {
// Add your button and give it a callback name.
const button = document.createElement("button");
button.setAttribute("text", Blockly.Msg.button_createVariable);
button.setAttribute("text", "Create Typed Variable");
button.setAttribute("callbackKey", "callbackName");
xmlList.push(button);
@ -40,7 +44,6 @@ class Toolbox extends React.Component {
// This gets all the variables that the user creates and adds them to the
// flyout.
const blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace);
console.log(blockList);
xmlList = xmlList.concat(blockList);
return xmlList;
}
@ -61,7 +64,6 @@ class Toolbox extends React.Component {
<Block type="sensebox_sensor_uv_light" />
<Block type="sensebox_sensor_bmx055_accelerometer" />
<Block type="sensebox_sensor_sds011" />
<Block type="sensebox_sensor_sps30" />
<Block type="sensebox_sensor_pressure" />
<Block type="sensebox_sensor_dps310" />
<Block type="sensebox_sensor_bme680_bsec" />
@ -74,6 +76,7 @@ class Toolbox extends React.Component {
<Block type="sensebox_sensor_watertemperature" />
{/* <Block type="sensebox_windspeed" /> */}
<Block type="sensebox_soundsensor_dfrobot" />
<Block type="sensebox_rainsensor_hydreon_rg15" />
<Block type="sensebox_multiplexer_init">
<Value name="nrChannels">
<Block type="math_number">
@ -296,7 +299,6 @@ class Toolbox extends React.Component {
</Value>
</Block>
</Category>
{/* <Category name="Telegram" colour={getColour().sensebox}>
<Block type="sensebox_telegram" />
<Block type="sensebox_telegram_do" />
@ -503,12 +505,6 @@ class Toolbox extends React.Component {
<Block type="time_micros"></Block>
<Block type="infinite_loop"></Block>
<Block type="sensebox_interval_timer"></Block>
<Category
id="time"
name={Blockly.Msg.toolbox_rtc}
colour={getColour().time}
>
<Label text={Blockly.Msg.toolbox_label_externalRTC}></Label>
<Block type="sensebox_rtc_init"></Block>
<Block type="sensebox_rtc_set">
<Value name="second">
@ -545,21 +541,6 @@ class Toolbox extends React.Component {
{/* <Block type="sensebox_rtc_set_ntp"></Block> */}
<Block type="sensebox_rtc_get"></Block>
<Block type="sensebox_rtc_get_timestamp"></Block>
<Sep gap="40"></Sep>
<Label text={Blockly.Msg.toolbox_label_internalRTC}></Label>
<Block type="sensebox_internal_rtc_init"></Block>
<Block type="sensebox_internal_rtc_set"></Block>
<Block type="sensebox_internal_rtc_get"></Block>
<Block type="sensebox_internal_rtc_get_timestamp"></Block>
</Category>
<Category
id="timeUTP"
name={Blockly.Msg.toolbox_ntp}
colour={getColour().time}
>
<Block type="sensebox_ntp_init"></Block>
<Block type="sensebox_ntp_get"></Block>
</Category>
</Category>
<Category
id="math"
@ -633,11 +614,7 @@ class Toolbox extends React.Component {
colour={getColour().procedures}
custom="PROCEDURE"
></Category>
<Category name="CleVerLab" colour={getColour().cleverlab}>
<Block type="CleVerLab_pH" />
<Block type="CleVerLab_pump" />
<Block type="CleVerLab_cali1" />
</Category>
<sep></sep>
<Category name={Blockly.Msg.toolbox_advanced} colour={getColour().io}>
<Category
name={Blockly.Msg.toolbox_serial}
@ -669,36 +646,6 @@ class Toolbox extends React.Component {
</Value>
</Block>
</Category>
<Category
name={Blockly.Msg.toolbox_motors}
colour={getColour().motors}
>
<Block type="sensebox_motors_beginServoMotor" />
<Block type="sensebox_motors_moveServoMotor">
<Value name="degrees">
<Block type="math_number">
<Field name="NUM">90</Field>
</Block>
</Value>
</Block>
{/* <Block type="sensebox_motors_I2CMotorBoard_begin" />
<Block type="sensebox_motors_I2CMotorBoard_moveDCMotor">
<Value name="speed">
<Block type="math_number">
<Field name="NUM">100</Field>
</Block>
</Value>
</Block>
<Block type="sensebox_motors_I2CMotorBoard_stopDCMotor" />
<Block type="sensebox_motors_beginStepperMotor" />
<Block type="sensebox_motors_moveStepperMotor">
<Value name="steps">
<Block type="math_number">
<Field name="NUM">2048</Field>
</Block>
</Value>
</Block> */}
</Category>
<Category name="Watchdog" colour={getColour().io}>
<Block type="watchdog_enable"></Block>
<Block type="watchdog_reset"></Block>

View File

@ -3,9 +3,9 @@ import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import clsx from 'clsx';
import withStyles from '@mui/styles/withStyles';
import MaterialUIBreadcrumbs from '@mui/material/Breadcrumbs';
import Typography from '@mui/material/Typography';
import { withStyles } from '@material-ui/core/styles';
import MaterialUIBreadcrumbs from '@material-ui/core/Breadcrumbs';
import Typography from '@material-ui/core/Typography';
import { faHome } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

View File

@ -1,281 +0,0 @@
import React from "react";
import { useState, useRef } from "react";
import { default as MonacoEditor } from "@monaco-editor/react";
import { withRouter } from "react-router-dom";
import { Button, Grid } from "@mui/material";
import Blockly from "blockly/core";
import Divider from "@mui/material/Divider";
import { saveAs } from "file-saver";
import Drawer from "@mui/material/Drawer";
import Sidebar from "./Sidebar";
import Dialog from "../Dialog";
import SaveIcon from "./SaveIcon";
import store from "../../store";
import DeviceSelection from "../DeviceSelection";
const CodeEditor = (props) => {
//const [filehandle, setFileHandle] = useState();
const [fileContent, setFileContent] = useState("");
const [progress, setProgress] = useState(false);
// const [id, setId] = useState("");
const [open, setOpen] = useState(false);
const [error, setError] = useState("");
const editorRef = useRef(null);
const [autoSave, setAutoSave] = useState(false);
const [time, setTime] = useState(null);
const [value, setValue] = useState("");
const [resetDialog, setResetDialog] = useState(false);
const compile = () => {
setProgress(true);
const data = {
board: process.env.REACT_APP_BOARD,
sketch: editorRef.current.getValue(),
};
fetch(`${process.env.REACT_APP_COMPILER_URL}/compile`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => {
if (data.code === "Internal Server Error") {
setProgress(false);
setOpen(true);
setError(data.message);
}
setProgress(false);
const result = data.data.id;
//setId(result);
const filename = "sketch";
window.open(
`${process.env.REACT_APP_COMPILER_URL}/download?id=${result}&board=${process.env.REACT_APP_BOARD}&filename=${filename}`,
"_self"
);
})
.catch((err) => {
console.log(err);
});
};
const saveIno = () => {
var filename = "sketch";
var code = editorRef.current.getValue();
filename = `${filename}.ino`;
var blob = new Blob([code], { type: "text/plain;charset=utf-8" });
saveAs(blob, filename);
};
const openIno = async () => {
const [myFileHandle] = await window.showOpenFilePicker();
//setFileHandle(myFileHandle);
const file = await myFileHandle.getFile();
const contents = await file.text();
setFileContent(contents);
};
const toggleDrawer = (anchor, open) => (event) => {
if (
event.type === "keydown" &&
(event.key === "Tab" || event.key === "Shift")
) {
return;
}
setOpen(false);
};
const resetCode = () => {
const resetCode = `
#include <senseBoxIO.h> //needs to be always included
void setup () {
}
void loop() {
}`;
editorRef.current.setValue(resetCode);
};
const resetTimeout = (id, newID) => {
clearTimeout(id);
return newID;
};
const editValue = (value) => {
setTime(resetTimeout(time, setTimeout(saveValue, 400)));
setValue(value);
};
const saveValue = () => {
localStorage.setItem("ArduinoCode", value);
setAutoSave(true);
setTimeout(() => setAutoSave(false), 1000);
};
const getBlocklyCode = () => {
var code = store.getState().workspace.code.arduino;
editorRef.current.setValue(code);
};
return (
<div>
<Grid container spacing={2}>
<Drawer
anchor={"bottom"}
open={open}
onClose={toggleDrawer("bottom", false)}
>
<h2
style={{
color: "#4EAF47",
paddingLeft: "1rem",
paddingRight: "1rem",
}}
>
{Blockly.Msg.drawer_ideerror_head}
</h2>
<p
style={{
color: "#4EAF47",
paddingLeft: "1rem",
paddingRight: "1rem",
}}
>
{Blockly.Msg.drawer_ideerror_text}
</p>
<Divider style={{ backgroundColor: "white" }} />
<p
style={{
backgroundColor: "black",
color: "#E47128",
padding: "1rem",
}}
>
{" "}
{`${error}`}{" "}
</p>
</Drawer>
<Grid item lg={8} md={8}>
<div style={{ display: "flex", alignItems: "center" }}>
<h1>Code Editor</h1>
<SaveIcon loading={autoSave} />
</div>
<MonacoEditor
height="80vh"
onChange={(value) => {
editValue(value);
}}
defaultLanguage="cpp"
defaultValue={
localStorage.getItem("ArduinoCode")
? localStorage.getItem("ArduinoCode")
: `#include <senseBoxIO.h> //needs to be always included
void setup () {
}
void loop() {
}`
}
value={fileContent}
onMount={(editor, monaco) => {
editorRef.current = editor;
saveValue();
}}
/>
</Grid>
<DeviceSelection />
<Grid item lg={4} md={4}>
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
onClick={() => compile()}
>
Kompilieren
</Button>
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
onClick={() => saveIno()}
>
{Blockly.Msg.codeeditor_save_code}
</Button>
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
onClick={() => openIno()}
>
{Blockly.Msg.codeeditor_open_code}
</Button>
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
onClick={() => setResetDialog(true)}
>
{Blockly.Msg.codeeditor_reset_code}
</Button>
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
onClick={() => getBlocklyCode()}
>
{Blockly.Msg.codeeditor_blockly_code}
</Button>
<Sidebar />
<Dialog
style={{ zIndex: 9999999 }}
fullWidth
maxWidth={"sm"}
open={progress}
title={"Code wird kompiliert"}
content={""}
>
<div>{Blockly.Msg.codeeditor_compile_progress}</div>
</Dialog>{" "}
<Dialog
open={resetDialog}
title={Blockly.Msg.resetDialog_headline}
content={Blockly.Msg.resetDialog_text}
onClose={() => {
setResetDialog(false);
}}
onClick={() => {
setResetDialog(false);
}}
button={Blockly.Msg.button_cancel}
>
{" "}
<div style={{ marginTop: "10px" }}>
<Button
variant="contained"
color="primary"
onClick={() => {
resetCode();
setResetDialog(false);
}}
>
Zurücksetzen
</Button>
</div>
</Dialog>
</Grid>
</Grid>
</div>
);
};
export default withRouter(CodeEditor);

View File

@ -1,333 +0,0 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { workspaceName } from "../../actions/workspaceActions";
import { detectWhitespacesAndReturnReadableResult } from "../../helpers/whitespace";
import withStyles from '@mui/styles/withStyles';
import Button from "@mui/material/Button";
import Backdrop from "@mui/material/Backdrop";
import CircularProgress from "@mui/material/CircularProgress";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import Divider from "@mui/material/Divider";
import { faClipboardCheck } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as Blockly from "blockly/core";
import Copy from "../copy.svg";
import MuiDrawer from "@mui/material/Drawer";
import Dialog from "../Dialog";
const styles = (theme) => ({
backdrop: {
zIndex: theme.zIndex.drawer + 1,
color: "#fff",
},
iconButton: {
backgroundColor: theme.palette.button.compile,
color: theme.palette.primary.contrastText,
width: "40px",
height: "40px",
"&:hover": {
backgroundColor: theme.palette.button.compile,
color: theme.palette.primary.contrastText,
},
},
button: {
backgroundColor: theme.palette.button.compile,
color: theme.palette.primary.contrastText,
"&:hover": {
backgroundColor: theme.palette.button.compile,
color: theme.palette.primary.contrastText,
},
},
});
const Drawer = withStyles((theme) => ({
paperAnchorBottom: {
backgroundColor: "black",
height: "20vH",
},
}))(MuiDrawer);
class Compile extends Component {
constructor(props) {
super(props);
this.state = {
progress: false,
open: false,
file: false,
title: "",
content: "",
name: props.name,
error: "",
appLink: "",
appDialog: false,
};
}
componentDidMount() {}
componentDidUpdate(props) {
if (props.name !== this.props.name) {
this.setState({ name: this.props.name });
}
}
compile = () => {
this.setState({ progress: true });
const data = {
board: process.env.REACT_APP_BOARD,
sketch: this.props.arduino,
};
fetch(`${process.env.REACT_APP_COMPILER_URL}/compile`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => {
if (data.code === "Internal Server Error") {
this.setState({
progress: false,
file: false,
open: true,
title: Blockly.Msg.compiledialog_headline,
content: Blockly.Msg.compiledialog_text,
error: data.message,
});
}
this.setState({ id: data.data.id }, () => {
this.createFileName();
});
})
.catch((err) => {
console.log(err);
//this.setState({ progress: false, file: false, open: true, title: Blockly.Msg.compiledialog_headline, content: Blockly.Msg.compiledialog_text });
});
};
download = () => {
const id = this.state.id;
const filename = detectWhitespacesAndReturnReadableResult(this.state.name);
this.toggleDialog();
this.props.workspaceName(this.state.name);
window.open(
`${process.env.REACT_APP_COMPILER_URL}/download?id=${id}&board=${process.env.REACT_APP_BOARD}&filename=${filename}`,
"_self"
);
this.setState({ progress: false });
};
toggleDialog = () => {
this.setState({ open: !this.state, progress: false, appDialog: false });
};
createFileName = () => {
if (this.props.platform === true) {
const filename = detectWhitespacesAndReturnReadableResult(
this.state.name
);
this.setState({
link: `blocklyconnect-app://sketch/${filename}/${this.state.id}`,
});
this.setState({ appDialog: true });
} else {
if (this.state.name) {
this.download();
} else {
this.setState({
file: true,
open: true,
title: "Projekt kompilieren",
content:
"Bitte gib einen Namen für die Bennenung des zu kompilierenden Programms ein und bestätige diesen mit einem Klick auf 'Eingabe'.",
});
}
}
// if (this.state.name) {
// this.download();
// } else {
// this.setState({
// file: true,
// open: true,
// title: "Projekt kompilieren",
// content:
// "Bitte gib einen Namen für die Bennenung des zu kompilierenden Programms ein und bestätige diesen mit einem Klick auf 'Eingabe'.",
// });
// }
};
setFileName = (e) => {
this.setState({ name: e.target.value });
};
toggleDrawer = (anchor, open) => (event) => {
if (
event.type === "keydown" &&
(event.key === "Tab" || event.key === "Shift")
) {
return;
}
this.setState({ open: false });
};
render() {
return (
<div style={{}}>
{this.props.iconButton ? (
<Tooltip
title={Blockly.Msg.tooltip_compile_code}
arrow
style={{ marginRight: "5px" }}
>
<IconButton
className={`compileBlocks ${this.props.classes.iconButton}`}
onClick={() => this.compile()}
size="large">
<FontAwesomeIcon icon={faClipboardCheck} size="xs" />
</IconButton>
</Tooltip>
) : (
<Button
style={{ float: "right", color: "white" }}
variant="contained"
className={this.props.classes.button}
onClick={() => this.compile()}
>
<FontAwesomeIcon
icon={faClipboardCheck}
style={{ marginRight: "5px" }}
/>{" "}
Kompilieren
</Button>
)}
{this.props.platform === false ? (
<Backdrop
className={this.props.classes.backdrop}
open={this.state.progress}
>
<div className="overlay">
<img src={Copy} width="400" alt="copyimage"></img>
<h2>{Blockly.Msg.compile_overlay_head}</h2>
<p>{Blockly.Msg.compile_overlay_text}</p>
<p>
{Blockly.Msg.compile_overlay_help}
<a href="/faq" target="_blank">
FAQ
</a>
</p>
<CircularProgress color="inherit" />
</div>
</Backdrop>
) : (
<Backdrop
className={this.props.classes.backdrop}
open={this.state.progress}
>
<div className="overlay">
{/* <img src={Copy} width="400" alt="copyimage"></img> */}
<h2>Dein Code wird kompiliert!</h2>
<p>übertrage ihn anschließend mithlfe der senseBoxConnect-App</p>
<p>
{Blockly.Msg.compile_overlay_help}
<a href="/faq" target="_blank">
FAQ
</a>
</p>
<CircularProgress color="inherit" />
</div>
</Backdrop>
)}
<Drawer
anchor={"bottom"}
open={this.state.open}
onClose={this.toggleDrawer("bottom", false)}
>
<h2
style={{
color: "#4EAF47",
paddingLeft: "1rem",
paddingRight: "1rem",
}}
>
{Blockly.Msg.drawer_ideerror_head}
</h2>
<p
style={{
color: "#4EAF47",
paddingLeft: "1rem",
paddingRight: "1rem",
}}
>
{Blockly.Msg.drawer_ideerror_text}
</p>
<Divider style={{ backgroundColor: "white" }} />
<p
style={{
backgroundColor: "black",
color: "#E47128",
padding: "1rem",
}}
>
{" "}
{`${this.state.error}`}{" "}
</p>
</Drawer>
<Dialog
style={{ zIndex: 9999999 }}
fullWidth
maxWidth={"sm"}
open={this.state.appDialog}
title=""
content={""}
onClose={this.toggleDialog}
onClick={this.toggleDialog}
button={Blockly.Msg.button_close}
>
<div>
<p>Dein Code wurde erfolgreich kompiliert</p>
<a href={this.state.link}>
<Button
style={{ color: "white" }}
variant="contained"
className={this.props.classes.button}
onClick={() => this.toggleDialog()}
>
<FontAwesomeIcon
icon={faClipboardCheck}
style={{ marginRight: "5px" }}
/>{" "}
Starte Übertragung
</Button>
</a>
</div>
</Dialog>
</div>
);
}
}
Compile.propTypes = {
arduino: PropTypes.string.isRequired,
name: PropTypes.string,
workspaceName: PropTypes.func.isRequired,
platform: PropTypes.bool.isRequired,
};
const mapStateToProps = (state) => ({
arduino: state.workspace.code.arduino,
name: state.workspace.name,
platform: state.general.platform,
});
export default connect(mapStateToProps, { workspaceName })(
withStyles(styles, { withTheme: true })(Compile)
);

View File

@ -1,42 +0,0 @@
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCircleNotch, faSave } from "@fortawesome/free-solid-svg-icons";
import Tooltip from "@mui/material/Tooltip";
import React from "react";
const SaveIcon = ({ loading }) => (
<Tooltip title={"Auto save enabled"} arrow placement="right">
<div
style={{
position: "relative",
width: "2rem",
height: "2rem",
margin: "1rem",
}}
>
{loading && (
<FontAwesomeIcon
style={{ position: "absolute" }}
icon={faCircleNotch}
spin={true}
size="2x"
color="grey"
/>
)}
<FontAwesomeIcon
style={{
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%,-50%)",
}}
icon={faSave}
color={loading ? "grey" : "green"}
size={loading ? "1x" : "lg"}
/>
</div>
</Tooltip>
);
export default SaveIcon;

View File

@ -1,91 +0,0 @@
import { useState } from "react";
import Button from "@mui/material/Button";
const SerialMonitor = () => {
const [serialPortContent, setSerialPortContent] = useState([]);
const [checked, setChecked] = useState(false);
const handleClick = () => setChecked(!checked);
const connectPort = async () => {
try {
const port = await navigator.serial.requestPort();
await port.open({ baudRate: 9600 });
while (port.readable) {
const reader = port.readable.getReader();
try {
while (true) {
const { value, done } = await reader.read();
if (done) {
// Allow the serial port to be closed later.
reader.releaseLock();
break;
}
if (value) {
// byte array to string: https://stackoverflow.com/a/37542820
const text = String.fromCharCode.apply(null, value);
setSerialPortContent((prevContent) => [
...prevContent,
[new Date(), text],
]);
}
}
} catch (error) {
setSerialPortContent((prevContent) => [
...prevContent,
[new Date(), error],
]);
}
}
} catch (error) {
setSerialPortContent((prevContent) => [
...prevContent,
[new Date(), error],
]);
}
};
return (
<>
<div className="flex items-center">
<Button type="button" variant="outlined" onClick={() => connectPort()}>
Connect to senseBox
</Button>
<label className="m-4 text-gray-700 text-base font-semibold px-6 py-3 rounded-lg">
Show timestamps
<input
onChange={handleClick}
checked={checked}
type="checkbox"
className="mx-4"
/>
</label>
<Button
type="button"
variant="outlined"
onClick={() => setSerialPortContent([])}
>
Clear
</Button>
</div>
<div className="font-mono">
{serialPortContent.map((log) => {
return (
<p>
{checked && (
<span className="font-medium mr-4">{log[0].toISOString()}</span>
)}
<span>{log[1]}</span>
</p>
);
})}
</div>
</>
);
};
export default SerialMonitor;

View File

@ -1,140 +0,0 @@
import React from "react";
import Blockly from "blockly";
import { useSelector } from "react-redux";
import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import Typography from "@mui/material/Typography";
import { LibraryVersions } from "../../data/versions.js";
import { useMonaco } from "@monaco-editor/react";
import { Button } from "@mui/material";
import SerialMonitor from "./SerialMonitor.js";
import axios from "axios";
const Sidebar = () => {
//const [examples, setExamples] = React.useState([]);
const user = useSelector((state) => state.auth.user);
// useEffect(() => {
// axios
// .get("https://coelho.opensensemap.org/items/blocklysamples")
// .then((res) => {
// setExamples(res.data.data);
// });
// }, []);
const monaco = useMonaco();
const loadCode = (code) => {
monaco.editor.getModels()[0].setValue(code);
};
const getOsemScript = (id) => {
axios
.get(`https://api.opensensemap.org/boxes/${id}/script/`)
.then((res) => {
loadCode(res.data);
});
};
return (
<div>
{"serial" in navigator ? (
<Accordion>
<AccordionSummary
expandIcon={""}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography>Serial Monitor</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>
<SerialMonitor />
</Typography>
</AccordionDetails>
</Accordion>
) : null}
{/* <Accordion>
<AccordionSummary
expandIcon={""}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography>Beispiele</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>
{examples.map((object, i) => {
return (
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
key={i}
onClick={() => loadCode(object.code)}
>
{object.name}
</Button>
);
})}
</Typography>
</AccordionDetails>
</Accordion> */}
{user ? (
<Accordion>
<AccordionSummary
expandIcon={""}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography>Deine openSenseMap Codes</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>
{user.boxes.map((box, i) => {
return (
<Button
style={{ padding: "1rem", margin: "1rem" }}
variant="contained"
color="primary"
key={i}
onClick={() => getOsemScript(box._id)}
>
{box.name}
</Button>
);
})}
</Typography>
</AccordionDetails>
</Accordion>
) : null}
<Accordion>
<AccordionSummary
expandIcon={""}
aria-controls="panel2a-content"
id="panel2a-header"
>
<Typography>{Blockly.Msg.codeeditor_libraries_head}</Typography>
</AccordionSummary>
<AccordionDetails
style={{ padding: 0, height: "60vH", backgroundColor: "white" }}
>
<Typography
style={{ overflow: "auto", width: "100%", padding: "1rem" }}
>
<p>{Blockly.Msg.codeeditor_libraries_text}</p>
{LibraryVersions().map((object, i) => {
return (
<p>
<a href={object.link} target="_blank" rel="noreferrer">
{object.library} {object.version}
</a>
</p>
);
})}
</Typography>
</AccordionDetails>
</Accordion>
</div>
);
};
export default Sidebar;

View File

@ -1,27 +1,30 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import withStyles from '@mui/styles/withStyles';
import MuiAccordion from "@mui/material/Accordion";
import MuiAccordionSummary from "@mui/material/AccordionSummary";
import MuiAccordionDetails from "@mui/material/AccordionDetails";
import { Card } from "@mui/material";
import * as Blockly from "blockly";
import { default as MonacoEditor } from "@monaco-editor/react";
import Prism from "prismjs";
import "prismjs/themes/prism.css";
import "prismjs/plugins/line-numbers/prism-line-numbers";
import "prismjs/plugins/line-numbers/prism-line-numbers.css";
import withWidth from '@material-ui/core/withWidth';
import { withStyles } from '@material-ui/core/styles';
import MuiAccordion from '@material-ui/core/Accordion';
import MuiAccordionSummary from '@material-ui/core/AccordionSummary';
import MuiAccordionDetails from '@material-ui/core/AccordionDetails';
import { Card } from '@material-ui/core';
import * as Blockly from 'blockly'
// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
const withWidth = () => (WrappedComponent) => (props) => <WrappedComponent {...props} width="xs" />;
const Accordion = withStyles((theme) => ({
root: {
border: `1px solid ${theme.palette.secondary.main}`,
boxShadow: "none",
"&:before": {
display: "none",
boxShadow: 'none',
'&:before': {
display: 'none',
},
"&$expanded": {
margin: "auto",
'&$expanded': {
margin: 'auto',
},
},
expanded: {},
@ -31,15 +34,15 @@ const AccordionSummary = withStyles((theme) => ({
root: {
backgroundColor: theme.palette.secondary.main,
borderBottom: `1px solid white`,
marginBottom: "-1px",
minHeight: "50px",
"&$expanded": {
minHeight: "50px",
marginBottom: '-1px',
minHeight: '50px',
'&$expanded': {
minHeight: '50px',
},
},
content: {
"&$expanded": {
margin: "12px 0",
'&$expanded': {
margin: '12px 0',
},
},
expanded: {},
@ -51,60 +54,40 @@ const AccordionDetails = withStyles((theme) => ({
},
}))(MuiAccordionDetails);
class CodeViewer extends Component {
constructor(props) {
super(props);
this.state = {
code: this.props.arduino,
changed: false,
expanded: true,
componentHeight: null,
componentHeight: null
};
this.myDiv = React.createRef();
}
componentDidMount() {
this.setState({ componentHeight: this.myDiv.current.offsetHeight + "px" });
Prism.highlightAll();
this.setState({ componentHeight: this.myDiv.current.offsetHeight + 'px' });
}
componentDidUpdate(prevProps, prevState) {
// if (this.props.arduino !== prevProps.arduino) {
// this.setState({ changed: true });
// console.log(`code changed: ${this.state.changed}`);
// if (this.state.changed && prevState.code !== this.props.arduino) {
// this.setState({ code: this.props.arduino });
// this.setState({ changed: false });
// }
// if (this.state.code !== prevState.code && this.state.changed) {
// this.setState({ changed: false });
// }
// if (this.props.arduino !== this.state.code) {
// this.setState({ changed: true });
// //this.setState({ code: this.props.arduino });
// }
if (
this.myDiv.current &&
this.myDiv.current.offsetHeight + "px" !== this.state.componentHeight
) {
this.setState({
componentHeight: this.myDiv.current.offsetHeight + "px",
});
componentDidUpdate(props, state) {
if (this.myDiv.current && this.myDiv.current.offsetHeight + 'px' !== this.state.componentHeight) {
this.setState({ componentHeight: this.myDiv.current.offsetHeight + 'px' });
}
Prism.highlightAll();
}
onChange = () => {
this.setState({ expanded: !this.state.expanded });
};
}
render() {
var curlyBrackets = "{ }";
var unequal = "<>";
var curlyBrackets = '{ }';
var unequal = '<>';
return (
<Card style={{ height: "100%", maxHeight: "60vH" }} ref={this.myDiv}>
<Card style={{ height: '100%', maxHeight: '60vH' }} ref={this.myDiv}>
<Accordion
square={true}
style={{ margin: 0 }}
@ -112,32 +95,15 @@ class CodeViewer extends Component {
onChange={this.onChange}
>
<AccordionSummary>
<b style={{ fontSize: "20px", marginRight: "5px", width: "35px" }}>
{curlyBrackets}
</b>
<div style={{ margin: "auto 5px 2px 0px" }}>
{Blockly.Msg.codeviewer_arduino}
</div>
<b style={{ fontSize: '20px', marginRight: '5px', width: '35px' }}>{curlyBrackets}</b>
<div style={{ margin: 'auto 5px 2px 0px' }}>{Blockly.Msg.codeviewer_arduino}</div>
</AccordionSummary>
<AccordionDetails
style={{
padding: 0,
height: `calc(${this.state.componentHeight} - 50px - 50px)`,
backgroundColor: "white",
}}
>
<MonacoEditor
height="80vh"
defaultLanguage="cpp"
value={this.props.arduino}
// modified={this.props.arduino}
// original={this.state.code}
options={{
readOnly: true,
fontSize: "16px",
}}
/>
<AccordionDetails style={{ padding: 0, height: `calc(${this.state.componentHeight} - 50px - 50px)`, backgroundColor: 'white' }}>
<pre className="line-numbers" style={{ paddingBottom: 0, width: '100%', overflow: 'auto', scrollbarWidth: 'thin', height: 'calc(100% - 30px)', margin: '15px 0', paddingTop: 0, whiteSpace: 'pre-wrap', backgroundColor: 'white' }}>
<code className="language-clike">
{this.props.arduino}
</code>
</pre>
</AccordionDetails>
</Accordion>
<Accordion
@ -147,43 +113,32 @@ class CodeViewer extends Component {
onChange={this.onChange}
>
<AccordionSummary>
<b style={{ fontSize: "20px", marginRight: "5px", width: "35px" }}>
{unequal}
</b>
<div style={{ margin: "auto 5px 2px 0px" }}>
{Blockly.Msg.codeviewer_xml}
</div>
<b style={{ fontSize: '20px', marginRight: '5px', width: '35px' }}>{unequal}</b>
<div style={{ margin: 'auto 5px 2px 0px' }}>{Blockly.Msg.codeviewer_xml}</div>
</AccordionSummary>
<AccordionDetails
style={{
padding: 0,
height: `calc(${this.state.componentHeight} - 50px - 50px)`,
backgroundColor: "white",
}}
>
<MonacoEditor
height="80vh"
defaultLanguage="xml"
value={this.props.xml}
readOnly={true}
/>
<AccordionDetails style={{ padding: 0, height: `calc(${this.state.componentHeight} - 50px - 50px)`, backgroundColor: 'white' }}>
<pre className="line-numbers" style={{ paddingBottom: 0, width: '100%', overflow: 'auto', scrollbarWidth: 'thin', height: 'calc(100% - 30px)', margin: '15px 0', paddingTop: 0, whiteSpace: 'pre-wrap', backgroundColor: 'white' }}>
<code className="language-xml">
{`${this.props.xml}`}
</code>
</pre>
</AccordionDetails>
</Accordion>
</Card>
);
}
};
}
CodeViewer.propTypes = {
arduino: PropTypes.string.isRequired,
xml: PropTypes.string.isRequired,
tooltip: PropTypes.string.isRequired,
tooltip: PropTypes.string.isRequired
};
const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
arduino: state.workspace.code.arduino,
xml: state.workspace.code.xml,
tooltip: state.workspace.code.tooltip,
tooltip: state.workspace.code.tooltip
});
export default connect(mapStateToProps, null)(withWidth()(CodeViewer));

View File

@ -10,7 +10,6 @@ import Navbar from './Navbar';
import Footer from './Footer';
import Routes from './Route/Routes';
import Cookies from './Cookies';
import { setBoard } from './Blockly/helpers/board';
class Content extends Component {
@ -20,7 +19,6 @@ class Content extends Component {
} else if (this.props.language === 'en_US') {
Blockly.setLocale(En);
}
setBoard(this.props.board)
}
componentDidUpdate(props) {
@ -31,7 +29,6 @@ class Content extends Component {
Blockly.setLocale(En);
}
}
setBoard(this.props.board)
}
render() {
@ -51,8 +48,7 @@ Content.propTypes = {
};
const mapStateToProps = state => ({
language: state.general.language,
board: state.board.board
language: state.general.language
});
export default connect(mapStateToProps, null)(Content);

View File

@ -9,7 +9,7 @@ class Cookies extends Component {
return (
<CookieConsent
location="bottom"
buttonText="Okay!"
buttonText="Okay!!"
cookieName="cookieConsent"
style={{ background: "#2B373B" }}
buttonStyle={{ background: "white", color: "#4EAF47", fontSize: "1rem" }}

View File

@ -1,133 +0,0 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import Dialog from "./Dialog";
import withStyles from '@mui/styles/withStyles';
import * as Blockly from "blockly";
import { IconButton, Grid, Avatar, Typography } from "@mui/material";
import { setBoard } from "../actions/boardAction";
const styles = (theme) => ({
link: {
color: theme.palette.primary.main,
textDecoration: "none",
"&:hover": {
color: theme.palette.primary.main,
textDecoration: `underline`,
},
},
label: {
fontSize: "0.9rem",
color: "grey",
},
});
class DeviceSeclection extends Component {
constructor(props) {
super(props);
this.state = {
open: props.selectedBoard ? false : true,
selectedBoard: "",
saveSettings: false,
};
}
toggleDialog = () => {
this.props.setBoard(this.state.selectedBoard)
};
onChange = (e) => {
if (e.target.checked) {
this.setState({ saveSettings: true });
} else {
this.setState({ saveSettings: false });
}
};
onclick = (e, value) => {
this.setState({ selectedBoard: value })
this.props.setBoard(value)
this.setState({ open: !this.state });
};
render() {
return (
<Dialog
style={{ zIndex: 9999999 }}
fullWidth
maxWidth={"xl"}
open={this.state.open}
title={Blockly.Msg.deviceselection_head}
content={""}
onClick={this.toggleDialog}
disabled={this.state.selectedBoard === ""}
>
<div>
<Grid container spacing={2} style={{ textAlign: "center" }}>
<Grid item xs={6}>
<IconButton onClick={(e) => this.onclick(e, "mcu")} size="large">
<Avatar
alt="Sensebox MCU"
src="/media/hardware/senseboxmcu.png"
style={{
border: this.state.selectedBoard === "mcu" ? 'medium solid DeepSkyBlue' : "0.1px solid lightgray",
width: "20vw",
height: "20vw"
}}
/>
</IconButton>
<p>senseBox MCU</p>
</Grid>
{/* <Grid item xs={4}>
<IconButton onClick={(e) => this.onclick(e, "esp")}>
<Avatar
alt="Sensebox ESP"
src="/media/hardware/senseboxmcu.png"
style={{
border: this.state.selectedBoard == "esp" ? 'medium solid DeepSkyBlue': "0.1px solid lightgray",
width:"20vw",
height: "20vw"
}}
/>
</IconButton>
<p>Sensebox ESP</p>
</Grid> */}
<Grid item xs={6}>
<IconButton onClick={(e) => this.onclick(e, "mini")} size="large">
<Avatar
alt="Sensebox Mini"
src="/media/hardware/senseboxmcumini.png"
style={{
border: this.state.selectedBoard === "mini" ? 'medium solid DeepSkyBlue' : "0.1px solid lightgray",
width: "20vw",
height: "20vw"
}}
/>
</IconButton>
<p>senseBox MCU:mini</p>
</Grid>
</Grid>
</div>
<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>
</Typography>
</Dialog>
);
}
}
DeviceSeclection.propTypes = {
pageVisits: PropTypes.number.isRequired,
};
const mapStateToProps = (state) => ({
pageVisits: state.general.pageVisits,
selectedBoard: state.board.board
});
export default connect(
mapStateToProps,
{ setBoard }
)(withStyles(styles, { withTheme: true })(DeviceSeclection));

View File

@ -1,10 +1,10 @@
import React, { Component } from 'react';
import Button from '@mui/material/Button';
import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import DialogActions from '@mui/material/DialogActions';
import MaterialUIDialog from '@mui/material/Dialog';
import Button from '@material-ui/core/Button';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import DialogActions from '@material-ui/core/DialogActions';
import MaterialUIDialog from '@material-ui/core/Dialog';
class Dialog extends Component {
@ -24,7 +24,7 @@ class Dialog extends Component {
</DialogContent>
<DialogActions>
{this.props.actions ? this.props.actions :
<Button onClick={this.props.onClick} disabled={this.props.disabled} color="primary">
<Button onClick={this.props.onClick} color="primary">
{this.props.button}
</Button>
}

View File

@ -1,37 +1,39 @@
import React, { Component } from "react";
import React, { Component } from 'react';
import Breadcrumbs from "./Breadcrumbs";
import Breadcrumbs from './Breadcrumbs';
import { withRouter } from "react-router-dom";
import { withRouter } from 'react-router-dom';
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import * as Blockly from "blockly";
import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import Container from "@mui/material/Container";
import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import * as Blockly from 'blockly'
import ReactMarkdown from 'react-markdown';
import Container from '@material-ui/core/Container';
import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { FaqQuestions } from "../data/faq";
import { FaqQuestions } from '../data/faq'
class Faq extends Component {
state = {
panel: "",
expanded: false,
};
panel: '',
expanded: false
}
handleChange = (panel) => {
this.setState({ panel: this.state.panel === panel ? "" : panel });
this.setState({ panel: this.state.panel === panel ? '' : panel });
};
componentDidMount() {
// Ensure that Blockly.setLocale is adopted in the component.
// Otherwise, the text will not be displayed until the next update of the component.
window.scrollTo(0, 0);
window.scrollTo(0, 0)
this.forceUpdate();
}
@ -39,64 +41,139 @@ class Faq extends Component {
const { panel } = this.state;
return (
<div>
<Breadcrumbs
content={[{ link: this.props.location.pathname, title: "FAQ" }]}
/>
<Breadcrumbs content={[{ link: this.props.location.pathname, title: 'FAQ' }]} />
<Container fixed>
<div style={{ margin: "0px 24px 0px 24px" }}>
<div style={{ margin: '0px 24px 0px 24px' }}>
<h1>FAQ</h1>
{FaqQuestions().map((object, i) => {
return (
<Accordion
expanded={panel === `panel${i}`}
onChange={() => this.handleChange(`panel${i}`)}
>
<AccordionSummary
expandIcon={<FontAwesomeIcon icon={faChevronDown} />}
<ExpansionPanel expanded={panel === `panel${i}`} onChange={() => this.handleChange(`panel${i}`)}>
<ExpansionPanelSummary
expandIcon={
<FontAwesomeIcon icon={faChevronDown} />
}
>
<Typography variant="h6">{object.question}</Typography>
</AccordionSummary>
<AccordionDetails>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Typography>
<ReactMarkdown
className="news"
allowDangerousHtml="true"
children={object.answer}
rehypePlugins={[rehypeRaw]}
></ReactMarkdown>
<ReactMarkdown className="news" allowDangerousHtml="true" children={object.answer}>
</ReactMarkdown>
</Typography>
</AccordionDetails>
</Accordion>
);
</ExpansionPanelDetails>
</ExpansionPanel>
)
})}
{this.props.button ? (
{
this.props.button ?
<Button
style={{ marginTop: "20px" }}
style={{ marginTop: '20px' }}
variant="contained"
color="primary"
onClick={() => {
this.props.history.push(this.props.button.link);
}}
onClick={() => { this.props.history.push(this.props.button.link) }}
>
{this.props.button.title}
</Button>
) : (
:
<Button
style={{ marginTop: "20px" }}
style={{ marginTop: '20px' }}
variant="contained"
color="primary"
onClick={() => {
this.props.history.push("/");
}}
onClick={() => { this.props.history.push('/') }}
>
{Blockly.Msg.button_back}
</Button>
)}
}
</div>
</Container>
</div >
);
}
};
}
export default withRouter(Faq);
/*
<ExpansionPanel expanded={panel === 'panel1'} onChange={() => this.handleChange('panel1')}>
<ExpansionPanelSummary
expandIcon={
<FontAwesomeIcon icon={faChevronDown} />
}
>
<Typography variant="h6">{Blockly.Msg.faq_q1_question}</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Typography>
<ReactMarkdown className="news" allowDangerousHtml="true" children={Blockly.Msg.faq_q1_answer}>
</ReactMarkdown>
</Typography>
</ExpansionPanelDetails>
</ExpansionPanel>
<ExpansionPanel expanded={panel === 'panel2'} onChange={() => this.handleChange('panel2')}>
<ExpansionPanelSummary
expandIcon={
<FontAwesomeIcon icon={faChevronDown} />
}
>
<Typography>Frage 2</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Typography>
Donec placerat, lectus sed mattis semper, neque lectus feugiat lectus, varius pulvinar
diam eros in elit. Pellentesque convallis laoreet laoreet.
</Typography>
</ExpansionPanelDetails>
</ExpansionPanel>
<ExpansionPanel expanded={panel === 'panel3'} onChange={() => this.handleChange('panel3')}>
<ExpansionPanelSummary
expandIcon={
<FontAwesomeIcon icon={faChevronDown} />
}
>
<Typography>Frage 3</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Typography>
Nunc vitae orci ultricies, auctor nunc in, volutpat nisl. Integer sit amet egestas eros,
vitae egestas augue. Duis vel est augue.
</Typography>
</ExpansionPanelDetails>
</ExpansionPanel>
<ExpansionPanel expanded={panel === 'panel4'} onChange={() => this.handleChange('panel4')}>
<ExpansionPanelSummary
expandIcon={
<FontAwesomeIcon icon={faChevronDown} />
}
>
<Typography>Frage 4</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Typography>
Nunc vitae orci ultricies, auctor nunc in, volutpat nisl. Integer sit amet egestas eros,
vitae egestas augue. Duis vel est augue.
</Typography>
</ExpansionPanelDetails>
</ExpansionPanel>
*/
// {{
// this.props.button ?
// <Button
// style={{ marginTop: '20px' }}
// variant="contained"
// color="primary"
// onClick={() => { this.props.history.push(this.props.button.link) }}
// >
// {this.props.button.title}
// </Button>
// :
// <Button
// style={{ marginTop: '20px' }}
// variant="contained"
// color="primary"
// onClick={() => { this.props.history.push('/') }}
// >
// {Blockly.Msg.button_back}
// </Button>
// }}

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import Typography from '@mui/material/Typography';
import Typography from '@material-ui/core/Typography';
class Footer extends Component {
render() {

View File

@ -11,19 +11,18 @@ import WorkspaceFunc from "./Workspace/WorkspaceFunc";
import BlocklyWindow from "./Blockly/BlocklyWindow";
import CodeViewer from "./CodeViewer";
import TrashcanButtons from "./Workspace/TrashcanButtons";
// import HintTutorialExists from "./Tutorial/HintTutorialExists";
import DeviceSelection from "./DeviceSelection";
import HintTutorialExists from "./Tutorial/HintTutorialExists";
import Grid from "@mui/material/Grid";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import withStyles from '@mui/styles/withStyles';
import Grid from "@material-ui/core/Grid";
import IconButton from "@material-ui/core/IconButton";
import Tooltip from "@material-ui/core/Tooltip";
import { withStyles } from "@material-ui/core/styles";
import { faCode } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import TooltipViewer from "./TooltipViewer";
import Dialog from "./Dialog";
// import Autosave from "./Workspace/AutoSave";
const styles = (theme) => ({
codeOn: {
backgroundColor: theme.palette.primary.main,
@ -55,11 +54,11 @@ class Home extends Component {
key: "",
message: "",
open: true,
initialXml: localStorage.getItem("autoSaveXML"),
};
}
componentDidMount() {
console.log(this.props.platform);
if (this.props.platform === true) {
this.setState({ codeOn: false });
}
@ -120,12 +119,10 @@ class Home extends Component {
<WorkspaceStats />
</div>
) : null}
<div
className="workspaceFunc"
style={{ float: "right", height: "40px", marginBottom: "20px" }}
>
{/* <Autosave /> */}
<WorkspaceFunc
project={this.props.project}
projectType={this.props.projectType}
@ -160,11 +157,10 @@ class Home extends Component {
zIndex: 21,
}}
onClick={() => this.onChange()}
size="large">
>
<FontAwesomeIcon icon={faCode} size="xs" />
</IconButton>
</Tooltip>
<TrashcanButtons />
<div className="blocklyWindow">
{this.props.project ? (
@ -173,10 +169,7 @@ class Home extends Component {
initialXml={this.props.project.xml}
/>
) : (
<BlocklyWindow
blocklyCSS={{ height: "80vH" }}
initialXml={this.state.initialXml}
/>
<BlocklyWindow blocklyCSS={{ height: "80vH" }} />
)}
</div>
</Grid>
@ -187,8 +180,7 @@ class Home extends Component {
</Grid>
) : null}
</Grid>
<DeviceSelection />
{/* <HintTutorialExists /> */}
<HintTutorialExists />
{this.props.platform ? (
<Dialog
style={{ zIndex: 9999999 }}
@ -224,7 +216,7 @@ Home.propTypes = {
workspaceName: PropTypes.func.isRequired,
message: PropTypes.object.isRequired,
statistics: PropTypes.bool.isRequired,
platform: PropTypes.bool.isRequired,
platform: PropTypes.object.isRequired,
};
const mapStateToProps = (state) => ({

View File

@ -1,6 +1,6 @@
import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import Container from "@mui/material/Container";
import Container from "@material-ui/core/Container";
class Impressum extends Component {
render() {
return (

View File

@ -5,8 +5,8 @@ import { workspaceChange } from '../actions/workspaceActions';
import * as Blockly from 'blockly/core';
import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
class MaxBlocks extends Component {
@ -28,12 +28,12 @@ class MaxBlocks extends Component {
return (
<div style={{display: 'inline', marginLeft: '10px'}}>
<TextField
variant="standard"
style={{width: '50px', marginRight: '5px'}}
name="max"
type="number"
onChange={this.onChange}
value={this.state.max} />
value={this.state.max}
/>
<Button style={{marginRight: '10px', color: 'white'}} variant="contained" color="primary" onClick={this.setMaxBlocks}>
Maximale Blöcke
</Button>

View File

@ -8,20 +8,19 @@ import senseboxLogo from "./sensebox_logo.svg";
import { withRouter } from "react-router-dom";
import withStyles from '@mui/styles/withStyles';
import Drawer from "@mui/material/Drawer";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import List from "@mui/material/List";
import Typography from "@mui/material/Typography";
import Divider from "@mui/material/Divider";
import IconButton from "@mui/material/IconButton";
import ListItem from "@mui/material/ListItem";
import ListItemIcon from "@mui/material/ListItemIcon";
import ListItemText from "@mui/material/ListItemText";
import LinearProgress from "@mui/material/LinearProgress";
import { withStyles } from "@material-ui/core/styles";
import Drawer from "@material-ui/core/Drawer";
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
import List from "@material-ui/core/List";
import Typography from "@material-ui/core/Typography";
import Divider from "@material-ui/core/Divider";
import IconButton from "@material-ui/core/IconButton";
import ListItem from "@material-ui/core/ListItem";
import ListItemIcon from "@material-ui/core/ListItemIcon";
import ListItemText from "@material-ui/core/ListItemText";
import LinearProgress from "@material-ui/core/LinearProgress";
import Tour from "reactour";
import { Badge } from "@mui/material";
import { home, assessment } from "./Tour";
import {
faBars,
@ -35,22 +34,10 @@ import {
faChalkboardTeacher,
faTools,
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";
import { Button } from "@mui/material";
import Tooltip from "@material-ui/core/Tooltip";
const styles = (theme) => ({
drawerWidth: {
@ -70,14 +57,9 @@ 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
};
}
@ -95,6 +77,7 @@ 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 &&
@ -130,7 +113,7 @@ class Navbar extends Component {
onClick={this.toggleDrawer}
style={{ margin: "0 10px" }}
className="MenuButton"
size="large">
>
<FontAwesomeIcon icon={faBars} />
</IconButton>
<Link to={"/"} style={{ textDecoration: "none", color: "inherit" }}>
@ -141,150 +124,44 @@ class Navbar extends Component {
<Link to={"/"} style={{ marginLeft: "10px" }}>
<img src={senseboxLogo} alt="senseBox-Logo" width="30" />
</Link>
<div style={{ margin: "0 0 0 auto", display: "flex", alignItems: 'center', justifyContent: 'center' }}>
{isTutorial ? (
<Link
to={"/tutorial"}
style={{
textDecoration: "none",
color: "inherit",
marginLeft: "10px",
}}
>
<Typography variant="h6" noWrap>
Tutorial
</Typography>
</Link>
) : null}
{isHome ? (
<div style={{ display: "flex" }}>
<div style={{ padding: "12px" }}>
<Button
style={{ textTransform: 'none', cursor: "pointer", alignItems: "center", alignContent: "center", background: "transparent", color: "inherit", fontWeight: "bold", border: "2px solid white", borderRadius: "25px" }}
ref={this.mcuRef}
onClick={() => {
this.setState({ anchorElBoard: this.mcuRef.current })
}}
startIcon={<FontAwesomeIcon icon={faMicrochip} />}
endIcon={<FontAwesomeIcon icon={faCaretDown} />}
sx={{ display: { xs: "none", sm: "none", md: "flex" } }}
>
{this.props.selectedBoard}
</Button>
<Menu
anchorEl={this.state.anchorElBoard}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
open={Boolean(this.state.anchorElBoard)}
onClose={() => {
this.setState({ anchorElBoard: null });
}}
>
<MenuItem
value="mcu"
onClick={(event) => {
this.props.setBoard(event.currentTarget.getAttribute("value"));
this.setState({ anchorElBoard: null });
}}
>
mcu
</MenuItem>
<MenuItem
value="mini"
onClick={(event) => {
this.props.setBoard(event.currentTarget.getAttribute("value"));
this.setState({ anchorElBoard: null });
}}
>
mini
</MenuItem>
</Menu>
</div>
<div style={{ padding: "12px" }}>
{
this.props.language === "en_US" ?
(
<Button
style={{ textTransform: 'none', cursor: "pointer", alignItems: "center", alignContent: "center", background: "transparent", color: "inherit", fontWeight: "bold", border: "2px solid white", borderRadius: "25px" }}
ref={this.langRef}
onClick={() => {
this.setState({ anchorElLang: this.langRef.current })
}}
startIcon={<FontAwesomeIcon icon={faEarthAmericas} />}
endIcon={<FontAwesomeIcon icon={faCaretDown} />}
sx={{ display: { xs: "none", sm: "none", md: "flex" } }}
>
English
</Button>
) : (
<Button
style={{ textTransform: 'none', cursor: "pointer", alignItems: "center", alignContent: "center", background: "transparent", color: "inherit", fontWeight: "bold", border: "2px solid white", borderRadius: "25px" }}
ref={this.langRef}
onClick={() => {
this.setState({ anchorElLang: this.langRef.current })
}}
startIcon={<FontAwesomeIcon icon={faEarthEurope} />}
endIcon={<FontAwesomeIcon icon={faCaretDown} />}
sx={{ display: { xs: "none", sm: "none", md: "flex" } }}
>
Deutsch
</Button>
)
}
<Menu
anchorEl={this.state.anchorElLang}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
open={Boolean(this.state.anchorElLang)}
onClose={() => {
this.setState({ anchorElLang: null });
}}
>
<MenuItem
value="de_DE"
onClick={(event) => {
this.props.setLanguage(event.currentTarget.getAttribute("value"));
this.setState({ anchorElLang: null });
}}
>
Deutsch
</MenuItem>
<MenuItem
value="en_US"
onClick={(event) => {
this.props.setLanguage(event.currentTarget.getAttribute("value"));
this.setState({ anchorElLang: null });
}}
>
English
</MenuItem>
</Menu>
</div>
</div>
) : (null)}
{isHome ? (
<Tooltip title={'Start Tour'} arrow>
<Tooltip title={Blockly.Msg.tooltip_start_tour} arrow>
<IconButton
color="inherit"
className={`openTour ${this.props.classes.button}`}
onClick={() => {
this.openTour();
}}
size="large">
style={{ margin: "0 30px 0 auto" }}
>
<FontAwesomeIcon icon={faQuestionCircle} />
</IconButton>
</Tooltip>
) : null}
{isAssessment ? (
<Tooltip title={'Start tour'} arrow>
<Tooltip title={Blockly.Msg.tooltip_start_tour} arrow>
<IconButton
color="inherit"
className={`openTour ${this.props.classes.button}`}
onClick={() => {
this.openTour();
}}
size="large">
style={{ margin: "0 30px 0 auto" }}
>
<FontAwesomeIcon icon={faQuestionCircle} />
</IconButton>
</Tooltip>
@ -296,71 +173,6 @@ class Navbar extends Component {
this.closeTour();
}}
/>
{this.props.user ? (
<div>
<IconButton
color="inherit"
onClick={(event) => { this.setState({ anchorElUser: event.target }) }}
style={{ margin: "0 30px 0 0" }}
size="large"
>
<FontAwesomeIcon icon={faUser} />
</IconButton>
<Menu
anchorEl={this.state.anchorElUser}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
keepMounted
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
open={Boolean(this.state.anchorElUser)}
onClose={() => { this.setState({ anchorElUser: null }); }}
>
<div className="" style={{ paddingLeft: "16px", paddingRight: "16px", paddingTop: "16px" }}>
<p style={{ fontWeight: "bold", margin: "0px" }}>
{this.props.user.name}
</p>
<p style={{ marginTop: "0px", color: "#696969" }}>
{this.props.user.email}
</p>
</div>
<hr style={{ borderTop: "3px solid #bbb", marginLeft: "5px", marginRight: "5px" }} />
<MenuItem>
<Link to={"/user"} style={{ textDecoration: 'none', color: "black" }}>
{Blockly.Msg.navbar_account}
</Link>
</MenuItem>
<MenuItem>
<Link to={"/settings"} style={{ textDecoration: 'none', color: "black" }}>
{Blockly.Msg.navbar_settings}
</Link>
</MenuItem>
<MenuItem
onClick={() => {
this.props.logout()
}}
>
{Blockly.Msg.navbar_logout}
</MenuItem>
</Menu>
</div>
)
:
(<Link to={"/user/login"} style={{ textDecoration: 'none', color: "white" }}>
<IconButton
color="inherit"
style={{ margin: "0 30px 0 auto" }}
>
<FontAwesomeIcon icon={faUser} />
</IconButton>
</Link>
)
}
</div>
</Toolbar>
</AppBar>
<Drawer
@ -399,11 +211,6 @@ class Navbar extends Component {
</div>
<List>
{[
{
text: Blockly.Msg.navbar_blockly,
icon: faPuzzlePiece,
link: "/",
},
{
text: Blockly.Msg.navbar_tutorials,
icon: faChalkboardTeacher,
@ -429,11 +236,6 @@ class Navbar extends Component {
link: "/project",
restriction: this.props.isAuthenticated,
},
{
text: "Code Editor",
icon: faCode,
link: "/codeeditor",
},
].map((item, index) => {
if (
item.restriction ||
@ -451,13 +253,7 @@ class Navbar extends Component {
<ListItemIcon>
<FontAwesomeIcon icon={item.icon} />
</ListItemIcon>
{item.text === "Code Editor" ? (
<Badge badgeContent={"Experimental"} color="primary" overlap="rectangular">
<ListItemText primary={item.text} />
</Badge>
) : (
<ListItemText primary={item.text} />
)}
</ListItem>
</Link>
);
@ -550,14 +346,10 @@ class Navbar extends Component {
Navbar.propTypes = {
tutorialIsLoading: PropTypes.bool.isRequired,
projectIsLoading: PropTypes.bool.isRequired,
isAuthenticated: PropTypes.bool,
isAuthenticated: PropTypes.bool.isRequired,
user: PropTypes.object,
tutorial: PropTypes.object,
tutorial: PropTypes.object.isRequired,
activeStep: PropTypes.number.isRequired,
setLanguage: PropTypes.func.isRequired,
language: PropTypes.string.isRequired,
setBoard: PropTypes.func.isRequired,
selectedBoard: PropTypes.string.isRequired
};
const mapStateToProps = (state) => ({
@ -567,10 +359,8 @@ 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, setLanguage, setBoard })(
export default connect(mapStateToProps, { logout })(
withStyles(styles, { withTheme: true })(withRouter(Navbar))
);

View File

@ -4,11 +4,11 @@ import Breadcrumbs from './Breadcrumbs';
import { withRouter } from 'react-router-dom';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import * as Blockly from 'blockly'
import ReactMarkdown from 'react-markdown';
import Container from '@mui/material/Container';
import Container from '@material-ui/core/Container';
const news = `

View File

@ -4,8 +4,8 @@ import Breadcrumbs from './Breadcrumbs';
import { withRouter } from 'react-router-dom';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import * as Blockly from 'blockly'
class NotFound extends Component {

View File

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
import Container from '@mui/material/Container';
import Container from '@material-ui/core/Container';
class Privay extends Component {
render() {
return (

View File

@ -10,8 +10,8 @@ import { withRouter } from 'react-router-dom';
import Home from '../Home';
import Breadcrumbs from '../Breadcrumbs';
import Backdrop from '@mui/material/Backdrop';
import CircularProgress from '@mui/material/CircularProgress';
import Backdrop from '@material-ui/core/Backdrop';
import CircularProgress from '@material-ui/core/CircularProgress';
class Project extends Component {

View File

@ -11,14 +11,13 @@ import BlocklyWindow from "../Blockly/BlocklyWindow";
import Snackbar from "../Snackbar";
import WorkspaceFunc from "../Workspace/WorkspaceFunc";
import withStyles from '@mui/styles/withStyles';
import Grid from "@mui/material/Grid";
import Paper from "@mui/material/Paper";
import Divider from "@mui/material/Divider";
import Typography from "@mui/material/Typography";
import Backdrop from "@mui/material/Backdrop";
import CircularProgress from "@mui/material/CircularProgress";
import DeviceSelection from "../DeviceSelection";
import { withStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
import Divider from "@material-ui/core/Divider";
import Typography from "@material-ui/core/Typography";
import Backdrop from "@material-ui/core/Backdrop";
import CircularProgress from "@material-ui/core/CircularProgress";
const styles = (theme) => ({
link: {
@ -61,7 +60,8 @@ class ProjectHome extends Component {
this.setState({
snackbar: true,
key: Date.now(),
message: `Dein angefragtes ${type === "gallery" ? "Galerie-" : ""
message: `Dein angefragtes ${
type === "gallery" ? "Galerie-" : ""
}Projekt konnte nicht gefunden werden.`,
type: "error",
});
@ -108,7 +108,6 @@ class ProjectHome extends Component {
/>
<h1>{data}</h1>
<DeviceSelection />
{this.props.progress ? (
<Backdrop open invisible>
<CircularProgress color="primary" />
@ -128,7 +127,8 @@ class ProjectHome extends Component {
}}
>
<Link
to={`/${data === "Projekte" ? "project" : "gallery"
to={`/${
data === "Projekte" ? "project" : "gallery"
}/${project._id}`}
style={{ textDecoration: "none", color: "inherit" }}
>

View File

@ -1,41 +1,44 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Route, Redirect, withRouter } from 'react-router-dom';
import { Route, Redirect, withRouter } from "react-router-dom";
class PrivateRoute extends Component {
render() {
return !this.props.progress ? (
return (
!this.props.progress ?
<Route
{...this.props.exact}
render={({ location }) =>
this.props.isAuthenticated
? this.props.children
: (() => {
this.props.isAuthenticated ? (
this.props.children
) : (()=>{
return (
<Redirect
to={{
pathname: "/user/login",
state: { from: location },
state: { from: location }
}}
/>
);
)
})()
}
/>
) : null;
/> : null
);
}
}
PrivateRoute.propTypes = {
isAuthenticated: PropTypes.bool,
progress: PropTypes.bool.isRequired,
isAuthenticated: PropTypes.bool.isRequired,
progress: PropTypes.bool.isRequired
};
const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
isAuthenticated: state.auth.isAuthenticated,
progress: state.auth.progress,
progress: state.auth.progress
});
export default connect(mapStateToProps, null)(withRouter(PrivateRoute));

View File

@ -1,7 +1,7 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { visitPage, setPlatform } from "../../actions/generalActions";
import { visitPage } from "../../actions/generalActions";
import { Route, Switch, withRouter } from "react-router-dom";
@ -24,27 +24,8 @@ import Login from "../User/Login";
import Account from "../User/Account";
import News from "../News";
import Faq from "../Faq";
import CodeEditor from "../CodeEditor/CodeEditor";
class Routes extends Component {
componentDidMount() {
const { location } = this.props;
const query = new URLSearchParams(location.search, [location.search]);
const mode = query.get('mode');
if (!this.props.platform && mode) {
switch (mode.toLowerCase()) {
case 'tablet':
this.props.setPlatform(true);
break;
default:
break;
}
}
}
componentDidUpdate() {
this.props.visitPage();
}
@ -66,9 +47,6 @@ class Routes extends Component {
<Route path="/tutorial/:tutorialId" exact>
<Tutorial />
</Route>
<Route path="/CodeEditor" exact>
<CodeEditor />
</Route>
{/* Sharing */}
<PublicRoute path="/share/:shareId" exact>
<Project />
@ -122,13 +100,7 @@ class Routes extends Component {
}
Home.propTypes = {
visitPage: PropTypes.func,
platform: PropTypes.bool.isRequired,
setPlatform: PropTypes.func.isRequired
visitPage: PropTypes.func.isRequired,
};
const mapStateToProps = (state) => ({
platform: state.general.platform,
});
export default connect(mapStateToProps, { visitPage, setPlatform })(withRouter(Routes));
export default connect(null, { visitPage })(withRouter(Routes));

View File

@ -1,77 +0,0 @@
import React from "react";
import Box from "@mui/material/Box";
import Tab from "@mui/material/Tab";
import TabContext from "@mui/lab/TabContext";
import TabList from "@mui/lab/TabList";
import TabPanel from "@mui/lab/TabPanel";
import store from "../store";
import ReactMarkdown from "react-markdown";
import * as Blockly from "blockly";
export default function LabTabs() {
const [value, setValue] = React.useState('1');
const handleChange = (event, newValue) => {
setValue(newValue);
};
// get the description in the current language if no lang is give return english or the first one
function filterLanguage(options) {
var lang;
if (window.localStorage.getItem("locale")) {
lang = window.localStorage.getItem("locale").split("_")[0];
}
else {
lang = "en";
}
for (var i = 0; i < options.length; i++) {
if (options[i].languageCode === lang) {
return options[i].text;
}
}
return options[0].text;
}
var currentStore = store.getState();
// ALL SENSOR DATA FROM WIKI
var sensorData = currentStore.sensorwiki;
// NAME OF SELECTED BLOCK
var sensorName = currentStore.workspace.code.data.name;
// SEARCH ALL DATA FOR SELECTED BLOCK NAME
var sensorInfo = sensorData.find(function (element) {
return element.slug === sensorName;
});
if (sensorInfo) {
sensorInfo.markdown = "Coming soon...";
// GET DESCRIPTION OF SELECTED BLOCK
sensorInfo.details = `# ${sensorName.toUpperCase()}
${Blockly.Msg.sensorinfo_explanation} [${sensorName.toUpperCase()}](https://sensors.wiki/sensor/detail/${sensorName})
## ${Blockly.Msg.sensorinfo_description}
${filterLanguage(sensorInfo.description.item)}
## ${Blockly.Msg.sensorinfo_measurable_phenos}
## ${Blockly.Msg.sensorinfo_manufacturer}
${sensorInfo.manufacturer}
## ${Blockly.Msg.sensorinfo_lifetime}
${sensorInfo.lifePeriod}`
}
return (
<Box sx={{ width: '100%', typography: 'body1' }}>
<TabContext value={value}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<TabList onChange={handleChange}>
<Tab label="Basic Information" value="1" />
<Tab label="Details" value="2" />
</TabList>
</Box>
<TabPanel value="1">
{sensorInfo ? <ReactMarkdown>{sensorInfo.markdown}</ReactMarkdown> : "No data available"}
</TabPanel>
<TabPanel value="2">
{sensorInfo ? <ReactMarkdown>{sensorInfo.details}</ReactMarkdown> : "No data available"}
</TabPanel>
</TabContext>
</Box>
);
}

View File

@ -1,55 +0,0 @@
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 '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import Typography from '@mui/material/Typography';
import FormHelperText from '@mui/material/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 variant="standard">
<InputLabel id="demo-simple-select-label">{Blockly.Msg.settings_board}</InputLabel>
<Select
variant="standard"
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);

View File

@ -5,12 +5,12 @@ import { setLanguage } from '../../actions/generalActions';
import * as Blockly from 'blockly/core';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import Typography from '@mui/material/Typography';
import FormHelperText from '@mui/material/FormHelperText';
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 LanguageSelector extends Component {
@ -29,14 +29,14 @@ class LanguageSelector extends Component {
<div>
<Typography style={{fontWeight: 'bold'}}>{Blockly.Msg.settings_language}</Typography>
<FormHelperText style={{color: 'black', lineHeight: 1.3, marginBottom: '8px'}}>{Blockly.Msg.settings_language_text}</FormHelperText>
<FormControl variant="standard">
<FormControl>
<InputLabel id="demo-simple-select-label">{Blockly.Msg.settings_language}</InputLabel>
<Select
variant="standard"
labelId="demo-simple-select-label"
id="demo-simple-select"
value={this.props.language}
onChange={this.handleChange}>
onChange={this.handleChange}
>
<MenuItem value={'de_DE'}>{Blockly.Msg.settings_language_de}</MenuItem>
<MenuItem value={'en_US'}>{Blockly.Msg.settings_language_en}</MenuItem>
</Select>

View File

@ -5,12 +5,12 @@ import { setPlatform } from "../../actions/generalActions";
import * as Blockly from "blockly/core";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
import Typography from "@mui/material/Typography";
import FormHelperText from "@mui/material/FormHelperText";
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 OtaSelector extends Component {
componentDidMount() {
@ -33,16 +33,16 @@ class OtaSelector extends Component {
https://sensebox.de/app
</a>
</FormHelperText>
<FormControl variant="standard">
<FormControl>
<InputLabel id="demo-simple-select-label">
{Blockly.Msg.settings_statistics}
</InputLabel>
<Select
variant="standard"
labelId="demo-simple-select-label"
id="demo-simple-select"
value={this.props.platform}
onChange={(e) => this.props.setPlatform(e.target.value)}>
onChange={(e) => this.props.setPlatform(e.target.value)}
>
<MenuItem value={true}>{Blockly.Msg.settings_ota_on}</MenuItem>
<MenuItem value={false}>{Blockly.Msg.settings_ota_off}</MenuItem>
</Select>

View File

@ -5,12 +5,12 @@ import { setRenderer } from '../../actions/generalActions';
import * as Blockly from 'blockly/core'
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import Typography from '@mui/material/Typography';
import FormHelperText from '@mui/material/FormHelperText';
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 RenderSelector extends Component {
@ -26,14 +26,14 @@ class RenderSelector extends Component {
<div>
<Typography style={{fontWeight: 'bold'}}>{Blockly.Msg.settings_renderer}</Typography>
<FormHelperText style={{color: 'black', lineHeight: 1.3, marginBottom: '8px'}}>{Blockly.Msg.settings_renderer_text}</FormHelperText>
<FormControl variant="standard">
<FormControl>
<InputLabel id="demo-simple-select-label">{Blockly.Msg.settings_renderer}</InputLabel>
<Select
variant="standard"
labelId="demo-simple-select-label"
id="demo-simple-select"
value={this.props.renderer}
onChange={(e) => this.props.setRenderer(e.target.value)}>
onChange={(e) => this.props.setRenderer(e.target.value)}
>
<MenuItem value={'geras'}>Geras</MenuItem>
<MenuItem value={'zelos'}>Zelos</MenuItem>
</Select>

View File

@ -12,10 +12,9 @@ import RenderSelector from "./RenderSelector";
import StatsSelector from "./StatsSelector";
import OtaSelector from "./OtaSelector";
import SoundsSelector from "./SoundsSelector";
import DeviceSelector from "./DeviceSelector";
import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";
class Settings extends Component {
componentDidMount() {
@ -53,9 +52,6 @@ class Settings extends Component {
<Paper style={{ margin: "10px 0px", padding: "10px" }}>
<SoundsSelector />
</Paper>
<Paper style={{ margin: "10px 0px", padding: "10px" }}>
<DeviceSelector />
</Paper>
<Button
style={{ marginTop: "10px" }}

View File

@ -5,12 +5,12 @@ import { setSounds } from "../../actions/generalActions";
import * as Blockly from "blockly/core";
import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@mui/material/MenuItem";
import FormControl from "@mui/material/FormControl";
import Select from "@mui/material/Select";
import Typography from "@mui/material/Typography";
import FormHelperText from "@mui/material/FormHelperText";
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() {
@ -30,16 +30,16 @@ class SoundsSelector extends Component {
>
{Blockly.Msg.settings_sounds_text}
</FormHelperText>
<FormControl variant="standard">
<FormControl>
<InputLabel id="demo-simple-select-label">
{Blockly.Msg.settings_sounds}
</InputLabel>
<Select
variant="standard"
labelId="demo-simple-select-label"
id="demo-simple-select"
value={this.props.sounds}
onChange={(e) => this.props.setSounds(e.target.value)}>
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>
@ -52,7 +52,7 @@ class SoundsSelector extends Component {
SoundsSelector.propTypes = {
setSounds: PropTypes.func.isRequired,
language: PropTypes.string.isRequired,
sounds: PropTypes.bool.isRequired,
sounds: PropTypes.string.isRequired,
};
const mapStateToProps = (state) => ({

View File

@ -5,12 +5,12 @@ import { setStatistics } from '../../actions/generalActions';
import * as Blockly from 'blockly/core'
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import Typography from '@mui/material/Typography';
import FormHelperText from '@mui/material/FormHelperText';
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 StatsSelector extends Component {
@ -25,14 +25,14 @@ class StatsSelector extends Component {
<div>
<Typography style={{fontWeight: 'bold'}}>{Blockly.Msg.settings_statistics}</Typography>
<FormHelperText style={{color: 'black', lineHeight: 1.3, marginBottom: '8px'}}>{Blockly.Msg.settings_statistics_text}</FormHelperText>
<FormControl variant="standard">
<FormControl>
<InputLabel id="demo-simple-select-label">{Blockly.Msg.settings_statistics}</InputLabel>
<Select
variant="standard"
labelId="demo-simple-select-label"
id="demo-simple-select"
value={this.props.statistics}
onChange={(e) => this.props.setStatistics(e.target.value)}>
onChange={(e) => this.props.setStatistics(e.target.value)}
>
<MenuItem value={true}>{Blockly.Msg.settings_statistics_on}</MenuItem>
<MenuItem value={false}>{Blockly.Msg.settings_statistics_off}</MenuItem>
</Select>

View File

@ -1,9 +1,9 @@
import React, { Component } from 'react';
import withStyles from '@mui/styles/withStyles';
import IconButton from '@mui/material/IconButton';
import MaterialUISnackbar from '@mui/material/Snackbar';
import SnackbarContent from '@mui/material/SnackbarContent';
import { withStyles } from '@material-ui/core/styles';
import IconButton from '@material-ui/core/IconButton';
import MaterialUISnackbar from '@material-ui/core/Snackbar';
import SnackbarContent from '@material-ui/core/SnackbarContent';
import { faTimes } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@ -69,7 +69,7 @@ class Snackbar extends Component {
style={{flexWrap: 'nowrap'}}
className={this.props.type === 'error' ? this.props.classes.error : this.props.classes.success}
action={
<IconButton onClick={this.onClose} style={{color: 'inherit'}} size="large">
<IconButton onClick={this.onClose} style={{color: 'inherit'}}>
<FontAwesomeIcon icon={faTimes} size="xs"/>
</IconButton>
}

View File

@ -1,113 +1,47 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { Button, Card } from "@mui/material";
import * as Blockly from "blockly";
import CardContent from "@mui/material/CardContent";
import Typography from "@mui/material/Typography";
import ReactMarkdown from "react-markdown";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import Slide from "@mui/material/Slide";
import SensorInfo from "./SensorInfo";
import store from "../store";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
const withWidth = () => (WrappedComponent) => (props) => <WrappedComponent {...props} width="xs" />;
import withWidth from '@material-ui/core/withWidth';
const Transition = React.forwardRef(function Transition(props, ref) {
return <Slide direction="up" ref={ref} {...props} />;
});
import { Card } from '@material-ui/core';
import * as Blockly from 'blockly'
import CardContent from '@material-ui/core/CardContent';
import Typography from '@material-ui/core/Typography';
import ReactMarkdown from 'react-markdown';
class TooltipViewer extends Component {
constructor(props) {
super(props);
this.inputRef = React.createRef();
this.state = {
open: false,
};
}
toggleDialog = () => {
this.setState({ open: !this.state });
};
openDialog = () => {
this.setState({ open: true });
};
render() {
return (
<Card
className="tooltipViewer"
style={{
height: "100%",
margin: "1vH 0 0 0",
maxHeight: "19vH",
overflow: "auto",
}}
ref={this.myDiv}
>
<Card className="tooltipViewer" style={{ height: '100%', margin: '1vH 0 0 0', maxHeight: '19vH', overflow: 'auto' }} ref={this.myDiv}>
<CardContent>
<Typography variant="h5" component="h2">
{Blockly.Msg.tooltip_viewer}
</Typography>
<Typography variant="body2" component="p">
<ReactMarkdown linkTarget="_blank">{this.props.tooltip}</ReactMarkdown>
{this.props.helpurl !== '' ? <ReactMarkdown>{`${Blockly.Msg.tooltip_moreInformation} [${Blockly.Msg.labels_here}](${this.props.helpurl})`}</ReactMarkdown> : null}
<Typography variant="body2" component="span">
<ReactMarkdown linkTarget="_blank">
{this.props.tooltip}
</ReactMarkdown>
{store.getState().workspace.code.data ? (
<Button
label="Mehr"
variant="contained"
color="primary"
onClick={() => {
this.openDialog();
}}
>
Sensor Informationen
</Button>
) : (
<ReactMarkdown>{`${Blockly.Msg.tooltip_moreInformation} [${Blockly.Msg.labels_here}](${this.props.helpurl})`}</ReactMarkdown>
)}
</Typography>
</CardContent>
{store.getState().workspace.code.data ? (<Dialog
open={this.state.open}
TransitionComponent={Transition}
keepMounted
aria-describedby="alert-dialog-slide-description"
onClose={() => {
this.toggleDialog();
}}
maxWidth={"md"}
fullWidth={true}
>
<DialogContent>
<SensorInfo></SensorInfo>
</DialogContent>
<DialogActions>
<Button onClick={() => {
this.toggleDialog();
}}>Close</Button>
</DialogActions>
</Dialog>) : (null)}
</Card>
);
}
};
}
TooltipViewer.propTypes = {
tooltip: PropTypes.string.isRequired,
helpurl: PropTypes.string.isRequired,
helpurl: PropTypes.string.isRequired
};
const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
tooltip: state.workspace.code.tooltip,
helpurl: state.workspace.code.helpurl,
helpurl: state.workspace.code.helpurl
});
export default connect(mapStateToProps, null)(withWidth()(TooltipViewer));

Some files were not shown because too many files have changed in this diff Show More