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

adding selection toggles to dashboard

parent 3db26287
No related branches found
No related tags found
3 merge requests!83Master,!82Master,!79adding selection toggles to dashboard
......@@ -117,26 +117,32 @@ def convert_config_to_html(querylist):
# aggregate information from the tasks table per workflow per status
def aggregate_resources_tasks():
# NOTE: uncomment (or refactor) the lines with ### to only aggregate the data for active tasks
def aggregate_resources_tasks(selection):
workflow_results = []
my_workflows = []
# get all active tasks
### active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
if 'active' in selection:
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
# retrieve all unique workflows from the active tasks
### active_workflows = active_tasks.values('workflow').distinct()
# retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct()
all_workflows = Workflow.objects.all()
# construct the list of workflows (cheap)
for w in active_workflows:
try:
workflow = Workflow.objects.get(id = w['workflow'])
my_workflows.append(workflow)
except:
pass
# iterate through the filters and accumulate logentries
### for w in all_workflows:
for workflow in all_workflows:
workflow_result = {}
else:
my_workflows = Workflow.objects.all()
# extract the workflow object (cheap)
### workflow = Workflow.objects.get(id = w['workflow'])
# iterate through the workflows
for workflow in my_workflows:
workflow_result = {}
# get the numbers for this workflow
......@@ -181,26 +187,30 @@ def aggregate_resources_tasks():
# aggregate information from the logentries table per workflow per status
def aggregate_resources_logs():
# NOTE: uncomment (or refactor) the lines with ### to only aggregate the data for active tasks
def aggregate_resources_logs(selection):
workflow_results = []
my_workflows = []
# get all active tasks
### active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
if 'active' in selection:
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
# retrieve all unique workflows
### active_workflows = active_tasks.values('workflow').distinct()
# retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct()
all_workflows = Workflow.objects.all()
# iterate through the filters and accumulate logentries
# construct the list of workflows (cheap)
for w in active_workflows:
try:
workflow = Workflow.objects.get(id = w['workflow'])
my_workflows.append(workflow)
except:
pass
### for w in active_workflows:
for workflow in all_workflows:
workflow_result = {}
else:
my_workflows = Workflow.objects.all()
# extract the workflow object (cheap)
### workflow = Workflow.objects.get(id = w['workflow'])
for workflow in my_workflows:
workflow_result = {}
# aggregate logentries per step for all active statusses
record_per_status = {}
......@@ -442,18 +452,19 @@ def construct_logs_per_workflow_html(request, workflow_results):
return results
def construct_dashboard_html(request):
def construct_dashboard_html(request, selection):
# gather and construct the dashboard based on the requested selection
# --- Progress of tasks per active workflow ---
workflow_results = aggregate_resources_tasks()
workflow_results = aggregate_resources_tasks(selection)
results_tasks = construct_tasks_per_workflow_html(request, workflow_results)
# --- logentries (first version with list instead of matrix---
# log_records = aggregate_resources_logs_version1()
#results_logs = construct_logs_per_workflow_html_version1(log_records)
# --- logentries ---
log_records = aggregate_resources_logs()
results_logs = construct_logs_per_workflow_html(request, log_records)
results_logs = "<p>Resources not shown. Click the 'Resources Invisible' toggle to show resources.</p>"
if 'resources' in selection:
log_records = aggregate_resources_logs(selection)
results_logs = construct_logs_per_workflow_html(request, log_records)
return results_tasks,results_logs
......@@ -7,7 +7,16 @@
<div class="card">
<div class="card-body">
<h4>Dashboard</h4>
<div class="container-fluid">
<div class="row">
<div class="col-8">
<h4>Dashboard</h4>
</div>
<div class="col-4">
{% include "dashboard/toggles.html" %}
</div>
</div>
</div>
&nbsp;
<table class="table table-striped">
......
<table>
<input type="checkbox" data-on="Active Workflows" data-off="All Workflows" checked data-toggle="toggle" data-onstyle="warning" data-offstyle="primary" data-style="slow">
<input type="checkbox" data-on="Resources Visible" data-off="Resources Invisible" checked data-toggle="toggle" data-onstyle="primary" data-style="slow">
<input type="checkbox"
id = "all_active_workflows"
name="all_active_workflows"
data-on="All Workflows"
data-off="Active Workflows"
data-toggle="toggle"
data-onstyle="warning"
data-offstyle="primary"
data-style
{% if not 'active' in selection %} checked {% endif %}
>&nbsp;
<input type="checkbox"
id = "resources_visible"
name="resources_visible"
data-on="Resources Visible"
data-off="Resources Invisible"
data-toggle="toggle"
data-onstyle="primary"
data-offstyle="secondary"
data-style
{% if 'resources' in selection %} checked {% endif %}
>&nbsp;
<script>
$(function() {
$('#all_active_workflows').change(function() {
let url = location.href
if ($(this).prop('checked')) {
url = url.replace('active','all');
location.assign(url);
} else {
url = url.replace('all','active');
location.assign(url);
}
})
})
</script>
<script>
$(function() {
$('#resources_visible').change(function() {
let url = location.href
if ($(this).prop('checked')) {
url = url.replace('nores','resources');
location.assign(url);
} else {
url = url.replace('resources','nores');
location.assign(url);
}
})
})
</script>
</table>
\ No newline at end of file
......@@ -45,7 +45,7 @@
<li><a class="nav-link" href="{% url 'task-details'%}">Details</a></li>
{% endif %}
<li><a class="nav-link" href="{% url 'dashboard' %}">Dashboard</a></li>
<li><a class="nav-link" href="{% url 'dashboard' 'active_nores' %}">Dashboard</a></li>
<li><a class="nav-link" href="{% url 'query' %}">Query</a></li>
......
......@@ -20,7 +20,7 @@ urlpatterns = [
path('show-inputs/<int:id>/', views.ShowInputs, name='show-inputs'),
path('show-outputs/<int:id>/', views.ShowOutputs, name='show-outputs'),
path('show-metrics/<int:id>/', views.ShowMetrics, name='show-metrics'),
path('dashboard/', views.ShowDashboard, name='dashboard'),
path('dashboard/<selection>', views.ShowDashboard, name='dashboard'),
path('workflow_details/<id>/', views.WorkflowDetails, name='workflow-details'),
path('query/', views.QueryView.as_view(), name='query'),
......
......@@ -275,10 +275,13 @@ def ShowConfig(request):
return render(request, "taskdatabase/config.html", {'results': results})
def ShowDashboard(request):
def ShowDashboard(request, selection):
# gather the results
results_tasks,results_logs = algorithms.construct_dashboard_html(request)
return render(request, "dashboard/dashboard.html", {'results_tasks': results_tasks, 'results_logs': results_logs})
results_tasks,results_logs = algorithms.construct_dashboard_html(request, selection)
return render(request, "dashboard/dashboard.html",
{'results_tasks': results_tasks,
'results_logs': results_logs,
'selection': selection})
def WorkflowDetails(request, id):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment