From b8f8b46b67460a4a16c42693cbdb05d59f9af58a Mon Sep 17 00:00:00 2001 From: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat, 20 Jan 2024 02:59:37 -0500 Subject: [PATCH] Added UI for unpairing individual clients --- src_assets/common/assets/web/pin.html | 50 +++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src_assets/common/assets/web/pin.html b/src_assets/common/assets/web/pin.html index fe18c49c66..1bb3091b9e 100644 --- a/src_assets/common/assets/web/pin.html +++ b/src_assets/common/assets/web/pin.html @@ -8,7 +8,7 @@
-

PIN Pairing

+

PIN Pairing

@@ -22,6 +22,19 @@

PIN Pairing

+
+
+
+

Paired Clients

+
Refresh
+
+
+
Success! Click 'Apply' to restart Sunshine and apply changes. This will terminate any running sessions.
+ +
+
    +
    +
    @@ -55,6 +68,39 @@

    PIN Pairing

    "#status" ).innerHTML = ``; } + refreshClients(); }); }); - + + const clientList = document.querySelector("#client-list"); + + function refreshClients() { + fetch("/api/clients/list") + .then((response) => response.json()) + .then((response) => { + clientList.innerHTML = ""; + if (response.status === 'true' && response.named_certs && response.named_certs.length) { + for (const named_cert of response.named_certs) { + clientList.innerHTML += `
    ${named_cert.name != "" ? named_cert.name : "Unknown"}
    Remove
    `; + } + } else { + clientList.innerHTML = `

    There are no paired clients.

    `; + } + for (const unpairOption of clientList.querySelectorAll(".unpair")) { + unpairOption.addEventListener("click", () => { + fetch("/api/clients/unpair-single", { method: "POST", body: JSON.stringify({ uniqueid: unpairOption.dataset.uniqueid }) }).then(() => { + document.querySelector("#apply-alert").style.display = ""; + refreshClients(); + }); + }); + } + }); + } + refreshClients(); + + document.querySelector("#client-refresh").addEventListener("click", refreshClients); + document.querySelector("#apply-alert .apply").addEventListener("click", () => { + document.querySelector("#apply-alert").style.display = "none!important"; + fetch("/api/restart", { method: "POST" }); + }); + \ No newline at end of file