| 1 | const removeEls = document.querySelectorAll(".ssh-key-remove"); |
| 2 | |
| 3 | [...removeEls].forEach(el => { |
| 4 | el.addEventListener("click", () => { |
| 5 | const title = el.dataset.title; |
| 6 | |
| 7 | if (confirm("Do you really want to remove \"" + title + "\"?")) { |
| 8 | removeSSHKey(el.dataset.username, el.dataset.id) |
| 9 | .then(() => location.reload()) |
| 10 | .catch(error => alert(error)); |
| 11 | } |
| 12 | }); |
| 13 | }); |
| 14 | |
| 15 | async function removeSSHKey(username, id) { |
| 16 | await fetch(`/${username}/settings/ssh-keys/${id}`, { |
| 17 | method: "DELETE" |
| 18 | }); |
| 19 | } |
| 20 | |