[Toaster] [PATCH 2/2] toaster: fix sorting after hiding a column in build tables

Elliot Smith elliot.smith at intel.com
Tue Mar 29 02:07:11 PDT 2016


When hiding a column in the build tasks or build packages included
table, if the column is set as the current order by for the table, the
order by is not reset to the default. The result is that the table
stays sorted by the hidden column.

Set the default_orderby for these two tables correctly to ensure the
corresponding table is re-sorted when a column is hidden, if that column
was being used as the order by.

[YOCTO #9011]

Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
 .../lib/toaster/toastergui/templates/tasks.html    |  2 +-
 bitbake/lib/toaster/toastergui/views.py            | 50 +++++++++++-----------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/templates/tasks.html b/bitbake/lib/toaster/toastergui/templates/tasks.html
index 23eb957..84bc103 100644
--- a/bitbake/lib/toaster/toastergui/templates/tasks.html
+++ b/bitbake/lib/toaster/toastergui/templates/tasks.html
@@ -131,7 +131,7 @@
 <script type="text/javascript">
 
     $(document).ready(function() {
-        // enable blue hightlight animation for the order link
+        // highlight heading on the column for the field used for ordering
         if (location.href.search('#') > -1) {
             var task_order = location.href.split('#')[1];
             $("#" + task_order).addClass("highlight");
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index cc7ad17..71c74e2 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -662,7 +662,9 @@ def recipe_packages(request, build_id, recipe_id):
 
 def target_common( request, build_id, target_id, variant ):
     template = "target.html"
-    (pagesize, orderby) = _get_parameters_values(request, 25, 'name:+')
+    default_orderby = 'name:+'
+
+    (pagesize, orderby) = _get_parameters_values(request, 25, default_orderby)
     mandatory_parameters = { 'count': pagesize,  'page' : 1, 'orderby': orderby }
     retval = _verify_parameters( request.GET, mandatory_parameters )
     if retval:
@@ -682,8 +684,6 @@ def target_common( request, build_id, target_id, variant ):
     queryset = queryset.select_related("recipe", "recipe__layer_version", "recipe__layer_version__layer")
     packages = _build_page_range( Paginator(queryset, pagesize), request.GET.get( 'page', 1 ))
 
-
-
     build = Build.objects.get( pk = build_id )
 
     # bring in package dependencies
@@ -800,7 +800,7 @@ eans multiple licenses exist that cover different parts of the source',
         'objects'              : packages,
         'packages_sum'         : packages_sum[ 'installed_size__sum' ],
         'object_search_display': "packages included",
-        'default_orderby'      : orderby,
+        'default_orderby'      : default_orderby,
         'tablecols'            : [
                     tc_package,
                     tc_packageVersion,
@@ -995,29 +995,29 @@ def tasks_common(request, build_id, variant, task_anchor):
         anchor=task_anchor
 
     # default ordering depends on variant
-    if   'buildtime' == variant:
-        title_variant='Time'
-        object_search_display="time data"
-        filter_search_display="tasks"
-        (pagesize, orderby) = _get_parameters_values(request, 25, 'elapsed_time:-')
-    elif 'diskio'    == variant:
-        title_variant='Disk I/O'
-        object_search_display="disk I/O data"
-        filter_search_display="tasks"
-        (pagesize, orderby) = _get_parameters_values(request, 25, 'disk_io:-')
-    elif 'cputime'  == variant:
+    default_orderby = None
+    filter_search_display = 'tasks'
+
+    if 'buildtime' == variant:
+        default_orderby = 'elapsed_time:-'
+        title_variant = 'Time'
+        object_search_display = 'time data'
+    elif 'diskio' == variant:
+        default_orderby = 'disk_io:-'
+        title_variant = 'Disk I/O'
+        object_search_display = 'disk I/O data'
+    elif 'cputime' == variant:
+        default_orderby = 'cpu_time_system:-'
         title_variant='CPU time'
-        object_search_display="CPU time data"
-        filter_search_display="tasks"
-        (pagesize, orderby) = _get_parameters_values(request, 25, 'cpu_time_system:-')
-    else :
-        title_variant='Tasks'
-        object_search_display="tasks"
-        filter_search_display="tasks"
-        (pagesize, orderby) = _get_parameters_values(request, 25, 'order:+')
+        object_search_display = 'CPU time data'
+    else:
+        default_orderby = 'order:+'
+        title_variant = 'Tasks'
+        object_search_display = 'tasks'
 
+    (pagesize, orderby) = _get_parameters_values(request, 25, default_orderby)
 
-    mandatory_parameters = { 'count': pagesize,  'page' : 1, 'orderby': orderby }
+    mandatory_parameters = {'count': pagesize, 'page' : 1, 'orderby': orderby}
 
     template = 'tasks.html'
     retval = _verify_parameters( request.GET, mandatory_parameters )
@@ -1211,7 +1211,7 @@ def tasks_common(request, build_id, variant, task_anchor):
                 'mainheading': title_variant,
                 'build': build,
                 'objects': task_objects,
-                'default_orderby' : orderby,
+                'default_orderby' : default_orderby,
                 'search_term': search_term,
                 'total_count': queryset_with_search.count(),
                 'tablecols':[
-- 
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the toaster mailing list