diff --git a/app/settings.py b/app/settings.py
index 9e7eed4..9f7fda5 100644
--- a/app/settings.py
+++ b/app/settings.py
@@ -35,11 +35,15 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
+ "django_htmx",
"crispy_forms",
"crispy_bulma",
+ "django_tables2",
+ "django_tables2_bulma_template",
]
CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
+DJANGO_TABLES2_TEMPLATE = "django-tables2/bulma.html"
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
@@ -49,6 +53,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
+ "django_htmx.middleware.HtmxMiddleware",
]
ROOT_URLCONF = "app.urls"
diff --git a/app/urls.py b/app/urls.py
index 97231fa..a7e0e26 100644
--- a/app/urls.py
+++ b/app/urls.py
@@ -51,7 +51,12 @@ from core.views.manage.threshold.threshold import (
)
# Main tool pages
-from core.views.ui.drilldown import Drilldown, DrilldownSearch, ThresholdInfoModal
+from core.views.ui.drilldown import (
+ Drilldown,
+ DrilldownSearch,
+ DrilldownTableView,
+ ThresholdInfoModal,
+)
from core.views.ui.insights import (
Insights,
InsightsChannels,
diff --git a/core/templates/ui/drilldown/table_results.html b/core/templates/ui/drilldown/table_results.html
new file mode 100644
index 0000000..849a7bf
--- /dev/null
+++ b/core/templates/ui/drilldown/table_results.html
@@ -0,0 +1,32 @@
+{% load static %}
+{% load index %}
+{% include 'partials/notify.html' %}
+{% if table %}
+
+
+
+
+
+
+
+
+
fetched {{ results|length }} of {{ card }} hits in {{ took }}ms
+
+ {% if exemption is not None %}
+
+
+
+ {% else %}
+ {% if redacted != 0 %}
+
+
{{ redacted }} redacted
+
+ {% endif %}
+ {% endif %}
+
+
+
+ {% include 'ui/drilldown/table_results_partial.html' %}
+
+
+{% endif %}
\ No newline at end of file
diff --git a/core/templates/ui/drilldown/table_results_partial.html b/core/templates/ui/drilldown/table_results_partial.html
new file mode 100644
index 0000000..c91481e
--- /dev/null
+++ b/core/templates/ui/drilldown/table_results_partial.html
@@ -0,0 +1,71 @@
+{% extends 'django-tables2/bulma.html' %}
+
+{% load django_tables2 %}
+
+{% load i18n %}
+
+{% block table.thead %}
+ {% if table.show_header %}
+
+
+ {% for column in table.columns %}
+
+ {{ column.header }}
+ |
+ {% endfor %}
+
+
+ {% endif %}
+{% endblock table.thead %}
+
+{# Pagination block overrides #}
+{% block pagination.previous %}
+
+
+ «
+ {% trans 'previous' %}
+
+
+{% endblock pagination.previous %}
+{% block pagination.range %}
+ {% for p in table.page|table_page_range:table.paginator %}
+
+
+ {{ p }}
+
+
+ {% endfor %}
+{% endblock pagination.range %}
+{% block pagination.next %}
+
+
+ {% trans 'next' %}
+ »
+
+
+{% endblock pagination.next %}
\ No newline at end of file
diff --git a/core/views/ui/__init__.py b/core/views/ui/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py
index d054528..a24ae06 100644
--- a/core/views/ui/drilldown.py
+++ b/core/views/ui/drilldown.py
@@ -3,7 +3,9 @@ import json
from django.conf import settings
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
+from django.utils.html import format_html
from django.views import View
+from django_tables2 import SingleTableMixin
from rest_framework.parsers import FormParser
from rest_framework.views import APIView
@@ -14,6 +16,33 @@ from core.lib.threshold import (
get_chans,
get_users,
)
+from core.views.ui.tables import DrilldownTable
+
+
+class DrilldownTableView(View, SingleTableMixin):
+ table_class = DrilldownTable
+ template_name = "ui/drilldown/table_results.html"
+ paginate_by = 5
+
+ def post(self, request):
+ context = query_results(request)
+ table = DrilldownTable(context["results"])
+ context["table"] = table
+ del context["results"]
+ if "message" in context:
+ return render(request, self.template_name, context)
+
+ if self.request.htmx:
+ print("IS HTMX")
+ template_name = "ui/drilldown/table_results.html"
+ else:
+ print("IS NOT HTMX")
+ template_name = "ui/drilldown/table_results_partial.html"
+
+ if context:
+ return render(request, self.template_name, context)
+ else:
+ return HttpResponse("No results")
class Drilldown(View):
diff --git a/core/views/ui/tables.py b/core/views/ui/tables.py
new file mode 100644
index 0000000..097704b
--- /dev/null
+++ b/core/views/ui/tables.py
@@ -0,0 +1,33 @@
+from django_tables2 import Table, Column
+
+class DrilldownTable(Table):
+ id = Column()
+ host = Column()
+ ident = Column()
+ nick = Column()
+ nick_id = Column()
+ user_id = Column()
+ msg = Column()
+ msg_id = Column()
+ net = Column()
+ net_id = Column()
+ num = Column()
+ src = Column()
+ ts = Column()
+ type = Column()
+ bot = Column()
+ channel = Column()
+ channel_category = Column()
+ channel_category_id = Column()
+ channel_category_nsfw = Column()
+ channel_id = Column()
+ channel_nsfw = Column()
+ guild_member_count = Column()
+ guild = Column()
+ guild_id = Column()
+ mode = Column()
+ modearg = Column()
+ sentiment = Column()
+ status = Column()
+ user = Column()
+ version_sentiment = Column()
diff --git a/docker/prod/requirements.prod.txt b/docker/prod/requirements.prod.txt
index 3d57592..8d818ff 100644
--- a/docker/prod/requirements.prod.txt
+++ b/docker/prod/requirements.prod.txt
@@ -7,4 +7,5 @@ stripe
django-rest-framework
numpy
uwsgi
-pyroscope-io
+django-tables2
+django-tables2-bulma-template
diff --git a/docker/requirements.dev.txt b/docker/requirements.dev.txt
index 9ea9856..04cd6a4 100644
--- a/docker/requirements.dev.txt
+++ b/docker/requirements.dev.txt
@@ -6,3 +6,6 @@ opensearch-py
stripe
django-rest-framework
numpy
+django-tables2
+django-tables2-bulma-template
+django-htmx
diff --git a/requirements.txt b/requirements.txt
index 2562843..1605cda 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,3 +7,5 @@ opensearch-py
stripe
django-rest-framework
numpy
+django-tables2
+django-tables2-bulma-template