Added settings and API key stuff
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
9d08e23352
commit
a80ad57ca9
14 changed files with 396 additions and 45 deletions
69
nixie-server/templates/settings/api_keys.tera.html
Normal file
69
nixie-server/templates/settings/api_keys.tera.html
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{% extends "base.tera.html" %}
|
||||
{% import "inputs.tera.html" as inputs %}
|
||||
|
||||
{% block title %}
|
||||
API Keys - {{ current_user.username }}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex flex-col md:flex-row grow">
|
||||
<div class="basis-1/4 p-4 m-4 space-y-4">
|
||||
{% include "settings/sidebar.tera.html" %}
|
||||
</div>
|
||||
<div class="basis-3/4 p-4">
|
||||
<h1 class="font-bold text-3xl">API Keys</h1>
|
||||
<form action="/settings/new_api_key" method="POST" class="space-y-4">
|
||||
{{ inputs::text_input(label="Name", name="name", id="name", type="text") }}
|
||||
{{ inputs::text_input(label="Expiration Date", name="expiration_date", id="expiration_date", type="date", value=one_year_date)}}
|
||||
<div class="flex flex-col">
|
||||
<button type="submit" class="bg-blue-500 p-2 rounded-lg text-white">
|
||||
Create API Key
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr class="my-4 w-1/2 border-0 bg-zinc-300 h-0.5 mx-auto">
|
||||
|
||||
<h2 class="font-bold text-2xl my-4">Current API Tokens</h2>
|
||||
|
||||
<table class="border-collapse border-spacing-2 border border-zinc-400 w-full">
|
||||
<thead class="bg-orange-50">
|
||||
<tr>
|
||||
<th class="border border-zinc-300 w-1/4 p-4 font-semibold">Name</th>
|
||||
<th class="border border-zinc-300 w-1/4 p-4 font-semibold">Active</th>
|
||||
<th class="border border-zinc-300 w-1/4 p-4 font-semibold">Expiration Date</th>
|
||||
<th class="border border-zinc-300 w-1/4 p-4 font-semibold">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for api_key in api_keys %}
|
||||
<tr>
|
||||
<td class="border border-zinc-200 p-2">{{ api_key.name}}</td>
|
||||
<td class="border border-zinc-200 p-2 text-center">
|
||||
{% if api_key.revoked %}
|
||||
<span class="align-middle">No Longer Active</span><span class="inline-block align-middle size-6 ml-2 bg-zinc-500 rounded-lg"></span>
|
||||
{% else %}
|
||||
<span class="align-middle">Currently Active</span><span class="inline-block align-middle size-6 ml-2 bg-green-500 rounded-lg"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-zinc-200 p-2 text-center">{{ api_key.expiration_date }}</td>
|
||||
<td class="border border-zinc-200 p-2 text-center">
|
||||
{% if api_key.revoked %}
|
||||
<span class="text-zinc-700">A revoked API Key cannot be revived</span>
|
||||
{% else %}
|
||||
<form action="/settings/revoke_api_key" method="POST">
|
||||
<input type="hidden" name="api_key_id" value="{{ api_key.id }}">
|
||||
<button type="submit" class="px-4 py-2 inline-block border border-red-700 bg-red-600 text-white rounded pointer-link">
|
||||
Revoke API Key
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
27
nixie-server/templates/settings/change_password.tera.html
Normal file
27
nixie-server/templates/settings/change_password.tera.html
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.tera.html" %}
|
||||
{% import "inputs.tera.html" as inputs %}
|
||||
|
||||
{% block title %}
|
||||
Change Password - {{ current_user.username }}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex flex-col md:flex-row grow">
|
||||
<div class="basis-1/4 p-4 m-4 space-y-4">
|
||||
{% include "settings/sidebar.tera.html" %}
|
||||
</div>
|
||||
<div class="basis-3/4 p-4">
|
||||
<h1 class="font-bold text-3xl">Change Password</h1>
|
||||
<form action="/settings/change_password" method="POST" class="space-y-4">
|
||||
{{ inputs::text_input(label="Old Password", name="old_password", id="old_password", type="password") }}
|
||||
{{ inputs::text_input(label="New Password", name="password", id="password", type="password") }}
|
||||
{{ inputs::text_input(label="Repeat New Password", name="confirm_password", id="confirm_password", type="password") }}
|
||||
<div class="flex flex-col">
|
||||
<button type="submit" class="bg-blue-500 p-2 rounded-lg text-white">
|
||||
Change Password
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
19
nixie-server/templates/settings/index.tera.html
Normal file
19
nixie-server/templates/settings/index.tera.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{% extends "base.tera.html" %}
|
||||
{% import "inputs.tera.html" as inputs %}
|
||||
|
||||
{% block title %}
|
||||
Settings - {{ current_user.username }}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex flex-col md:flex-row grow">
|
||||
<div class="basis-1/4 p-4 m-4 space-y-4">
|
||||
{% include "settings/sidebar.tera.html" %}
|
||||
</div>
|
||||
<div class="basis-3/4 p-4">
|
||||
<p>THIS IS YOUR MAIN SETTINGS WOOHOOOO</p>
|
||||
|
||||
<p>Your username is: <em>{{ current_user.username }}</em></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
12
nixie-server/templates/settings/sidebar.tera.html
Normal file
12
nixie-server/templates/settings/sidebar.tera.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<h2 class="text-xl font-bold px-4">Settings</h2>
|
||||
<ul class="space-y-2 bg-zinc-200 p-2 rounded border border-zinc-400 shadow">
|
||||
<li class="hover:bg-zinc-400">
|
||||
<a class="p-1 px-2 inline-block w-full" href="/settings">Overview</a>
|
||||
</li>
|
||||
<li class="hover:bg-zinc-400">
|
||||
<a class="p-1 px-2 inline-block w-full" href="/settings/change_password">Change Password</a>
|
||||
</li>
|
||||
<li class="hover:bg-zinc-400">
|
||||
<a class="p-1 px-2 inline-block w-full" href="/settings/api_keys">API Keys</a>
|
||||
</li>
|
||||
</ul>
|
||||
Loading…
Add table
Add a link
Reference in a new issue