-
Notifications
You must be signed in to change notification settings - Fork 0
/
adodb.html
127 lines (123 loc) · 5.01 KB
/
adodb.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<script type="text/html" data-template-name="adodb_db">
TEST
<div class="form-row">
<label for="node-config-input-db"><i class="fa fa-database"></i> <span data-i18n="adodb.label.database"></label>
<input type="text" id="node-config-input-db" placeholder="...">
</div>
<div class="form-row">
<label for="node-config-input-mode" data-i18n="adodb.label.mode"></label>
</div>
<!-- <div class="form-tips" data-i18n="[html]adodb.tips.memoryDb"></div> -->
</script>
<script type="text/javascript">
RED.nodes.registerType('adodb_db',{
category: 'config',
defaults: {
db: {value:"", required:true},
mode: {value:"RWC"}
},
label: function() {
return this.db;
}
});
</script>
<script type="text/html" data-template-name="adodb">
<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">
</div>
<div class="form-row">
<label for="node-input-mydb"><i class="fa fa-database"></i> <span data-i18n="adodb.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="adodb.label.sqlQuery"></label>
<select id="node-input-sqlquery">
<option value="viaMsgTopicWithResponse" data-i18n="adodb.label.viaMsgTopicWithResponse"></option>
<option value="viaMsgTopicWithoutResponse" data-i18n="adodb.label.viaMsgTopicWithoutResponse"></option>
<option value="queryWithResponse" data-i18n="adodb.label.queryWithResponse"></option>
<option value="queryWithoutResponse" data-i18n="adodb.label.queryWithoutResponse"></option>
</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="adodb.label.sqlStatement"></label>
</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('adodb',{
category: 'storage-input',
color:"#697b10",
defaults: {
mydb: {type:"adodb_db",required:true},
sqlquery: {value:"msg.topic",required:true},
sql: {value:""},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "adodb.png",
label: function() {
var dbNode = RED.nodes.node(this.mydb);
return this.name||(dbNode?dbNode.label():"adodb");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
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
}
});
$("#node-input-sqlquery").change(function() {
if ($("#node-input-sqlquery").val() == "msg.topic" || $("#node-input-sqlquery").val() == "batch"){
$("#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>