From 8516f825e1f580e2c580157245c158c92ed776ba Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 26 Apr 2024 16:05:56 +0300 Subject: [PATCH 1/2] feat(web-ui): add confirmation dialog before deleting streams --- www/index.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/www/index.html b/www/index.html index 675e7079..85aa729a 100644 --- a/www/index.html +++ b/www/index.html @@ -81,7 +81,7 @@ }); const tbody = document.getElementById('streams'); - tbody.addEventListener('click', ev => { + tbody.addEventListener('click', async ev => { if (ev.target.innerText !== 'delete') return; ev.preventDefault(); @@ -89,8 +89,22 @@ const url = new URL('api/streams', location.href); const src = decodeURIComponent(ev.target.dataset.name); url.searchParams.set('src', src); - fetch(url, {method: 'DELETE'}).then(reload); + const message = `Please type the name of the stream "${src}" to confirm its stop and deletion from the configuration. This action is irreversible.`; + + const userInput = prompt(message); + if (userInput !== src) { + alert("Stream name does not match. Deletion cancelled."); + return; + } + + try { + await fetch(url, { method: 'DELETE' }); + reload(); + } catch (error) { + console.error('Failed to delete the stream:', error); + } }); + document.getElementById('selectall').addEventListener('change', ev => { document.querySelectorAll('#streams input').forEach(el => { From 8d6aabce7aad73cce0cb7ee1f6ac840f2fd8a234 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sat, 27 Apr 2024 11:40:59 +0300 Subject: [PATCH 2/2] Code refactoring after #1063 --- www/index.html | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/www/index.html b/www/index.html index 85aa729a..983e26f1 100644 --- a/www/index.html +++ b/www/index.html @@ -4,11 +4,8 @@ - go2rtc -