From 589ee6d7354d80d6c5dbaf14e0e2be5372a9b2a8 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:52:31 +0100 Subject: [PATCH] Add online status and jumping to nick to Insights page --- core/templates/ui/insights/insights.html | 2 +- core/templates/ui/insights/nicks.html | 25 +++++++++++++++++++++++- core/views/dynamic/insights.py | 4 +++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/templates/ui/insights/insights.html b/core/templates/ui/insights/insights.html index fea6c1e..2645bbf 100644 --- a/core/templates/ui/insights/insights.html +++ b/core/templates/ui/insights/insights.html @@ -49,7 +49,7 @@
- + diff --git a/core/templates/ui/insights/nicks.html b/core/templates/ui/insights/nicks.html index b59f3d7..8d8c4ab 100644 --- a/core/templates/ui/insights/nicks.html +++ b/core/templates/ui/insights/nicks.html @@ -1,18 +1,41 @@ +{% load index %} +
{% for nick in nicks %} {% endfor %} diff --git a/core/views/dynamic/insights.py b/core/views/dynamic/insights.py index a79d42b..e41c4af 100644 --- a/core/views/dynamic/insights.py +++ b/core/views/dynamic/insights.py @@ -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)
+ {% if nick in online %} + {% if online|index:nick is True %} + + + + {% elif online|index:nick is False %} + + + + {% else %} + + + + {% endif %} + {% endif %} {{ nick }} + + +