-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql-server.hni
More file actions
49 lines (47 loc) · 2.45 KB
/
mysql-server.hni
File metadata and controls
49 lines (47 loc) · 2.45 KB
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
<script type="text/x-red" data-template-name="mysql-server">
<div class="form-row">
<label for="node-config-input-server"><i class="fa fa-globe"></i> <span data-i18n="mysql-server.label.server"></span></label>
<input class="input-append-left" type="text" id="node-config-input-server" placeholder="e.g. localhost" style="width:40%;" >
<label for="node-config-input-port" style="margin-left:20px; width:35px;"> <span data-i18n="mysql-server.label.port"></span></label>
<input type="text" id="node-config-input-port" data-i18n="[placeholder]mysql-server.label.port" style="width:55px">
</div>
<div class="form-row">
<label for="node-config-input-database"><i class="fa fa-database"></i> <span data-i18n="mysql-server.label.database"></span></label>
<input type="text" id="node-config-input-database" data-i18n="[placeholder]mysql-server.label.database">
</div>
<div class="form-row">
<label for="node-config-input-user"><i class="fa fa-user"></i> <span data-i18n="mysql-server.label.user"></span></label>
<input type="text" id="node-config-input-user" data-i18n="[placeholder]mysql-server.label.user">
</div>
<div class="form-row">
<label for="node-config-input-pwd"><i class="fa fa-lock"></i> <span data-i18n="mysql-server.label.pwd"></span></label>
<input type="password" id="node-config-input-pwd" data-i18n="[placeholder]mysql-server.label.pwd">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('mysql-server', {
category: 'config',
namespace: 'mysql',
defaults: {
server: {value: "", required: true},
port: {value: 3306, required: true, validate: RED.validators.number()},
database: {value: "", required: true},
user: {value: "", required: true}
},
label: function () {
var b = this.server || undefined;
return (this.database ? this.database + "@" : "") + b;
},
oneditprepare: function () {
RED.comms.homegear().invoke("getNodeData", function (data) {
$("#node-config-input-pwd").val(data.result)
}, this.id, "password");
},
oneditsave: function () {
var pwd = $.trim($("#node-config-input-pwd").val());
if (pwd != "*") {
RED.comms.homegear().invoke("setNodeData", null, this.id, "password", pwd);
}
}
});
</script>