Skip to content

Commit

Permalink
feat(web-ui): add confirmation dialog before deleting streams
Browse files Browse the repository at this point in the history
  • Loading branch information
skrashevich committed Apr 26, 2024
1 parent 12a7503 commit 5035320
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,26 @@
});

const tbody = document.getElementById('streams');
tbody.addEventListener('click', ev => {
tbody.addEventListener('click', async ev => {
if (ev.target.innerText !== 'delete') return;

ev.preventDefault();

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 = `Are you sure you want to stop and delete the stream "${src}" from the configuration? This action is irreversible`;

const confirmDelete = confirm(message);
if (!confirmDelete) return;

try {

await fetch(url, { method: 'DELETE' });
reload();
} catch (error) {
console.error('Failed to delete the stream:', error);
}
});

document.getElementById('selectall').addEventListener('change', ev => {
Expand Down

0 comments on commit 5035320

Please sign in to comment.