Add adduser to admin view

This commit is contained in:
Dominic Zimmer
2020-07-18 01:14:14 +02:00
parent 3047a6de77
commit cd3c8dd4f8
2 changed files with 21 additions and 0 deletions

View File

@@ -27,6 +27,25 @@ Object.defineProperty(String.prototype, 'hashCode', {
function render_table(data) {
const users = Object.values(data.users);
const newusername = document.querySelector("#newusername");
const newuserbutton = document.querySelector("#newuserbutton");
newuserbutton.addEventListener("click", async () => {
const r = await fetch(admin_api_path + 'add_user', {
method: "POST",
body: JSON.stringify({
username: newusername.value,
}),
});
if (r.status !== 200) {
console.log("something went wrong");
return;
}
update_table();
})
const tbody = document.querySelector("#scoreboard tbody");
while (tbody.children.length) {