mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Corrected output label logic
This commit is contained in:
parent
2efc2bc186
commit
3e898c487a
@ -168,21 +168,38 @@
|
|||||||
inputs:0,
|
inputs:0,
|
||||||
outputs:1,
|
outputs:1,
|
||||||
outputLabels: function(index) {
|
outputLabels: function(index) {
|
||||||
var lab = this.payloadType;
|
var lab = '';
|
||||||
if (lab === "json") {
|
|
||||||
try {
|
// if only payload and topic - display payload type
|
||||||
lab = typeof JSON.parse(this.payload);
|
// if only one property - show it's type
|
||||||
if (lab === "object") {
|
// if more than one property (other than payload and topic) - show "x properties" where x is the number of properties.
|
||||||
if (Array.isArray(JSON.parse(this.payload))) { lab = "Array"; }
|
|
||||||
}
|
// this.props will not be an array for legacy inject nodes until they are re-deployed
|
||||||
} catch(e) {
|
if (Array.isArray(this.props)) {
|
||||||
return this._("inject.label.invalid"); }
|
var propertyCount = this.props.length;
|
||||||
}
|
var payloadProperty = this.props.find(p => p.p === 'payload');
|
||||||
var name = "inject.label."+lab;
|
var topicProperty = this.props.find(p => p.p === 'topic' && p.vt === 'str');
|
||||||
var label = this._(name);
|
|
||||||
if (name !== label) {
|
if (payloadProperty && topicProperty) {
|
||||||
return label;
|
lab = payloadProperty.vt;
|
||||||
|
} else if (propertyCount > 1){
|
||||||
|
lab = propertyCount + ' properties';
|
||||||
|
} else if(propertyCount === 1){
|
||||||
|
lab = this.props[0].vt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Friendly names
|
||||||
|
switch(lab){
|
||||||
|
case 'date': lab = 'timestamp'; break;
|
||||||
|
case 'str': lab = 'string'; break;
|
||||||
|
case 'num': lab = 'number'; break;
|
||||||
|
case 'bin': lab = 'buffer'; break;
|
||||||
|
case '': lab = 'nothing'; break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
lab = 'legacy payload';
|
||||||
}
|
}
|
||||||
|
|
||||||
return lab;
|
return lab;
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user