forked from cory/tildefriends
		
	Exposed deleting users, mostly for my own testing, and used it to make a primitive admin app. Add a handful of apps I've been kicking around without version control, while I'm at it.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3950 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		
							
								
								
									
										13
									
								
								apps/cory/admin/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								apps/cory/admin/app.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| import * as tfrpc from '/tfrpc.js'; | ||||
|  | ||||
| tfrpc.register(function delete_user(user) { | ||||
| 	return core.deleteUser(user); | ||||
| }); | ||||
|  | ||||
| async function main() { | ||||
| 	let data = { | ||||
| 		users: await core.users(), | ||||
| 	}; | ||||
| 	await app.setDocument(utf8Decode(getFile('index.html')).replace('$data', JSON.stringify(data))); | ||||
| } | ||||
| main(); | ||||
							
								
								
									
										10
									
								
								apps/cory/admin/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								apps/cory/admin/index.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <!DOCTYPE html> | ||||
| <html> | ||||
| 	<head> | ||||
| 		<script>const g_data = $data;</script> | ||||
| 	</head> | ||||
| 	<body style="color: #fff"> | ||||
| 		<h1>Test</h1> | ||||
| 	</body> | ||||
| 	<script type="module" src="script.js"></script> | ||||
| </html> | ||||
							
								
								
									
										13
									
								
								apps/cory/admin/lit.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								apps/cory/admin/lit.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										21
									
								
								apps/cory/admin/script.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								apps/cory/admin/script.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| 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); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user