Skip to content

Commit

Permalink
chore: release v8.2.0
Browse files Browse the repository at this point in the history
* (PeterVoronov) Added toArray to result object of $-selector
* (klein0r) Added Blockly block for onLog
  • Loading branch information
klein0r committed May 7, 2024
1 parent 5e205b1 commit 4f4547a
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG_OLD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
The newest change log is in README.md
## 8.0.1 (2024-04-08)

* (klein0r) Fixed some missing translations (uk)
* (klein0r) Raised supported ecmaVersion from es2021 to es2022 (node18)

## 8.0.0 (2024-04-05)

NodeJS >= 18.x and js-controller >= 5 is required
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
### 8.2.0 (2024-05-07)

* (PeterVoronov) Added toArray to result object of $-selector
* (klein0r) Added Blockly block for onLog
Expand All @@ -63,11 +63,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the

* (klein0r) Forced downgrade of socket-client (object change issues)

### 8.0.1 (2024-04-08)

* (klein0r) Fixed some missing translations (uk)
* (klein0r) Raised supported ecmaVersion from es2021 to es2022 (node18)

## License
The MIT License (MIT)

Expand Down
10 changes: 5 additions & 5 deletions admin/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files": {
"main.js": "/static/js/main.14858ad5.js",
"main.js": "/static/js/main.567b63d3.js",
"static/css/373.d5afd7f9.chunk.css": "/static/css/373.d5afd7f9.chunk.css",
"static/js/373.b2a9ea25.chunk.js": "/static/js/373.b2a9ea25.chunk.js",
"static/js/373.121bcab3.chunk.js": "/static/js/373.121bcab3.chunk.js",
"static/js/966.088c1225.chunk.js": "/static/js/966.088c1225.chunk.js",
"static/js/30.8bf17a3b.chunk.js": "/static/js/30.8bf17a3b.chunk.js",
"static/js/704.4ede9892.chunk.js": "/static/js/704.4ede9892.chunk.js",
Expand Down Expand Up @@ -162,9 +162,9 @@
"static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
"static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
"static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
"main.14858ad5.js.map": "/static/js/main.14858ad5.js.map",
"main.567b63d3.js.map": "/static/js/main.567b63d3.js.map",
"373.d5afd7f9.chunk.css.map": "/static/css/373.d5afd7f9.chunk.css.map",
"373.b2a9ea25.chunk.js.map": "/static/js/373.b2a9ea25.chunk.js.map",
"373.121bcab3.chunk.js.map": "/static/js/373.121bcab3.chunk.js.map",
"966.088c1225.chunk.js.map": "/static/js/966.088c1225.chunk.js.map",
"30.8bf17a3b.chunk.js.map": "/static/js/30.8bf17a3b.chunk.js.map",
"704.4ede9892.chunk.js.map": "/static/js/704.4ede9892.chunk.js.map",
Expand Down Expand Up @@ -197,6 +197,6 @@
"516.837647f3.chunk.js.map": "/static/js/516.837647f3.chunk.js.map"
},
"entrypoints": [
"static/js/main.14858ad5.js"
"static/js/main.567b63d3.js"
]
}
142 changes: 139 additions & 3 deletions admin/google-blockly/own/blocks_trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Blockly.Trigger = {
HUE: 330,
blocks: {},
WARNING_PARENTS: [
'on', 'on_ext', 'schedule', 'schedule_by_id', 'schedule_create', 'astro', 'onMessage', 'onFile', // trigger blocks
'on', 'on_ext', 'schedule', 'schedule_by_id', 'schedule_create', 'astro', 'onMessage', 'onFile', 'onLog', // trigger blocks
'timeouts_setinterval', 'timeouts_setinterval_variable', // timeouts
'controls_repeat_ext', 'controls_repeat_ext', 'controls_for', 'controls_forEach', // loops
],
Expand Down Expand Up @@ -269,7 +269,7 @@ Blockly.Blocks['on_ext'] = {
this.inputList.push(input);
} else {
this.appendStatementInput('STATEMENT')
.setCheck(null)
.setCheck(null);
}
},
/**
Expand Down Expand Up @@ -1302,7 +1302,7 @@ Blockly.Blocks['onFile_data'] = {
this.setInputsInline(true);
this.setOutput(true);
this.setColour(Blockly.Trigger.HUE);
this.setTooltip(Blockly.Translate('onFile_datatooltip'));
this.setTooltip(Blockly.Translate('onFile_data_tooltip'));
//this.setHelpUrl(getHelp('onFile_data'));
},
/**
Expand Down Expand Up @@ -1392,3 +1392,139 @@ Blockly.JavaScript['offFile'] = function (block) {

return `offFile(${value_objectid}${objectName ? ` /* ${objectName} */` : ''}, ${file});\n`;
};

// --- onLog -----------------------------------------------------------
Blockly.Trigger.blocks['onLog'] =
'<block type="onLog">'
+ ' <value name="Severity">'
+ ' </value>'
+ ' <value name="STATEMENT">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['onLog'] = {
init: function() {
this.appendDummyInput('TEXT')
.appendField('💬 ' + Blockly.Translate('onLog'));

this.appendDummyInput('Severity')
.appendField(Blockly.Translate('loglevel'))
.appendField(new Blockly.FieldDropdown([
[Blockly.Translate('loglevel_error'), 'error'],
[Blockly.Translate('loglevel_warn'), 'warn'],
[Blockly.Translate('loglevel_info'), 'info'],
[Blockly.Translate('loglevel_debug'), 'debug'],
[Blockly.Translate('loglevel_all'), '*'],
]), 'Severity');

this.appendStatementInput('STATEMENT')
.setCheck(null);

this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(false);
this.setColour(Blockly.Trigger.HUE);
this.setTooltip(Blockly.Translate('onLog_tooltip'));
this.setHelpUrl(getHelp('onLog_help'));
},
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!Blockly.Events.Abstract} e Change event.
* @this Blockly.Block
*/
onchange: function(e) {
let legal = true;

// Is the block nested in a trigger?
let block = this;
while (block = block.getSurroundParent()) {
if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
legal = false;
break;
}
}

if (legal) {
this.setWarningText(null, this.id);
} else {
this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
}
}
};

Blockly.JavaScript['onLog'] = function (block) {
const logLevel = block.getFieldValue('Severity');
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');

return `onLog('${logLevel}', async (data) => {\n` +
statement +
'});\n';
};

// --- onLog_data -----------------------------------------------------------
Blockly.Trigger.blocks['onLog_data'] =
'<block type="onLog_data">'
+ ' <value name="ATTR">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['onLog_data'] = {
/**
* Block for conditionally returning a value from a procedure.
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField('💬 ');

this.appendDummyInput('ATTR')
.appendField(new Blockly.FieldDropdown([
[Blockly.Translate('onLog_data_message'), 'data.message'],
[Blockly.Translate('loglevel'), 'data.severity'],
[Blockly.Translate('onLog_data_from'), 'data.from'],
[Blockly.Translate('onLog_data_ts'), 'data.ts'],
]), 'ATTR');

this.setInputsInline(true);
this.setOutput(true);
this.setColour(Blockly.Trigger.HUE);
this.setTooltip(Blockly.Translate('onLog_data_tooltip'));
//this.setHelpUrl(getHelp('onLog_data_help'));
},
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!Blockly.Events.Abstract} e Change event.
* @this Blockly.Block
*/
onchange: function(e) {
let legal = false;
// Is the block nested in a trigger?
let block = this;
do {
if (this.FUNCTION_TYPES.includes(block.type)) {
legal = true;
break;
}
block = block.getSurroundParent();
} while (block);

if (legal) {
this.setWarningText(null, this.id);
} else {
this.setWarningText(Blockly.Translate('onLog_data_warning'), this.id);
}
},
/**
* List of block types that are functions and thus do not need warnings.
* To add a new function type add this to your code:
* Blockly.Blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func');
*/
FUNCTION_TYPES: ['onLog'],
};
Blockly.JavaScript['onLog_data'] = function(block) {
const attr = block.getFieldValue('ATTR');

return [attr, Blockly.JavaScript.ORDER_ATOMIC];
};
Loading

0 comments on commit 4f4547a

Please sign in to comment.