mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add sub options to Inject node
This commit is contained in:
parent
80873e4ea9
commit
c243481432
@ -14,10 +14,40 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
(function($) {
|
||||
var contextParse = function(v) {
|
||||
var parts = {};
|
||||
var m = /^#:\((\S+?)\)::(.*)$/.exec(v);
|
||||
if (m) {
|
||||
parts.option = m[1];
|
||||
parts.value = m[2];
|
||||
} else {
|
||||
parts.value = v;
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
var contextExport = function(v,opt) {
|
||||
return "#:("+((typeof opt === "string")?opt:opt.value)+")::"+v;
|
||||
}
|
||||
var allOptions = {
|
||||
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression},
|
||||
flow: {value:"flow",label:"flow.",validate:RED.utils.validatePropertyExpression},
|
||||
global: {value:"global",label:"global.",validate:RED.utils.validatePropertyExpression},
|
||||
flow: {value:"flow",label:"flow.",hasValue:true,
|
||||
options:[
|
||||
{value:"memory",label: "memory", icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #ddd"></i>'}//,
|
||||
// {value:"redis",label:"redis",icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #777"></i>'}
|
||||
],
|
||||
validate:RED.utils.validatePropertyExpression,
|
||||
parse: contextParse,
|
||||
export: contextExport
|
||||
},
|
||||
global: {value:"global",label:"global.",hasValue:true,
|
||||
options:[
|
||||
{value:"memory",label: "memory", icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #ddd"></i>'},
|
||||
{value:"redis",label:"redis",icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #777"></i>'}
|
||||
],
|
||||
validate:RED.utils.validatePropertyExpression,
|
||||
parse: contextParse,
|
||||
export: contextExport
|
||||
},
|
||||
str: {value:"str",label:"string",icon:"red/images/typedInput/az.png"},
|
||||
num: {value:"num",label:"number",icon:"red/images/typedInput/09.png",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/},
|
||||
bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.png",options:["true","false"]},
|
||||
|
@ -237,10 +237,13 @@ If you want every 20 minutes from now - use the <i>"interval"</i> option.</p>
|
||||
} else {
|
||||
return this._("inject.timestamp")+suffix;
|
||||
}
|
||||
} else if (this.payloadType === 'flow' && this.payload.length < 19) {
|
||||
return 'flow.'+this.payload+suffix;
|
||||
} else if (this.payloadType === 'global' && this.payload.length < 17) {
|
||||
return 'global.'+this.payload+suffix;
|
||||
} else if (this.payloadType === 'flow' || this.payloadType === 'global') {
|
||||
var key = this.payload;
|
||||
var m = /^#:\((\S+?)\)::(.*)$/.exec(key);
|
||||
if (m) {
|
||||
key = m[2];
|
||||
}
|
||||
return 'flow.'+key+suffix;
|
||||
} else {
|
||||
return this._("inject.inject")+suffix;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user