Implement scrollback modal
This commit is contained in:
@@ -10,6 +10,7 @@ from django_tables2 import SingleTableView
|
||||
from rest_framework.parsers import FormParser
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from core.lib.context import construct_query
|
||||
from core.lib.opensearch import query_results
|
||||
from core.lib.threshold import (
|
||||
annotate_num_chans,
|
||||
@@ -114,10 +115,13 @@ def drilldown_search(request, return_context=False, template=None):
|
||||
query_params["from_time"] = dates["from_time"]
|
||||
query_params["to_time"] = dates["to_time"]
|
||||
|
||||
if request.GET:
|
||||
context = query_results(request, query_params)
|
||||
elif request.POST:
|
||||
context = query_results(request, query_params)
|
||||
if "query" in query_params:
|
||||
if request.GET:
|
||||
context = query_results(request, query_params)
|
||||
elif request.POST:
|
||||
context = query_results(request, query_params)
|
||||
else:
|
||||
context = {"object_list": []}
|
||||
|
||||
# URI we're passing to the template for linking
|
||||
if "csrfmiddlewaretoken" in query_params:
|
||||
@@ -238,7 +242,10 @@ class DrilldownContextModal(APIView):
|
||||
def post(self, request):
|
||||
# if not request.user.has_plan(self.plan_name):
|
||||
# return JsonResponse({"success": False})
|
||||
num = ""
|
||||
num = None
|
||||
index = "main"
|
||||
size = 10
|
||||
# Check right fields exist
|
||||
if "net" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "channel" not in request.data:
|
||||
@@ -250,17 +257,49 @@ class DrilldownContextModal(APIView):
|
||||
if "date" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "num" in request.data:
|
||||
num = request.data["num"]
|
||||
if request.data["num"]:
|
||||
if not request.data["num"] == "—":
|
||||
num = request.data["num"]
|
||||
if "index" in request.data:
|
||||
if request.data["index"]:
|
||||
index = request.data["index"]
|
||||
net = request.data["net"]
|
||||
channel = request.data["channel"]
|
||||
# results =
|
||||
# Create the query params from the POST arguments
|
||||
blacklisted = ["date", "time"]
|
||||
query_params = {
|
||||
k: v for k, v in request.data.items() if v and k not in blacklisted
|
||||
}
|
||||
query_params["sorting"] = "desc"
|
||||
|
||||
# Create the query with the context helper
|
||||
search_query = construct_query(net, channel, request.data["src"], num, size)
|
||||
print("SEARCH QUERY", search_query)
|
||||
results = query_results(
|
||||
request, query_params, annotate=True, custom_query=search_query
|
||||
)
|
||||
if "message" in results:
|
||||
return render(request, self.template_name, results)
|
||||
results["object_list"] = results["object_list"][::-1]
|
||||
|
||||
# Make the time nicer
|
||||
# for index, item in enumerate(results["object_list"]):
|
||||
# results["object_list"][index]["time"] = item["time"]+"SSS"
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
"channel": channel,
|
||||
"num": num,
|
||||
"src": request.data["src"],
|
||||
"ts": f"{request.data['date']} {request.data['time']}",
|
||||
"object_list": results["object_list"],
|
||||
"time": request.data["time"],
|
||||
"date": request.data["date"],
|
||||
"index": request.data["date"],
|
||||
}
|
||||
if index:
|
||||
context["index"] = index
|
||||
if num:
|
||||
context["num"] = num
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user