2016-06-04 01:40:40 +02:00
|
|
|
<!--
|
2017-01-11 16:24:33 +01:00
|
|
|
Copyright JS Foundation and other contributors, http://js.foundation
|
2016-06-04 01:40:40 +02:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
|
|
|
|
2020-03-02 20:50:39 +01:00
|
|
|
<script type="text/html" data-template-name="split">
|
2017-06-13 22:01:04 +02:00
|
|
|
<div class="form-row"><span data-i18n="[html]split.intro"></span></div>
|
|
|
|
<div class="form-row"><span data-i18n="[html]split.strBuff"></span></div>
|
2016-06-04 01:40:40 +02:00
|
|
|
<div class="form-row">
|
2017-06-22 19:42:54 +02:00
|
|
|
<label for="node-input-splt" style="padding-left:10px; margin-right:-10px;" data-i18n="split.splitUsing"></label>
|
|
|
|
<input type="text" id="node-input-splt" style="width:70%">
|
2017-06-13 22:01:04 +02:00
|
|
|
<input type="hidden" id="node-input-spltType">
|
2016-06-04 01:40:40 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2017-06-22 19:42:54 +02:00
|
|
|
<input type="checkbox" id="node-input-stream" style="margin-left:10px; vertical-align:top; width:auto;">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label for="node-input-stream" style="width:auto;" data-i18n="split.stream"></label>
|
|
|
|
</div>
|
|
|
|
<div class="form-row"><span data-i18n="[html]split.array"></span></div>
|
|
|
|
<div class="form-row">
|
2017-06-22 19:42:54 +02:00
|
|
|
<label for="node-input-arraySplt" style="padding-left:10px; margin-right:-10px;" data-i18n="split.splitUsing"></label>
|
|
|
|
<input type="text" id="node-input-arraySplt" style="width:70%">
|
2017-06-13 22:01:04 +02:00
|
|
|
<input type="hidden" id="node-input-arraySpltType">
|
|
|
|
</div>
|
2017-06-22 19:42:54 +02:00
|
|
|
<div class="form-row"><span data-i18n="[html]split.object"></span></div>
|
|
|
|
<div class="form-row" style="padding-left: 10px"><span data-i18n="[html]split.objectSend"></span></div>
|
|
|
|
<div class="form-row">
|
2017-06-26 17:51:27 +02:00
|
|
|
<input type="checkbox" id="node-input-addname-cb" style="margin-left:10px; vertical-align:baseline; width:auto;">
|
|
|
|
<label for="node-input-addname-cb" style="width:auto;" data-i18n="split.addname"></label>
|
|
|
|
<input type="text" id="node-input-addname" style="width:70%">
|
2017-06-22 19:42:54 +02:00
|
|
|
</div>
|
2017-06-13 22:01:04 +02:00
|
|
|
<hr/>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
2016-06-04 01:40:40 +02:00
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('split',{
|
2019-07-09 21:26:26 +02:00
|
|
|
category: 'sequence',
|
2016-06-04 01:40:40 +02:00
|
|
|
color:"#E2D96E",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
2017-06-13 22:01:04 +02:00
|
|
|
splt: {value:"\\n"},
|
|
|
|
spltType: {value:"str"},
|
|
|
|
arraySplt: {value:1},
|
|
|
|
arraySpltType: {value:"len"},
|
2017-06-22 19:42:54 +02:00
|
|
|
stream: {value:false},
|
2018-01-17 11:08:23 +01:00
|
|
|
addname: {value:""}
|
2016-06-04 01:40:40 +02:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2019-06-21 13:36:20 +02:00
|
|
|
icon: "split.svg",
|
2016-06-04 01:40:40 +02:00
|
|
|
label: function() {
|
2018-03-30 15:31:59 +02:00
|
|
|
return this.name||this._("split.split");
|
2016-06-04 01:40:40 +02:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
2017-06-13 22:01:04 +02:00
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
$("#node-input-splt").typedInput({
|
|
|
|
default: 'str',
|
|
|
|
typeField: $("#node-input-spltType"),
|
|
|
|
types:[
|
|
|
|
'str',
|
|
|
|
'bin',
|
|
|
|
{value:"len", label:RED._("node-red:split.splitLength"),validate:/^\d+$/}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
if (this.arraySplt === undefined) {
|
|
|
|
$("#node-input-arraySplt").val(1);
|
|
|
|
}
|
|
|
|
$("#node-input-arraySplt").typedInput({
|
|
|
|
default: 'len',
|
|
|
|
typeField: $("#node-input-arraySpltType"),
|
|
|
|
types:[
|
|
|
|
{value:"len", label:RED._("node-red:split.splitLength"),validate:/^\d+$/}
|
|
|
|
]
|
|
|
|
});
|
2017-06-26 17:51:27 +02:00
|
|
|
$("#node-input-addname").typedInput({
|
2017-06-22 19:42:54 +02:00
|
|
|
typeField: $("#node-input-fnameType"),
|
|
|
|
types:['msg']
|
|
|
|
});
|
2017-06-26 17:51:27 +02:00
|
|
|
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-addname-cb").on("change", function() {
|
2017-06-26 17:51:27 +02:00
|
|
|
$("#node-input-addname").prop('disabled',!this.checked);
|
|
|
|
})
|
|
|
|
if (this.addname === "") {
|
|
|
|
$("#node-input-addname-cb").prop('checked',false);
|
|
|
|
$("#node-input-addname").val('topic');
|
|
|
|
} else {
|
|
|
|
$("#node-input-addname-cb").prop('checked',true);
|
|
|
|
}
|
|
|
|
$("#node-input-addname-cb").change();
|
|
|
|
},
|
|
|
|
oneditsave: function() {
|
|
|
|
if (!$("#node-input-addname-cb").prop('checked')) {
|
|
|
|
$("#node-input-addname").val('');
|
|
|
|
}
|
2016-06-04 01:40:40 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2017-06-22 19:42:54 +02:00
|
|
|
|
2020-03-02 20:50:39 +01:00
|
|
|
<script type="text/html" data-template-name="join">
|
2016-06-04 01:40:40 +02:00
|
|
|
<div class="form-row">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label data-i18n="join.mode.mode"></label>
|
2016-06-06 22:18:20 +02:00
|
|
|
<select id="node-input-mode" style="width:200px;">
|
2017-06-13 22:01:04 +02:00
|
|
|
<option value="auto" data-i18n="join.mode.auto"></option>
|
|
|
|
<option value="custom" data-i18n="join.mode.custom"></option>
|
2018-01-17 11:08:23 +01:00
|
|
|
<option value="reduce" data-i18n="join.mode.reduce"></option>
|
2016-06-04 01:40:40 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
2016-06-06 22:18:20 +02:00
|
|
|
<div class="node-row-custom">
|
|
|
|
<div class="form-row node-row-property">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label data-i18n="join.combine"> </label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<input type="text" id="node-input-property" style="width:70%;">
|
2016-06-06 22:18:20 +02:00
|
|
|
<input type="hidden" id="node-input-propertyType">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label data-i18n="join.create"></label>
|
2017-06-05 18:04:17 +02:00
|
|
|
<select id="node-input-build" style="width:70%;">
|
2017-06-27 18:10:52 +02:00
|
|
|
<option value="string" data-i18n="join.type.string"></option>
|
|
|
|
<option value="buffer" data-i18n="join.type.buffer"></option>
|
2017-06-13 22:01:04 +02:00
|
|
|
<option value="array" data-i18n="join.type.array"></option>
|
|
|
|
<option value="object" data-i18n="join.type.object"></option>
|
|
|
|
<option value="merged" data-i18n="join.type.merged"></option>
|
2016-06-06 22:18:20 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row node-row-key">
|
2017-06-27 18:10:52 +02:00
|
|
|
<label style="vertical-align:top; margin-top:7px; width:auto; margin-right: 5px;" data-i18n="join.using"></label>
|
2016-06-06 22:18:20 +02:00
|
|
|
<div style="display:inline-block">
|
2017-06-27 18:10:52 +02:00
|
|
|
<input type="text" id="node-input-key" style="width:220px;"> <span data-i18n="join.key"></span>
|
2016-06-06 22:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-row node-row-joiner">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label for="node-input-joiner" data-i18n="join.joinedUsing"></label>
|
2017-06-27 18:10:52 +02:00
|
|
|
<input type="text" id="node-input-joiner" style="width:70%">
|
|
|
|
<input type="hidden" id="node-input-joinerType">
|
2016-06-06 22:18:20 +02:00
|
|
|
</div>
|
2017-06-05 18:04:17 +02:00
|
|
|
<div class="form-row node-row-trigger" id="trigger-row">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label style="width:auto;" data-i18n="join.send"></label>
|
2016-06-06 22:18:20 +02:00
|
|
|
<ul>
|
2017-06-05 18:04:17 +02:00
|
|
|
<li>
|
2017-06-13 22:01:04 +02:00
|
|
|
<label style="width:280px;" for="node-input-count" data-i18n="join.afterCount"></label> <input id="node-input-count" data-i18n="[placeholder]join.count" type="text" style="width:75px;">
|
2017-06-05 18:04:17 +02:00
|
|
|
</li>
|
2017-06-27 18:10:52 +02:00
|
|
|
<li class="node-row-accumulate" style="list-style-type:none;">
|
|
|
|
<input type="checkbox" id="node-input-accumulate" style="display:inline-block; width:20px; margin-left:20px; vertical-align:top;"> <label style="width: auto" for="node-input-accumulate" data-i18n="join.subsequent"></label>
|
2016-06-06 22:18:20 +02:00
|
|
|
</li>
|
2017-06-05 18:04:17 +02:00
|
|
|
<li>
|
2017-06-13 22:01:04 +02:00
|
|
|
<label style="width:280px;" for="node-input-timeout" data-i18n="join.afterTimeout"></label> <input id="node-input-timeout" data-i18n="[placeholder]join.seconds" type="text" style="width:75px;">
|
2016-06-06 22:18:20 +02:00
|
|
|
</li>
|
2017-06-05 18:04:17 +02:00
|
|
|
<li>
|
2017-06-13 22:01:04 +02:00
|
|
|
<label style="width:auto; padding-top:6px;" data-i18n="[html]join.complete"></label>
|
2016-06-06 22:18:20 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2016-06-04 01:40:40 +02:00
|
|
|
</div>
|
2018-01-17 11:08:23 +01:00
|
|
|
<div class="node-row-reduce">
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-reduceExp" data-i18n="join.reduce.exp" style="margin-left:10px;"></label>
|
|
|
|
<input type="text" id="node-input-reduceExp" data-i18n="[placeholder]join.reduce.exp-value" style="width:65%">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-reduceInit" data-i18n="join.reduce.init" style="margin-left:10px;"></label>
|
|
|
|
<input type="text" id="node-input-reduceInit" data-i18n="[placeholder]join.reduce.init" style="width:65%">
|
|
|
|
<input type="hidden" id="node-input-reduceInitType">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-reduceFixup" data-i18n="join.reduce.fixup" style="margin-left:10px;"></label>
|
|
|
|
<input type="text" id="node-input-reduceFixup" data-i18n="[placeholder]join.reduce.exp-value" style="width:65%">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label> </label>
|
|
|
|
<input type="checkbox" id="node-input-reduceRight" style="display:inline-block; width:auto; vertical-align:top; margin-left:10px;">
|
|
|
|
<label for="node-input-reduceRight" style="width:70%;" data-i18n="join.reduce.right" style="margin-left:10px;"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-06-05 18:04:17 +02:00
|
|
|
<div class="form-row">
|
2017-06-13 22:01:04 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
2017-06-05 18:04:17 +02:00
|
|
|
</div>
|
2017-06-13 22:01:04 +02:00
|
|
|
<div class="form-tips form-tips-auto hide" data-i18n="[html]join.tip"></div>
|
2016-06-04 01:40:40 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('join',{
|
2019-07-09 21:26:26 +02:00
|
|
|
category: 'sequence',
|
2016-06-04 01:40:40 +02:00
|
|
|
color:"#E2D96E",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
2016-06-06 22:18:20 +02:00
|
|
|
mode: {value:"auto"},
|
|
|
|
build: { value:"string"},
|
2017-06-05 18:04:17 +02:00
|
|
|
property: { value:"payload", validate:RED.validators.typedInput("propertyType")},
|
2016-06-06 00:32:03 +02:00
|
|
|
propertyType: { value:"msg"},
|
|
|
|
key: {value:"topic"},
|
|
|
|
joiner: { value:"\\n"},
|
2017-06-27 18:10:52 +02:00
|
|
|
joinerType: { value:"str"},
|
2017-06-05 18:04:17 +02:00
|
|
|
accumulate: { value:"false" },
|
2016-06-04 01:40:40 +02:00
|
|
|
timeout: {value:""},
|
2018-01-17 11:08:23 +01:00
|
|
|
count: {value:""},
|
|
|
|
reduceRight: {value:false},
|
|
|
|
reduceExp: {value:undefined},
|
|
|
|
reduceInit: {value:undefined},
|
|
|
|
reduceInitType: {value:undefined},
|
|
|
|
reduceFixup: {value:undefined}
|
2016-06-04 01:40:40 +02:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2019-06-21 13:36:20 +02:00
|
|
|
icon: "join.svg",
|
2016-06-04 01:40:40 +02:00
|
|
|
label: function() {
|
2018-03-30 15:31:59 +02:00
|
|
|
return this.name||this._("join.join");
|
2016-06-04 01:40:40 +02:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
2018-01-17 11:08:23 +01:00
|
|
|
var node = this;
|
|
|
|
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-mode").on("change", function(e) {
|
2016-06-06 22:18:20 +02:00
|
|
|
var val = $(this).val();
|
|
|
|
$(".node-row-custom").toggle(val==='custom');
|
2018-01-17 11:08:23 +01:00
|
|
|
$(".node-row-reduce").toggle(val==='reduce');
|
|
|
|
$(".form-tips-auto").toggle((val==='auto') || (val==='reduce'));
|
2017-06-15 01:11:35 +02:00
|
|
|
if (val === "auto") {
|
|
|
|
$("#node-input-accumulate").attr('checked', false);
|
|
|
|
}
|
2018-01-21 12:46:57 +01:00
|
|
|
else if (val === "custom") {
|
|
|
|
$("#node-input-build").change();
|
|
|
|
}
|
2018-01-17 11:08:23 +01:00
|
|
|
else if (val === "reduce") {
|
|
|
|
var jsonata_or_empty = {
|
|
|
|
value: "jsonata",
|
|
|
|
label: "expression",
|
|
|
|
icon: "red/images/typedInput/expr.png",
|
|
|
|
validate: function(v) {
|
|
|
|
try{
|
|
|
|
if(v !== "") {
|
|
|
|
jsonata(v);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch(e){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
expand:function() {
|
|
|
|
var that = this;
|
|
|
|
RED.editor.editExpression({
|
|
|
|
value: this.value().replace(/\t/g,"\n"),
|
|
|
|
complete: function(v) {
|
|
|
|
that.value(v.replace(/\n/g,"\t"));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$("#node-input-reduceExp").typedInput({types:[jsonata_or_empty]});
|
|
|
|
$("#node-input-reduceInit").typedInput({
|
|
|
|
default: 'num',
|
2018-07-16 06:45:59 +02:00
|
|
|
types:['flow','global','str','num','bool','json','bin','date','jsonata','env'],
|
2018-01-17 11:08:23 +01:00
|
|
|
typeField: $("#node-input-reduceInitType")
|
|
|
|
});
|
|
|
|
$("#node-input-reduceFixup").typedInput({types:[jsonata_or_empty]});
|
|
|
|
}
|
2016-06-06 22:18:20 +02:00
|
|
|
});
|
|
|
|
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-build").on("change", function(e) {
|
2016-06-04 01:40:40 +02:00
|
|
|
var val = $(this).val();
|
2017-06-13 22:01:04 +02:00
|
|
|
$(".node-row-key").toggle(val==='object');
|
2017-06-27 18:10:52 +02:00
|
|
|
$(".node-row-accumulate").toggle(val==='object' || val==='merged');
|
|
|
|
$(".node-row-joiner").toggle(val==='string' || val==='buffer');
|
2016-06-04 01:40:40 +02:00
|
|
|
$(".node-row-trigger").toggle(val!=='auto');
|
2017-06-27 18:10:52 +02:00
|
|
|
if (val === 'string' || val==='buffer') {
|
2016-06-06 00:32:03 +02:00
|
|
|
$("#node-input-property").typedInput('types',['msg']);
|
2018-01-21 12:46:57 +01:00
|
|
|
$("#node-input-joiner").typedInput("show");
|
2016-06-06 22:18:20 +02:00
|
|
|
} else {
|
2019-10-30 11:58:29 +01:00
|
|
|
$("#node-input-property").typedInput('types', ['msg', {
|
|
|
|
value: "full",
|
|
|
|
label: RED._("node-red:join.completeMessage"),
|
|
|
|
hasValue: false
|
|
|
|
}]);
|
2016-06-06 00:32:03 +02:00
|
|
|
}
|
2017-06-05 18:04:17 +02:00
|
|
|
});
|
2016-06-04 01:40:40 +02:00
|
|
|
|
2017-06-27 18:10:52 +02:00
|
|
|
$("#node-input-joiner").typedInput({
|
|
|
|
default: 'str',
|
|
|
|
typeField: $("#node-input-joinerType"),
|
2018-09-04 18:41:14 +02:00
|
|
|
types:['str', 'bin']
|
2017-06-27 18:10:52 +02:00
|
|
|
});
|
|
|
|
|
2016-06-04 01:40:40 +02:00
|
|
|
$("#node-input-property").typedInput({
|
|
|
|
typeField: $("#node-input-propertyType"),
|
2019-10-30 11:58:29 +01:00
|
|
|
types: ['msg', {
|
|
|
|
value: "full",
|
|
|
|
label: RED._("node-red:join.completeMessage"),
|
|
|
|
hasValue: false
|
|
|
|
}]
|
2017-06-05 18:04:17 +02:00
|
|
|
});
|
|
|
|
|
2016-06-04 01:40:40 +02:00
|
|
|
$("#node-input-key").typedInput({
|
2018-09-04 18:41:14 +02:00
|
|
|
types:['msg']
|
2017-06-05 18:04:17 +02:00
|
|
|
});
|
2016-06-04 01:40:40 +02:00
|
|
|
|
2016-06-06 00:32:03 +02:00
|
|
|
$("#node-input-build").change();
|
2016-06-06 22:18:20 +02:00
|
|
|
$("#node-input-mode").change();
|
2017-06-27 18:10:52 +02:00
|
|
|
},
|
|
|
|
oneditsave: function() {
|
|
|
|
var build = $("#node-input-build").val();
|
|
|
|
if (build !== 'object' && build !== 'merged') {
|
|
|
|
$("#node-input-accumulate").prop("checked",false);
|
|
|
|
}
|
2016-06-04 01:40:40 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|