Relocate admin routes to make room for API

I want to use the top-level /users route for the API that we'll access from the front-end site running on Vercel, and this is the easiest way to make space. Eventually we won't have admin pages, but I want to be additive for now.
This commit is contained in:
Nathan Sobo 2021-12-19 09:06:57 -07:00
parent 29bc2db6e8
commit f4b9772ec2
2 changed files with 22 additions and 16 deletions

View File

@ -30,10 +30,10 @@ impl RequestExt for Request {
pub fn add_routes(app: &mut tide::Server<Arc<AppState>>) { pub fn add_routes(app: &mut tide::Server<Arc<AppState>>) {
app.at("/admin").get(get_admin_page); app.at("/admin").get(get_admin_page);
app.at("/users").post(post_user); app.at("/admin/users").post(post_user);
app.at("/users/:id").put(put_user); app.at("/admin/users/:id").put(put_user);
app.at("/users/:id/delete").post(delete_user); app.at("/admin/users/:id/delete").post(delete_user);
app.at("/signups/:id/delete").post(delete_signup); app.at("/admin/signups/:id/delete").post(delete_signup);
} }
#[derive(Serialize)] #[derive(Serialize)]

View File

@ -24,13 +24,15 @@
<div class="flex flex-row items-center justify-between p-5 border-b border-white pl-7 pr-7 admin-nav"> <div class="flex flex-row items-center justify-between p-5 border-b border-white pl-7 pr-7 admin-nav">
<h1 class="font-display font-extralight">Admin</h1> <h1 class="font-display font-extralight">Admin</h1>
<ul class="flex flex-row"> <ul class="flex flex-row">
<li><a href="#userlist" class="mr-4 leading-relaxed no-underline lowercase text-main hover:underline">Users</a></li> <li><a href="#userlist"
<li><a href="#signuplist" class="leading-relaxed no-underline lowercase text-main hover:underline">Signups</a></li> class="mr-4 leading-relaxed no-underline lowercase text-main hover:underline">Users</a></li>
<li><a href="#signuplist"
class="leading-relaxed no-underline lowercase text-main hover:underline">Signups</a></li>
</ul> </ul>
</div> </div>
<h2 id="userlist" class="pt-10 mb-5 text-white pl-7 pr-7 font-display font-extralight">Users</h2> <h2 id="userlist" class="pt-10 mb-5 text-white pl-7 pr-7 font-display font-extralight">Users</h2>
<div class="flex flex-col w-full pb-5 font-mono text-xs" id="users"> <div class="flex flex-col w-full pb-5 font-mono text-xs" id="users">
<div class="flex flex-row pl-5 pr-10 font-bold"> <div class="flex flex-row pl-5 pr-10 font-bold">
<p class="w-1/3 p-2">Github Username</p> <p class="w-1/3 p-2">Github Username</p>
@ -38,16 +40,17 @@
<p class="w-24 p-2"> </p> <p class="w-24 p-2"> </p>
</div> </div>
<div class="flex flex-col pl-5 pr-10 text-gray-100"> <div class="flex flex-col pl-5 pr-10 text-gray-100">
<form action="/users" method="post" class="m-0"> <form action="/admin/users" method="post" class="m-0">
<div class="flex flex-row items-center"> <div class="flex flex-row items-center">
<p class="w-1/3 p-2"><input class="block w-full p-2 text-xs bg-transparent border border-white" type="text" name="github_login" required minlength="4" placeholder="@github_handle"></p> <p class="w-1/3 p-2"><input class="block w-full p-2 text-xs bg-transparent border border-white"
type="text" name="github_login" required minlength="4" placeholder="@github_handle"></p>
<p class="w-32 p-2 text-center"><input type="checkbox" id="admin" name="admin" value="true"></p> <p class="w-32 p-2 text-center"><input type="checkbox" id="admin" name="admin" value="true"></p>
<p class="w-24 p-2"><button class="underline hover:no-underline">Add</button></p> <p class="w-24 p-2"><button class="underline hover:no-underline">Add</button></p>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<div class="flex flex-col w-full pb-10 font-mono text-xs border-b border-white"> <div class="flex flex-col w-full pb-10 font-mono text-xs border-b border-white">
<div class="flex flex-row pl-5 pr-10 font-bold"> <div class="flex flex-row pl-5 pr-10 font-bold">
<p class="w-1/3 p-2">Github Username</p> <p class="w-1/3 p-2">Github Username</p>
@ -56,10 +59,11 @@
</div> </div>
{{#each users}} {{#each users}}
<div class="flex flex-col pl-5 pr-10 text-gray-100 alternate-bg"> <div class="flex flex-col pl-5 pr-10 text-gray-100 alternate-bg">
<form action="/users/{{id}}/delete" method="post" class="m-0"> <form action="/admin/users/{{id}}/delete" method="post" class="m-0">
<div class="flex flex-row items-center"> <div class="flex flex-row items-center">
<p class="w-1/3 p-2">{{github_login}}</p> <p class="w-1/3 p-2">{{github_login}}</p>
<p class="w-32 p-2 text-center"><input action="/users/{{id}}" type="checkbox" {{#if admin}}checked{{/if}}></p> <p class="w-32 p-2 text-center"><input action="/admin/users/{{id}}" type="checkbox" {{#if
admin}}checked{{/if}}></p>
<p class="w-24 p-2"><button class="underline hover:no-underline">Remove</button></p> <p class="w-24 p-2"><button class="underline hover:no-underline">Remove</button></p>
</div> </div>
</form> </form>
@ -70,7 +74,7 @@
<h2 class="pt-10 mb-5 text-white pl-7 pr-7 font-display font-extralight">Signups</h2> <h2 class="pt-10 mb-5 text-white pl-7 pr-7 font-display font-extralight">Signups</h2>
<div class="flex flex-col w-full pb-10 font-mono text-xs border-b border-white"> <div class="flex flex-col w-full pb-10 font-mono text-xs border-b border-white">
<div class="flex flex-row justify-between pl-5 pr-10 font-bold"> <div class="flex flex-row justify-between pl-5 pr-10 font-bold">
<p class="w-1/5 p-2">Email</p> <p class="w-1/5 p-2">Email</p>
<p class="w-1/5 p-2">Github</p> <p class="w-1/5 p-2">Github</p>
@ -81,17 +85,19 @@
</div> </div>
{{#each signups}} {{#each signups}}
<div class="flex flex-col pb-1 pl-5 pr-10 text-gray-100 alternate-bg"> <div class="flex flex-col pb-1 pl-5 pr-10 text-gray-100 alternate-bg">
<form action="/signups/{{id}}/delete" method="post" class="m-0"> <form action="/admin/signups/{{id}}/delete" method="post" class="m-0">
<div class="flex flex-row items-center justify-between"> <div class="flex flex-row items-center justify-between">
<p class="w-1/5 p-2 pb-1">{{email_address}}</p> <p class="w-1/5 p-2 pb-1">{{email_address}}</p>
<p class="w-1/5 p-2 pb-1">{{github_login}}</p> <p class="w-1/5 p-2 pb-1">{{github_login}}</p>
<p class="w-24 p-2 pb-1 text-center">{{#if wants_releases}}[✓]{{else}}[ ]{{/if}}</p> <p class="w-24 p-2 pb-1 text-center">{{#if wants_releases}}[✓]{{else}}[ ]{{/if}}</p>
<p class="w-24 p-2 pb-1 text-center">{{#if wants_updates}}[✓]{{else}}[ ]{{/if}}</p> <p class="w-24 p-2 pb-1 text-center">{{#if wants_updates}}[✓]{{else}}[ ]{{/if}}</p>
<p class="w-24 p-2 pb-1 text-center">{{#if wants_community}}[✓]{{else}}[ ]{{/if}}</p> <p class="w-24 p-2 pb-1 text-center">{{#if wants_community}}[✓]{{else}}[ ]{{/if}}</p>
<p class="w-24 p-2 pb-1 text-right"><button class="text-lg text-gray-500 hover:text-white">×</button></p> <p class="w-24 p-2 pb-1 text-right"><button
class="text-lg text-gray-500 hover:text-white">×</button></p>
</div> </div>
</form> </form>
<p class="max-w-full p-2 pt-0 overflow-hidden leading-normal text-gray-400 max-h-5 whitespace-nowrap overflow-ellipsis" title="{{about}}">{{about}}</p> <p class="max-w-full p-2 pt-0 overflow-hidden leading-normal text-gray-400 max-h-5 whitespace-nowrap overflow-ellipsis"
title="{{about}}">{{about}}</p>
</div> </div>
{{/each}} {{/each}}
</div> </div>