mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
move client script and shared func to iife
prevent global polution with other nodes doing this
This commit is contained in:
parent
041342d511
commit
bb4345fb50
@ -42,37 +42,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
RED.nodes.registerType('mongodb', {
|
|
||||||
category: 'config',
|
|
||||||
color: "rgb(218, 196, 180)",
|
|
||||||
defaults: {
|
|
||||||
hostname: {value: "127.0.0.1", required: true},
|
|
||||||
topology: {value: "direct", required: true},
|
|
||||||
connectOptions: {value: "", required: false},
|
|
||||||
port: {value: 27017, required: true},
|
|
||||||
db: {value: "", required: true},
|
|
||||||
name: {value: ""}
|
|
||||||
},
|
|
||||||
credentials: {
|
|
||||||
user: {type: "text"},
|
|
||||||
password: {type: "password"}
|
|
||||||
},
|
|
||||||
label: function() {
|
|
||||||
return this.name || this.db + "@" + this.hostname;
|
|
||||||
},
|
|
||||||
oneditprepare: function() {
|
|
||||||
$("#node-config-input-topology").on("change", function() {
|
|
||||||
var topology = $("#node-config-input-topology option:selected").val();
|
|
||||||
if (topology === "direct") {
|
|
||||||
$(".node-config-input-port").show();
|
|
||||||
} else {
|
|
||||||
$(".node-config-input-port").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/html" data-template-name="mongodb out">
|
<script type="text/html" data-template-name="mongodb out">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -114,58 +83,6 @@
|
|||||||
<div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]mongodb.tip"></span></div>
|
<div class="form-tips" id="node-warning" style="display: none"><span data-i18n="[html]mongodb.tip"></span></div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function oneditprepare() {
|
|
||||||
$("#node-input-operation").change(function () {
|
|
||||||
var id = $("#node-input-operation option:selected").val();
|
|
||||||
|
|
||||||
if (id === "update") {
|
|
||||||
$(".node-input-payonly").hide();
|
|
||||||
$(".node-input-upsert, .node-input-multi").show();
|
|
||||||
} else if (id === "delete") {
|
|
||||||
$(".node-input-payonly, .node-input-upsert, .node-input-multi").hide();
|
|
||||||
} else {
|
|
||||||
$(".node-input-payonly").show();
|
|
||||||
$(".node-input-upsert, .node-input-multi").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#node-input-collection").change(function () {
|
|
||||||
if($("#node-input-collection").val() === "") {
|
|
||||||
$("#node-warning").show();
|
|
||||||
} else {
|
|
||||||
$("#node-warning").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
RED.nodes.registerType('mongodb out', {
|
|
||||||
category: 'storage-output',
|
|
||||||
color: "rgb(218, 196, 180)",
|
|
||||||
defaults: {
|
|
||||||
mongodb: {type: "mongodb", required: true},
|
|
||||||
name: {value: ""},
|
|
||||||
collection: {value: ""},
|
|
||||||
payonly: {value: false},
|
|
||||||
upsert: {value: false},
|
|
||||||
multi: {value: false},
|
|
||||||
operation: {value: "store"}
|
|
||||||
},
|
|
||||||
inputs: 1,
|
|
||||||
outputs: 0,
|
|
||||||
icon: "mongodb.png",
|
|
||||||
align: "right",
|
|
||||||
label: function() {
|
|
||||||
var mongoNode = RED.nodes.node(this.mongodb);
|
|
||||||
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
|
||||||
},
|
|
||||||
labelStyle: function() {
|
|
||||||
return this.name ? "node_label_italic" : "";
|
|
||||||
},
|
|
||||||
oneditprepare: oneditprepare
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/html" data-template-name="mongodb in">
|
<script type="text/html" data-template-name="mongodb in">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-mongodb"><i class="fa fa-bookmark"></i> <span data-i18n="mongodb.label.server"></span></label>
|
<label for="node-input-mongodb"><i class="fa fa-bookmark"></i> <span data-i18n="mongodb.label.server"></span></label>
|
||||||
@ -191,6 +108,88 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
function _oneditprepare() {
|
||||||
|
$("#node-input-operation").change(function () {
|
||||||
|
var id = $("#node-input-operation option:selected").val();
|
||||||
|
|
||||||
|
if (id === "update") {
|
||||||
|
$(".node-input-payonly").hide();
|
||||||
|
$(".node-input-upsert, .node-input-multi").show();
|
||||||
|
} else if (id === "delete") {
|
||||||
|
$(".node-input-payonly, .node-input-upsert, .node-input-multi").hide();
|
||||||
|
} else {
|
||||||
|
$(".node-input-payonly").show();
|
||||||
|
$(".node-input-upsert, .node-input-multi").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#node-input-collection").change(function () {
|
||||||
|
if($("#node-input-collection").val() === "") {
|
||||||
|
$("#node-warning").show();
|
||||||
|
} else {
|
||||||
|
$("#node-warning").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
RED.nodes.registerType('mongodb', {
|
||||||
|
category: 'config',
|
||||||
|
color: "rgb(218, 196, 180)",
|
||||||
|
defaults: {
|
||||||
|
hostname: {value: "127.0.0.1", required: true},
|
||||||
|
topology: {value: "direct", required: true},
|
||||||
|
connectOptions: {value: "", required: false},
|
||||||
|
port: {value: 27017, required: true},
|
||||||
|
db: {value: "", required: true},
|
||||||
|
name: {value: ""}
|
||||||
|
},
|
||||||
|
credentials: {
|
||||||
|
user: {type: "text"},
|
||||||
|
password: {type: "password"}
|
||||||
|
},
|
||||||
|
label: function() {
|
||||||
|
return this.name || this.db + "@" + this.hostname;
|
||||||
|
},
|
||||||
|
oneditprepare: function() {
|
||||||
|
$("#node-config-input-topology").on("change", function() {
|
||||||
|
var topology = $("#node-config-input-topology option:selected").val();
|
||||||
|
if (topology === "direct") {
|
||||||
|
$(".node-config-input-port").show();
|
||||||
|
} else {
|
||||||
|
$(".node-config-input-port").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
RED.nodes.registerType('mongodb out', {
|
||||||
|
category: 'storage-output',
|
||||||
|
color: "rgb(218, 196, 180)",
|
||||||
|
defaults: {
|
||||||
|
mongodb: {type: "mongodb", required: true},
|
||||||
|
name: {value: ""},
|
||||||
|
collection: {value: ""},
|
||||||
|
payonly: {value: false},
|
||||||
|
upsert: {value: false},
|
||||||
|
multi: {value: false},
|
||||||
|
operation: {value: "store"}
|
||||||
|
},
|
||||||
|
inputs: 1,
|
||||||
|
outputs: 0,
|
||||||
|
icon: "mongodb.png",
|
||||||
|
align: "right",
|
||||||
|
label: function() {
|
||||||
|
var mongoNode = RED.nodes.node(this.mongodb);
|
||||||
|
return this.name || (mongoNode ? mongoNode.label() + " " + this.collection : "mongodb");
|
||||||
|
},
|
||||||
|
labelStyle: function() {
|
||||||
|
return this.name ? "node_label_italic" : "";
|
||||||
|
},
|
||||||
|
oneditprepare: _oneditprepare
|
||||||
|
});
|
||||||
|
|
||||||
RED.nodes.registerType('mongodb in', {
|
RED.nodes.registerType('mongodb in', {
|
||||||
category: 'storage-input',
|
category: 'storage-input',
|
||||||
color: "rgb(218, 196, 180)",
|
color: "rgb(218, 196, 180)",
|
||||||
@ -210,6 +209,7 @@
|
|||||||
labelStyle: function() {
|
labelStyle: function() {
|
||||||
return this.name ? "node_label_italic" : "";
|
return this.name ? "node_label_italic" : "";
|
||||||
},
|
},
|
||||||
oneditprepare: oneditprepare
|
oneditprepare: _oneditprepare
|
||||||
});
|
});
|
||||||
|
})()
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-mongodb",
|
"name" : "node-red-node-mongodb",
|
||||||
"version" : "0.2.5",
|
"version" : "0.2.6",
|
||||||
"description" : "Node-RED nodes to talk to a Mongo database",
|
"description" : "Node-RED nodes to talk to a Mongo database",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"mongodb" : "^3.6.3"
|
"mongodb" : "^3.6.3"
|
||||||
|
Loading…
Reference in New Issue
Block a user