Skip to content

Commit

Permalink
Merge pull request #1063 from skrashevich/feat-confirm-dialog-before-…
Browse files Browse the repository at this point in the history
…delete-stream

feat(web-ui): add confirmation dialog before delete stream
  • Loading branch information
AlexxIT authored Apr 27, 2024
2 parents 12a7503 + 8d6aabc commit ab405b3
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>go2rtc</title>

<style>

body {
margin: 0;
padding: 0;
Expand Down Expand Up @@ -81,15 +78,28 @@
});

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);

const message = `Please type the name of the stream "${src}" to confirm its deletion from the configuration. This action is irreversible.`;
if (prompt(message) !== src) {
alert('Stream name does not match. Deletion cancelled.');
return;
}

const url = new URL('api/streams', location.href);
url.searchParams.set('src', src);
fetch(url, {method: 'DELETE'}).then(reload);

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 ab405b3

Please sign in to comment.