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-body">
<div class="field"> <div class="field">
<div class="control is-expanded has-icons-left"> <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"> <span class="icon is-small is-left">
<i class="fas fa-magnifying-glass"></i> <i class="fas fa-magnifying-glass"></i>
</span> </span>

View File

@ -1,9 +1,26 @@
{% load index %}
<div id="nicks"> <div id="nicks">
<div class="content" style="max-height: 30em; overflow: auto;"> <div class="content" style="max-height: 30em; overflow: auto;">
<table class="table is-fullwidth is-hoverable"> <table class="table is-fullwidth is-hoverable">
{% for nick in nicks %} {% for nick in nicks %}
<tr> <tr>
<td> <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 <span
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'modal_drilldown' %}" hx-post="{% url 'modal_drilldown' %}"
@ -13,6 +30,12 @@
class="button is-small"> class="button is-small">
{{ nick }} {{ nick }}
</span> </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> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

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