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

bonus link in dashboard

parent e7591758
No related branches found
No related tags found
3 merge requests!74Acceptance,!73Master,!60bonus link in dashboard
...@@ -13,6 +13,10 @@ TD { ...@@ -13,6 +13,10 @@ TD {
color: blue; color: blue;
} }
.active {
background-color: lemonchiffon;
}
.error,.failed,.staging_failed,.processed_failed { .error,.failed,.staging_failed,.processed_failed {
color: red; color: red;
font-weight: bold; font-weight: bold;
......
...@@ -198,20 +198,15 @@ def aggregate_resources_tasks(): ...@@ -198,20 +198,15 @@ def aggregate_resources_tasks():
return workflow_results return workflow_results
def convert_aggregation_to_html(): def convert_aggregation_to_html(request):
# gather the data
workflow_results = aggregate_resources_tasks()
records = aggregate_resources_logs()
# layout the data
# --- Progress of tasks per active workflow --- # --- Progress of tasks per active workflow ---
workflow_results = aggregate_resources_tasks()
results_tasks = "<p>Progress of tasks per (active) workflow</p>" results_tasks = "<p>Progress of tasks per (active) workflow</p>"
header = "<th>Workflow</th>" header = "<th>Workflow</th>"
for status in settings.ALL_STATUSSES: for status in settings.ALL_STATUSSES:
header += "<th>" + status + "</th>" header += "<th>" + status + "</th>"
results_tasks += header + "<th>active</th><th>total</th>" results_tasks += header + '<th class="active">active</th><th>total</th>'
for workflow_result in workflow_results: for workflow_result in workflow_results:
...@@ -219,18 +214,37 @@ def convert_aggregation_to_html(): ...@@ -219,18 +214,37 @@ def convert_aggregation_to_html():
values = "<td><b>" + str(workflow_result['id'])+" - "+workflow_result['name'] + "</b></td>" values = "<td><b>" + str(workflow_result['id'])+" - "+workflow_result['name'] + "</b></td>"
for key in d: for key in d:
percentage = round(int(d[key]) / int(workflow_result['nr_of_tasks']) * 100) percentage = round(int(d[key]) / int(workflow_result['nr_of_tasks']) * 100)
values += "<td>" + str(percentage) + "% ("+str(d[key])+")</td>"
# distinguish active statusses
style = ""
if key in settings.ACTIVE_STATUSSES or key=='active':
style = "active"
# bonus: add a query link
query = "?status="+key+ "&workflow="+str(workflow_result['id'])
url = request.build_absolute_uri('/atdb/tasks')+query
link = '<a href="' + url + '" target="_blank">' + str(d[key]) + "</a>"
values += "<td class=" + style + ">" + str(percentage) + "% (" + link + ")</td>"
#values += "<td class="+style+">" + str(percentage) + "% ("+str(d[key])+")</td>"
#values += "<td>" + str(d[key]) + "</td>" #values += "<td>" + str(d[key]) + "</td>"
results_tasks += "<tr>" + values + "</tr>" results_tasks += "<tr>" + values + "</tr>"
results_tasks = "<tbody>" + results_tasks + "</tbody>" results_tasks = "<tbody>" + results_tasks + "</tbody>"
# --- logentries --- # --- logentries ---
log_records = aggregate_resources_logs()
results_logs = "" results_logs = ""
for record in records:
for record in log_records:
# distinguish active statusses
style = ""
if record['status'] in settings.ACTIVE_STATUSSES:
style = "active"
line = "<tr><td><b>" + record['name'] + "</b></td>"\ line = "<tr><td><b>" + record['name'] + "</b></td>"\
'<td class="' + record['status'] + '" >' + record['status'] + \ '<td class="' + style + '" >' + record['status'] + \
"</td><td>" + str(record['cpu_cycles']) + \ "</td><td>" + str(record['cpu_cycles']) + \
"</td><td>" + str(record['wall_clock_time']) + "</td><tr>" "</td><td>" + str(record['wall_clock_time']) + "</td><tr>"
results_logs += line results_logs += line
......
...@@ -13,6 +13,10 @@ TD { ...@@ -13,6 +13,10 @@ TD {
color: blue; color: blue;
} }
.active {
background-color: lemonchiffon;
}
.error,.failed,.staging_failed,.processed_failed { .error,.failed,.staging_failed,.processed_failed {
color: red; color: red;
font-weight: bold; font-weight: bold;
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4>Dashboard</h4> <h4>Dashboard</h4>
&nbsp;
<table class="table table-striped"> <table class="table table-striped">
{{ results_tasks | safe }} {{ results_tasks | safe }}
</table> </table>
&nbsp;
<table class="table table-striped"> <table class="table table-striped">
<p>Resources used per step per active workflow</p> <p>Resources used per step per active workflow</p>
<th>Workflow</th><th>Status</th><th>CPU cycles</th><th>wall clock time</th> <th>Workflow</th><th>Status</th><th>CPU cycles</th><th>wall clock time</th>
......
...@@ -253,7 +253,7 @@ def ShowConfig(request): ...@@ -253,7 +253,7 @@ def ShowConfig(request):
def ShowDashboard(request): def ShowDashboard(request):
# gather the results # gather the results
results_tasks,results_logs = algorithms.convert_aggregation_to_html() results_tasks,results_logs = algorithms.convert_aggregation_to_html(request)
return render(request, "dashboard/dashboard.html", {'results_tasks': results_tasks, 'results_logs': results_logs}) return render(request, "dashboard/dashboard.html", {'results_tasks': results_tasks, 'results_logs': results_logs})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment