Skip to content
Snippets Groups Projects
Commit 634a22d2 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

Merge branch 'SDC-1635-monitoring-page' into 'master'

SDC-1635 monitoring page

See merge request !384
parents 0db093dd 4951643e
No related branches found
No related tags found
1 merge request!384SDC-1635 monitoring page
Pipeline #104884 passed
......@@ -137,7 +137,7 @@ p.title {
font-weight: bold;
}
#search_box
.search_box
{
color: darkblue;
display: inline-block;
......
......@@ -137,7 +137,7 @@ p.title {
font-weight: bold;
}
#search_box
.search_box
{
color: darkblue;
display: inline-block;
......
......@@ -33,7 +33,7 @@
{% block extra_js %}{% endblock %}
</head>
<body onload="readFromLocalStorage('search_box')">
<body>
{% include "astronauth/navbar.html" %}
......@@ -59,17 +59,30 @@
</html>
<script type="text/javascript">
function readFromLocalStorage(id) {
var s = localStorage.getItem(id);
if (s !== null) {
document.getElementById(id).value = s;
const value = localStorage.getItem(id);
if (value !== null) {
const element = document.getElementById(id);
if (element) {
element.value = value; // Set the input value from localStorage
}
}
}
window.addEventListener('load', () => {
readFromLocalStorage('search_services');
readFromLocalStorage('search_box');
});
</script>
<script type="text/javascript">
function writeToLocalStorage(id) {
var s = document.getElementById(id).value
localStorage.setItem(id, s);
function writeToLocalStorage(id, event) {
//event.preventDefault(); // Prevent the form from submitting
const element = document.getElementById(id);
if (element) {
localStorage.setItem(id, element.value); // Store the input value in localStorage
}
}
</script>
\ No newline at end of file
<form class="navbar-form navbar-left" role="Search" onsubmit="writeToLocalStorage('search_services')" method="get" action="">
<div class="form-group">
<input type="text" class="search_box" id="search_services" name="search_services" placeholder="Search for..." value="">
</div>
</form>
......@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 2 Jan 2025</p>
<p class="footer"> Version 17 Jan 2025</p>
</div>
{% include 'taskdatabase/refresh.html' %}
......
......@@ -24,6 +24,8 @@
<a href="{% url 'create_status_graph' %}" class="btn btn-primary btn-sm" role="button"><i class="fas fa-chart-line"></i> Status Graph</a>
<a href="{% url 'create_logentry_graph' %}" class="btn btn-primary btn-sm" role="button"><i class="fas fa-chart-line"></i> LogEntry Graph</a>
{% include 'taskdatabase/filter/search_services.html' %}
</p>
<table class="table table-striped">
......
......@@ -910,6 +910,16 @@ def ShowMonitoring(request):
distinct_services_per_host = LatestMonitor.objects.order_by('name', 'hostname', '-timestamp').distinct('name',
'hostname')
# filter on the value that is set into the localstorage 'search_services' with the filter_services.html component.
search = request.GET.get('search_services', None)
if (search is not None):
distinct_services_per_host = distinct_services_per_host.filter(
Q(name__icontains=search) |
Q(hostname__icontains=search) |
Q(status__icontains=search) |
Q(timestamp__icontains=search)
)
monitor_results = algorithms.convert_monitor_to_html(request, distinct_services_per_host)
return render(request, "taskdatabase/monitoring_page.html", {'monitor_results': monitor_results})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment