From 9de9ddff6f67d4488d8fd376a2b31b3a6c2813c7 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:52:06 +0100 Subject: [PATCH] Implement channel pane for insights --- core/templates/modals/drilldown.html | 12 +- core/templates/modals/insights.html | 132 ---------- core/templates/ui/drilldown/drilldown.html | 5 +- core/templates/ui/drilldown/results.html | 283 ++++++++++----------- core/templates/ui/insights/channels.html | 28 ++ core/templates/ui/insights/insights.html | 20 +- core/templates/ui/insights/results.html | 167 ++++++------ core/views/dynamic/insights.py | 29 ++- 8 files changed, 299 insertions(+), 377 deletions(-) delete mode 100644 core/templates/modals/insights.html create mode 100644 core/templates/ui/insights/channels.html diff --git a/core/templates/modals/drilldown.html b/core/templates/modals/drilldown.html index 9d7587d..9595161 100644 --- a/core/templates/modals/drilldown.html +++ b/core/templates/modals/drilldown.html @@ -21,7 +21,7 @@ - diff --git a/core/templates/ui/drilldown/drilldown.html b/core/templates/ui/drilldown/drilldown.html index 692cab0..929f2b5 100644 --- a/core/templates/ui/drilldown/drilldown.html +++ b/core/templates/ui/drilldown/drilldown.html @@ -79,7 +79,7 @@ hx-post="{% url 'search_drilldown' %}" hx-trigger="click" hx-target="#results" - hx-swap="outerHTML"> + hx-swap="innerHTML"> Search @@ -90,5 +90,6 @@
- +
+
{% endblock %} diff --git a/core/templates/ui/drilldown/results.html b/core/templates/ui/drilldown/results.html index 75f3af6..f3d981c 100644 --- a/core/templates/ui/drilldown/results.html +++ b/core/templates/ui/drilldown/results.html @@ -1,157 +1,154 @@ {% load static %} {% load index %} -
- {% if results is not None %} -
- -
-
-

2

-
-
- + +
+
- - - - - -{% endblock %} +
+{% endblock %} \ No newline at end of file diff --git a/core/templates/ui/insights/results.html b/core/templates/ui/insights/results.html index a0586d6..896cbf0 100644 --- a/core/templates/ui/insights/results.html +++ b/core/templates/ui/insights/results.html @@ -1,83 +1,94 @@ {% load static %} {% load index %} - -
-
- {% if item is not None %} -
- - - - - - - - - - - - - - - - - - - - - - - -
src - {% if item|index:'src' == 'irc' %} - - - - IRC - {% elif item|index:'src' == 'dis' %} - - - - Discord - {% endif %} -
nick - {% if item|index:'online' is True %} - - - - {{ item.nick }} - {% elif item|index:'online' is False %} - - - - {{ item|index:'nick' }} - {% else %} - - - - {{ item|index:'nick'}} - {% endif %} - {% if item|index:'num_chans' is not None %} - - {{ item|index:'num_chans' }} - - {% endif %} -
host{{ item.host }}
actions - {% if item.src == 'irc' %} - -
- {% endif %} -
net{{ item.net }}
-
- {% endif %} +
+

+ Information +

+
+
+ {% if item is not None %} +
+ + + + + + + + + + + + + + + + + + + + + + + +
src + {% if item.src == 'irc' %} + + + + IRC + {% elif item.src == 'dis' %} + + + + Discord + {% endif %} +
nick + {% if item.online is True %} + + + + {{ item.nick }} + {% elif item.online is False %} + + + + {{ item.nick }} + {% else %} + + + + {{ item.nick }} + {% endif %} + {% if item.num_chans is not None %} + + {{ item.num_chans }} + + {% endif %} +
host{{ item.host }}
actions + {% if item.src == 'irc' %} + + {% endif %} +
net{{ item.net }}
+
+ {% endif %} +
+
+
\ No newline at end of file diff --git a/core/views/dynamic/insights.py b/core/views/dynamic/insights.py index 20cf62a..f50c0d9 100644 --- a/core/views/dynamic/insights.py +++ b/core/views/dynamic/insights.py @@ -22,7 +22,6 @@ class InsightsSearch(LoginRequiredMixin, View): def post(self, request): if not request.user.has_plan(self.plan_name): return HttpResponseForbidden() - results, context = query_single_result(request) if not context: return HttpResponseForbidden() @@ -32,10 +31,36 @@ class InsightsSearch(LoginRequiredMixin, View): return HttpResponse("No results") +class InsightsChannels(LoginRequiredMixin, APIView): + parser_classes = [FormParser] + template_name = "ui/insights/channels.html" + plan_name = "drilldown" + + def post(self, request): + if not request.user.has_plan(self.plan_name): + return HttpResponseForbidden() + if "net" not in request.data: + return HttpResponse("No net") + if "nick" not in request.data: + return HttpResponse("No nick") + net = request.data["net"] + nick = request.data["nick"] + print("Insights channels item", nick) + chans = get_chans(net, [nick]) + print("GET CHANS", chans) + if not chans: + return HttpResponseForbidden() + context = {"net": net, "nick": nick, "chans": chans} + if chans: + return render(request, self.template_name, context) + else: + return HttpResponse("No results") + + class InsightsInfoModal(LoginRequiredMixin, APIView): parser_classes = [FormParser] plan_name = "drilldown" - template_name = "modals/insights.html" + template_name = "modals/drilldown.html" def post(self, request): if not request.user.has_plan(self.plan_name):