diff --git a/core/lib/context.py b/core/lib/context.py index d67866d..57a1287 100644 --- a/core/lib/context.py +++ b/core/lib/context.py @@ -1,4 +1,4 @@ -def construct_query(index, net, channel, src, num, size, nicks=None): +def construct_query(index, net, channel, src, num, size, type=None, nicks=None): # Get the initial query extra_must = [] extra_should = [] @@ -26,8 +26,14 @@ def construct_query(index, net, channel, src, num, size, nicks=None): ] if index == "int": fields.append("mtype") - for ctype in types: - extra_should.append({"match": {"mtype": ctype}}) + if channel == "*status" or type == "znc": + if {"match": {"channel": channel}} in extra_must: + extra_must.remove({"match": {"channel": channel}}) + extra_should2 = [] + extra_must.append({"match": {"type": "znc"}}) + else: + for ctype in types: + extra_should.append({"match": {"mtype": ctype}}) else: for ctype in types: extra_should.append({"match": {"type": ctype}}) @@ -54,5 +60,4 @@ def construct_query(index, net, channel, src, num, size, nicks=None): "fields": fields, "_source": False, } - return query diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index db906eb..06f0097 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -104,15 +104,15 @@ hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-post="{% url 'modal_context' %}" hx-vals='{"net": "{{ net }}", - "num": "{{ relay.id }}", - "src": "irc", - "channel": "None", - "time": "None", - "date": "None", - "index": "int", - "type": "znc", - "mtype": "None", - "nick": "None"}' + "num": "{{ relay.id }}", + "src": "irc", + "channel": "*status", + "time": "None", + "date": "None", + "index": "int", + "type": "znc", + "mtype": "None", + "nick": "*status"}' hx-target="#modals-here" hx-trigger="click" class="button is-small has-background-info has-text-white"> @@ -120,7 +120,7 @@ - {# actions-top #} + @@ -134,7 +134,7 @@ - {# id #} + - {# reg #} + - {# auth #} - {# conn #} + + {% if relay.enabled %} {% endif %} - {# on #} + @@ -199,7 +199,7 @@ - {# actions-bottom #} + {% endfor %} diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index cc767c9..e33edb6 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -104,7 +104,7 @@ class ThresholdIRCNetworkRelays(SuperUserRequiredMixin, View): def get(self, request, net): relays = threshold.get_irc_relays(net) - context = {"relays": relays["relays"]} + context = {"net": net, "relays": relays["relays"]} return render(request, self.template_name, context) diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index cc61a12..adcc5c9 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -253,7 +253,7 @@ class DrilldownContextModal(APIView): size = 20 nicks = None # Create the query params from the POST arguments - mandatory = ["net", "channel", "num", "src", "index", "nick"] + mandatory = ["net", "channel", "num", "src", "index", "nick", "type"] invalid = [None, False, "—", "None"] query_params = {k: v for k, v in request.data.items() if v} for key in query_params: @@ -275,6 +275,13 @@ class DrilldownContextModal(APIView): and not query_params["type"] == "query" ): query_params["index"] = "main" + + type = None + if "type" in query_params: + type = query_params["type"] + if type == "znc": + query_params["channel"] = "*status" + # Create the query with the context helper search_query = construct_query( query_params["index"], @@ -283,10 +290,16 @@ class DrilldownContextModal(APIView): query_params["src"], query_params["num"], size, + type=type, nicks=nicks, ) + annotate = False + if query_params["src"] == "irc": + if query_params["type"] in ["query", "notice", "msg", "highlight"]: + annotate = True + results = query_results( - request, query_params, annotate=True, custom_query=search_query + request, query_params, annotate=annotate, custom_query=search_query ) if "message" in results: return render(request, self.template_name, results)