diff --git a/changelog.d/1044.added.md b/changelog.d/1044.added.md new file mode 100644 index 000000000..4c606c151 --- /dev/null +++ b/changelog.d/1044.added.md @@ -0,0 +1 @@ +Add text field to filter incident list by tags diff --git a/src/argus/htmx/incident/filter.py b/src/argus/htmx/incident/filter.py index 7ede7cb19..78208927f 100644 --- a/src/argus/htmx/incident/filter.py +++ b/src/argus/htmx/incident/filter.py @@ -1,7 +1,7 @@ from django import forms from argus.filter import get_filter_backend -from argus.incident.models import SourceSystem +from argus.incident.models import SourceSystem, Tag from argus.incident.constants import Level from argus.htmx.widgets import BadgeDropdownMultiSelect @@ -26,6 +26,16 @@ class IncidentFilterForm(forms.Form): required=False, label="Sources", ) + tags = forms.CharField( + widget=forms.TextInput( + attrs={ + "placeholder": "enter tags...", + "class": "show-selected-box input input-accent input-bordered input-md border overflow-y-auto min-h-8 h-auto max-h-16 max-w-xs leading-tight", + } + ), + required=False, + label="Tags", + ) maxlevel = forms.IntegerField( widget=forms.NumberInput( attrs={"type": "range", "step": "1", "min": min(Level).value, "max": max(Level).value} @@ -63,6 +73,10 @@ def to_filterblob(self): if source: filterblob["sourceSystemIds"] = source + tags = self.cleaned_data.get("tags", []) + if tags: + filterblob["tags"] = tags.split(", ") + maxlevel = self.cleaned_data.get("maxlevel", 0) if maxlevel: filterblob["maxlevel"] = maxlevel diff --git a/src/argus/htmx/templates/htmx/incident/_incident_filterbox.html b/src/argus/htmx/templates/htmx/incident/_incident_filterbox.html index 39aeb5944..69ac5bf7b 100644 --- a/src/argus/htmx/templates/htmx/incident/_incident_filterbox.html +++ b/src/argus/htmx/templates/htmx/incident/_incident_filterbox.html @@ -14,7 +14,7 @@ {% for field in filter_form %} {% if not field.field.in_header %}