2013-12-20 10:00:35 +01:00
|
|
|
<!--
|
2013-12-20 10:33:06 +01:00
|
|
|
Copyright 2013 Kris Daniels.
|
2013-12-20 10:00:35 +01: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.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script type="text/x-red" data-template-name="postgresdb">
|
|
|
|
<div class="form-row">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-config-input-hostname"><i class="fa fa-bookmark"></i> Host</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
<input class="input-append-left" type="text" id="node-config-input-hostname" placeholder="localhost" style="width: 40%;" >
|
|
|
|
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
|
|
|
|
<input type="text" id="node-config-input-port" placeholder="5432" style="width:45px">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-config-input-db"><i class="fa fa-briefcase"></i> Database</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
<input type="text" id="node-config-input-db" placeholder="test">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-config-input-name"><i class="fa fa-user"></i> Username</label>
|
2013-12-21 11:01:19 +01:00
|
|
|
<input type="text" id="node-config-input-user" placeholder="postgres">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
<input type="password" id="node-config-input-password" placeholder="postgres">
|
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('postgresdb',{
|
|
|
|
category: 'config',
|
|
|
|
color:"rgb(218, 196, 180)",
|
|
|
|
defaults: {
|
|
|
|
hostname: { value:"localhost",required:true},
|
|
|
|
port: { value: 5432,required:true},
|
2013-12-21 11:01:19 +01:00
|
|
|
db: { value:"postgres",required:true}
|
2013-12-20 10:00:35 +01:00
|
|
|
},
|
2015-02-06 22:10:14 +01:00
|
|
|
credentials: {
|
|
|
|
user: {type:"text"},
|
|
|
|
password: {type: "password"}
|
|
|
|
},
|
2013-12-20 10:00:35 +01:00
|
|
|
label: function() {
|
|
|
|
return this.name||this.hostname+":"+this.port+"/"+this.db;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/x-red" data-template-name="postgres">
|
|
|
|
<div class="form-row">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2014-09-03 17:12:26 +02:00
|
|
|
<label for="node-input-postgresdb"><i class="fa fa-tag"></i> Server</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
<input type="text" id="node-input-postgresdb">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2013-12-21 09:23:46 +01:00
|
|
|
<label> </label>
|
|
|
|
<input type="checkbox" id="node-input-output" placeholder="once" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-output" style="width: 70%;">Receive query output ?</label>
|
2013-12-20 10:00:35 +01:00
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/x-red" data-help-name="postgres">
|
|
|
|
<p>A PostgreSql I/O node. </p>
|
2013-12-21 09:23:46 +01:00
|
|
|
<p>Executes the query specified in msg.payload with optional query parameters in msg.queryParameters</p>
|
|
|
|
<p>The queryParameters in the query must be specified as $propertyname</p>
|
|
|
|
<p>See the node-postgres-named package for more info</p>
|
|
|
|
<p>When receiving data from the query, the msg.payload on the output will be a json array of the returned records</p>
|
2013-12-20 10:18:22 +01:00
|
|
|
|
2013-12-20 10:00:35 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('postgres',{
|
2013-12-21 16:55:44 +01:00
|
|
|
category: 'storage-output',
|
|
|
|
color:"rgb(148, 226, 252)",
|
|
|
|
defaults: {
|
|
|
|
postgresdb: { type:"postgresdb",required:true},
|
|
|
|
name: {value:""},
|
|
|
|
output: {value:false},
|
|
|
|
outputs: {value:0}
|
|
|
|
},
|
|
|
|
inputs: 1,
|
|
|
|
outputs: 0,
|
|
|
|
icon: "postgres.png",
|
|
|
|
align: "right",
|
|
|
|
label: function() {
|
|
|
|
return this.name||(this.sqlquery?this.sqlquery:"postgres");
|
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
|
|
|
|
$( "#node-input-output" ).prop( "checked", this.output );
|
|
|
|
$("#node-input-name").focus();
|
|
|
|
|
|
|
|
},
|
|
|
|
oneditsave: function() {
|
2013-12-21 11:01:19 +01:00
|
|
|
|
2013-12-21 16:55:44 +01:00
|
|
|
var hasOutput = $( "#node-input-output" ).prop( "checked" );
|
|
|
|
this.outputs = hasOutput ? 1:0;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-12-20 10:00:35 +01:00
|
|
|
</script>
|