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

apply filter to dashboard

add 'clear filter' button
parent 7a57408b
No related branches found
No related tags found
2 merge requests!200apply filter to dashboard,!199apply filter to dashboard
...@@ -274,13 +274,13 @@ def convert_monitor_to_html(request, monitor_data): ...@@ -274,13 +274,13 @@ def convert_monitor_to_html(request, monitor_data):
# aggregate information from the tasks table per workflow per status # aggregate information from the tasks table per workflow per status
def aggregate_resources_tasks(selection): def aggregate_resources_tasks(request, selection, filtered_tasks):
workflow_results = [] workflow_results = []
my_workflows = [] my_workflows = []
# get all active tasks # get all active tasks
if 'active' in selection: if 'active' in selection:
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES).filter(task_type='regular') active_tasks = filtered_tasks.filter(status__in=settings.ACTIVE_STATUSSES).filter(task_type='regular')
# retrieve all unique workflows from the active tasks # retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct() active_workflows = active_tasks.values('workflow').distinct()
...@@ -303,7 +303,7 @@ def aggregate_resources_tasks(selection): ...@@ -303,7 +303,7 @@ def aggregate_resources_tasks(selection):
# get the numbers for this workflow # get the numbers for this workflow
# all tasks for this workflow for the 'grand total' # all tasks for this workflow for the 'grand total'
tasks_per_workflow = Task.objects.filter(workflow=workflow).filter(task_type='regular') tasks_per_workflow = filtered_tasks.filter(workflow=workflow).filter(task_type='regular')
nr_of_tasks_per_workflow = tasks_per_workflow.count() nr_of_tasks_per_workflow = tasks_per_workflow.count()
sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process')) sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process'))
...@@ -471,24 +471,27 @@ def highlight_value(values, value_to_highlight): ...@@ -471,24 +471,27 @@ def highlight_value(values, value_to_highlight):
def construct_tasks_per_workflow_html(request, workflow_results): def construct_tasks_per_workflow_html(request, workflow_results):
try:
query_list_of_ids = request.session['query_list_of_ids']
current_query_params = request.session['current_query_params']
except:
pass
# --- Progress of tasks per active workflow --- # --- Progress of tasks per active workflow ---
results_tasks = "<p>Progress of tasks per workflow</p>" results_tasks = "<p>Progress of tasks per workflow</p>"
# construct the header # construct the header
###header = ""
header = '<th class="aggregate_failed">failed</th><th class="aggregate">active</th><th class="aggregate">total</th>' header = '<th class="aggregate_failed">failed</th><th class="aggregate">active</th><th class="aggregate">total</th>'
for status in settings.ALL_STATUSSES: for status in settings.ALL_STATUSSES:
header += "<th>" + status + "</th>" header += "<th>" + status + "</th>"
###header += '<th class="failed">failed</th><th class="active">active</th><th>total</th>'
results_tasks += header results_tasks += header
for workflow_result in workflow_results: for workflow_result in workflow_results:
link = construct_link_to_workflow_api(request, workflow_result) link = construct_link_to_workflow_api(request, workflow_result)
# values = "<tr><td colspan='5'><b>" + link + "</b></td></tr><tr>"
values = "<tr class='info'><td colspan='6'><b>" + link + "</b></td>" values = "<tr class='info'><td colspan='6'><b>" + link + "</b></td>"
# add sizes # add sizes
...@@ -615,8 +618,14 @@ def construct_logs_per_workflow_html(request, workflow_results): ...@@ -615,8 +618,14 @@ def construct_logs_per_workflow_html(request, workflow_results):
def construct_dashboard_html(request, selection): def construct_dashboard_html(request, selection):
# gather and construct the dashboard based on the requested selection # gather and construct the dashboard based on the requested selection
try:
filtered_tasks_as_list = request.session['filtered_tasks_as_list']
filtered_tasks = Task.objects.filter(id__in=filtered_tasks_as_list)
except:
filtered_tasks = Task.objects.all()
# --- Progress of tasks per active workflow --- # --- Progress of tasks per active workflow ---
workflow_results = aggregate_resources_tasks(selection) workflow_results = aggregate_resources_tasks(request, selection, filtered_tasks)
results_tasks = construct_tasks_per_workflow_html(request, workflow_results) results_tasks = construct_tasks_per_workflow_html(request, workflow_results)
# --- logentries --- # --- logentries ---
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
data-onstyle="warning" data-onstyle="warning"
data-offstyle="primary" data-offstyle="primary"
data-style data-style
{% if not 'active' in selection %} checked {% endif %} {% if not 'active' in toggle_selection %} checked {% endif %}
>&nbsp; >&nbsp;
<input type="checkbox" <input type="checkbox"
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<form action="" method="get" class="form form-inline"> <form action="" method="get" class="form form-inline">
{% bootstrap_form filter.form layout='inline' %} {% bootstrap_form filter.form layout='inline' %}
&nbsp;<button type="submit" class="btn-success btn-sm" title="Filter"><i class="fas fa-filter"></i> Filter</button> &nbsp;<button type="submit" class="btn-success btn-sm" title="Filter"><i class="fas fa-filter"></i> Filter</button>
{% include "taskdatabase/filter/clear_filter_button.html" %}
</form> </form>
</div> </div>
{% endif %} {% endif %}
......
<a href="{% url 'clear-filter' %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-window-close"></i> Clear Filter</a>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<tr><td>Click to Filter</td></tr> <tr><td>Click to Filter</td></tr>
<tr> <tr>
<td> <td>
<a href="{% url 'task-set-filter' 'all' %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-layer-group"></i> All</a> {% include "taskdatabase/filter/clear_filter_button.html" %}
<a href="{% url 'task-set-active-filter' %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-layer-group"></i> Active</a> <a href="{% url 'task-set-active-filter' %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-layer-group"></i> Active</a>
<a href="{% url 'task-set-filter' 'failed' %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-layer-group"></i> Failed</a> <a href="{% url 'task-set-filter' 'failed' %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-layer-group"></i> Failed</a>
<a href="{% url 'task-set-onhold-filter' True %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-layer-group"></i> On Hold</a> <a href="{% url 'task-set-onhold-filter' True %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-layer-group"></i> On Hold</a>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 1.0.0 (4 feb 2021 - 16:00) <p class="footer"> Version 1.0.0 (7 feb 2021 - 14:00)
</div> </div>
......
...@@ -83,6 +83,8 @@ urlpatterns = [ ...@@ -83,6 +83,8 @@ urlpatterns = [
path('tasks/set_filter/<filter>', views.TaskSetFilter, name='task-set-filter'), path('tasks/set_filter/<filter>', views.TaskSetFilter, name='task-set-filter'),
path('tasks/set_active_filter', views.TaskSetActiveFilter, name='task-set-active-filter'), path('tasks/set_active_filter', views.TaskSetActiveFilter, name='task-set-active-filter'),
path('tasks/task-set-onhold-filter/<onhold>', views.TaskSetOnHoldFilter, name='task-set-onhold-filter'), path('tasks/task-set-onhold-filter/<onhold>', views.TaskSetOnHoldFilter, name='task-set-onhold-filter'),
path('tasks/clear_filter/', views.TaskClearFilter, name='clear-filter'),
path('tasks/<int:pk>/set_status/<new_status>/<query_params>', views.TaskSetStatusTables2, name = 'task-setstatus'), path('tasks/<int:pk>/set_status/<new_status>/<query_params>', views.TaskSetStatusTables2, name = 'task-setstatus'),
path('tasks/set_status_multi/<new_status>/<query_params>', views.TaskMultiStatus, name='task-multi-setstatus'), path('tasks/set_status_multi/<new_status>/<query_params>', views.TaskMultiStatus, name='task-multi-setstatus'),
path('tasks/set_multi_hold/<onhold>/<query_params>', views.TaskMultiHold, name='task-multi-hold'), path('tasks/set_multi_hold/<onhold>/<query_params>', views.TaskMultiHold, name='task-multi-hold'),
......
...@@ -172,7 +172,12 @@ class QueryView(SingleTableMixin, FilterView): ...@@ -172,7 +172,12 @@ class QueryView(SingleTableMixin, FilterView):
query_list_of_ids = list(self.object_list.values_list('id'))[:limit] query_list_of_ids = list(self.object_list.values_list('id'))[:limit]
filtered_tasks_as_list = []
for id in query_list_of_ids:
filtered_tasks_as_list.append(id[0])
# store on the session # store on the session
self.request.session['filtered_tasks_as_list'] = filtered_tasks_as_list
self.request.session['query_list_of_ids'] = query_list_of_ids self.request.session['query_list_of_ids'] = query_list_of_ids
return self.object_list return self.object_list
...@@ -483,7 +488,7 @@ def ShowDashboard(request, selection): ...@@ -483,7 +488,7 @@ def ShowDashboard(request, selection):
return render(request, "dashboard/dashboard.html", return render(request, "dashboard/dashboard.html",
{'results_tasks': results_tasks, {'results_tasks': results_tasks,
'results_logs': results_logs, 'results_logs': results_logs,
'selection': selection}) 'toggle_selection': selection})
def WorkflowDetails(request, id): def WorkflowDetails(request, id):
...@@ -803,6 +808,13 @@ def TaskSetOnHoldFilter(request, onhold): ...@@ -803,6 +808,13 @@ def TaskSetOnHoldFilter(request, onhold):
request.session['task_onhold_filter'] = onhold request.session['task_onhold_filter'] = onhold
return redirect('/atdb/?page=1') return redirect('/atdb/?page=1')
def TaskClearFilter(request):
request.session['task_filter'] = 'all'
request.session['task_onhold_filter'] = None
request.session['filtered_tasks_as_list'] = None
request.session['query_list_of_ids'] = None
request.session['search_box'] = ''
return redirect('/atdb/?page=1')
@login_required @login_required
def ChangePriority(request, pk, priority_change, page=0): def ChangePriority(request, pk, priority_change, page=0):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment