-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.html
165 lines (146 loc) · 5.15 KB
/
main.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<script type="text/html" data-template-name="Stackhero-MySQL-Server">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-config-input-host" placeholder="xxxxxx.stackhero-network.com">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-random"></i> Port</label>
<input type="text" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-tls"><i class="fa fa-shield"></i> TLS</label>
<input type="checkbox" id="node-config-input-tls" style="display:inline-block; width:auto; vertical-align:top;">
<label for="node-config-input-tls" style="width:auto !important;"> Encrypt connection to database</label>
</div>
<div class="form-row">
<label for="node-config-input-user"><i class="fa fa-user"></i> User</label>
<input type="text" id="node-config-input-user">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label for="node-config-input-database"><i class="fa fa-database"></i> Database</label>
<input type="text" id="node-config-input-database">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('Stackhero-MySQL-Server', {
category: 'config',
defaults: {
name: {
value: ""
},
host: {
value: "xxxxxx.stackhero-network.com",
required: true
},
port: {
value: "3306",
required: true
},
tls: {
value: true,
required: true
},
database: {
value: "",
required: true
}
},
credentials: {
user: {
type: "text"
},
password: {
type: "password"
}
},
// Note: label (and probably labelStyle) have to be a classical function (not an arrow function)
label: function () {
return this.name || this.database
}
});
</script>
<!-- See https://nodered.org/docs/creating-nodes/help-style-guide -->
<script type="text/html" data-help-name="Stackhero-MySQL-Server">
<p>
Add the credentials for accessing your database here.<br />
You can find your credentials on Stackhero by choosing your MySQL service and then clicking on the "Configure" button.
</p>
</script>
<script type="text/html" data-template-name="Stackhero-MySQL">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-database"></i> Database</label>
<input type="text" id="node-input-server">
</div>
<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>
</script>
<!-- See https://nodered.org/docs/creating-nodes/help-style-guide -->
<script type="text/html" data-help-name="Stackhero-MySQL">
<p>Connects to a MySQL database.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>
topic <span class="property-type">string</span>
</dt>
<dd> the SQL query.</dd>
<dt class="optional">
payload <span class="property-type">object</span>
</dt>
<dd> the arguments passed to the query.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">array</span></dt>
<dd>the results of the SQL query.</dd>
</dl>
<h3>Example</h3>
<p>
The query:
<pre>msg.topic = 'SELECT * FROM `users` WHERE `name` = :name AND `age` > :age;'</pre>
The arguments:
<pre>msg.payload = { name: 'Adrien', age: 30 };</pre>
</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/stackhero-io/node-red-contrib-stackhero-mysql">Repository</a> - the node repository</li>
<li><a href="https://www.stackhero.io/services/MySQL">MySQL</a> - Managed MySQL database</li>
<li><a href="https://www.stackhero.io/services/MariaDB">MariaDB</a> - Managed MariaDB database</li>
<li><a href="https://www.stackhero.io/services/Node-RED">Node-RED</a> - Managed Node-RED service</li>
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('Stackhero-MySQL', {
category: 'storage-input',
color: '#C0DEED', // See https://nodered.org/docs/creating-nodes/appearance#background-colour
defaults: {
server: {
type: 'Stackhero-MySQL-Server',
required: true
},
name: {
value: ''
}
},
inputs: 1, // Number of input
outputs: 1, // Number of outputs
icon: 'db.png', // See https://nodered.org/docs/creating-nodes/appearance#icon
// Note: label (and probably labelStyle) have to be a classical function (not an arrow function)
label: function () {
const levelNode = RED.nodes.node(this.server);
return this.name || (levelNode ? levelNode.label() : 'Stackhero MySQL');
},
labelStyle: function () {
return this.name ? 'node_label_italic' : ''
}
});
</script>