diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 45d14adcbe7843e43c99b03272326dd9da344689..0489a857b0231f25120047d52bd4e0cb33f2840f 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -274,13 +274,13 @@ def convert_monitor_to_html(request, monitor_data): # 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 = [] my_workflows = [] # get all active tasks 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 active_workflows = active_tasks.values('workflow').distinct() @@ -303,7 +303,7 @@ def aggregate_resources_tasks(selection): # get the numbers for this workflow # 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() sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process')) @@ -471,24 +471,27 @@ def highlight_value(values, value_to_highlight): 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 --- results_tasks = "<p>Progress of tasks per workflow</p>" # construct the header - ###header = "" header = '<th class="aggregate_failed">failed</th><th class="aggregate">active</th><th class="aggregate">total</th>' for status in settings.ALL_STATUSSES: header += "<th>" + status + "</th>" - ###header += '<th class="failed">failed</th><th class="active">active</th><th>total</th>' - results_tasks += header for workflow_result in workflow_results: 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>" # add sizes @@ -615,8 +618,14 @@ def construct_logs_per_workflow_html(request, workflow_results): def construct_dashboard_html(request, 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 --- - 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) # --- logentries --- diff --git a/atdb/taskdatabase/templates/dashboard/toggles.html b/atdb/taskdatabase/templates/dashboard/toggles.html index 5b2a785052b6ad96ff09f2271b27732372433d75..1cdf43c17e07c3c83bf1a00463670c366b6c34fc 100644 --- a/atdb/taskdatabase/templates/dashboard/toggles.html +++ b/atdb/taskdatabase/templates/dashboard/toggles.html @@ -9,7 +9,7 @@ data-onstyle="warning" data-offstyle="primary" data-style - {% if not 'active' in selection %} checked {% endif %} + {% if not 'active' in toggle_selection %} checked {% endif %} > <input type="checkbox" diff --git a/atdb/taskdatabase/templates/query/index.html b/atdb/taskdatabase/templates/query/index.html index 8bff93a4252480b291915f1dc3add8f05482086d..a37ce6095dfdd596ec649d451389317df4c1c16a 100644 --- a/atdb/taskdatabase/templates/query/index.html +++ b/atdb/taskdatabase/templates/query/index.html @@ -15,8 +15,8 @@ <form action="" method="get" class="form form-inline"> {% bootstrap_form filter.form layout='inline' %} <button type="submit" class="btn-success btn-sm" title="Filter"><i class="fas fa-filter"></i> Filter</button> - - </form> + {% include "taskdatabase/filter/clear_filter_button.html" %} + </form> </div> {% endif %} diff --git a/atdb/taskdatabase/templates/taskdatabase/filter/clear_filter_button.html b/atdb/taskdatabase/templates/taskdatabase/filter/clear_filter_button.html new file mode 100644 index 0000000000000000000000000000000000000000..3f103a32e3666bab3fa9eeb6ea0cf909298051f3 --- /dev/null +++ b/atdb/taskdatabase/templates/taskdatabase/filter/clear_filter_button.html @@ -0,0 +1 @@ +<a href="{% url 'clear-filter' %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-window-close"></i> Clear Filter</a> diff --git a/atdb/taskdatabase/templates/taskdatabase/filter/filter_buttons.html b/atdb/taskdatabase/templates/taskdatabase/filter/filter_buttons.html index 8bb3b20fec911c4d3632415907a693139240d84e..cd5dcca5b893cf809a32256abc77da0d8e395298 100644 --- a/atdb/taskdatabase/templates/taskdatabase/filter/filter_buttons.html +++ b/atdb/taskdatabase/templates/taskdatabase/filter/filter_buttons.html @@ -6,7 +6,7 @@ <tr><td>Click to Filter</td></tr> <tr> <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-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> diff --git a/atdb/taskdatabase/templates/taskdatabase/filter/filter.html b/atdb/taskdatabase/templates/taskdatabase/filter/filter_xxx.html similarity index 100% rename from atdb/taskdatabase/templates/taskdatabase/filter/filter.html rename to atdb/taskdatabase/templates/taskdatabase/filter/filter_xxx.html diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 592574f4787eac1c0da9ee24b1180266cc1af899..1abdb6fea53d5e3d95a5c0bcdcde826110db5c90 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 (4 feb 2021 - 16:00) + <p class="footer"> Version 1.0.0 (7 feb 2021 - 14:00) </div> diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index bddabc88d16811e3aeff0b16d6c829eea3abbefa..47ab03e1a24b7fb6f30a7406f87c6ac813d87947 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -83,6 +83,8 @@ urlpatterns = [ 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/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/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'), diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index 191b504e4802f5a7f203280ec5dde7db7e6494e6..203c6361023932262d419156100b92d7fa3906b6 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -172,7 +172,12 @@ class QueryView(SingleTableMixin, FilterView): 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 + self.request.session['filtered_tasks_as_list'] = filtered_tasks_as_list self.request.session['query_list_of_ids'] = query_list_of_ids return self.object_list @@ -483,7 +488,7 @@ def ShowDashboard(request, selection): return render(request, "dashboard/dashboard.html", {'results_tasks': results_tasks, 'results_logs': results_logs, - 'selection': selection}) + 'toggle_selection': selection}) def WorkflowDetails(request, id): @@ -803,6 +808,13 @@ def TaskSetOnHoldFilter(request, onhold): request.session['task_onhold_filter'] = onhold 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 def ChangePriority(request, pk, priority_change, page=0):