Begin implementing modern tables

This commit is contained in:
2022-08-09 09:04:31 +01:00
parent 7e010bd9b8
commit ba51922fe9
10 changed files with 183 additions and 2 deletions

View File

@@ -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):