add ability to delete peerings

+ format all files
+ fix "selected_peering" not being defined in /peerings/edit
This commit is contained in:
lare 2022-12-07 17:00:52 +01:00
parent ff4865f4b6
commit 537400f77a
10 changed files with 464 additions and 238 deletions

View file

@ -1,22 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{config["MNT"]}} Autopeering</title>
<link rel="stylesheet" href="{{config['base-dir']}}static/style.css">
</head>
<body>
<header class="flex flex-row"><div></div><a href="{{config['base-dir']}}">{{config["MNT"]}} Autopeering</a>{% if "login" in session %} <div><a href="{{config['base-dir']}}peerings">manage</a> <a href="{{config['base-dir']}}logout">logout</a></div>{% else %} <a href="{{config['base-dir']}}login?return=/peerings">login</a>{%endif%}</header>
<div class="content flex">
{% block content %}
{% endblock %}
</div>
<link rel="stylesheet" href="{{config['base-dir']}}static/style.css" />
</head>
<body>
<header class="flex flex-row">
<div></div>
<a href="{{config['base-dir']}}">{{config["MNT"]}} Autopeering</a>{% if
"login" in session %}
<div>
<a href="{{config['base-dir']}}peerings">manage</a>
<a href="{{config['base-dir']}}logout">logout</a>
</div>
{% else %}
<a href="{{config['base-dir']}}login?return=/peerings">login</a>{%endif%}
</header>
<div class="content flex">{% block content %} {% endblock %}</div>
<footer class="flex">
<div></div>
<div></div>
<div> &#127279; LARE-MNT</div>
<div></div>
<div></div>
<div>&#127279; LARE-MNT</div>
</footer>
</body>
</html>
</body>
</html>

View file

@ -1,28 +1,25 @@
{% extends 'base.html' %}
{% block content %}
{% extends 'base.html' %} {% block content %}
<div></div>
<div>
<table>
<thead>
<tr>
<th>NodeName</th>
<th>Country</th>
<th>City</th>
<th>peerings</th>
<th>Peer!</th>
</tr>
</thead>
{% for node in config["nodes"] %}
<tr>
<td>{{node}}</td>
<td>{{config["nodes"][node]["country"]}}</td>
<td>{{config["nodes"][node]["city"]}}</td>
<td></td>
<td><a href="peerings/new?node={{node}}">peer</a></td>
</tr>
{% endfor %}
</table>
</div>
<div>
<table>
<thead>
<tr>
<th>NodeName</th>
<th>Country</th>
<th>City</th>
<th>peerings</th>
<th>Peer!</th>
</tr>
</thead>
{% for node in config["nodes"] %}
<tr>
<td>{{node}}</td>
<td>{{config["nodes"][node]["country"]}}</td>
<td>{{config["nodes"][node]["city"]}}</td>
<td></td>
<td><a href="peerings/new?node={{node}}">peer</a></td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
{% endblock %}

View file

@ -1,31 +1,64 @@
{% extends 'base.html' %}
{% block content %}
{% if msg %}
<div style="background-color: red;">
{{msg}}
</div>
{% extends 'base.html' %} {% block content %} {% if msg %}
<div style="background-color: red">{{msg}}</div>
{% endif %}
<form action="https://dn42.g-load.eu/auth/">
<link rel="stylesheet" href="https://dn42.g-load.eu/auth/assets/button-font/auth.css">
<input type="hidden" id="return" name="return" value='{{"http://"+config["domain"]+"/api/auth/kverify"}}'>
<button type="submit" class="kioubit-btn kioubit-btn-primary kioubit-btn-dark kioubit-btn-main">
<link
rel="stylesheet"
href="https://dn42.g-load.eu/auth/assets/button-font/auth.css"
/>
<input
type="hidden"
id="return"
name="return"
value='{{"http://"+config["domain"]+"/api/auth/kverify"}}'
/>
<button
type="submit"
class="kioubit-btn kioubit-btn-primary kioubit-btn-dark kioubit-btn-main"
>
<span class="icon-kioubit-auth"></span>Authenticate with Kioubit.dn42
</button>
</button>
</form>
{% if config["debug-mode"] %}
<form action="" method="post" class="flex">
<label for="debug">Debug login, if you see this in Production contact {{config["MNT"]}}</label><br>
<input type="text" name="mnt" id="mnt" placeholder="YOUR-MNT" required><br>
<input type="text" name="asn" id="asn" placeholder="AS4242420000" required><br>
<input type="text" name="allowed4" id="allowed4" placeholder="ipv4 subnet (optional)"><br>
<input type="text" name="allowed6" id="allowed6" placeholder="ipv6 subnet (optional)"><br>
<input type="number" name="theanswer" id="theanswer" placeholder="The answer for everything" required><br>
<input type="submit" value="login">
<label for="debug"
>Debug login, if you see this in Production contact {{config["MNT"]}}</label
><br />
<input
type="text"
name="mnt"
id="mnt"
placeholder="YOUR-MNT"
required
/><br />
<input
type="text"
name="asn"
id="asn"
placeholder="AS4242420000"
required
/><br />
<input
type="text"
name="allowed4"
id="allowed4"
placeholder="ipv4 subnet (optional)"
/><br />
<input
type="text"
name="allowed6"
id="allowed6"
placeholder="ipv6 subnet (optional)"
/><br />
<input
type="number"
name="theanswer"
id="theanswer"
placeholder="The answer for everything"
required
/><br />
<input type="submit" value="login" />
</form>
{% endif %}
{% endblock %}
{% endif %} {% endblock %}

View file

@ -0,0 +1,45 @@
{% extends 'base.html' %} {% block content %}
<form class="flex" action="" method="post">
<div id="warning" style="background-color: yellow">
{% if msg %}{{msg}}{% else %}confirm the deletion of this peering{% endif %}
</div>
<table>
<tr>
<td><label for="asn">ASn</label></td>
<td>
<input
type="text"
id="asn"
readonly="readonly"
value="{{request_args['asn']}}"
/>
</td>
</tr>
<tr>
<td><label for="node">node</label></td>
<td>
<input
type="text"
id="node"
readonly="readonly"
value="{{request_args['node']}}"
/>
</td>
</tr>
<tr>
<td><label for="confirm">confirm</label></td>
<td>
<input type="checkbox" name="confirm" id="delete-confirm" required />
</td>
</tr>
</table>
<div>
<a href="../peerings">
<input type="button" class="button-green" value="back"
/></a>
<button type="submit" class="button-red">confirm</button>
</div>
</form>
{% endblock %}

View file

@ -182,7 +182,7 @@
{% endfor %}
</div>
<form action="" method="post" class="flex" onsubmit="return form_validate(this)">
<div id="peer-invalid-note" style="background-color:red;">{% if msg %}{{msg}}{%endif%}</div>
<div id="peer-invalid-note" style="background-color:red;">{% if msg %}{{msg}}{%elif not selected_node%}please select one of the nodes above{%endif%}</div>
<table>
<tr>
<td><label for="peer-asn">Your ASN</label></td>
@ -283,8 +283,8 @@ protocol bgp dn42_{{config["MNT"][:-4].lower()}}_v6 from dnpeers {
};
}
</pre>
</div>
</pre>
</div>
<script>
document.onload();

View file

@ -1,39 +1,58 @@
{% extends 'base.html' %}
{% block content %}
{% extends 'base.html' %} {% block content %}
<div>
<a href="peerings/new"><button>add new</button></a>
<a href="peerings/new"
><button class="button-green default-border-color">add new</button></a
>
</div>
<div class="flex flex-row">
{% for peering in peerings.get_peerings_by_mnt(session["login"]) %}
<div class="peering">
<div>
<div>Node: {{peering["node"]}}</div>
</div>
<div>
<table>
<tr><td>ASN:</td><td>{{peering["ASN"]}}</td></tr>
<tr><td>WG-PublicKey:</td><td>{{peering["wg_key"][:8]}}...</td></tr>
</table>
</div>
<div>
<table>
{% if peering["ipv6ll"] %}<tr><td>ipv6 linklocal:</td><td>{{peering["ipv6ll"]}}</td></tr>{% endif %}
{% if peering["ipv4"] %}<tr><td>ipv4:</td><td>{{peering["ipv4"]}}</td></tr>{% endif %}
{% if peering["ipv6"] %}<tr><td>ipv6:</td><td>{{peering["ipv6"]}}</td></tr>{% endif %}
</table>
</div>
<!-- <div>{{peering}}</div> -->
<div>
<a href="peerings/edit?node={{peering['node']}}&asn={{peering['ASN']}}">
<button class="peering-edit">edit</button>
</a>
<a href="peerings/delete?node={{peering['node']}}&asn={{peering['ASN']}}">
<button class="peering-delete">delete</button>
</a>
</div>
{% for peering in peerings.get_peerings_by_mnt(session["login"]) %}
<div class="peering">
<div>
<div>Node: {{peering["node"]}}</div>
</div>
{% endfor %}
<div>
<table>
<tr>
<td>ASN:</td>
<td>{{peering["ASN"]}}</td>
</tr>
<tr>
<td>WG-PublicKey:</td>
<td>{{peering["wg_key"][:8]}}...</td>
</tr>
</table>
</div>
<div>
<table>
{% if peering["ipv6ll"] %}
<tr>
<td>ipv6 linklocal:</td>
<td>{{peering["ipv6ll"]}}</td>
</tr>
{% endif %} {% if peering["ipv4"] %}
<tr>
<td>ipv4:</td>
<td>{{peering["ipv4"]}}</td>
</tr>
{% endif %} {% if peering["ipv6"] %}
<tr>
<td>ipv6:</td>
<td>{{peering["ipv6"]}}</td>
</tr>
{% endif %}
</table>
</div>
<!-- <div>{{peering}}</div> -->
<div>
<a href="peerings/edit?node={{peering['node']}}&asn={{peering['ASN']}}">
<button class="button-blue">edit</button>
</a>
<a href="peerings/delete?node={{peering['node']}}&asn={{peering['ASN']}}">
<button class="button-red">delete</button>
</a>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
{% endblock %}

View file

@ -17,6 +17,7 @@ header {
background-color: var(--other-background);
height: 50px;
}
a {
color: var(--text-color);
}
@ -27,6 +28,7 @@ a {
margin: auto;
padding-bottom: 50px;
}
.content>* {
padding: 5%;
}
@ -35,6 +37,7 @@ a {
display: flex;
flex-direction: column;
}
.flex-row {
flex-direction: row;
}
@ -54,6 +57,7 @@ footer {
height: 40px;
background: var(--other-background);
}
footer.flex {
flex-direction: row;
}
@ -63,14 +67,14 @@ footer.flex {
padding: 1%;
}
.example-config > pre{
.example-config>pre {
border-color: var(--other-background);
border-radius: 10px;
padding: 10px;
border-style: groove;
}
form > div > * {
form>div>* {
margin: 10px;
}
@ -85,40 +89,59 @@ form > div > * {
width: 100%;
margin: 10px;
}
.peering > div {
.peering>div {
display: flex;
flex-direction: column;
}
.peering > div > * {
.peering>div>* {
padding: 10px;
}
button {
button,
input[type=button] {
background-color: #00000020;
border-color: var(--text-color);
border-width: 5px;
padding: 10px;
}
button.button-selected{
button.button-selected,
input[type=button].button-selected {
background-color: var(--other-background);
color: var(--text-color-dark);
}
.peering>* {
width:auto;
width: auto;
align-items: center;
}
.peering-edit {
.button-blue {
border-color: lightblue;
}
.peering-edit:hover {
.button-blue:hover {
background-color: #87cefaaa;
}
.peering-delete {
.button-red {
border-color: darkred;
}
.peering-delete:hover {
.button-red:hover {
background-color: #ff0000aa;
}
.button-green {
border-color: lightgreen;
}
.button-green:hover {
background-color: greenyellow;
}
.default-border-color {
border-color: inherit;
}