diff --git a/atdb/taskdatabase/migrations/0012_task_environment.py b/atdb/taskdatabase/migrations/0012_task_environment.py new file mode 100644 index 0000000000000000000000000000000000000000..42d59cec3db44f0c9e7f4623e55c38d025346503 --- /dev/null +++ b/atdb/taskdatabase/migrations/0012_task_environment.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2022-02-01 13:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taskdatabase', '0011_auto_20220131_1103'), + ] + + operations = [ + migrations.AddField( + model_name='task', + name='environment', + field=models.JSONField(blank=True, null=True), + ), + ] diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 45d14adcbe7843e43c99b03272326dd9da344689..3db3fa8364398018e841ed568b357db120eceac3 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,20 @@ def highlight_value(values, value_to_highlight): def construct_tasks_per_workflow_html(request, workflow_results): + # --- 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 +611,16 @@ 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 + filtered_tasks = Task.objects.all() + try: + if 'applyfilter' in selection: + filtered_tasks_as_list = request.session['filtered_tasks_as_list'] + filtered_tasks = Task.objects.filter(id__in=filtered_tasks_as_list) + except: + pass + # --- 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..07829575d3b096c6714a301d9b1e8fa97629ac29 100644 --- a/atdb/taskdatabase/templates/dashboard/toggles.html +++ b/atdb/taskdatabase/templates/dashboard/toggles.html @@ -24,6 +24,17 @@ {% if 'resources' in selection %} checked {% endif %} > + <input type="checkbox" + id = "apply_filter" + name="apply_filter" + data-on="Latest Filter Applied" + data-off="No Filter Applied" + data-toggle="toggle" + data-onstyle="primary" + data-offstyle="secondary" + data-style + {% if 'applyfilter' in selection %} checked {% endif %} + > <script> $(function() { @@ -58,4 +69,21 @@ }) }) </script> + + <script> + $(function() { + $('#apply_filter').change(function() { + + let url = location.href + if ($(this).prop('checked')) { + url = url.replace('nofilter','applyfilter'); + location.assign(url); + } else { + url = url.replace('applyfilter','nofilter'); + location.assign(url); + } + + }) + }) + </script> </table> \ No newline at end of file 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/base.html b/atdb/taskdatabase/templates/taskdatabase/base.html index 1ca7e6141cdf3d1ff27a875b5898b3927b8cb39b..2e7799d65a1d4aa182147a006f744286e942ff9f 100644 --- a/atdb/taskdatabase/templates/taskdatabase/base.html +++ b/atdb/taskdatabase/templates/taskdatabase/base.html @@ -52,7 +52,7 @@ <li><a class="nav-link" href="{% url 'quality' %}">Quality</a></li> {% endif %} - <li><a class="nav-link" href="{% url 'dashboard' 'active_nores' %}">Dashboard</a></li> + <li><a class="nav-link" href="{% url 'dashboard' 'active_nores_nofilter' %}">Dashboard</a></li> <li><a class="nav-link" href="{% url 'query' %}">Filter</a></li> 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..1187bbc5b849a3ecfc487c03bf39d48b8177923f 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 - 15: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..2b06e3b23d094a6bffabc57545efe2e35f36ddc1 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -172,8 +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['query_list_of_ids'] = query_list_of_ids + self.request.session['filtered_tasks_as_list'] = filtered_tasks_as_list return self.object_list @@ -803,6 +807,12 @@ 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['search_box'] = '' + return redirect('/atdb/?page=1') @login_required def ChangePriority(request, pk, priority_change, page=0): @@ -869,13 +879,13 @@ def TaskSetStatusTables2(request, pk, new_status, query_params): @login_required def TaskMultiStatus(request, new_status, query_params): # get the list of id's from the session - query_list_of_ids = request.session['query_list_of_ids'] - count = len(query_list_of_ids) + filtered_tasks_as_list = request.session['filtered_tasks_as_list'] + count = len(filtered_tasks_as_list) if request.method == "POST": - for id in query_list_of_ids: - task = Task.objects.get(id=id[0]) + for id in filtered_tasks_as_list: + task = Task.objects.get(id=id) task.new_status = new_status task.save() @@ -893,13 +903,13 @@ def TaskMultiStatus(request, new_status, query_params): @login_required def TaskMultiHold(request, onhold, query_params): # get the list of id's from the session - query_list_of_ids = request.session['query_list_of_ids'] - count = len(query_list_of_ids) + filtered_tasks_as_list = request.session['filtered_tasks_as_list'] + count = len(filtered_tasks_as_list) if request.method == "POST": - for id in query_list_of_ids: - task = Task.objects.get(id=id[0]) + for id in filtered_tasks_as_list: + task = Task.objects.get(id=id) task.resume = (onhold == 'resume') task.save()