Text from dashboard not showing sub-property from payload - node.js

I've been using dashboard's Text node to show msg.payload.time in web-ui without any issues. However, I recently updated my dashboard to version 2.3.10 and now my Text node is not showing anything.
This is my data model:
{
"topic": "agent/last-download",
"payload": {
"time": "2017-05-15 16:48:43",
"name": "dummy name",
"path": "/mnt/externalDrive/dummyFolder"
},
"qos": 0,
"retain": true,
"_topic": "agent/last-download",
"_msgid": "1c476895.e3b897"
}
This is how I'm setting Value format:
{{msg.payload.time}}
When I output msg.payload.time to debug node, it works fine. Or if I set msg.payload to Text then it also works but dumps complete payload as text - which is not my requirement. I've also tested setting msg.topic, msg._msgid and etc. to Text and they all work fine.
Any idea why the behavior is changed? or Is there any other way to retrieve payload's sub values?

This is a regression in behaviour in the 2.3.10.
Until a fix is released, you can add a Change node ahead of the ui_text node to move msg.payload.time to msg.payload and the value will be displayed.

Related

How can I send documents with http request to power automate?

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

Read user entered input in blockly block

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

Web push messaging.setBackgroundMessageHandler not working

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",
}

Buildfire: Private Portal plugin

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

flot gets the data from json but shows blank graph

This is the code, when i mannually paste the json data inplace of series the graph is obtained but through ajax call am able to get the json data but the chart is blank.
$(document).ready(function(){
$.ajax({
url:"sqljson.php",
method:"GET",
datatype:"json",
success:graph
})
function graph(series){
var data=series;
alert(series);
var options={
lines:{show:true},
points:{show:true,hoverable:true},
grid:{hoverable:true,clickable:true}
}
$.plot($("#place"),[data], options);
}
});
json data:obtained on the alert window
[["253","5"],["254","32"],["255","10"],["256","50"],["257","1"],["258","2"["259","100"],["260","38"],["261","2"],["262","20"],["263","2000"],["264","500"], ["265","400"],["266","10"],["267","50"],["268","9"],["269","200"],["270","40"]["271","700"],["272","188"],["273","73"]]
As per the Flot FAQ:
Q: Flot isn't working when I'm using JSON data as source!
A: Actually, Flot loves JSON data, you just got the format wrong.
Double check that you're not inputting strings instead of numbers,
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
the error might not show up immediately because Javascript can do some
conversion automatically.
You need to change your output JSON so there are no quotes, i.e.:
[[253,5],[254,32],[255,10],[256,50],[257,1],[258,2],[259,100],[260,38],[261,2],[262,20],[263,2000],[264,500],[265,400],[266,10],[267,50],[268,9],[269,200],[270,40][271,700],[272,188],[273,73]]
However, this may not do it, it needs to be in a format similar to this, so:
{
"label": "example",
"data": [[253,5],[254,32],[255,10],[256,50],[257,1],[258,2],[259,100],[260,38],[261,2],[262,20],[263,2000],[264,500],[265,400],[266,10],[267,50],[268,9],[269,200],[270,40][271,700],[272,188],[273,73]]
}

Resources