SSH keys CRUD working

This commit is contained in:
2020-05-11 11:57:39 -05:00
parent 18e6a1b141
commit 452f236c6b
11 changed files with 232 additions and 71 deletions

View File

@ -27,7 +27,6 @@
{% if session["account"] %}
<a href="/console/">Console</a>
<a href="/console/billing">Billing</a>
{% endif %}
<a href="/support">Support</a>

View File

@ -0,0 +1,37 @@
{% extends 'console-base.html' %}
{% block title %}Console{% endblock %}
{% block consoletitle %}Console{% endblock %}
{% block consolecontent %}
{% if vms[0] is defined %}
<table>
<thead>
<tr>
<th>id</th>
<th>size</th>
<th>ipv4</th>
<th>os</th>
<th>created</th>
</tr>
</thead>
<tbody>
{% for vm in vms %}
<a href="/console/{{ vm['id'] }}">
<tr>
<td>{{ vm["id"] }}</td>
<td>{{ vm["size"] }}</td>
<td>{{ vm["ipv4"] }}</td>
<td>{{ vm["os"] }}</td>
<td>{{ vm["created"] }}</td>
</tr>
</a>
{% endfor %}
</tbody>
</table>
{% else %}
You don't have any Capsuls running. <a href="/console/create">Create one</a> today!
{% endif %}
{% endblock %}
{% block pagesource %}/templates/capsuls.html{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}
<div class="third-margin">
<h1>{% block consoletitle %}{% endblock %}</h1>
</div>
<div class="third-margin">
<div class="nav-row">
<a href="/console">Capsuls</a>
<a href="/console/ssh">SSH Public Keys</a>
<a href="/console/billing">Billing</a>
</div>
</div>
<div class="third-margin">
{% block consolecontent %}{% endblock %}
</div>
{% endblock %}

View File

@ -1,49 +0,0 @@
{% extends 'base.html' %}
{% block title %}Console{% endblock %}
{% block content %}
<div class="third-margin">
<h1>CONSOLE</h1>
</div>
<div class="third-margin">
<div class="nav-row">
<a href="/console">Capsuls</a>
<a href="/console/ssh">SSH Public Keys</a>
<a href="/console/billing">Billing</a>
</div>
</div>
<div class="third-margin">
{% if vms[0] is defined %}
<table>
<thead>
<tr>
<th>id</th>
<th>size</th>
<th>ipv4</th>
<th>os</th>
<th>created</th>
</tr>
</thead>
<tbody>
{% for vm in vms %}
<a href="/console/{{ vm['id'] }}">
<tr>
<td>{{ vm["id"] }}</td>
<td>{{ vm["size"] }}</td>
<td>{{ vm["ipv4"] }}</td>
<td>{{ vm["os"] }}</td>
<td>{{ vm["created"] }}</td>
</tr>
</a>
{% endfor %}
</tbody>
</table>
{% else %}
You don't have any Capsuls running. <a href="/console/create">Create one</a> today!
{% endif %}
</div>
{% endblock %}
{% block pagesource %}/templates/console.html{% endblock %}

View File

@ -1,12 +1,10 @@
{% extends 'base.html' %}
{% extends 'console-base.html' %}
{% block title %}Create{% endblock %}
{% block consoletitle %}Console - Create Capsul{% endblock %}
{% block consolecontent %}
{% block content %}
<div class="half-margin">
<h1>CONSOLE - CREATE CAPSUL</h1>
</div>
<div class="half-margin">
{% if ssh_public_keys[0] is defined %}
<pre>
CAPSUL SIZES
@ -22,7 +20,7 @@ f1-xxx $57.58 8 16G 25G 16TB
* net is calculated as a per-month average
* all VMs come standard with one public IPv4 addr</pre>
</div>
<form method="post">
<div class="row justify-start">
<label class="align" for="size">Capsul Size</label>
@ -65,4 +63,4 @@ f1-xxx $57.58 8 16G 25G 16TB
{% endif %}
{% endblock %}
{% block pagesource %}/templates/console.html{% endblock %}
{% block pagesource %}/templates/create-capsul.html{% endblock %}

View File

@ -141,5 +141,5 @@ $ doas su -</pre>
{% endblock %}
{% block pagesource %}/templates/changelog.html{% endblock %}
{% block pagesource %}/templates/faq.html{% endblock %}

View File

@ -0,0 +1,55 @@
{% extends 'console-base.html' %}
{% block title %}SSH Public Keys{% endblock %}
{% block consoletitle %}Console - SSH Public Keys{% endblock %}
{% block consolecontent %}
{% if ssh_public_keys[0] is defined %} <hr/> {% endif %}
{% for ssh_public_key in ssh_public_keys %}
<form method="post">
<input type="hidden" name="method" value="DELETE"></input>
<input type="hidden" name="name" value="{{ ssh_public_key['name'] }}"></input>
<div class="row">
<span class="code">{{ ssh_public_key['name'] }}</span>
<span class="dim">{{ ssh_public_key['content'] }}</span>
<input type="submit" value="Delete">
</div>
</form>
{% endfor %}
{% if ssh_public_keys[0] is defined %} <hr/> {% endif %}
<div class="third-margin">
<h1>UPLOAD A NEW SSH KEY</h1>
</div>
<form method="post">
<input type="hidden" name="method" value="POST"></input>
<div class="row justify-start">
<label class="align" for="name">Name</label>
<input type="text" id="name" name="name"></input>
</div>
<div class="row justify-start">
<label class="align" for="content">Content</label>
<textarea class="expand" id="content" name="content"></textarea>
</div>
<div class="smalltext">
<p>Paste the contents of your SSH public key file here.
( Something like <span class='code'>~/.ssh/id_rsa.pub</span> )
</p><p>
The contents of this file should look similar to
<span class='code'>ssh-rsa AAAAC3NzaC1l...Yqv== me@my-computer</span>
</p><p>
If you wish, you can <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key">
generate a new SSH key pair using the ssh-keygen utility</a>.
</p>
</div>
<div class="row justify-end">
<input type="submit" value="Upload">
</div>
</form>
{% endblock %}
{% block pagesource %}/templates/ssh-public-keys.html{% endblock %}