Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter incident by tags using simple input field #1114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading