Simplify trigger logic to port-only matching and improve Samsung detection

This commit is contained in:
Lago
2026-03-27 15:09:16 +01:00
parent 33e762c182
commit 37eb9e9fa0
8 changed files with 276 additions and 186 deletions
+6 -25
View File
@@ -250,7 +250,7 @@
<p class="eyebrow">Alienware-Only Targeting</p>
<h1>Internal KVM Switch Dashboard</h1>
<p>
Samsung is trigger-only and uses fixed codes: Tower = 15 and Laptop = 19. This dashboard only controls which Alienware input port each machine should switch to.
Samsung is trigger-only. This device switches Alienware AW3423DWF when Samsung input matches the configured local port code: DP1 = 15, DP2 = 19, HDMI = 17.
</p>
</section>
@@ -258,13 +258,6 @@
<article class="card">
<h2>Settings</h2>
<form id="settings-form">
<label class="field" for="device-role">
<span>This Device Role</span>
<select id="device-role" required>
<option value="tower">Tower</option>
<option value="laptop">Laptop</option>
</select>
</label>
<label class="field" for="device-port">
<span>This Device Alienware Port</span>
<select id="device-port" required>
@@ -273,7 +266,7 @@
<option value="HDMI">HDMI</option>
</select>
</label>
<p class="hint">Samsung trigger logic is fixed: <code>15 = Tower</code>, <code>19 = Laptop</code>. The selected role and port are saved locally in <code>config.json</code>.</p>
<p class="hint">The selected port is saved locally in <code>config.json</code>.</p>
<div class="actions">
<button id="save-btn" type="submit">Save Settings</button>
</div>
@@ -293,7 +286,6 @@
<script>
const els = {
form: document.getElementById("settings-form"),
role: document.getElementById("device-role"),
port: document.getElementById("device-port"),
saveBtn: document.getElementById("save-btn"),
msg: document.getElementById("form-message"),
@@ -313,26 +305,20 @@
function renderStatus(payload) {
const config = payload.config || {};
const roleVal = config.device_role;
const portVal = config.device_port;
if (!formDirty && document.activeElement !== els.role) {
els.role.value = roleVal ?? "tower";
}
if (!formDirty && document.activeElement !== els.port) {
els.port.value = portVal ?? "DP1";
}
els.stats.innerHTML = [
stat("Device Role", config.device_role),
stat("This Device Port", config.device_port),
stat("Samsung Present", payload.samsung_present ? "Yes" : "No"),
stat("Trigger Input", payload.trigger_input_code),
stat("Tower Trigger", "15"),
stat("Laptop Trigger", "19"),
stat("Trigger Target Port", payload.trigger_target_port),
stat("Trigger Matches This Device Port", payload.trigger_matches_device_port ? "Yes" : "No"),
stat("Alienware Detected", payload.alienware_detected ? "Yes" : "No"),
stat("Alienware Input", payload.alienware_input_code),
stat("Resolved Target", payload.resolved_target),
stat("Attempted This Samsung Session", payload.samsung_session_attempted ? "Yes" : "No"),
stat("Successful This Samsung Session", payload.samsung_session_successful ? "Yes" : "No"),
stat("Attempts This Samsung Session", payload.samsung_session_attempt_count),
@@ -372,12 +358,11 @@
async function saveSettings(event) {
event.preventDefault();
const role = els.role.value;
const port = els.port.value;
if (!role || !port) {
if (!port) {
els.msg.className = "message error";
els.msg.textContent = "Both device role and device port must be selected.";
els.msg.textContent = "A device port must be selected.";
return;
}
@@ -390,7 +375,6 @@
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
device_role: role,
device_port: port,
}),
});
@@ -428,9 +412,6 @@
els.port.addEventListener("change", () => {
formDirty = true;
});
els.role.addEventListener("change", () => {
formDirty = true;
});
els.form.addEventListener("submit", saveSettings);
loadStatus(true);
setInterval(() => loadStatus(false), 1500);