I have the below code in my blockly.js file
Blockly.Blocks['account_number'] = {
// Other type.
init: function() {
this.jsonInit({
"message0": "account_number %1",
"args0": [{"type": "field_input", "name": "TYPE", "text": ""}],
"output": "Type",
"colour": 320,
"tooltip": "Custom type to allow.",
"helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=702"
});
}
};
I am using this in my index.html as follows
<category name="sender" colour="%{BKY_MATH_HUE}">
<block type="account_number" name="accnum"></block>
</category>
How can I get the user entered number in the account number block in this js file?
The short answer:
Blockly.JavaScript['account_number'] = function(block) {
var code = block.getFieldValue('TYPE');
return code;
}
(You appear to have named your field "TYPE", by the way - are you entirely sure that's what you want to name it?)
The medium answer: include the above, and generate the JavaScript for your workspace by getting your workspace and using:
var generatedCode = Blockly.JavaScript.workspaceToCode(workspace);
in wherever you are trying to generate your JavaScript.
The long answer is that if that isn't enough to get you started, I'll need to see a bit more about how you're trying to generate your code and what you're going to do with it.
These links may also be helpful, if you haven't checked them out already:
https://developers.google.com/blockly/guides/configure/web/custom-blocks#add_generator_function
https://developers.google.com/blockly/guides/create-custom-blocks/generating-code
Related
How can I send array documents and images with an HTTP request to power automate?
I am using type script with nodejs as backend.
Please see the code I am using below:
Services.ts:
sendEmailData( Notice_ID: string, Site_Notice_ID: string,EmailAddress:
string,Issued_To: string,Issue_To_Email: string,Description: string,Documents: any){
const postData: Post = {Notice_ID:Notice_ID, Site_Notice_ID:
Site_Notice_ID,EmailAddress: EmailAddress,Issued_To:Issued_To,
Issue_To_Email: Issue_To_Email,Description:Description, Documents: Documents};
this.http.post(this.SendEmailUrl, postData).subscribe(responseData => {
console.log(responseData)
});
}
Component.ts:
sendEmail(){
// console.log(emailData)
let Description = (document.getElementById("input2") as HTMLInputElement).value
this.postsService.sendEmailData(
emailData.Notice_ID,
emailData.Site_Notice_ID,
emailData.EmailAddress,
emailData.Issued_To,
emailData.Issue_To_Email,
Description,
this.Documents)
}
Power automate HTTP received sample:
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [
{},
{},
{}
]
}
You wanna send documents to PWA flow, right? What is the origin format and what format do you want to save these documents in? Where do you want to save them?
I'm considering you want to send them to PWA by a post request and save it in a OneDrive Business' folder.
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [ {"$content-type":"application/pdf","$content":"your base64 encoded
file here"}]
}
You can take a look at the complete example: https://api.npoint.io/073b1351d9b0cd0c7f88
Then, add the key "Documents" to a variable, like this:
Create an "apply to each" action to run your "documents" list.
For each dictionary in your document list, create a file:
In the "file content" field you can put the "Current action" variable.
Don't forget to create a counter or find some other way to name your created files with different names. You can also bring them named from your application and use the JSON body below:
"Documents": [ {"filename":"myfile.pdf","file":{"$content-
type":"application/pdf","$content":"your base64 encoded
file here"}}]
And set the filename in the "Apply to each":
Change the "file content":
You can use this website for generating base64 encoded files for testing your flow: https://base64.guru/converter/encode/pdf
I am using the config.json for the 1st time. from the library https://www.npmjs.com/package/config
Besides the Server Url's , id,password and all other Constants, I want to store there a query but I would like to have an opportunity to change some of the parameters in it:
"queryExample": {
"interval": "",
"order": "desc",
"paging": {
"pageSize": 100,
"pageNumber": 1
}
}
In this case I will need to set the values for the interval and then, when paginating, increment the pageNumber.
I've tried :
let query = config.get("queryExample");
query.interval = interval;
console.log(query);
as well as :
let query = config.queryExample;
config.queryExample.interval = interval;
console.log(config.agentsQuery);
in multiple variations but I cannot make the interval appear.
I am sure that interval arrives to the function.
Should my solution be rather create a local variable in the code and change pageNumber interval etc there or Is there a way to change it in .config/default. json?
Please help :_|
You need to place your config file as /config/default.json. Config has a few "opinions" on the naming and placement of your config file. Y Read more here
I implemented web-push notifications on my site with Google Firebase service.
firebase.google.com/docs/cloud-messaging/js/client
I tested it and everything works fine, but when my website window isn't in focus (it's in background) or closed and if I get push-notification it will disappear after 20 seconds.
In my https://hdlava.me/j/firebase_subscribe.js file I added
requireInteraction: true
flag in messaging.onMessage so if I get push mesage when my website is open the message won't disappear until I click on it.
I tried to add this
requireInteraction: true
in messaging.setBackgroundMessageHandler in my https://hdlava.me/firebase-messaging-sw.js, but it's not working. Even:
console.log('[firebase-messaging-sw.js] Received background message ', payload)
doesn't work. It looks like whole messaging.setBackgroundMessageHandler does not work.
Can someone please help me figure out what is the problem ? Also if I use in firebase-messaging-sw.js
self.addEventListener("push",function(event)
instead messaging.setBackgroundMessageHandler so I have two messges at once. First message disappears and second one doesn't, but second one is not clickable. Is it possible to prevent first message and make second one to be clickable ?
Referring to the FCM docs:
https://firebase.google.com/docs/cloud-messaging/js/receive
"Note: If you set notification fields in your HTTP or XMPP send request, those values take precedence over any values specified in the service worker."
So, if you have
{
"notification": {
"title": "Your title",
"body": "Your message"
},
"to": "topic",
}
It never triggers the BackgroundMessageHandler. Because sending data this way, simply overrides your variables. If you want to trigger it you need to send your notification like this:
{
"data": {
"notification": {
"title": "Your title",
"body": "Your message"
}
},
"to": "topic",
}
I am having a very specific issue with a gateway plugin I am trying to finish.
I am trying to navigate to a different plugin using
'buildfire.pluginInstance.get($scope.deepLinnk,function (err, plugin) {
if (err) {
$scope.status = 'error!';
}
else {
console.log(plugin);
$scope.navigateSignIn(plugin);}
});
$scope.navigateSignIn = function (plugin) {
buildfire.navigation.navigateTo({
pluginId: plugin.token,
instanceId: plugin.instanceId,
title: plugin.title,
folderName: plugin.pluginTypeId
});
};
The navigateTo object is the only way I can get buildfire.navigate.navigateTo to work for buildfire made plugins.
However, when I try to navigate to plugins that I have created, the debugger shows and an alert saying "cannot load config file" then the entire platform crashes and makes me sign in again.
How can I navigate to plugins that I have created?
How are you getting the pluginId, instanceId and folderName? You cant simply save them or hard code them in. You need to initiate a dynamic data lookup see https://github.com/BuildFire/sdk/wiki/How-to-use-the-Datastore-Dynamic-Data
also you can look at an example such as the folder plugin https://github.com/BuildFire/folderPlugin/blob/d84551feb06cfc304c325480ca96d87795a66929/widget/widget.controller.js#L163
Basically every time a plugin is updated the plugin identifiers like folderName or title may change. So you need to keep your reference data fresh using dynamic data.
Here is a simple example that may draw a better picture. If you are referencing a plugin titled "Holiday Sales" so you save to your datastore collection {title: "Holiday Sales"} and hence forth refer to it by that title. This may work for a short period of time. However, if the app owner changes the title to "Summer Sale" now your copy is out-of-date. In traditional databases you would have 2 tables one with the source of truth and the other would have a foreign key referencing the first table. This way you join and always display the latest data.
Dynamic data is sort of an assisted lookup for you. You simply give it a key and what that key references. Then at run time when you make the call it will make the lookup you need server side and return to you the latest data you are looking for.
sample:
buildfire.datastore.save("MyData",{
_buildfire: { /// key identifier
myPluginsToNavTo: {
data:["123123-123123","asdasda-asdasd"] /// plugin instances
,dataType: "pluginInstance"
}
}
});
======
buildfire.datastore.getWithDynamicData("MyData",function(err,data){
// data would be:
/*
_buildfire: { /// key identifier
myPluginsToNavTo: {
data:["55f71347d06b61b4010351dc","asdasda-asdasd"]
,dataType: "pluginInstance"
,result: [ /// <=============new property added dynamically
{
"id": "55f71347d06b61b4010351dc",
"data": {
"pluginTypeId": 3212,
"token": "6372b101-addf-45da-bb0a-9208a09e7b6b",
"title": "YouTube Plugin",
"iconUrl": "http://s3-us-west-2.amazonaws.com/pluginserver/plugins/6372b101-addf-45da-bb0a-9208a09e7b6b/resources/image.png",
}
,{
"id": "asdasda-asdasd",
"data": {
"pluginTypeId": 123123,
"token": "1223123123-addf-45da-bb0a-9208a09e7b6b",
"title": "Plugin 2",
"iconUrl": "...",
}
}
}
]
}
}
*/
});
hope this helps
Hopefully someone has an answer because looking at the example code in the documentation and the 'Free Icons' script I just can't see how this isn't working.
My issue is I am trying to create a beanie (hat). This beanie is made up of a number of different sections which I have stored in a variable named 'beanie' like so:
beanie = {
section1: "PATH CO-ORDINATES",
section2: "PATH CO-ORDINATES",
section3: "PATH CO-ORDINATES"
};
Basically the same way the 'Free Icons' are done as mentioned previously. I have then looped through all sections and created each on the paper like so:
for (var section in beanie) {
activeSection = beanieWindow.path(beanie[section]).attr({
'fill': '#ffffff',
'stroke': 'none'
})
.data('section', beanie[section])
.click(function () {
makeActiveSection(this);
})
.hover(
function () {
this.attr('stroke', 'red');
},
function () {
this.attr('stroke', 'none');
}
);
}
This this all works wonderfully, but when inspecting the paths there is no data-section attribute added - not even an 'id' attribute, which Neil mentions in his answer on Raphael, after assigning data, i am not able to get it that the id is provided by Raphael.
Not sure if I'm missing something obvious, but if I am I just can't see it :-/
Any help would be much appreciated!
Thanks in advance,
Mat