From fa6c1dc1aabd91fa18ae15da4dd8007c68b5d369 Mon Sep 17 00:00:00 2001 From: Nico Vermaas <vermaas@astron.nl> Date: Tue, 19 Apr 2022 15:25:26 +0200 Subject: [PATCH] service resume/hold buttons (in progress) --- atdb/taskdatabase/services/algorithms.py | 14 +++++++++----- .../taskdatabase/templates/taskdatabase/index.html | 2 +- .../templates/taskdatabase/monitoring_page.html | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index fc31a65c..cce3f3a6 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -288,18 +288,22 @@ def convert_monitor_to_html(request, monitor_data): line += "<td><b>" + link_to_service_history + "</b></td>" line += "<td>" + str(record.hostname) + "</td>" - if record.enabled=="True": - button_html = '<a href="service_hold_resume/' + str(record.pk) + '/False"' + 'class="btn btn-warning btn-sm" role="button"><i class="fas fa-pause"></i> Hold</a>' + # only provide the hold/resume buttons for superusers, otherwise just show the state + if request.user.is_superuser: + if record.enabled=="True": + service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + str(record.pk) + '/False"' + 'class="btn btn-warning btn-sm" role="button"><i class="fas fa-pause"></i> Hold</a>' + else: + service_enabled = str(record.enabled) + ' <a href="service_hold_resume/' + str(record.pk) + '/True"' + 'class="btn btn-success btn-sm" role="button"><i class="fas fa-play"></i> Resume</a>' else: - button_html = '<a href="service_hold_resume/' + str(record.pk) + '/True"' + 'class="btn btn-success btn-sm" role="button"><i class="fas fa-play"></i> Resume</a>' + service_enabled = str(record.enabled) # if the heartbeat is 30 minutes late, show '(late)' in red if delta.seconds > 1800: - line += '<td>' + button_html + str(record.enabled) + "</td>" + line += "<td>" + service_enabled + "</td>" line += "<td><i>unknown</i></td>" line += '<td class="error">' + str(record.timestamp.strftime(TIME_FORMAT)) + " - (late)</td>" else: - line += '<td>' + button_html + str(record.enabled) + "</td>" + line += "<td>" + service_enabled + "</td>" line += '<td class="' + record.status + '" >' + str(record.status) + "</td>" line += '<td>' + str(record.timestamp.strftime(TIME_FORMAT)) + "</td>" diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 36cbd2dd..d8b4f2fd 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -34,7 +34,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 1.0.0 (14 apr 2021 - 13:00) + <p class="footer"> Version 1.0.0 (19 apr 2021 - 13:00) </div> diff --git a/atdb/taskdatabase/templates/taskdatabase/monitoring_page.html b/atdb/taskdatabase/templates/taskdatabase/monitoring_page.html index f6b7aced..0679ca22 100644 --- a/atdb/taskdatabase/templates/taskdatabase/monitoring_page.html +++ b/atdb/taskdatabase/templates/taskdatabase/monitoring_page.html @@ -22,7 +22,7 @@ </p> {% endif %} <table class="table table-striped"> - <th>LDV-Service</th><th>Host</th><th>Enabled</th><th>Status</th><th>Timestamp</th><th>Process id</th><th>Description</th> + <th>LDV-Service</th><th>Host</th><th>Enabled</th><th>Last Status</th><th>Timestamp</th><th>Process id</th><th>Description</th> <tbody> {{ monitor_results | safe }} </tbody> -- GitLab