Implement showing LIST information
This commit is contained in:
parent
18448dce5a
commit
ad9276c071
|
@ -30,7 +30,7 @@ from core.views.manage.threshold.irc import (
|
||||||
ThresholdIRCAliasesEdit,
|
ThresholdIRCAliasesEdit,
|
||||||
ThresholdIRCNetworkActions,
|
ThresholdIRCNetworkActions,
|
||||||
ThresholdIRCNetworkActionsAuto,
|
ThresholdIRCNetworkActionsAuto,
|
||||||
ThresholdIRCNetworkActionsList,
|
ThresholdIRCNetworkList, # Actions and just get list output
|
||||||
ThresholdIRCNetworkActionsRelay,
|
ThresholdIRCNetworkActionsRelay,
|
||||||
ThresholdIRCNetworkChannels,
|
ThresholdIRCNetworkChannels,
|
||||||
ThresholdIRCNetworkDel,
|
ThresholdIRCNetworkDel,
|
||||||
|
@ -212,8 +212,8 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"manage/threshold/irc/list/<str:net>/",
|
"manage/threshold/irc/list/<str:net>/",
|
||||||
ThresholdIRCNetworkActionsList.as_view(),
|
ThresholdIRCNetworkList.as_view(),
|
||||||
name="threshold_irc_network_actions_list",
|
name="threshold_irc_network_list",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"manage/threshold/irc/msg/<str:net>/<int:num>/<str:channel>/",
|
"manage/threshold/irc/msg/<str:net>/<int:num>/<str:channel>/",
|
||||||
|
|
|
@ -210,3 +210,10 @@ def get_irc_nick(net, num):
|
||||||
payload = {}
|
payload = {}
|
||||||
nick = threshold_request(url, payload, method="GET")
|
nick = threshold_request(url, payload, method="GET")
|
||||||
return nick
|
return nick
|
||||||
|
|
||||||
|
def get_irc_list_info(net):
|
||||||
|
url = f"irc/list/{net}"
|
||||||
|
payload = {}
|
||||||
|
listinfo = threshold_request(url, payload, method="GET")
|
||||||
|
print("LISTINFO", listinfo)
|
||||||
|
return listinfo
|
|
@ -31,7 +31,7 @@
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
hx-post="{% url 'threshold_irc_network_actions_list' net %}"
|
hx-post="{% url 'threshold_irc_network_list' net %}"
|
||||||
hx-trigger="click"
|
hx-trigger="click"
|
||||||
hx-target="#actions"
|
hx-target="#actions"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
|
|
|
@ -37,6 +37,16 @@
|
||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div
|
||||||
|
style="display: none;"
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-get="{% url 'threshold_irc_network_list' net %}"
|
||||||
|
hx-trigger="load"
|
||||||
|
hx-target="#stats"
|
||||||
|
hx-swap="outerHTML">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
@ -61,8 +71,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div id="alerts">
|
<div id="stats">
|
||||||
Alerts here
|
Stats here
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<div id="stats">
|
||||||
|
{% include 'manage/threshold/partials/notify.html' %}
|
||||||
|
{% if list 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 list.items %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ key }}</th>
|
||||||
|
<td>
|
||||||
|
{% if item is not None %}
|
||||||
|
{{ item }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
|
@ -384,7 +384,7 @@ class ThresholdIRCNetworkActionsAuto(SuperUserRequiredMixin, View):
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkActionsList(SuperUserRequiredMixin, View):
|
class ThresholdIRCNetworkList(SuperUserRequiredMixin, View):
|
||||||
template_name = "manage/threshold/irc/network/actions.html"
|
template_name = "manage/threshold/irc/network/actions.html"
|
||||||
|
|
||||||
def post(self, request, net):
|
def post(self, request, net):
|
||||||
|
@ -409,6 +409,28 @@ class ThresholdIRCNetworkActionsList(SuperUserRequiredMixin, View):
|
||||||
}
|
}
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
def get(self, request, net):
|
||||||
|
"""
|
||||||
|
Get list results from network.
|
||||||
|
"""
|
||||||
|
template_name = "manage/threshold/irc/network/stats.html"
|
||||||
|
listinfo = threshold.get_irc_list_info(net)
|
||||||
|
if not listinfo["success"]:
|
||||||
|
if "reason" in listinfo:
|
||||||
|
message = listinfo["reason"]
|
||||||
|
else:
|
||||||
|
message = "Could not get list info."
|
||||||
|
message = listinfo["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
context = {"message": message, "class": message_class}
|
||||||
|
return render(request, template_name, context)
|
||||||
|
|
||||||
|
context = {
|
||||||
|
"net": net,
|
||||||
|
"list": listinfo["listinfo"],
|
||||||
|
}
|
||||||
|
return render(request, template_name, context)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkActionsRelay(SuperUserRequiredMixin, APIView):
|
class ThresholdIRCNetworkActionsRelay(SuperUserRequiredMixin, APIView):
|
||||||
template_name = "manage/threshold/irc/network/actions.html"
|
template_name = "manage/threshold/irc/network/actions.html"
|
||||||
|
|
Loading…
Reference in New Issue