Skip to content
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 changes/233.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added Circuit Maintenance Parser version to the dashboard.
8 changes: 8 additions & 0 deletions docs/user/app_use_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ When notifications are created, there is also a Job that may be run to determine

## General Usage

### Dashboard

The Circuit Maintenance App provides a dashboard that gives a quick overview of the current state of maintenances.

#### About Card

The dashboard includes an "About" card that displays the currently installed version of the `circuit-maintenance-parser` library. This is useful for verifying which version of the parser logic is being used to process notifications.

### Notification Sources

#### IMAP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ <h3 class="text-start">Metrics</h3>
</table>
</div>
</div>
<div class="card">
<div class="container">
<h3 class="text-start">About</h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more aesthetic to do a div class="card-header" in place of the h3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image If we do the card-header then we should probably do it in the rest of the sections too. Thoughts @glennmatthews ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be in favor of that, yes. The current styling is very inconsistent with the rest of Nautobot, IMHO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good by that. I'll be diving in later today looking for a styling guide or how I can make the dashboard page look more appropriate.

<table class="table table-hover nb-table-headings">
<tbody>
<tr>
<td>Circuit Maintenance Parser Version</td>
<td>{{ circuit_maintenance_parser_version }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

Expand Down
12 changes: 12 additions & 0 deletions nautobot_circuit_maintenance/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,18 @@ def test_get_maintenances_per_month(self):

self.assertEqual(expected_result, result)

@patch("importlib.metadata.version")
def test_extra_context_contains_parser_version(self, mock_version):
"""Test that the parser version is in the extra context."""
mock_version.return_value = "1.2.3"
test_object = CircuitMaintenanceOverview()
# Mocking the queryset as we are not testing the database interaction here and it may fail if not properly set up
test_object.queryset = CircuitMaintenance.objects.none()

context = test_object.extra_context()
self.assertIn("circuit_maintenance_parser_version", context)
self.assertEqual(context["circuit_maintenance_parser_version"], "1.2.3")


class DashboardTestZeroMaintenances(ModelViewTestCase):
"""View tests for CircuitMaintenance Dashboard."""
Expand Down
2 changes: 2 additions & 0 deletions nautobot_circuit_maintenance/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Views for Circuit Maintenance."""

import datetime
import importlib.metadata
import logging

import google_auth_oauthlib
Expand Down Expand Up @@ -104,6 +105,7 @@ def extra_context(self):
"upcoming_maintenances": maintenance_in_upcoming_days,
"circuit_maint_metric_data": metric_values,
"n_days": n_days,
"circuit_maintenance_parser_version": importlib.metadata.version("circuit-maintenance-parser"),
}

return self.extra_content
Expand Down
Loading