Finish Threshold stats and implement network listing
This commit is contained in:
parent
c66055db9d
commit
45891cb0fb
23
app/urls.py
23
app/urls.py
|
@ -37,6 +37,13 @@ from core.views.dynamic.insights import (
|
|||
InsightsNicks,
|
||||
InsightsSearch,
|
||||
)
|
||||
from core.views.dynamic.manage.threshold.irc import (
|
||||
ThresholdIRCNetworks,
|
||||
ThresholdIRCStats,
|
||||
)
|
||||
|
||||
# Management stuff
|
||||
from core.views.manage.threshold import ThresholdIRCOverview
|
||||
|
||||
urlpatterns = [
|
||||
path("", Home.as_view(), name="home"),
|
||||
|
@ -68,6 +75,22 @@ urlpatterns = [
|
|||
path("ui/insights/meta/", InsightsMeta.as_view(), name="meta_insights"),
|
||||
path("ui/insights/modal/", InsightsInfoModal.as_view(), name="modal_insights"),
|
||||
##
|
||||
path(
|
||||
"manage/threshold/irc/overview/",
|
||||
ThresholdIRCOverview.as_view(),
|
||||
name="threshold_irc_overview",
|
||||
),
|
||||
path(
|
||||
"manage/threshold/irc/stats/",
|
||||
ThresholdIRCStats.as_view(),
|
||||
name="threshold_irc_stats",
|
||||
),
|
||||
path(
|
||||
"manage/threshold/irc/networks/",
|
||||
ThresholdIRCNetworks.as_view(),
|
||||
name="threshold_irc_networks",
|
||||
),
|
||||
##
|
||||
path("api/chans/", ThresholdChans.as_view(), name="chans"),
|
||||
path("api/users/", ThresholdUsers.as_view(), name="users"),
|
||||
path("api/online/", ThresholdOnline.as_view(), name="online"),
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
from core.lib.threshold import threshold_request
|
||||
|
||||
def get_irc_stats():
|
||||
url = "irc/stats"
|
||||
payload = {}
|
||||
stats = threshold_request(url, payload)
|
||||
if not stats:
|
||||
return {}
|
||||
print("tsats", stats)
|
||||
return stats
|
||||
|
||||
def get_irc_networks():
|
||||
url = "irc/networks"
|
||||
payload = {}
|
||||
networks = threshold_request(url, payload)
|
||||
if not networks:
|
||||
return {}
|
||||
return networks
|
|
@ -123,7 +123,7 @@
|
|||
</a>
|
||||
|
||||
<div class="navbar-dropdown">
|
||||
<a class="navbar-item" href="#">
|
||||
<a class="navbar-item" href="{% url 'threshold_irc_overview' %}">
|
||||
Overview
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
|
|
|
@ -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>name</th>
|
||||
<th>relays</th>
|
||||
<th>channels</th>
|
||||
<th>records</th>
|
||||
</thead>
|
||||
{% for key, net in networks.items %}
|
||||
<tr>
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
<span class="icon has-text-info has-tooltip-info">
|
||||
<i class="fa-brands fa-unity"></i>
|
||||
</span>
|
||||
{{ net.relays }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="icon has-text-info has-tooltip-info">
|
||||
<i class="fa-solid fa-hashtag"></i>
|
||||
</span>
|
||||
{{ net.channels }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="icon has-text-info has-tooltip-info">
|
||||
<i class="fa-solid fa-album"></i>
|
||||
</span>
|
||||
{{ net.records }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,57 @@
|
|||
<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>X</th>
|
||||
<th>total</th>
|
||||
<th>unique</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>total</th>
|
||||
<td>
|
||||
{{ stats.servers_total_total }}
|
||||
</td>
|
||||
<td>
|
||||
{{ stats.servers_total_unique }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>online</th>
|
||||
<td>
|
||||
{{ stats.servers_online_total }}
|
||||
</td>
|
||||
<td>
|
||||
{{ stats.servers_online_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>
|
|
@ -1,9 +0,0 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="block">
|
||||
<h1> hello</h1>
|
||||
{{ perms.app }}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,51 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div
|
||||
style="display: none;"
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
hx-post="{% url 'threshold_irc_stats' %}"
|
||||
hx-trigger="load"
|
||||
hx-target="#stats"
|
||||
hx-swap="outerHTML">
|
||||
</div>
|
||||
|
||||
<div
|
||||
style="display: none;"
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
hx-post="{% url 'threshold_irc_networks' %}"
|
||||
hx-trigger="load"
|
||||
hx-target="#networks"
|
||||
hx-swap="outerHTML">
|
||||
</div>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="box">
|
||||
<div id="stats">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="box">
|
||||
<div id="networks">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="box">
|
||||
<div id="channels">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="box">
|
||||
<div id="alerts">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -0,0 +1,23 @@
|
|||
from django.views import View
|
||||
from django.shortcuts import render
|
||||
from core.views.manage.permissions import SuperUserRequiredMixin
|
||||
from core.lib.manage.threshold import get_irc_stats, get_irc_networks
|
||||
|
||||
class ThresholdIRCStats(SuperUserRequiredMixin, View):
|
||||
stats_template = "dynamic/manage/threshold/irc/stats.html"
|
||||
|
||||
|
||||
def post(self, request):
|
||||
stats = get_irc_stats()
|
||||
context = {"stats": stats}
|
||||
return render(request, self.stats_template, context)
|
||||
|
||||
|
||||
class ThresholdIRCNetworks(SuperUserRequiredMixin, View):
|
||||
stats_template = "dynamic/manage/threshold/irc/networks.html"
|
||||
|
||||
|
||||
def post(self, request):
|
||||
stats = get_irc_networks()
|
||||
context = {"networks": stats}
|
||||
return render(request, self.stats_template, context)
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||
|
||||
class SuperUserRequiredMixin(LoginRequiredMixin, UserPassesTestMixin):
|
||||
|
||||
class SuperUserRequiredMixin(LoginRequiredMixin, UserPassesTestMixin):
|
||||
def test_func(self):
|
||||
return self.request.user.is_superuser
|
|
@ -0,0 +1,11 @@
|
|||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
|
||||
from core.views.manage.permissions import SuperUserRequiredMixin
|
||||
|
||||
|
||||
class ThresholdIRCOverview(SuperUserRequiredMixin, View):
|
||||
template_name = "manage/threshold/irc/overview.html"
|
||||
|
||||
def get(self, request):
|
||||
return render(request, self.template_name)
|
Loading…
Reference in New Issue