Implement searching int events
This commit is contained in:
@@ -243,41 +243,29 @@ class DrilldownContextModal(APIView):
|
||||
if request.resolver_match.url_name == "modal_context_table":
|
||||
print("POST CONTEXT TABLE")
|
||||
self.template_name = "modals/context_table.html"
|
||||
# if not request.user.has_plan(self.plan_name):
|
||||
# return JsonResponse({"success": False})
|
||||
num = None
|
||||
index = "main"
|
||||
|
||||
size = 20
|
||||
# Check right fields exist
|
||||
if "net" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "channel" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "src" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "time" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "date" not in request.data:
|
||||
return JsonResponse({"success": False})
|
||||
if "num" in request.data:
|
||||
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"]
|
||||
# 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
|
||||
}
|
||||
mandatory = ["net", "channel", "num", "src", "index"]
|
||||
invalid = [None, False, "—", "None"]
|
||||
query_params = {k: v for k, v in request.data.items() if v}
|
||||
for key in query_params:
|
||||
if query_params[key] in invalid:
|
||||
query_params[key] = None
|
||||
for key in mandatory:
|
||||
if key not in query_params:
|
||||
query_params[key] = None
|
||||
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)
|
||||
search_query = construct_query(
|
||||
query_params["index"],
|
||||
query_params["net"],
|
||||
query_params["channel"],
|
||||
query_params["src"],
|
||||
query_params["num"],
|
||||
size,
|
||||
)
|
||||
results = query_results(
|
||||
request, query_params, annotate=True, custom_query=search_query
|
||||
)
|
||||
@@ -290,19 +278,18 @@ class DrilldownContextModal(APIView):
|
||||
# results["object_list"][index]["time"] = item["time"]+"SSS"
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
"channel": channel,
|
||||
"src": request.data["src"],
|
||||
"ts": f"{request.data['date']} {request.data['time']}",
|
||||
"net": query_params["net"],
|
||||
"channel": query_params["channel"],
|
||||
"src": query_params["src"],
|
||||
"ts": f"{query_params['date']} {query_params['time']}",
|
||||
"object_list": results["object_list"],
|
||||
"time": request.data["time"],
|
||||
"date": request.data["date"],
|
||||
"index": request.data["date"],
|
||||
"time": query_params["time"],
|
||||
"date": query_params["date"],
|
||||
"index": query_params["index"],
|
||||
"num": query_params["num"],
|
||||
}
|
||||
if index:
|
||||
context["index"] = index
|
||||
if num:
|
||||
context["num"] = num
|
||||
print("CONTEXT", context)
|
||||
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
|
||||
@@ -64,5 +64,6 @@ class DrilldownTable(Table):
|
||||
mtype = Column()
|
||||
realname = Column()
|
||||
server = Column()
|
||||
mtype = Column()
|
||||
template_name = "ui/drilldown/table_results.html"
|
||||
paginate_by = settings.DRILLDOWN_RESULTS_PER_PAGE
|
||||
|
||||
Reference in New Issue
Block a user