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

Merge pull request #2198 from node-red-hitachi/allow-env-in-switch-node

Allow environment variable as target of switch node
This commit is contained in:
Nick O'Leary 2019-06-11 15:13:46 +01:00 committed by GitHub
commit cfcb3a69e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View File

@ -128,7 +128,7 @@
var node = this;
var previousValueType = {value:"prev",label:this._("inject.previous"),hasValue:false};
$("#node-input-property").typedInput({default:this.propertyType||'msg',types:['msg','flow','global','jsonata']});
$("#node-input-property").typedInput({default:this.propertyType||'msg',types:['msg','flow','global','jsonata','env']});
var outputCount = $("#node-input-outputs").val("{}");
var andLabel = this._("switch.and");

View File

@ -22,7 +22,7 @@
<p>Optionally, the node can be set to stop evaluating rules once it finds one
that matches.</p>
<p>The rules can be evaluated against an individual message property, a flow or global
context property or the result of a JSONata expression.</p>
context property, environment variable or the result of a JSONata expression.</p>
<h4>Rules</h4>
<p>There are four types of rule:</p>
<ol>

View File

@ -19,7 +19,7 @@
<h3>詳細</h3>
<p>受信したメッセージに対し、指定されたルールを順に評価し、マッチしたルールに対応する出力ポートにメッセージを送出します。</p>
<p>最初にルールがマッチしたところで評価を止めることも可能です。</p>
<p>評価ルールには、メッセージプロパティ、フローコンテキスト/グローバルコンテキストのプロパティ、JSONata式の評価結果が利用できます。</p>
<p>評価ルールには、メッセージプロパティ、フローコンテキスト/グローバルコンテキストのプロパティ、環境変数、JSONata式の評価結果が利用できます。</p>
<h4>ルール</h4>
<p>振り分けルールは以下の4つに分類されます。</p>
<ol>

View File

@ -818,6 +818,14 @@ describe('switch Node', function() {
});
});
it('should handle env var expression', function(done) {
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"VAR",propertyType:"env",rules:[{"t":"eq","v":"VAL"}],checkall:true,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];
process.env.VAR = "VAL";
customFlowSwitchTest(flow, true, "OK", done);
});
it('should take head of message sequence (no repair)', function(done) {
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"head","v":3}],checkall:false,repair:false,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];