summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-19 13:30:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 11:59:45 +0100
commitfea4a82a2b9fdbbccd0a09a76208cebbefdd8b20 (patch)
tree2b1e673def85529d4b05151cd20e9dd308ce4eb0 /bitbake/lib
parent1b6a50c6b2857c7c21fe4287966f3babca71a142 (diff)
downloadpoky-fea4a82a2b9fdbbccd0a09a76208cebbefdd8b20.tar.gz
bitbake: toasterui: replace cookie-based preferences with session data
We switch from storing the user preferences using cookies to saving them in the server-side session. Patch for "count/pagesize" and "orderby" fields in the table-based pages. This patch will solve two problems: * the browser-side race between the GET header data and the cookie data * page breakages when field names chances in orderby statements. (Bitbake rev: 125d0e05805247450be0675e281a21bd6146d108) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basetable_bottom.html4
-rw-r--r--bitbake/lib/toaster/toastergui/templates/basetable_top.html9
-rw-r--r--bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html5
-rw-r--r--bitbake/lib/toaster/toastergui/templates/detail_sorted_header.html2
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py37
5 files changed, 20 insertions, 37 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
index d48ad92020..4c28cae810 100644
--- a/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
+++ b/bitbake/lib/toaster/toastergui/templates/basetable_bottom.html
@@ -60,8 +60,6 @@
60 // load cookie for number of entries to be displayed on page 60 // load cookie for number of entries to be displayed on page
61 if ({{request.GET.count}} != "") { 61 if ({{request.GET.count}} != "") {
62 pagesize = {{request.GET.count}}; 62 pagesize = {{request.GET.count}};
63 } else {
64 pagesize = $.cookie('_count');
65 } 63 }
66 64
67 $('.pagesize option').prop('selected', false) 65 $('.pagesize option').prop('selected', false)
@@ -84,8 +82,6 @@
84 $('.progress, .lead span').tooltip({container:'table', placement:'top'}); 82 $('.progress, .lead span').tooltip({container:'table', placement:'top'});
85 83
86 $(".pagesize").change(function () { 84 $(".pagesize").change(function () {
87 // save cookie with pagesize
88 $.cookie("_count", $(this).val(), { path : $(location).attr('pathname') });
89 reload_params({"count":$(this).val()}); 85 reload_params({"count":$(this).val()});
90 }); 86 });
91}); 87});
diff --git a/bitbake/lib/toaster/toastergui/templates/basetable_top.html b/bitbake/lib/toaster/toastergui/templates/basetable_top.html
index 92a3b50801..fcd2f036ec 100644
--- a/bitbake/lib/toaster/toastergui/templates/basetable_top.html
+++ b/bitbake/lib/toaster/toastergui/templates/basetable_top.html
@@ -156,13 +156,6 @@
156 showhideImmediateTableAction( clname, sh, orderkey ); 156 showhideImmediateTableAction( clname, sh, orderkey );
157 } 157 }
158 158
159 //
160 // saves a cookie with selected order field
161 //
162 function saveOrderCookie( orderfield ) {
163 $.cookie("orderby", orderfield, { path: $(location).attr('pathname') });
164 }
165
166 </script> 159 </script>
167 160
168<!-- control header --> 161<!-- control header -->
@@ -230,7 +223,7 @@
230 <tr> 223 <tr>
231 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}"> 224 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}">
232 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%} 225 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%}
233 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })" onclick="saveOrderCookie('{{tc.orderfield}}')">{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%} 226 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })">{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%}
234 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%} 227 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%}
235 {%if tc.filter%}<div class="btn-group pull-right"> 228 {%if tc.filter%}<div class="btn-group pull-right">
236 <a href="#filter_{{tc.filter.class}}" role="button" class="btn btn-mini {%if request.GET.filter%}{{tc.filter.options|filtered_icon:request.GET.filter}} {%endif%}" {%if request.GET.filter and tc.filter.options|filtered_tooltip:request.GET.filter %} title="<p>{{tc.filter.options|filtered_tooltip:request.GET.filter}}</p><p><a class='btn btn-small btn-primary' href=javascript:reload_params({'filter':''})>Show all {% if filter_search_display %}{{filter_search_display}}{% else %}{{objectname}}{% endif %}</a></p>" {%endif%} data-toggle="modal"> <i class="icon-filter filtered"></i> </a> 229 <a href="#filter_{{tc.filter.class}}" role="button" class="btn btn-mini {%if request.GET.filter%}{{tc.filter.options|filtered_icon:request.GET.filter}} {%endif%}" {%if request.GET.filter and tc.filter.options|filtered_tooltip:request.GET.filter %} title="<p>{{tc.filter.options|filtered_tooltip:request.GET.filter}}</p><p><a class='btn btn-small btn-primary' href=javascript:reload_params({'filter':''})>Show all {% if filter_search_display %}{{filter_search_display}}{% else %}{{objectname}}{% endif %}</a></p>" {%endif%} data-toggle="modal"> <i class="icon-filter filtered"></i> </a>
diff --git a/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html b/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html
index 355ae9073c..434facba93 100644
--- a/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html
+++ b/bitbake/lib/toaster/toastergui/templates/detail_pagination_bottom.html
@@ -41,17 +41,12 @@
41 // load cookie for number of entries to be displayed on page 41 // load cookie for number of entries to be displayed on page
42 if ({{request.GET.count}} != "") { 42 if ({{request.GET.count}} != "") {
43 pagesize = {{request.GET.count}}; 43 pagesize = {{request.GET.count}};
44 } else {
45 pagesize = $.cookie('_count');
46 } 44 }
47
48 $('.pagesize option').prop('selected', false) 45 $('.pagesize option').prop('selected', false)
49 .filter('[value="' + pagesize + '"]') 46 .filter('[value="' + pagesize + '"]')
50 .attr('selected', true); 47 .attr('selected', true);
51 48
52 $(".pagesize").change(function () { 49 $(".pagesize").change(function () {
53 // save cookie with pagesize
54 $.cookie("_count", $(this).val(), { path : $(location).attr('pathname') });
55 reload_params({"count":$(this).val()}); 50 reload_params({"count":$(this).val()});
56 }); 51 });
57}); 52});
diff --git a/bitbake/lib/toaster/toastergui/templates/detail_sorted_header.html b/bitbake/lib/toaster/toastergui/templates/detail_sorted_header.html
index a7917dcf5a..5214444ee0 100644
--- a/bitbake/lib/toaster/toastergui/templates/detail_sorted_header.html
+++ b/bitbake/lib/toaster/toastergui/templates/detail_sorted_header.html
@@ -11,7 +11,7 @@
11 <tr> 11 <tr>
12 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}"> 12 {% for tc in tablecols %}<th class="{{tc.dclass}} {{tc.clclass}}">
13 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%} 13 {%if tc.qhelp%}<i class="icon-question-sign get-help" title="{{tc.qhelp}}"></i>{%endif%}
14 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })" onclick="saveOrderCookie('{{tc.orderfield}}')">{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%} 14 {%if tc.orderfield%}<a {%if tc.ordericon%} class="sorted" {%endif%}href="javascript:reload_params({'page': 1, 'orderby' : '{{tc.orderfield}}' })">{{tc.name}}</a>{%else%}<span class="muted">{{tc.name}}</span>{%endif%}
15 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%} 15 {%if tc.ordericon%} <i class="icon-caret-{{tc.ordericon}}"></i>{%endif%}
16 {% if request.GET.search and forloop.first %} 16 {% if request.GET.search and forloop.first %}
17 <span class="badge badge-info">{{objects.paginator.count}}</span> 17 <span class="badge badge-info">{{objects.paginator.count}}</span>
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index f70cf205b7..0e248a7435 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -20,7 +20,6 @@
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 21
22import operator,re 22import operator,re
23import HTMLParser
24 23
25from django.db.models import Q, Sum, Count, Max 24from django.db.models import Q, Sum, Count, Max
26from django.db import IntegrityError 25from django.db import IntegrityError
@@ -278,11 +277,11 @@ def _get_parameters_values(request, default_count, default_order):
278 277
279# set cookies for parameters. this is usefull in case parameters are set 278# set cookies for parameters. this is usefull in case parameters are set
280# manually from the GET values of the link 279# manually from the GET values of the link
281def _save_parameters_cookies(response, pagesize, orderby, request): 280def _set_parameters_values(pagesize, orderby, request):
282 html_parser = HTMLParser.HTMLParser() 281 from django.core.urlresolvers import resolve
283 response.set_cookie(key='count', value=pagesize, path=request.path) 282 current_url = resolve(request.path_info).url_name
284 response.set_cookie(key='orderby', value=html_parser.unescape(orderby), path=request.path) 283 request.session['%s_count' % current_url] = pagesize
285 return response 284 request.session['%s_orderby' % current_url] =orderby
286 285
287# date range: normalize GUI's dd/mm/yyyy to date object 286# date range: normalize GUI's dd/mm/yyyy to date object
288def _normalize_input_date(date_str,default): 287def _normalize_input_date(date_str,default):
@@ -563,7 +562,7 @@ def recipe_packages(request, build_id, recipe_id):
563 ] 562 ]
564 } 563 }
565 response = render(request, template, context) 564 response = render(request, template, context)
566 _save_parameters_cookies(response, pagesize, orderby, request) 565 _set_parameters_values(pagesize, orderby, request)
567 return response 566 return response
568 567
569def target_common( request, build_id, target_id, variant ): 568def target_common( request, build_id, target_id, variant ):
@@ -737,7 +736,7 @@ eans multiple licenses exist that cover different parts of the source',
737 context['tablecols'].append(tc_layerDir) 736 context['tablecols'].append(tc_layerDir)
738 737
739 response = render(request, template, context) 738 response = render(request, template, context)
740 _save_parameters_cookies(response, pagesize, orderby, request) 739 _set_parameters_values(pagesize, orderby, request)
741 return response 740 return response
742 741
743def target( request, build_id, target_id ): 742def target( request, build_id, target_id ):
@@ -1129,7 +1128,7 @@ def tasks_common(request, build_id, variant, task_anchor):
1129 context['tablecols'].append(tc_log) 1128 context['tablecols'].append(tc_log)
1130 1129
1131 response = render(request, template, context) 1130 response = render(request, template, context)
1132 _save_parameters_cookies(response, pagesize, orderby, request) 1131 _set_parameters_values(pagesize, orderby, request)
1133 return response 1132 return response
1134 1133
1135def tasks(request, build_id): 1134def tasks(request, build_id):
@@ -1265,7 +1264,7 @@ def recipes(request, build_id):
1265 1264
1266 1265
1267 response = render(request, template, context) 1266 response = render(request, template, context)
1268 _save_parameters_cookies(response, pagesize, orderby, request) 1267 _set_parameters_values(pagesize, orderby, request)
1269 return response 1268 return response
1270 1269
1271def configuration(request, build_id): 1270def configuration(request, build_id):
@@ -1378,7 +1377,7 @@ def configvars(request, build_id):
1378 } 1377 }
1379 1378
1380 response = render(request, template, context) 1379 response = render(request, template, context)
1381 _save_parameters_cookies(response, pagesize, orderby, request) 1380 _set_parameters_values(pagesize, orderby, request)
1382 return response 1381 return response
1383 1382
1384def bpackage(request, build_id): 1383def bpackage(request, build_id):
@@ -1479,7 +1478,7 @@ def bpackage(request, build_id):
1479 context['tablecols'].append(tc_layerDir) 1478 context['tablecols'].append(tc_layerDir)
1480 1479
1481 response = render(request, template, context) 1480 response = render(request, template, context)
1482 _save_parameters_cookies(response, pagesize, orderby, request) 1481 _set_parameters_values(pagesize, orderby, request)
1483 return response 1482 return response
1484 1483
1485def bfile(request, build_id, package_id): 1484def bfile(request, build_id, package_id):
@@ -1640,7 +1639,7 @@ def package_built_detail(request, build_id, package_id):
1640 context['disable_sort'] = True; 1639 context['disable_sort'] = True;
1641 1640
1642 response = render(request, template, context) 1641 response = render(request, template, context)
1643 _save_parameters_cookies(response, pagesize, orderby, request) 1642 _set_parameters_values(pagesize, orderby, request)
1644 return response 1643 return response
1645 1644
1646def package_built_dependencies(request, build_id, package_id): 1645def package_built_dependencies(request, build_id, package_id):
@@ -1705,7 +1704,7 @@ def package_included_detail(request, build_id, target_id, package_id):
1705 if paths.all().count() < 2: 1704 if paths.all().count() < 2:
1706 context['disable_sort'] = True 1705 context['disable_sort'] = True
1707 response = render(request, template, context) 1706 response = render(request, template, context)
1708 _save_parameters_cookies(response, pagesize, orderby, request) 1707 _set_parameters_values(pagesize, orderby, request)
1709 return response 1708 return response
1710 1709
1711def package_included_dependencies(request, build_id, target_id, package_id): 1710def package_included_dependencies(request, build_id, target_id, package_id):
@@ -1780,7 +1779,7 @@ def package_included_reverse_dependencies(request, build_id, target_id, package_
1780 if objects.all().count() < 2: 1779 if objects.all().count() < 2:
1781 context['disable_sort'] = True 1780 context['disable_sort'] = True
1782 response = render(request, template, context) 1781 response = render(request, template, context)
1783 _save_parameters_cookies(response, pagesize, orderby, request) 1782 _set_parameters_values(pagesize, orderby, request)
1784 return response 1783 return response
1785 1784
1786def image_information_dir(request, build_id, target_id, packagefile_id): 1785def image_information_dir(request, build_id, target_id, packagefile_id):
@@ -1842,7 +1841,7 @@ if toastermain.settings.MANAGED:
1842 return _redirect_parameters( builds, request.GET, e.response) 1841 return _redirect_parameters( builds, request.GET, e.response)
1843 1842
1844 response = render(request, template, context) 1843 response = render(request, template, context)
1845 _save_parameters_cookies(response, pagesize, orderby, request) 1844 _set_parameters_values(pagesize, orderby, request)
1846 return response 1845 return response
1847 1846
1848 1847
@@ -2748,7 +2747,7 @@ if toastermain.settings.MANAGED:
2748 return _redirect_parameters(projectbuilds, request.GET, e.response, pid = pid) 2747 return _redirect_parameters(projectbuilds, request.GET, e.response, pid = pid)
2749 2748
2750 response = render(request, template, context) 2749 response = render(request, template, context)
2751 _save_parameters_cookies(response, pagesize, orderby, request) 2750 _set_parameters_values(pagesize, orderby, request)
2752 2751
2753 return response 2752 return response
2754 2753
@@ -2967,7 +2966,7 @@ if toastermain.settings.MANAGED:
2967 } 2966 }
2968 2967
2969 response = render(request, template, context) 2968 response = render(request, template, context)
2970 _save_parameters_cookies(response, pagesize, orderby, request) 2969 _set_parameters_values(pagesize, orderby, request)
2971 return response 2970 return response
2972 2971
2973 def buildrequestdetails(request, pid, brid): 2972 def buildrequestdetails(request, pid, brid):
@@ -3171,7 +3170,7 @@ else:
3171 context.update(context_date) 3170 context.update(context_date)
3172 3171
3173 response = render(request, template, context) 3172 response = render(request, template, context)
3174 _save_parameters_cookies(response, pagesize, orderby, request) 3173 _set_parameters_values(pagesize, orderby, request)
3175 return response 3174 return response
3176 3175
3177 3176