change block data to json
This commit is contained in:
parent
a8704316ac
commit
9ac98aa06d
@ -28,6 +28,7 @@ export const onChangeCode = () => (dispatch, getState) => {
|
||||
} else if (selectedBlock === null) {
|
||||
code.tooltip = Blockly.Msg.tooltip_hint
|
||||
code.helpurl = ''
|
||||
code.data = null
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ 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 = "hdc1080";
|
||||
this.data = {name: "hdc1080", connection: "I2C"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -52,7 +52,7 @@ 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 = "veml6070";
|
||||
this.data = {name: "veml6070"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -93,7 +93,7 @@ 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 = "bmx055";
|
||||
this.data = {name: "bmx055"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -125,7 +125,7 @@ Blockly.Blocks["sensebox_sensor_sds011"] = {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sds011_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sds011_helpurl);
|
||||
this.data = "sds011";
|
||||
this.data = {name: "sds011"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -159,7 +159,7 @@ 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 = "bmp280";
|
||||
this.data = {name: "bmp280"};
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
@ -206,7 +206,7 @@ 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 = "bme680";
|
||||
this.data = {name: "bme680"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -251,7 +251,7 @@ 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 = "hc-sr04";
|
||||
this.data = {name: "hc-sr04"};
|
||||
},
|
||||
/**
|
||||
* Parse XML to restore the number of pins available.
|
||||
@ -389,7 +389,7 @@ Blockly.Blocks["sensebox_scd30"] = {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_scd_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_scd_helpurl);
|
||||
this.data = "scd30";
|
||||
this.data = {name: "scd30"};
|
||||
},
|
||||
onchange: function (e) {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
@ -456,7 +456,7 @@ 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 = "smt50";
|
||||
this.data = {name: "smt50"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -479,7 +479,7 @@ Blockly.Blocks["sensebox_sensor_watertemperature"] = {
|
||||
.appendField(new Blockly.FieldDropdown(dropdownOptions), "Port");
|
||||
this.setOutput(true, Types.NUMBER.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_watertemperature_tip);
|
||||
this.data = "ds18b20";
|
||||
this.data = {name: "ds18b20"};
|
||||
},
|
||||
};
|
||||
|
||||
@ -552,7 +552,7 @@ 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 = "dps310";
|
||||
this.data = {name: "dps310"};
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
|
@ -16,36 +16,35 @@ export default function LabTabs() {
|
||||
setValue(newValue);
|
||||
};
|
||||
|
||||
// get the description in the current language if no lang is give return english
|
||||
// get the description in the current language if no lang is give return english or the first one
|
||||
function filterLanguage(options) {
|
||||
console.log(options);
|
||||
var lang;
|
||||
if (window.localStorage.getItem("locale")) {
|
||||
var lang = window.localStorage.getItem("locale").split("_")[0];
|
||||
lang = window.localStorage.getItem("locale").split("_")[0];
|
||||
}
|
||||
else {
|
||||
var lang = "en";
|
||||
lang = "en";
|
||||
}
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
console.log(options[i].languageCode, lang);
|
||||
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;
|
||||
var sensorName = currentStore.workspace.code.data.name;
|
||||
// SEARCH ALL DATA FOR SELECTED BLOCK NAME
|
||||
var sensorInfo = sensorData.find(function (element) {
|
||||
return element.slug === sensorName;
|
||||
});
|
||||
console.log("SENSOR INFO: ", sensorInfo);
|
||||
if (sensorInfo) {
|
||||
sensorInfo.markdown = "# Markdown Test \n ## Markdown Test 2 \n ### Markdown Test 3";
|
||||
|
||||
// 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}
|
||||
|
@ -57,7 +57,6 @@ class TooltipViewer extends Component {
|
||||
<ReactMarkdown linkTarget="_blank">
|
||||
{this.props.tooltip}
|
||||
</ReactMarkdown>
|
||||
|
||||
{store.getState().workspace.code.data ? (
|
||||
<Button
|
||||
label="Mehr"
|
||||
@ -74,7 +73,7 @@ class TooltipViewer extends Component {
|
||||
)}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<Dialog
|
||||
{store.getState().workspace.code.data ? (<Dialog
|
||||
open={this.state.open}
|
||||
TransitionComponent={Transition}
|
||||
keepMounted
|
||||
@ -93,7 +92,7 @@ class TooltipViewer extends Component {
|
||||
this.toggleDialog();
|
||||
}}>Close</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Dialog>) : (null)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user