Refactor code into fewer files, removing dynamic folders

This commit is contained in:
2022-07-27 13:12:16 +01:00
parent da235fedd6
commit 3d91c4164e
16 changed files with 53 additions and 63 deletions

View File

@@ -0,0 +1,22 @@
<div id="channels">
{% if channels is not None %}
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<tbody>
{% for channel, info in channels.items %}
<tr>
<td>
{{ channel }}
<span class="tag">
{{ info }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,74 @@
<form
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'threshold_irc_network_edit' net %}"
hx-target="this"
hx-swap="outerHTML">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<thead>
<th>attribute</th>
<th>value</th>
</thead>
<tbody>
{% for key, item in network.items %}
<tr>
<th>{{ key }}</th>
<td>
<div class="field">
{% if key == 'auth' %}
<div class="select">
<select name="{{ key }}">
{% if item == 'sasl' %}
<option selected>sasl</option>
{% else %}
<option>sasl</option>
{% endif %}
{% if item == 'ns' %}
<option selected>ns</option>
{% else %}
<option>ns</option>
{% endif %}
{% if item == 'none' %}
<option selected>none</option>
{% else %}
<option>none</option>
{% endif %}
</select>
</div>
{% elif key == 'security' %}
<div class="select">
<select name="{{ key }}">
{% if item == 'ssl' %}
<option selected>ssl</option>
{% else %}
<option>ssl</option>
{% endif %}
{% if item == 'plain' %}
<option selected>plain</option>
{% else %}
<option>plain</option>
{% endif %}
</select>
</div>
{% else %}
<input class="input" type="text" name="{{ key }}" value="{{ item }}">
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<button class="button is-primary">Submit</button>
<button
class="button is-primary"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'threshold_irc_network_info' net %}">
Cancel
</button>
</div>
</form>

View File

@@ -0,0 +1,65 @@
<div id="info">
{% if message is not None %}
<div class="notification is-{{ class }}" hx-ext="remove-me" remove-me="3s">
{{ message }}
</div>
{% endif %}
{% if network is not None %}
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<thead>
<th>attribute</th>
<th>value</th>
</thead>
<tbody>
{% for key, item in network.items %}
<tr>
<th>{{ key }}</th>
<td>
{% if key == 'security' %}
{% if item == 'none' %}
<span class="icon">
<i class="fa-solid fa-lock-open" aria-hidden="true"></i>
</span>
{% elif item == 'ssl' %}
<span class="icon">
<i class="fa-solid fa-lock" aria-hidden="true"></i>
</span>
{% endif %}
{% elif key == 'relays' %}
<span class="icon">
<i class="fa-brands fa-unity"></i>
</span>
{% elif key == 'channels' %}
<span class="icon">
<i class="fa-solid fa-hashtag"></i>
</span>
{% elif key == 'records' %}
<span class="icon">
<i class="fa-solid fa-album"></i>
</span>
{% elif key == 'host' %}
<span class="icon">
<i class="fa-solid fa-router"></i>
</span>
{% endif %}
{% if item is not None %}
{{ item }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div hx-target="#info" hx-swap="outerHTML">
<button hx-get="{% url 'threshold_irc_network_info_edit' network.net %}" class="button is-primary is-fullwidth">
<span class="icon" data-tooltip="Edit">
<i class="fa-solid fa-pencil" aria-hidden="true"></i>
</span>
</button>
</div>
</div>
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,56 @@
<div id="relays">
{% if relays is not None %}
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<thead>
<th>id</th>
<th>registered</th>
<th>enabled</th>
<th>
<span class="icon">
<i class="fa-solid fa-hashtag"></i>
</span>
</th>
<th>nick</th>
</thead>
<tbody>
{% for relay in relays %}
<tr>
<td>{{ relay.id }}</td>
<td>
{% if relay.registered %}
<span class="icon">
<i class="fa-solid fa-check" aria-hidden="true"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
</span>
{% endif %}
</td>
<td>
{% if relay.enabled %}
<span class="icon">
<i class="fa-solid fa-check" aria-hidden="true"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
</span>
{% endif %}
</td>
<td>
{{ relay.chans }}
</td>
<td>
{{ relay.nick }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,35 @@
<div id="networks">
<div class="content" style="max-height: 30em; overflow: auto;">
<table class="table is-fullwidth is-hoverable">
<thead>
<th>net</th>
<th>relays</th>
<th>channels</th>
<th>records</th>
</thead>
{% for key, net in networks.items %}
<tr>
<th><a href="{% url 'threshold_irc_network' key %}">{{ key }}</a></th>
<td>
<span class="icon">
<i class="fa-brands fa-unity"></i>
</span>
{{ net.relays }}
</td>
<td>
<span class="icon">
<i class="fa-solid fa-hashtag"></i>
</span>
{{ net.channels }}
</td>
<td>
<span class="icon">
<i class="fa-solid fa-album"></i>
</span>
{{ net.records }}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>

View File

@@ -0,0 +1,49 @@
<div id="stats">
<div class="content" style="max-height: 30em; overflow: auto;">
<div class="table-container">
<table class="table is-fullwidth is-hoverable">
<thead>
<tr>
<th>attribute</th>
<th>count</th>
</tr>
</thead>
<tbody>
<tr>
<th>relays</th>
<td>
{{ stats.servers_online_total }}/{{ stats.servers_total_total }}
</td>
</tr>
<tr>
<th>networks</th>
<td>
{{ stats.servers_online_unique }}/{{ stats.servers_total_unique }}
</td>
</tr>
<tr>
<th>channels</th>
<td>
{{ stats.channels}}
</td>
</tr>
<tr>
<th>records</th>
<td>
{{ stats.records }}
</td>
</tr>
<tr>
<th>events</th>
<td>
{{ stats.eventrate }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>