Implement deleting networks
This commit is contained in:
parent
62ef524ac7
commit
ad153cdefa
|
@ -33,6 +33,7 @@ from core.views.manage.threshold.irc import (
|
||||||
ThresholdIRCNetworkActionsList,
|
ThresholdIRCNetworkActionsList,
|
||||||
ThresholdIRCNetworkActionsRelay,
|
ThresholdIRCNetworkActionsRelay,
|
||||||
ThresholdIRCNetworkChannels,
|
ThresholdIRCNetworkChannels,
|
||||||
|
ThresholdIRCNetworkDel,
|
||||||
ThresholdIRCNetworkInfo,
|
ThresholdIRCNetworkInfo,
|
||||||
ThresholdIRCNetworkInfoEdit,
|
ThresholdIRCNetworkInfoEdit,
|
||||||
ThresholdIRCNetworkRelayDel,
|
ThresholdIRCNetworkRelayDel,
|
||||||
|
@ -119,6 +120,11 @@ urlpatterns = [
|
||||||
ThresholdIRCNetwork.as_view(),
|
ThresholdIRCNetwork.as_view(),
|
||||||
name="threshold_irc_network",
|
name="threshold_irc_network",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"manage/threshold/irc/overview/network/<str:net>/delete/",
|
||||||
|
ThresholdIRCNetworkDel.as_view(),
|
||||||
|
name="threshold_irc_network_del",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"manage/threshold/irc/network/<str:net>/info/",
|
"manage/threshold/irc/network/<str:net>/info/",
|
||||||
ThresholdIRCNetworkInfo.as_view(),
|
ThresholdIRCNetworkInfo.as_view(),
|
||||||
|
|
|
@ -132,3 +132,10 @@ def create_network(data):
|
||||||
payload = data
|
payload = data
|
||||||
ran = threshold_request(url, payload, method="PUT")
|
ran = threshold_request(url, payload, method="PUT")
|
||||||
return ran
|
return ran
|
||||||
|
|
||||||
|
|
||||||
|
def del_network(net):
|
||||||
|
url = f"irc/network/{net}"
|
||||||
|
payload = {}
|
||||||
|
deleted = threshold_request(url, payload, method="DELETE")
|
||||||
|
return deleted
|
||||||
|
|
|
@ -55,40 +55,40 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
{% if relay.enabled %}
|
{% if relay.enabled %}
|
||||||
|
<button
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-get="{% url 'threshold_irc_network_relay_status' relay|index:'net' relay|index:'id' 0 %}"
|
||||||
|
hx-target="#relays"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="button is-danger is-small">
|
||||||
|
<span class="icon" data-tooltip="Disable">
|
||||||
|
<i class="fa-solid fa-wifi-slash" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<button
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-get="{% url 'threshold_irc_network_relay_status' relay|index:'net' relay|index:'id' 1 %}"
|
||||||
|
hx-target="#relays"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="button is-success is-small">
|
||||||
|
<span class="icon" data-tooltip="Enable">
|
||||||
|
<i class="fa-solid fa-wifi" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
<button
|
<button
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
hx-get="{% url 'threshold_irc_network_relay_status' relay|index:'net' relay|index:'id' 0 %}"
|
hx-delete="{% url 'threshold_irc_network_relay_del' relay|index:'net' relay|index:'id' %}"
|
||||||
hx-target="#relays"
|
hx-target="#relays"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
class="button is-danger is-small">
|
class="button is-danger is-small">
|
||||||
<span class="icon" data-tooltip="Disable">
|
<span class="icon" data-tooltip="Delete">
|
||||||
<i class="fa-solid fa-wifi-slash" aria-hidden="true"></i>
|
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{% else %}
|
</div>
|
||||||
<button
|
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
|
||||||
hx-get="{% url 'threshold_irc_network_relay_status' relay|index:'net' relay|index:'id' 1 %}"
|
|
||||||
hx-target="#relays"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
class="button is-success is-small">
|
|
||||||
<span class="icon" data-tooltip="Enable">
|
|
||||||
<i class="fa-solid fa-wifi" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
<button
|
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
|
||||||
hx-delete="{% url 'threshold_irc_network_relay_del' relay|index:'net' relay|index:'id' %}"
|
|
||||||
hx-target="#relays"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
class="button is-danger is-small">
|
|
||||||
<span class="icon" data-tooltip="Delete">
|
|
||||||
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
hx-put="{% url 'threshold_irc_actions_add-network' %}"
|
hx-put="{% url 'threshold_irc_actions_add-network' %}"
|
||||||
hx-target="#networks"
|
hx-target="#networks"
|
||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
<div class="content">
|
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Network name</label>
|
<label class="label">Network name</label>
|
||||||
|
|
|
@ -5,13 +5,23 @@
|
||||||
<thead>
|
<thead>
|
||||||
<th>net</th>
|
<th>net</th>
|
||||||
<th>relays</th>
|
<th>relays</th>
|
||||||
<th>channels</th>
|
<th>
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa-solid fa-hashtag"></i>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
<th>records</th>
|
<th>records</th>
|
||||||
|
<th>
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa-solid fa-wrench" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
</thead>
|
</thead>
|
||||||
{% for key, net in networks.items %}
|
{% for key, net in networks.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<th><a href="{% url 'threshold_irc_network' key %}">{{ key }}</a></th>
|
<th><a href="{% url 'threshold_irc_network' key %}">{{ key }}</a></th>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="fa-brands fa-unity"></i>
|
<i class="fa-brands fa-unity"></i>
|
||||||
</span>
|
</span>
|
||||||
|
@ -29,6 +39,18 @@
|
||||||
</span>
|
</span>
|
||||||
{{ net.records }}
|
{{ net.records }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-delete="{% url 'threshold_irc_network_del' key %}"
|
||||||
|
hx-target="#networks"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="button is-danger is-small">
|
||||||
|
<span class="icon" data-tooltip="Delete">
|
||||||
|
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% if message is not None %}
|
{% if message is not None %}
|
||||||
<div class="notification is-{{ class }}" hx-ext="remove-me" remove-me="3s">
|
<div class="notification is-{{ class }}" hx-ext="remove-me" remove-me="3s">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
|
@ -25,6 +25,25 @@ class ThresholdIRCNetworks(SuperUserRequiredMixin, View):
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
class ThresholdIRCNetworkDel(SuperUserRequiredMixin, View):
|
||||||
|
template_name = "manage/threshold/irc/overview/networks.html"
|
||||||
|
|
||||||
|
def delete(self, request, net):
|
||||||
|
deleted = threshold.del_network(net)
|
||||||
|
message = f"Deleted network {net}"
|
||||||
|
message_class = "success"
|
||||||
|
if not deleted["success"]:
|
||||||
|
message = deleted["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
networks = threshold.get_irc_networks()
|
||||||
|
context = {
|
||||||
|
"networks": networks,
|
||||||
|
"message": message,
|
||||||
|
"class": message_class,
|
||||||
|
}
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworkInfo(SuperUserRequiredMixin, View):
|
||||||
template_name = "manage/threshold/irc/network/info.html"
|
template_name = "manage/threshold/irc/network/info.html"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue