diff --git a/changelog.d/1941.added.md b/changelog.d/1941.added.md index 72e583006..7fea5d07d 100644 --- a/changelog.d/1941.added.md +++ b/changelog.d/1941.added.md @@ -1,2 +1,3 @@ -Added a way to to store expected heartbeat frequency (in seconds, minimum 60) -to a source system, and made the new field visible in the admin. +Added a way to to store expected heartbeat frequency (as a Postgres interval, +minimum 60 seconds) to a source system, and made the new field visible in the +admin. diff --git a/changelog.d/1962.added.md b/changelog.d/1962.added.md new file mode 100644 index 000000000..26148c944 --- /dev/null +++ b/changelog.d/1962.added.md @@ -0,0 +1 @@ +Show `last_seen` and `heartbeat_frequency` in the source list and allow altering `heartbeat_frequency`. diff --git a/src/argus/htmx/sourcesystem/forms.py b/src/argus/htmx/sourcesystem/forms.py index 68c61f776..e9e45db33 100644 --- a/src/argus/htmx/sourcesystem/forms.py +++ b/src/argus/htmx/sourcesystem/forms.py @@ -9,16 +9,18 @@ class Meta(AddSourceSystemForm.Meta): widgets = { "name": forms.TextInput, "base_url": forms.TextInput, + "heartbeat_frequency": forms.TextInput(attrs={"placeholder": "00:01:00"}), } class UpdateSourceSystemForm(forms.ModelForm): class Meta: model = SourceSystem - fields = ["name", "type", "base_url"] + fields = ["name", "type", "base_url", "heartbeat_frequency"] widgets = { "name": forms.TextInput, "base_url": forms.TextInput, + "heartbeat_frequency": forms.TextInput(attrs={"placeholder": "00:01:00"}), } diff --git a/src/argus/htmx/templates/htmx/sourcesystem/_sourcesystem_row.html b/src/argus/htmx/templates/htmx/sourcesystem/_sourcesystem_row.html index 1517a40ee..be0379f91 100644 --- a/src/argus/htmx/templates/htmx/sourcesystem/_sourcesystem_row.html +++ b/src/argus/htmx/templates/htmx/sourcesystem/_sourcesystem_row.html @@ -1,3 +1,4 @@ +{% load argus_htmx %} @@ -8,6 +9,12 @@ {{ source.base_url|default:"-" }} + + {{ source.last_seen|default:"Never" }} + + + {{ source.heartbeat_frequency|pretty_timedelta:"Off" }} + {% if source.token_status == "valid" %} diff --git a/src/argus/htmx/templates/htmx/sourcesystem/sourcesystem_form.html b/src/argus/htmx/templates/htmx/sourcesystem/sourcesystem_form.html index 7cee4bf0c..27d101e25 100644 --- a/src/argus/htmx/templates/htmx/sourcesystem/sourcesystem_form.html +++ b/src/argus/htmx/templates/htmx/sourcesystem/sourcesystem_form.html @@ -78,6 +78,66 @@

{% endif %} +
+ + {% render_field form.heartbeat_frequency class+="input input-bordered w-full" %} + {% if form.heartbeat_frequency.help_text %} +
+
+

Expected to send heartbeat at least every N seconds. Lower bound: 60 seconds. Upper bound: 1 day.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Valid inputsShortLongNotes
seconds as an integer100086400
DD HH:MM:SS00:16:401 00:00:00This is the format that is displayed in the form
+ ISO 8601 periods + PT16M40SP1DThe T is needed if less than a day.
+ PostgreSQL’s day-time interval format + 00:16:401 day 00:00:00
+
+
+ {% endif %} + {% if form.heartbeat_frequency.errors %} +
+ {% for error in form.heartbeat_frequency.errors %} + {{ error }} + {% endfor %} +
+ {% endif %} +