Add online status and jumping to nick to Insights page

This commit is contained in:
Mark Veidemanis 2022-07-21 13:52:31 +01:00
parent bb8f6d119e
commit 589ee6d735
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 28 additions and 3 deletions

View File

@ -49,7 +49,7 @@
<div class="field-body">
<div class="field">
<div class="control is-expanded has-icons-left">
<input name="query" class="input" type="text" placeholder="nickname">
<input id="query" name="query" class="input" type="text" placeholder="nickname">
<span class="icon is-small is-left">
<i class="fas fa-magnifying-glass"></i>
</span>

View File

@ -1,18 +1,41 @@
{% load index %}
<div id="nicks">
<div class="content" style="max-height: 30em; overflow: auto;">
<table class="table is-fullwidth is-hoverable">
{% for nick in nicks %}
<tr>
<td>
{% if nick in online %}
{% if online|index:nick is True %}
<span class="icon has-text-success has-tooltip-success" data-tooltip="Online">
<i class="fa-solid fa-circle"></i>
</span>
{% elif online|index:nick is False %}
<span class="icon has-text-danger has-tooltip-danger" data-tooltip="Offline">
<i class="fa-solid fa-circle"></i>
</span>
{% else %}
<span class="icon has-text-warning has-tooltip-warning" data-tooltip="Unknown">
<i class="fa-solid fa-circle"></i>
</span>
{% endif %}
{% endif %}
<span
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'modal_drilldown' %}"
hx-vals='{"net": "{{ net }}", "nick": "{{ nick }}", "channel": "{{ chan }}"}'
hx-target="#modals-here"
hx-target="#modals-here"
hx-trigger="click"
class="button is-small">
{{ nick }}
</span>
<a
class="icon has-text-info has-tooltip-info"
data-tooltip="Populate search"
onclick="document.getElementById('query').value='nick: {{ nick }}';">
<i class="fa-solid fa-arrow-left-long-to-line"></i>
</a>
</td>
</tr>
{% endfor %}

View File

@ -10,6 +10,7 @@ from core.lib.opensearch import query_single_result
from core.lib.threshold import (
annotate_num_chans,
annotate_num_users,
annotate_online,
get_chans,
get_users,
)
@ -66,9 +67,10 @@ class InsightsNicks(LoginRequiredMixin, APIView):
net = request.data["net"]
nick = request.data["nick"]
nicks = get_nicks(request, net, nick)
online = annotate_online(net, nicks)
if not nicks:
return HttpResponseForbidden()
context = {"net": net, "nick": nick, "nicks": nicks}
context = {"net": net, "nick": nick, "nicks": nicks, "online": online}
return render(request, self.template_name, context)