1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add port labels to inject node (to show types)

This commit is contained in:
Dave Conway-Jones 2017-03-03 10:21:07 +00:00
parent 84077505b0
commit 4a8a5ed8d4

View File

@ -181,9 +181,21 @@
crontab: {value:""},
once: {value:false}
},
icon: "inject.png",
inputs:0,
outputs:1,
icon: "inject.png",
outputLabels: function(index) {
var labels = { str:"string", num:"number", bool:"boolean", json:"object", flow:"flow context", global:"global context" };
var lab = labels[this.payloadType] || this.payloadType;
if (lab === "object") {
try {
lab = typeof JSON.parse(this.payload);
if (lab === "object") {
if (Array.isArray(JSON.parse(this.payload))) { lab = "Array"; }
}
} catch(e) { lab = "Invalid JSON Object"; }
}
return lab; },
label: function() {
var suffix = "";
// if fire once then add small indication