1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
node-red-nodes/storage/sqlite/sqlite.html

132 lines
5.2 KiB
HTML
Raw Permalink Normal View History

2019-11-13 14:31:08 +01:00
<script type="text/html" data-template-name="sqlitedb">
<div class="form-row">
<label for="node-config-input-db"><i class="fa fa-database"></i> <span data-i18n="sqlite.label.database"></label>
<input type="text" id="node-config-input-db" placeholder="/tmp/sqlite">
</div>
<div class="form-row">
<label for="node-config-input-mode" data-i18n="sqlite.label.mode"></label>
<select id="node-config-input-mode" style="width:70%">
<option value="RWC" data-i18n="sqlite.label.readWriteCreate"></option>
<option value="RW" data-i18n="sqlite.label.readWrite"></option>
<option value="RO" data-i18n="sqlite.label.readOnly"></option>
</select>
</div>
<div class="form-tips" data-i18n="[html]sqlite.tips.memoryDb"></div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlitedb',{
category: 'config',
defaults: {
db: {value:"", required:true},
mode: {value:"RWC"}
},
label: function() {
return this.db;
}
});
</script>
2019-11-13 14:31:08 +01:00
<script type="text/html" data-template-name="sqlite">
2018-03-20 20:04:23 +01:00
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
2018-03-20 20:04:23 +01:00
</div>
<div class="form-row">
<label for="node-input-mydb"><i class="fa fa-database"></i> <span data-i18n="sqlite.label.database"></label>
<input type="text" id="node-input-mydb">
</div>
<div class="form-row">
<label for=""><i class="fa fa-code"></i> <span data-i18n="sqlite.label.sqlQuery"></label>
2018-03-20 20:04:23 +01:00
<select id="node-input-sqlquery">
<option value="msg.topic" data-i18n="sqlite.label.viaMsgTopic"></option>
<option value="fixed" data-i18n="sqlite.label.fixedStatement"></option>
<option value="prepared" data-i18n="sqlite.label.preparedStatement"></option>
<option value="batch" data-i18n="sqlite.label.batchWithoutResponse"></option>
2018-03-20 20:04:23 +01:00
</select>
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="" style="width: unset;" id="node-input-sqllabel"><i class="fa fa-code"></i> <span data-i18n="sqlite.label.sqlStatement"></label>
2018-03-20 20:04:23 +01:00
</div>
<div>
<input type="hidden" id="node-input-sql" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-sql-editor" ></div>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlite',{
category: 'storage-input',
color:"#e97b00",
defaults: {
mydb: {type:"sqlitedb",required:true},
2018-03-20 20:04:23 +01:00
sqlquery: {value:"msg.topic",required:true},
sql: {value:""},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "sqlite.png",
label: function() {
var dbNode = RED.nodes.node(this.mydb);
return this.name||(dbNode?dbNode.label():"sqlite");
},
2018-03-20 20:04:23 +01:00
labelStyle: function() {
return this.name?"node_label_italic":"";
2018-03-20 20:04:23 +01:00
},
oneditprepare: function() {
var ace = this;
this.editor = RED.editor.createEditor({
id: 'node-input-sql-editor',
mode: 'ace/mode/sql',
value: $("#node-input-sql").val(),
globals: {
msg:true,
context:true,
RED: true,
util: true,
flow: true,
global: true,
console: true,
Buffer: true,
setTimeout: true,
clearTimeout: true,
setInterval: true,
clearInterval: true
}
});
2018-03-20 20:04:23 +01:00
$("#node-input-sqlquery").change(function() {
if ($("#node-input-sqlquery").val() == "msg.topic" || $("#node-input-sqlquery").val() == "batch"){
2018-03-20 20:04:23 +01:00
$("#node-input-sqllabel").hide();
$("#node-input-sql-editor").hide();
}
else{
$("#node-input-sqllabel").show();
$("#node-input-sql-editor").show();
ace.editor.renderer.updateFull();
}
});
$("#node-input-sqlquery").change();
},
oneditsave: function() {
$("#node-input-sql").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditresize: function(size) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var height = $("#dialog-form").height();
for (var i=0; i<rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-text-editor-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
this.editor.resize();
}
});
</script>