forked from cory/tildefriends
Cory McWilliams
fbfbd6a6b4
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3950 ed5197a5-7fde-0310-b194-c3ffbd925b24
21 lines
721 B
JavaScript
21 lines
721 B
JavaScript
import {html, render} from './lit.min.js';
|
|
import * as tfrpc from '/static/tfrpc.js';
|
|
|
|
function delete_user(user) {
|
|
if (confirm(`Are you sure you want to delete the user "${user}"?`)) {
|
|
tfrpc.rpc.delete_user(user).then(function() {
|
|
alert(`User "${user}" deleted successfully.`);
|
|
}).catch(function(error) {
|
|
alert(`Failed to delete user "${user}": ${JSON.stringify(error, null, 2)}.`);
|
|
});
|
|
}
|
|
}
|
|
|
|
window.addEventListener('load', function() {
|
|
const user_template = (user) => html`<li><button @click=${(e) => delete_user(user)}>Delete</button> ${user}</li>`;
|
|
const users_template = (users) =>
|
|
html`<ul>
|
|
${users.map(u => user_template(u))}
|
|
</ul>`;
|
|
render(users_template(g_data.users), document.body);
|
|
}); |