node-red-contrib-deconz
Version:
deCONZ connectivity nodes for node-red
148 lines (137 loc) • 5.33 kB
HTML
<script type="text/html" data-template-name="deconz-server">
<link rel="stylesheet" href="resources/node-red-contrib-deconz/css/common.css" type="text/css"/>
<div class="deconz-editor">
<!-- --- Tip Box --- -->
<div class="form-row" id="node-input-tip-box"></div>
<!--#region --- Main settings --- -->
<!-- --- Name --- -->
<div class="form-row">
<label for="node-config-input-name" class="l-width"><i class="icon-bookmark"></i> <span
data-i18n="label.name"></span></label>
<input type="text" id="node-config-input-name">
</div>
<!-- --- Magick button --- -->
<div class="form-row">
<label for="node-contrib-deconz-get-settings" class="l-width"><i class="fa fa-refresh"></i> <span
data-i18n="label.magick"></span></label>
<a style="width: 70%" class="red-ui-button primary" id="node-contrib-deconz-get-settings"
name="force-refresh"><span
data-i18n="label.get_settings"></span></a>
</div>
<!-- --- IP-Address --- -->
<div class="form-row">
<label for="node-config-input-ip" class="l-width"><i class="icon-globe"></i> <span
data-i18n="label.ip_address"></span></label>
<input type="text" id="node-config-input-ip">
</div>
<!-- --- Port --- -->
<div class="form-row">
<label for="node-config-input-port" class="l-width"><i class="icon-tag"></i> <span
data-i18n="label.port"></span></label>
<input type="text" id="node-config-input-port">
</div>
<!-- --- API Key --- -->
<div class="form-row">
<label for="node-config-input-secured_apikey" class="l-width"><i class="icon-lock"></i> <span
data-i18n="label.api_key"></span></label>
<input type="text" id="node-config-input-secured_apikey">
</div>
<!-- --- WebSocket Port --- -->
<div class="form-row">
<label for="node-config-input-ws_port" class="l-width"><i class="icon-tag"></i> <span
data-i18n="label.websocket_port"></span></label>
<input type="text" id="node-config-input-ws_port">
</div>
<!-- --- SSL --- -->
<div class="form-row">
<label for="node-config-input-secure" class="l-width"><i class="icon-tag"></i> SSL</label>
<input type="checkbox" id="node-config-input-secure"
style="display: inline-block; width: auto; vertical-align: top;"> <span
data-i18n="label.use_secured_ssl"></span>
</div>
<!-- --- Polling --- -->
<div class="form-row">
<label for="node-config-input-polling" class="l-width"><i class="icon-time"></i> <span
data-i18n="label.polling"></span></label>
<input type="text" id="node-config-input-polling" placeholder="15">
</div>
<!--#endregion -->
<div class="form-row">
<div class="form-tips" data-i18n="[html]tip.deploy"></div>
</div>
</div>
</script>
<script type='text/javascript'>
RED.nodes.registerType('deconz-server', {
category: 'config',
defaults: {
name: {
value: '',
required: false
},
config_version: {
value: 1,
required: true
},
ip: {
value: '',
required: true
},
port: {
value: '',
required: true
},
// Not used anymore but needed in case of upgrading from 1.2.0 or lower to save it in credentials
apikey: {
value: '',
required: false
},
ws_port: {
value: '',
required: true
},
secure: {
value: false,
required: true
},
polling: {
value: 15,
required: false,
validate: function (value) {
return !value || value > 2;
}
},
},
credentials: {
secured_apikey: {
value: '',
required: true
}
},
label: function () {
return this.name || this.ip + ':' + this.port;
},
oneditprepare: function () {
(async () => {
let node = this;
node.nodeEditor = new DeconzMainEditor(node, {
have: {
statustext: false,
query: false,
device: false,
output_rules: false,
commands: false,
specific: true
}
});
await node.nodeEditor.init();
})().then().catch((error) => {
console.error(error);
});
},
oneditsave: function () {
let node = this;
node.nodeEditor.oneditsave();
}
});
</script>