node-red-contrib-knx-ultimate
Version:
Control your KNX and KNX Secure intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control, ETS group address importer, KNX AI for diagnosticsand KNX routing between interfaces. Easy to use and highly configurable.
178 lines (160 loc) • 9.31 kB
HTML
<script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/htmlUtils.js"></script>
<script type="text/javascript">
RED.nodes.registerType('knxUltimateLogger', {
category: "KNX Ultimate",
color: '#C7E9C0',
defaults: {
server: { type: "knxUltimate-config", required: true },
topic: { value: "" },
intervalCreateETSXML: { value: 15, required: true, validate: RED.validators.number() },
name: { value: "" },
autoStartTimerCreateETSXML: { value: true },
maxRowsInETSXML: { value: 0, required: true, validate: RED.validators.number() },
saveMode: { value: "emit" },
filePath: { value: "" },
autoStartTimerTelegramCounter: { value: false },
intervalTelegramCount: { value: 60, required: false, validate: RED.validators.number() }
},
inputs: 1,
outputs: 2,
outputLabels: ["ETS Diag file", "Telegram Count"],
icon: "node-logger-icon.svg",
label: function () {
return ((this.name || "KNX Logger") + " " + this.topic);
},
paletteLabel: "KNX Logger",
oneditprepare: function () {
// Go to the help panel
try {
RED.sidebar.show("help");
} catch (error) { }
$("#mlxETSFileAccordion").accordion({
header: "h3",
heightStyle: "content",
collapsible: true,
active: false
});
const nodeId = this.id;
const resolveAdminRoot = () => {
const raw = (RED.settings && typeof RED.settings.httpAdminRoot === "string") ? RED.settings.httpAdminRoot : "/";
const trimmed = String(raw || "/").trim();
if (trimmed === "" || trimmed === "/") return "";
return "/" + trimmed.replace(/^\/+|\/+$/g, "");
};
const resolveAccessToken = () => {
try {
const tokens = (RED.settings && typeof RED.settings.get === "function") ? RED.settings.get("auth-tokens") : null;
const token = tokens && typeof tokens.access_token === "string" ? tokens.access_token.trim() : "";
return token;
} catch (error) {
return "";
}
};
const toggleFilePath = () => {
const isEmitSave = $("#node-input-saveMode").val() === "emit_save";
const $filePathRow = $("#knx-logger-filePath-row");
if (isEmitSave) {
$filePathRow.show();
} else {
$filePathRow.hide();
}
};
$("#node-input-saveMode").on("change", toggleFilePath);
const currentFilePath = this.filePath || "";
$("#node-input-filePath").val(currentFilePath);
toggleFilePath();
$("#knx-logger-downloadButton").on("click", function (evt) {
evt.preventDefault();
const filePathVal = $("#node-input-filePath").val() || "";
if (!filePathVal) {
try {
const msg = (RED._ && RED._("node-red-contrib-knx-ultimate/knxUltimateLogger:noFilePath")) || "File path is empty";
RED.notify(msg, "warning");
} catch (error) {
alert("File path is empty");
}
return;
}
const adminRoot = resolveAdminRoot();
const targetBase = adminRoot + "/knxUltimateLoggerDownload";
const params = new URLSearchParams();
if (nodeId) params.set("nodeId", nodeId);
params.set("_", String(Date.now()));
const accessToken = resolveAccessToken();
if (accessToken) params.set("access_token", accessToken);
const target = targetBase + "?" + params.toString();
const wnd = window.open(target, "_blank", "noopener,noreferrer");
try { if (wnd && typeof wnd.focus === "function") wnd.focus(); } catch (e) { }
});
},
oneditsave: function () {
// Return to the info tab
try {
RED.sidebar.show("info");
} catch (error) { }
this.filePath = $("#node-input-filePath").val() || "";
}
})
</script>
<script type="text/html" data-template-name="knxUltimateLogger">
<div class="form-row">
<b><span data-i18n="knxUltimateLogger.title"></span></b>
<br/><br/>
<label for="node-input-server"><i class="fa fa-tag"></i> <span data-i18n="knxUltimateLogger.properties.node-input-server"></span> </label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> <span data-i18n="knxUltimateLogger.properties.node-input-topic"></span></label>
<input type="text" id="node-input-topic" data-i18n="[placeholder]knxUltimateLogger.properties.node-input-topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="knxUltimateLogger.properties.node-input-name"></span> </label>
<input type="text" id="node-input-name" data-i18n="[placeholder]knxUltimateLogger.properties.node-input-name" style="flex:1 1 240px; min-width:240px; max-width:240px;">
</div>
<div id="mlxETSFileAccordion">
<h3><span data-i18n="knxUltimateLogger.properties.mlxETSFileAccordion"></span></h3>
<div>
<p>
<div class="form-row">
<input type="checkbox" id="node-input-autoStartTimerCreateETSXML" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-autoStartTimerCreateETSXML"> <i class="fa fa-play-circle"></i> <span data-i18n="knxUltimateLogger.properties.node-input-autoStartTimerCreateETSXML"></span> </label>
</div>
<div class="form-row">
<label style="width:290px" for="node-input-saveMode"><i class="fa fa-save"></i> <span data-i18n="knxUltimateLogger.properties.node-input-saveMode"></span></label>
<select style="width:100%" id="node-input-saveMode">
<option value="emit" data-i18n="knxUltimateLogger.selectlists.saveMode.emit"></option>
<option value="emit_save" data-i18n="knxUltimateLogger.selectlists.saveMode.emit_save"></option>
</select>
</div>
<div class="form-row" id="knx-logger-filePath-row">
<label style="width:290px" for="node-input-filePath"><i class="fa fa-file-text-o"></i> <span data-i18n="knxUltimateLogger.properties.node-input-filePath"></span></label>
<input style="width:calc(100% - 80px)" type="text" id="node-input-filePath" data-i18n="[placeholder]knxUltimateLogger.placeholder.node-input-filePath">
<button type="button" class="red-ui-button" id="knx-logger-downloadButton" style="margin-left:6px;" title="Download">
<i class="fa fa-download"></i>
</button>
</div>
<div class="form-row">
<label style="width:290px" for="node-input-intervalCreateETSXML"><i class="fa fa-clock-o"></i> <span data-i18n="knxUltimateLogger.properties.node-input-intervalCreateETSXML"></span></label>
<input style="width:90px" type="number" id="node-input-intervalCreateETSXML">
</div>
<div class="form-row">
<label style="width:290px" for="node-input-maxRowsInETSXML"><i class="fa fa-bars"></i> <span data-i18n="knxUltimateLogger.properties.node-input-maxRowsInETSXML"></span></label>
<input style="width:90px" type="number" id="node-input-maxRowsInETSXML">
</div>
</p>
</div>
<h3><span data-i18n="knxUltimateLogger.properties.telegramCounter"></span></h3>
<div>
<p>
<div class="form-row">
<input type="checkbox" id="node-input-autoStartTimerTelegramCounter" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-autoStartTimerTelegramCounter"> <i class="fa fa-play-circle"></i> <span data-i18n="knxUltimateLogger.properties.node-input-autoStartTimerCreateETSXML"></span> </label>
</div>
<div class="form-row">
<label style="width:290px" for="node-input-intervalTelegramCount"><i class="fa fa-clock-o"></i> <span data-i18n="knxUltimateLogger.properties.node-input-intervalTelegramCount"></span></label>
<input style="width:90px" type="number" id="node-input-intervalTelegramCount">
</div>
</p>
</div>
</div>
</script>