-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmysql_src.html
146 lines (140 loc) · 6.16 KB
/
mysql_src.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<script type="text/javascript">
RED.nodes.registerType('mysql.src', {
category: 'gulp',
color: '#00758F',
// color: '#3984FF', // dropbox blue night
defaults: {
name: { value: "" },
path: { value: "" },
config: {
value: JSON.stringify({
"buffer": false,
"connection": {
"host": "example.org",
"user": "bob",
"password": "secret",
"database": "schemaName"
}
}, undefined, " ")
},
sql: { value: "" }
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-files-o",
label: function () {
return this.name || this.path || "mysql.src";
},
oneditprepare: function () {
const that = this;
const sqlStateId = RED.editor.generateViewStateId("node", this, "");
this.sqlEditor = RED.editor.createEditor({
id: 'node-input-sql-editor',
mode: 'ace/mode/sql',
value: $("#node-input-sql").val(),
stateId: sqlStateId
});
const configStateId = RED.editor.generateViewStateId("node", this, "");
this.configEditor = RED.editor.createEditor({
id: 'node-input-config-editor',
mode: 'ace/mode/json',
value: $("#node-input-config").val(),
stateId: configStateId
});
RED.popover.tooltip($("#node-template-expand-sql-editor"), RED._("node-red:common.label.expand"));
$("#node-template-expand-sql-editor").on("click", function (e) {
e.preventDefault();
const value = that.sqlEditor.getValue();
that.sqlEditor.saveView();
RED.editor.editText({
// mode: $("#node-input-format").val(),
value: value,
stateId: sqlStateId,
width: "Infinity",
focus: true,
complete: function (v, cursor) {
that.sqlEditor.setValue(v, -1);
setTimeout(function () {
that.sqlEditor.restoreView();
that.sqlEditor.focus();
}, 250);
}
})
})
RED.popover.tooltip($("#node-template-expand-config-editor"), RED._("node-red:common.label.expand"));
$("#node-template-expand-config-editor").on("click", function (e) {
e.preventDefault();
const value = that.configEditor.getValue();
that.configEditor.saveView();
RED.editor.editText({
// mode: $("#node-input-format").val(),
value: value,
stateId: configStateId,
width: "Infinity",
focus: true,
complete: function (v, cursor) {
that.configEditor.setValue(v, -1);
setTimeout(function () {
that.configEditor.restoreView();
that.configEditor.focus();
}, 250);
}
})
})
},
oneditsave: function () {
try {
$("#node-input-sql").val(this.sqlEditor.getValue());
this.sqlEditor.destroy();
delete this.sqlEditor;
}
catch { }
try {
$("#node-input-config").val(this.configEditor.getValue());
this.configEditor.destroy();
delete this.configEditor;
}
catch { }
},
oneditcancel: function () {
this.sqlEditor.destroy();
delete this.sqlEditor;
this.configEditor.destroy();
delete this.configEditor;
}
});
</script>
<script type="text/html" data-template-name="mysql.src">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-path"><i class="fa fa-folder-open-o"></i> Path</label>
<input type="text" id="node-input-path">
</div>
<div class="form-row" style="position: relative; margin-bottom: 0px;">
<label for="node-input-config"><i class="fa fa-file-code-o"></i> <span>Config</span></label>
<input type="hidden" id="node-input-config" autofocus="autofocus">
<div style="position: absolute; right:0;display:inline-block; text-align: right; font-size: 0.8em;">
<button type="button" id="node-template-expand-config-editor" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button>
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-config-editor" ></div>
</div>
</div>
<div class="form-row" style="position: relative; margin-bottom: 0px;">
<label for="node-input-sql"><i class="fa fa-file-code-o"></i> <span>SQL</span></label>
<input type="hidden" id="node-input-sql" autofocus="autofocus">
<div style="position: absolute; right:0;display:inline-block; text-align: right; font-size: 0.8em;">
<button type="button" id="node-template-expand-sql-editor" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button>
</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>
</div>
</script>
<script type="text/html" data-help-name="mysql.src">
<p>Creates a stream for reading Vinyl objects from the file system.</p>
<p>Can be used at the beginning or in the middle of a pipeline to add files based on the given globs.</p>
</script>