Skip to content

Commit a0dbf4d

Browse files
reduce code for test and production with drop-down options
1 parent 1a093e7 commit a0dbf4d

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

node-red-contrib-treeview/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-treeview",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "Custom treeView strcture of data saved into cloudantDb for Dri-list application.",
55
"node-red": {
66
"nodes": {

node-red-contrib-treeview/treeView/treeView.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
username : { value:"", required:true },
88
password : { value:"", required:true },
99
operation : { value:"", required: true},
10-
flag: {value: "", required: true},
10+
flagMode: {value: "", required: true},
1111
},
1212
inputs:1,
1313
outputs:1,
@@ -40,14 +40,21 @@
4040
</select>
4141
</div>
4242

43-
<div class="form-row node-input-flag">
43+
<div class="form-row node-input-flag" style="display: none;">
4444
<label for="node-input-flag"><i class="fa fa-flag-checkered"></i> Partial Flag</label>
45-
<select type="text" id="node-input-flag" style="width:68%;">
45+
<select type="text" id="node-input-flagMode" style="width:68%;">
4646
<option value="true">True</option>
4747
<option value="false">False</option>
4848
</select>
4949
</div>
5050

51+
<script>
52+
$("#node-input-operation").change(function() {
53+
var id = $("#node-input-operation option:selected").val();
54+
if (id == "test") $(".node-input-flag").show();
55+
else $(".node-input-flag").hide();
56+
});
57+
</script>
5158
</script>
5259

5360
<script type="text/x-red" data-help-name="Tree View">

node-red-contrib-treeview/treeView/treeView.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function(RED) {
1010
databaseName = config.database,
1111
username = config.username,
1212
password = config.password,
13-
partialFlag = config.flag ;
13+
partialFlag = config.flagMode ;
1414
operation = config.operation;
1515

1616
//initalizing helper init method
@@ -31,23 +31,6 @@ module.exports = function(RED) {
3131
return false;
3232
}
3333

34-
if(_.isEmpty(partialFlag)){
35-
msg.payload = `'partialFlag' must not empty to make ${node.type} node working properly.`;
36-
node.send(msg);
37-
return false;
38-
}
39-
40-
if(_.isEmpty(msg.node_original1) ){
41-
msg.payload = `'node_original1' should not empty to make ${node.type} node working properly.`;
42-
node.send(msg);
43-
return false;
44-
}
45-
46-
if(_.isEmpty(msg.node_original2) ){
47-
msg.payload = `'node_original2' should not empty to make ${node.type} node working properly.`;
48-
node.send(msg);
49-
return false;
50-
}
5134

5235
var localMsg = {},
5336
action_array = [],
@@ -74,10 +57,12 @@ module.exports = function(RED) {
7457
}
7558
}
7659

77-
// changeing true/false string to boolean value;
78-
partialFlag = JSON.parse(partialFlag);
60+
7961

8062
if(operation == "test"){
63+
// changeing true/false string to boolean value;
64+
partialFlag = JSON.parse(config.flagMode);
65+
8166
reset_db_new(msg, true, partialFlag, function(return_object1){
8267
console.log('return_object1', return_object1);
8368
treeViewHelper.process_msg(action_array, function(return_object){
@@ -87,14 +72,14 @@ module.exports = function(RED) {
8772
});
8873
});
8974
}else if( operation == "prod"){
90-
reset_db_new(msg, false, partialFlag, function(return_object1){
91-
console.log('return_object1', return_object1);
75+
//reset_db_new(msg, false, partialFlag, function(return_object1){
76+
//console.log('return_object1', return_object1);
9277
treeViewHelper.process_msg(action_array, function(return_object){
93-
console.log(return_object);
78+
console.log(JSON.stringify(return_object));
9479
msg.payload = return_object;
9580
node.send(msg);
9681
});
97-
});
82+
//});
9883
}else{
9984
msg.payload = "Un-specified operation for Tree view node.";
10085
node.send(msg);

0 commit comments

Comments
 (0)