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

Dashboard View #191

Merged
merged 39 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
35de9fe
First set of dashboard view.
jvanderaa Jul 7, 2022
b6120df
Moves to using queryset to gather maintenances
jvanderaa Jul 7, 2022
f1b4c95
Calculate future maintenances
jvanderaa Jul 7, 2022
2a2f601
Finishes the dashboard page.
jvanderaa Jul 9, 2022
7c72b1c
Adds dashboard as home view
jvanderaa Jul 9, 2022
21bfa49
Updates for tests.
jvanderaa Jul 9, 2022
5aaffb8
Merge branch 'develop' into jv_cm_dashboard
jvanderaa Aug 11, 2022
3e6fa1f
Updates for the dashboard.
jvanderaa Aug 18, 2022
9f12c93
Updates flake8 setup
jvanderaa Aug 19, 2022
a72f167
Updates views for QA
jvanderaa Aug 19, 2022
87d592b
Remove left over learning.
jvanderaa Aug 26, 2022
095902d
Updates for views and documentation.
jvanderaa Aug 26, 2022
70a5b86
Updates and adds tests!
jvanderaa Aug 26, 2022
c83c9b3
Updates dashboard name in menu.
jvanderaa Aug 27, 2022
a910015
Adds test for historical gathering.
jvanderaa Aug 27, 2022
109859b
Adds test for future_maintenances
jvanderaa Aug 27, 2022
a047948
Adds tests for new methods.
jvanderaa Aug 27, 2022
f804f2e
Get tests to pass.
jvanderaa Aug 27, 2022
8085f53
Updates tests.
jvanderaa Aug 27, 2022
8c0d010
Style update.
jvanderaa Aug 27, 2022
6623b0f
Remove unused imports.
jvanderaa Aug 27, 2022
6a48cee
Updates for pylint and flake8
jvanderaa Aug 27, 2022
a163ee9
Move to using queryset all to alleviate test cache
jvanderaa Aug 28, 2022
bc250ec
Updates test to ignore too many pub methods
jvanderaa Aug 28, 2022
390afe5
Updates comments.
jvanderaa Aug 29, 2022
24e9017
Updates pylint control.
jvanderaa Aug 29, 2022
7e3646a
Updates messaging
jvanderaa Aug 29, 2022
ea322ab
Update pyproject.toml
jvanderaa Sep 1, 2022
de1f9cc
Uses total_seconds() method instead of seconds.
jvanderaa Sep 1, 2022
b73f8e0
Merge branch 'jv_cm_dashboard' of github.com:jvanderaa/nautobot-plugi…
jvanderaa Sep 1, 2022
48a8f5a
Update README.md
jvanderaa Sep 2, 2022
160abea
Updates for many comments.
jvanderaa Sep 4, 2022
433a20e
Merge branch 'jv_cm_dashboard' of github.com:jvanderaa/nautobot-plugi…
jvanderaa Sep 4, 2022
fd97fb1
Simplifies month calculations.
jvanderaa Sep 5, 2022
5636abc
Update nautobot_circuit_maintenance/templates/nautobot_circuit_mainte…
jvanderaa Sep 6, 2022
2c8dcc1
Updates to remove unnecessary code.
jvanderaa Sep 6, 2022
7343b52
Updates tests for one without all the views.
jvanderaa Sep 8, 2022
0759785
Removes unused js import (for now).
jvanderaa Sep 9, 2022
f6fac8a
Update nautobot_circuit_maintenance/templates/nautobot_circuit_mainte…
jvanderaa Sep 12, 2022
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A plugin for [Nautobot](https://github.com/nautobot/nautobot) to easily handle C

## Installation

The plugin is available as a Python package in pypi and can be installed with pip
The plugin is available as a Python package in PyPI and can be installed with `pip`:

```shell
pip install nautobot-circuit-maintenance
Expand All @@ -17,7 +17,7 @@ pip install nautobot-circuit-maintenance
To ensure Circuit Maintenance is automatically re-installed during future upgrades, create a file named `local_requirements.txt` (if not already existing) in the Nautobot root directory (alongside `requirements.txt`) and list the `nautobot-circuit-maintenance` package:

```no-highlight
# echo nautobot-circuit-maintenance >> local_requirements.txt
echo nautobot-circuit-maintenance >> local_requirements.txt
```

Once installed, the plugin needs to be enabled in your `configuration.py`.
Expand All @@ -32,6 +32,7 @@ PLUGINS_CONFIG = {
"nautobot_circuit_maintenance": {
"raw_notification_initial_days_since": 100,
"raw_notification_size": 16384,
"dashboard_n_days": 30, # Defaults to 30 days in the configurations, change/override here
"notification_sources": [
{
...
Expand Down
2 changes: 2 additions & 0 deletions nautobot_circuit_maintenance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ class CircuitMaintenanceConfig(PluginConfig):
default_settings = {
"raw_notification_initial_days_since": 7,
"raw_notification_size": 8192,
"dashboard_n_days": 30,
jvanderaa marked this conversation as resolved.
Show resolved Hide resolved
}
caching_config = {}
home_view_name = "plugins:nautobot_circuit_maintenance:circuitmaintenance_overview"
jvanderaa marked this conversation as resolved.
Show resolved Hide resolved

def ready(self):
super().ready()
Expand Down
5 changes: 5 additions & 0 deletions nautobot_circuit_maintenance/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from nautobot.utilities.choices import ButtonColorChoices

menu_items = (
PluginMenuItem(
link="plugins:nautobot_circuit_maintenance:circuitmaintenance_overview",
link_text="Dashboard",
permissions=["nautobot_circuit_maintenance.view_circuitmaintenance"],
),
PluginMenuItem(
link="plugins:nautobot_circuit_maintenance:circuitmaintenance_list",
link_text="Circuit Maintenances",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{% extends 'base.html' %}
{% load buttons %}
{% load static %}
{% load custom_links %}
{% load helpers %}
{% load plugins %}

{% block header %}
{% endblock %}
{% block content %}

<h1>{% block title %}Circuit Maintenance Dashboard{% endblock %}</h1>
<div class="col-md-3">
<!-- Visual block -->
<div class="card">
<div class="container">
<h3 class="text s-2 p-3">Circuits With Maintenances in the Next {{ n_days }} Days</h3>
<table class="table table-hover table-headings">
<thead>
<tr>
<th>Circuit ID</th>
<th>Sites</th>
<th>Circuit Status</th>
<th>Maintenance Start</th>
</tr>
</thead>
<tbody>
{% for maintenance in upcoming_maintenances %}
{% for circuit in maintenance.circuits %}
<tr>
<td>
<a href="{{ circuit.get_absolute_url }}">{{ circuit.cid }}</a>
</td>
<td>
{% if circuit.termination_a.connected_endpoint %}
{% with circuit_term_a_site=circuit.termination_a.connected_endpoint.parent.site %}
{% comment %}Fix up this line after if move to Jinja templating. Unable to shrink due to whitespace {% endcomment %}
<a href="{{ circuit_term_a_site.get_absolute_url }}">{{ circuit_term_a_site.name }}</a>
{% if circuit.termination_z.connected_endpoint and circuit_term_a_site != circuit.termination_z.connected_endpoint.parent.site %}
| <a href="{{ circuit.termination_z.connected_endpoint.parent.site.get_absolute_url }}">{{ circuit.termination_z.connected_endpoint.parent.site.name}}</a>
{% endif %}
{% endwith %}
{% endif %}
</td>
<td>
{{ circuit.status.name }}
</td>
<td>
{{ maintenance.start_time | date:'Y-m-d H:i e' }}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card">
<div class="container card-body">
<h3 class="text-left">Devices with Maintenances in the Next {{ n_days }} Days</h3>
<table class="table table-hover table-headings">
<thead>
<tr>
<th>Device Name</th>
<th>Maintenance Start</th>
</tr>
</thead>
<tbody>
{% for maintenance in upcoming_maintenances %}
{% for circuit in maintenance.circuits %}
{% if circuit.termination_a.connected_endpoint %}
<tr>
<td>
{% with device_obj=circuit.termination_a.connected_endpoint.parent %}
<a href="{{ device_obj.get_absolute_url }}">{{ device_obj.name }}</a>
{% endwith %}
</td>
<td>
{{ maintenance.start_time | date:'Y-m-d H:i e' }}
</td>
</tr>
{% endif %}
{% if circuit.termination_z.connected_endpoint %}
<tr>
<td>
{% with device_obj=circuit.termination_z.connected_endpoint.parent %}
<a href="{{ device_obj.get_absolute_url }}">{{ device_obj.name }}</a>
{% endwith %}
</td>
<td>
{{ maintenance.start_time | date:'Y-m-d H:i e' }}
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card">
<div class="container">
<h3 class="text-left">Metrics</h3>
<table class="table table-hover table-headings">
<thead>
<tr>
<th>Metric</th>
<th>Metric Value</th>
</tr>
</thead>
<tbody>
{% for cm_metric_key, cm_metric_value in circuit_maint_metric_data.items %}
<tr>
<td>{{ cm_metric_key }}</td>
<td>{{ cm_metric_value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

{% endblock %}
Loading