Skip to content

Commit

Permalink
Filter incident by tags with simple input field
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Jan 23, 2025
1 parent 605b38e commit b969ae6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1044.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add text field to filter incident list by tags
14 changes: 14 additions & 0 deletions src/argus/htmx/incident/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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}
Expand Down Expand Up @@ -89,6 +99,10 @@ def to_filterblob(self):
if sourceSystemIds:
filterblob["sourceSystemIds"] = sourceSystemIds

tags = self.cleaned_data.get("tags", [])
if tags:
filterblob["tags"] = tags.split(", ")

maxlevel = self.cleaned_data.get("maxlevel", 0)
if maxlevel:
filterblob["maxlevel"] = maxlevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% for field in filter_form %}
{% if not field.field.in_header %}
<li class="form-control">
{% if field.name == "sourceSystemIds" %}
{% if field.name == "sourceSystemIds" or field.name == "tags" %}
<div class="flex flex-nowrap">
<label class="label">
<span class="label-text">{{ field.label }}</span>
Expand Down

0 comments on commit b969ae6

Please sign in to comment.