{% extends "base.html" %}
{% from "_macros.html" import empty %}
{% block title %}Keypairs · mgf-cloud-web{% endblock %}
{% block content %}
<header class="page-header">
  <div>
    <p class="eyebrow">access</p>
    <h1>Keypairs</h1>
  </div>
</header>
<div class="split">
  <div>
    {% if keypairs %}
    <div class="table-wrap">
      <table class="table">
        <thead><tr><th>Name</th><th>Fingerprint</th><th class="actions"></th></tr></thead>
        <tbody>
        {% for k in keypairs %}
          <tr>
            <td>{{ k.name }}</td>
            <td class="mono">{{ k.fingerprint }}</td>
            <td class="actions"><form method="post" action="/keypairs/{{ k.name }}/delete"><button class="button button-danger button-sm">delete</button></form></td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
    </div>
    {% else %}
    {{ empty("No keypairs.", "Add an SSH public key to inject into new instances.") }}
    {% endif %}
  </div>
  <aside class="card">
    <p class="eyebrow">add keypair</p>
    <form class="form" method="post" action="/keypairs">
      <div class="field"><label class="label" for="kname">Name</label><input class="input" id="kname" name="name" required></div>
      <div class="field"><label class="label" for="kpub">Public key</label><textarea class="textarea" id="kpub" name="public_key" rows="3" placeholder="ssh-ed25519 AAAA..." required></textarea></div>
      <button class="button button-accent" type="submit">Add</button>
    </form>
  </aside>
</div>
{% endblock %}
