Implement form for editing network

This commit is contained in:
2022-07-27 08:29:20 +01:00
parent 729f6beea5
commit b7411fd664
7 changed files with 201 additions and 105 deletions

View File

@@ -1,10 +1,10 @@
<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 %}
{% 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 }}
@@ -13,10 +13,10 @@
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,34 @@
<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">
<input type="text" name="{{ key }}" value="{{ item }}">
</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

@@ -1,51 +1,65 @@
<div id="info">
{% 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' %}
{% 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-brands fa-unity"></i>
<i class="fa-solid fa-lock-open" aria-hidden="true"></i>
</span>
{% elif key == 'channels' %}
{% elif item == 'ssl' %}
<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>
<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 }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% 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>
{% endif %}
</div>
</div>
{% endif %}
</div>

View File

@@ -1,59 +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>net</th>
<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>
<th>{{ relay.net }}</th>
<td>{{ relay.id }}</td>
<td>
{% if relay.registered %}
<span class="icon">
<i class="fa-solid fa-check" aria-hidden="true"></i>
</span>
{% else %}
{% 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 %}
{% 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>
{% endif %}
</td>
<td>
{{ relay.chans }}
</td>
<td>
{{ relay.nick }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>