69 lines
3.4 KiB
Text
69 lines
3.4 KiB
Text
{% extends "base.html.tera" %}
|
|
{% import "inputs.html.tera" 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.html.tera" %}
|
|
</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 %}
|