action blocks converted

This commit is contained in:
Loren Norman 2025-07-17 12:45:27 -04:00
parent 2f4743cd13
commit 0522e0d919
6 changed files with 82 additions and 133 deletions

View file

@ -1,19 +1,9 @@
export default {
type: "action_log",
toolbox: {
category: 'Actions',
},
visualization: {
colour: "0",
tooltip: [
"Executes the block you plug in and reveals its final value or error message.",
"---------------",
"Parameters:",
"EXPRESSION - a block you'd like to see the resolved value of"
].join('\n'),
},
bytecodeKey: "logAction",
name: "Log",
colour: "0",
description: "Executes the block you plug in and reveals its final value or error message.",
connections: {
mode: "statement",
@ -21,13 +11,14 @@ export default {
next: 'expression'
},
lines: [
["Log:", {
inputValue: 'EXPRESSION',
// check: ['expression', 'String'],
template: "Log: %EXPRESSION",
inputs: {
EXPRESSION: {
description: "A Block diagram you'd like to see the resolved value and type of.",
shadow: 'io_text'
}]
],
}
},
generators: {
json: (block, generator) => {

View file

@ -1,17 +1,10 @@
// deprecated: use feeds/set_value
export default {
type: "action_publish",
visualization: {
colour: "0",
tooltip: [
"Sends a given VALUE to a given FEED.",
"---------------",
"Parameters:",
"VALUE - the value to write",
"FEED - the feed to write to",
].join('\n'),
},
bytecodeKey: "publishAction",
name: "Publish to Feed",
colour: "0",
description: "Sends the given value to the specified Feed.",
connections: {
mode: "statement",
@ -19,21 +12,23 @@ export default {
next: 'expression'
},
lines: [
[ "📈 Publish", "CENTER" ],
template: `
📈 Publish |CENTER
...value: %VALUE
...to: %FEED
`,
[ "...value:", {
inputValue: "VALUE",
// check: [ "String", "Number" ],
inputs: {
VALUE: {
description: "The value to write to the Feed.",
shadow: 'io_text'
}],
},
[ "...to:", {
inputValue: "FEED",
// check: "feed",
FEED: {
description: "The Feed to write to.",
shadow: 'feed_selector'
}]
],
},
},
generators: {
json: (block, generator) => {

View file

@ -1,20 +1,13 @@
import { multilineLineTemplate } from "#app/blocks/shadows.js"
export default {
type: "action_sms",
toolbox: {
category: 'Actions',
},
visualization: {
colour: "0",
tooltip: [
"(IO+ only)",
"Sends a text message with a given BODY template.",
"---------------",
"Parameters:",
"BODY - a template for generating the SMS body",
].join('\n')
},
bytecodeKey: "smsAction",
name: "SMS",
colour: "0",
description: "Sends a text message with a given body template.",
ioPlus: true,
connections: {
mode: "statement",
@ -22,25 +15,17 @@ export default {
next: 'expression'
},
lines: [
[ "📲 SMS", "CENTER" ],
template: `
📲 SMS |CENTER
Message: %BODY
`,
[ "Message:", {
inputValue: "BODY",
// check: "String",
shadow: {
type: 'text_template',
inputs: { TEMPLATE: {
shadow: {
type: 'io_text_multiline',
fields: {
TEXT: ' \n\n\n'
}
}
}}
}
}],
],
inputs: {
BODY: {
description: "A template for generating the SMS body",
shadow: multilineLineTemplate
}
},
generators: {
json: (block, generator) => {

View file

@ -1,21 +1,12 @@
import { multilineLineTemplate } from "#app/blocks/shadows.js"
export default {
type: "action_webhook",
toolbox: {
category: 'Actions',
},
visualization: {
colour: "0",
tooltip: [
"Sends an HTTP POST request to a given URL, with a BODY template using FEED data.",
"---------------",
"Parameters:",
"URL - a valid web location to send a request to",
"BODY - a JSON template to render and POST",
"FORM_ENCODE - optionally encode as form input",
].join('\n')
},
bytecodeKey: "webhookAction",
name: "Webhook",
colour: "0",
description: "Sends an HTTP POST request to a given URL, with a BODY template using FEED data.",
connections: {
mode: "statement",
@ -23,41 +14,35 @@ export default {
next: 'expression'
},
lines: [
[ "🔗 Webhook", "CENTER" ],
[ "URL:", {
inputValue: "URL",
// check: "String",
template: `
🔗 Webhook |CENTER
URL: %URL
Form Encode? %FORM_ENCODE
POST Body: %BODY
`,
inputs: {
URL: {
description: "A valid web location to send a POST request to.",
shadow: {
type: 'io_text',
fields: { TEXT: 'https://...' }
}
}],
},
[ "Form Encode?", {
field: "FORM_ENCODE",
BODY: {
description: "A JSON template to render and POST",
shadow: multilineLineTemplate
}
},
fields: {
FORM_ENCODE: {
description: "Encode as an HTML form input",
checked: false
}],
[ "POST Body:", {
inputValue: "BODY",
// check: "String",
shadow: {
type: 'text_template',
inputs: {
TEMPLATE: {
shadow: {
type: 'io_text_multiline',
fields: {
TEXT: ' \n\n\n'
}
}
}
}
}
}],
],
}
},
generators: {
json: (block, generator) => {

View file

@ -51,7 +51,7 @@ Type: \`${definition.type}\`
${ renderDescription(definition) }
${ renderIOPlusAlert(definition)}
${ renderIOPlusAlert(definition) }
## Workspace
${ renderWorkspace(definition) }

View file

@ -37,7 +37,7 @@ exports[`Block Snapshots > Blockly JSON > action_log 1`] = `
"inputsInline": false,
"type": "action_log",
"colour": "0",
"tooltip": "Executes the block you plug in and reveals its final value or error message.\\n---------------\\nParameters:\\nEXPRESSION - a block you'd like to see the resolved value of",
"tooltip": "Executes the block you plug in and reveals its final value or error message.",
"nextStatement": "expression",
"previousStatement": "expression",
"message0": "Log: %1",
@ -56,7 +56,7 @@ exports[`Block Snapshots > Blockly JSON > action_publish 1`] = `
"inputsInline": false,
"type": "action_publish",
"colour": "0",
"tooltip": "Sends a given VALUE to a given FEED.\\n---------------\\nParameters:\\nVALUE - the value to write\\nFEED - the feed to write to",
"tooltip": "Sends the given value to the specified Feed.",
"nextStatement": "expression",
"previousStatement": "expression",
"message0": "📈 Publish %1",
@ -146,7 +146,7 @@ exports[`Block Snapshots > Blockly JSON > action_sms 1`] = `
"inputsInline": false,
"type": "action_sms",
"colour": "0",
"tooltip": "(IO+ only)\\nSends a text message with a given BODY template.\\n---------------\\nParameters:\\nBODY - a template for generating the SMS body",
"tooltip": "Sends a text message with a given body template.",
"nextStatement": "expression",
"previousStatement": "expression",
"message0": "📲 SMS %1",
@ -172,7 +172,7 @@ exports[`Block Snapshots > Blockly JSON > action_webhook 1`] = `
"inputsInline": false,
"type": "action_webhook",
"colour": "0",
"tooltip": "Sends an HTTP POST request to a given URL, with a BODY template using FEED data.\\n---------------\\nParameters:\\nURL - a valid web location to send a request to\\nBODY - a JSON template to render and POST\\nFORM_ENCODE - optionally encode as form input",
"tooltip": "Sends an HTTP POST request to a given URL, with a BODY template using FEED data.",
"nextStatement": "expression",
"previousStatement": "expression",
"message0": "🔗 Webhook %1",
@ -2695,9 +2695,9 @@ exports[`Block Snapshots > Blockly JSON > io_math_arithmetic 1`] = `
"inputsInline": true,
"type": "io_math_arithmetic",
"colour": 120,
"tooltip": "Perform the specified arithmetic operation on two specified operands.\\n-\\nInputs:\\n---------------\\nNumber A - the first input\\nOperation - the operation to perform on the operands\\n+ addition\\n- subtraction\\nx multiplication\\n/ division\\n^ exponent\\nNumber B - the second input",
"tooltip": "Perform the specified arithmetic operation on two specified operands.",
"output": null,
"message0": " %1",
"message0": "%1",
"args0": [
{
"type": "input_value",
@ -2734,13 +2734,6 @@ exports[`Block Snapshots > Blockly JSON > io_math_arithmetic 1`] = `
],
"text": ""
},
{
"type": "input_dummy",
"align": "RIGHT"
}
],
"message2": " %1",
"args2": [
{
"type": "input_value",
"name": "B",