Fix for YB6538
cover Fix for YB6538
The following changes since commit c1ee6cdfde5d1fe5f38a1e8eef5b7b0dd086df95:
README: add required version for django-nvd3 (2014-03-06 13:43:30 +0200)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib roxana/YB6538
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=roxana/YB6538
Roxana Ciobanu (9):
error-report: add 'Submitted on' column
error-report: add 'Submitted on' detail
error-report: add 'Submitter' column
error-report: add 'Edit columns' menu jquery.cookie.js: add the Cookie Plugin
error-report: remember state of the menu
error-report: sort table by 'Submitted on' column
error-report: add css customization
error-report: add top 'Show rows' menu
Post/createStatistics.py | 4 + Post/getInfo.py | 3 + Post/parser.py | 3 +- Post/static/css/custom.css | 8 ++ Post/static/js/jquery.cookie.js | 117 +++++++++++++++++++++++++ Post/templatetags/__init__.py | 0 Post/templatetags/projecttags.py | 12 +++ Post/views.py | 27 +++++- README | 2 + templates/base.html | 2 +- templates/error-details.html | 2 + templates/search-details.html | 179 +++++++++++++++++++++++++++++++-------- 12 files changed, 322 insertions(+), 37 deletions(-) create mode 100644 Post/static/js/jquery.cookie.js create mode 100644 Post/templatetags/__init__.py create mode 100644 Post/templatetags/projecttags.py
Signature · 1 line
1.9.1
PATCH 1/9 error-report: add 'Submitted on' column
Show the submission date and time for an error in the search results page
[YOCTO #6538]
--- Post/createStatistics.py | 4 ++++ Post/getInfo.py | 3 +++ Post/parser.py | 3 ++- templates/search-details.html | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-)
Post/createStatistics.py +4 -0
@@ -39,6 +39,10 @@ class Statistics: def chart_statistics(self, string): startdate = datetime.now() enddate = startdate - timedelta(days=30) + if string == "DATE": + date = Build.objects.filter(DATE__range=[enddate, startdate]).values('DATE').annotate(dcount=Count('DATE')) + items = list(date) + return self.create_statistic(items, "DATE") if string == "MACHINE": machines = Build.objects.filter(DATE__range=[enddate, startdate]).values('MACHINE').annotate(dcount=Count('MACHINE')) items = list(machines)
Post/getInfo.py +3 -0
@@ -68,6 +68,9 @@ class Info: except: pass + if category == "DATE": + build = Build.objects.filter(DATE__icontains = string) + results.append(self.getBuildFailures(build)) if category == "MACHINE": build = Build.objects.filter(MACHINE__icontains = string) results.append(self.getBuildFailures(build))
Post/parser.py +2 -1
@@ -10,6 +10,7 @@ import sys, os, json, re from Post.models import Build, BuildFailure from django.conf import settings +from django.utils import timezone from datetime import datetime class Parser:
@@ -30,7 +31,7 @@ class Parser: NAME = str(jsondata['username']) EMAIL = str(jsondata['email']) g = re.match(r'(.*): (.*)', str(BRANCH_COMMIT)) - b=Build(DATE = datetime.now(), MACHINE = MACHINE_NAME, BRANCH = g.group(1), COMMIT = str(g.group(2)), TARGET = COMPONENT, DISTRO = DISTRO, NATIVELSBSTRING = NATIVELSBSTRING, BUILD_SYS = BUILD_SYS, TARGET_SYS = TARGET_SYS, NAME = NAME, EMAIL = EMAIL) + b=Build(DATE = timezone.now(), MACHINE = MACHINE_NAME, BRANCH = g.group(1), COMMIT = str(g.group(2)), TARGET = COMPONENT, DISTRO = DISTRO, NATIVELSBSTRING = NATIVELSBSTRING, BUILD_SYS = BUILD_SYS, TARGET_SYS = TARGET_SYS, NAME = NAME, EMAIL = EMAIL) b.save() failures = jsondata['failures'] for fail in failures:
templates/search-details.html +2 -0
@@ -16,6 +16,7 @@ <table class="table table-bordered table-hover"> <thead> <tr> + <th>Submitted on</th> <th>Recipe</th> <th>Recipe version</th> <th>Task</th>
@@ -31,6 +32,7 @@ <tbody> {%for detail in details %} <tr> + <td><a href="{% url id detail.id details.number items d %}">{{ detail.BUILD.DATE|date:"d/m/y H:i"}}</a></td> <td><a href="{% url id detail.id details.number items d %}">{{ detail.RECIPE }}</a></td> <td><a href="{% url id detail.id details.number items d %}">{{ detail.RECIPE_VERSION }}</a></td> <td><a href="{% url id detail.id details.number items d %}">{{ detail.TASK }}</a></td>
Signature · 1 line
1.9.1
PATCH 2/9 error-report: add 'Submitted on' detail
In reply to Roxana CiobanuShow the submission date and time for an error in the the error details page.
[YOCTO #6538]
--- templates/error-details.html | 2 ++ 1 file changed, 2 insertions(+)
templates/error-details.html +2 -0
@@ -21,6 +21,8 @@ <div class="well"> <h2>Error details</h2> <dl class="dl-vertical"> + <dt>Submitted on:</dt> + <dd>{{ detail.BUILD.DATE|date:"d/m/y H:i"}}</dd> <dt>Task:</dt> <dd>{{ detail.TASK }}</dd> <dt>Recipe:</dt>
Signature · 1 line
1.9.1
PATCH 3/9 error-report: add 'Submitter' column
In reply to Roxana CiobanuShow the submitter in the search results page
[YOCTO #6538]
--- templates/search-details.html | 2 ++ 1 file changed, 2 insertions(+)
templates/search-details.html +2 -0
@@ -27,6 +27,7 @@ <th>Host distro</th> <th>Branch</th> <th>Commit</th> + <th>Submitter</th> </tr> </thead> <tbody>
@@ -49,6 +50,7 @@ {{ detail.BUILD.COMMIT|truncatechars:10}} </div> </td> + <td><a href="{% url id detail.id details.number items d %}">{{ detail.BUILD.NAME }} </a></td> </tr> {%endfor%} </tbody>
Signature · 1 line
1.9.1
PATCH 4/9 error-report: add 'Edit columns' menu
In reply to Roxana CiobanuAdd 'Edit columns' menu.
[YOCTO #6538]
--- Post/templatetags/__init__.py | 0 Post/templatetags/projecttags.py | 12 +++++ Post/views.py | 26 +++++++++- templates/search-details.html | 105 ++++++++++++++++++++++++++------------- 4 files changed, 108 insertions(+), 35 deletions(-) create mode 100644 Post/templatetags/__init__.py create mode 100644 Post/templatetags/projecttags.py
Post/templatetags/__init__.py new file +0 -0
Post/templatetags/projecttags.py new file +12 -0
@@ -0,0 +1,12 @@ +from datetime import datetime, timedelta +import re +from django import template +from django.utils import timezone +from django.template.defaultfilters import filesizeformat + +register = template.Library() + [email protected](name = 'sortcols') +def sortcols(tablecols): + return sorted(tablecols, key = lambda t: t['name']) +
Post/views.py +25 -1
@@ -84,7 +84,31 @@ def search(request, template_name, items = None, page = None, query = None): else: index = paginator.page_range.index(c.number) - 2 end = index + 5 - return render_to_response(template_name, {'details':c, 'd' : query, "no" : no, 'list' : paginator.page_range[index:end], 'items' : items}, RequestContext(request)) + + context = { + 'details':c, + 'd' : query, + "no" : no, + 'list' : paginator.page_range[index:end], + 'items' : items, + 'objectname' : 'errors', + 'tablecols' : [ + {'name': 'Submitted on', 'clclass': 'submitted_on'}, + {'name': 'Recipe'}, + {'name': 'Recipe version', 'clclass': 'recipe_version'}, + {'name': 'Task'}, + {'name': 'Machine'}, + {'name': 'Distro'}, + {'name': 'Build system', 'clclass': 'build_sys', 'hidden': 1}, + {'name': 'Target system', 'clclass': 'target_sys', 'hidden': 1}, + {'name': 'Host distro', 'clclass': 'host_distro'}, + {'name': 'Branch', 'clclass': 'branch'}, + {'name': 'Commit', 'clclass': 'commit'}, + {'name': 'Submitter', 'clclass': 'submitter','hidden': 1}], + } + + return render_to_response(template_name, context, RequestContext(request)) + def searchDetails(request, template_name, pk, page = None, query = None, items = None): results=''
templates/search-details.html +71 -34
140 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 5/9 jquery.cookie.js: add the Cookie Plugin
In reply to Roxana CiobanuAdd the Cookie Plugin
[YOCTO #6538]
--- Post/static/js/jquery.cookie.js | 117 ++++++++++++++++++++++++++++++++++++++++ README | 2 + 2 files changed, 119 insertions(+) create mode 100644 Post/static/js/jquery.cookie.js
Post/static/js/jquery.cookie.js new file +117 -0
@@ -0,0 +1,117 @@ +/*! + * jQuery Cookie Plugin v1.4.0 + * https://github.com/carhartl/jquery-cookie + * + * Copyright 2013 Klaus Hartl + * Released under the MIT license + */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as anonymous module. + define(['jquery'], factory); + } else { + // Browser globals. + factory(jQuery); + } +}(function ($) { + + var pluses = /\+/g; + + function encode(s) { + return config.raw ? s : encodeURIComponent(s); + } + + function decode(s) { + return config.raw ? s : decodeURIComponent(s); + } + + function stringifyCookieValue(value) { + return encode(config.json ? JSON.stringify(value) : String(value)); + } + + function parseCookieValue(s) { + if (s.indexOf('"') === 0) { + // This is a quoted cookie as according to RFC2068, unescape... + s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); + } + + try { + // Replace server-side written pluses with spaces. + // If we can't decode the cookie, ignore it, it's unusable. + s = decodeURIComponent(s.replace(pluses, ' ')); + } catch(e) { + return; + } + + try { + // If we can't parse the cookie, ignore it, it's unusable. + return config.json ? JSON.parse(s) : s; + } catch(e) {} + } + + function read(s, converter) { + var value = config.raw ? s : parseCookieValue(s); + return $.isFunction(converter) ? converter(value) : value; + } + + var config = $.cookie = function (key, value, options) { + + // Write + if (value !== undefined && !$.isFunction(value)) { + options = $.extend({}, config.defaults, options); + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + return (document.cookie = [ + encode(key), '=', stringifyCookieValue(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // Read + + var result = key ? undefined : {}; + + // To prevent the for loop in the first place assign an empty array + // in case there are no cookies at all. Also prevents odd result when + // calling $.cookie(). + var cookies = document.cookie ? document.cookie.split('; ') : []; + + for (var i = 0, l = cookies.length; i < l; i++) { + var parts = cookies[i].split('='); + var name = decode(parts.shift()); + var cookie = parts.join('='); + + if (key && key === name) { + // If second argument (value) is a function it's a converter... + result = read(cookie, value); + break; + } + + // Prevent storing a cookie that we couldn't decode. + if (!key && (cookie = read(cookie)) !== undefined) { + result[name] = cookie; + } + } + + return result; + }; + + config.defaults = {}; + + $.removeCookie = function (key, options) { + if ($.cookie(key) !== undefined) { + // Must not alter options, thus extending a fresh object... + $.cookie(key, '', $.extend({}, options, { expires: -1 })); + return true; + } + return false; + }; + +}));
README +2 -0
@@ -50,6 +50,8 @@ the Apache License 2.0. Bundled jQuery is redistributed under the MIT license. +Bundled jquery.cookie.js is redistributed under the MIT license. + Bundled d3.js is redistributed under the BSD License. Bundled nvd3.js is redistributed under the Apache License 2.0.
Signature · 1 line
1.9.1
PATCH 6/9 error-report: remember state of the menu
In reply to Roxana CiobanuRemember the state of the menu, so that people are not forced to customise the columns every time they search.
[YOCTO #6538]
--- templates/base.html | 2 +- templates/search-details.html | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
templates/base.html +1 -1
@@ -60,7 +60,7 @@ <script type = "text/javascript" src = "{% static "js/bootstrap.min.js" %}"></script> <script type = "text/javascript" src = "{% static "js/d3.v2.js" %}"></script> <script type = "text/javascript" src = "{% static "js/nv.d3.js" %}"></script> - + <script type = "text/javascript" src = "{% static "js/jquery.cookie.js" %}"></script> {% block content %}{% endblock %} </body> </html>
templates/search-details.html +28 -0
@@ -14,6 +14,15 @@ else { $('.' + clname ).hide( 100 ); } + // save cookie for all checkboxes$ + save = ''; + $( '.chbxtoggle' ).each(function( ) { + if ( $( this ).attr( 'id' ) != undefined ) { + save += ';' + $( this ).attr( 'id' ) +':'+ $( this ).is( ':checked' ) + } + }); + $.cookie( '_displaycols_{{objectname}}', save ); + save = ''; } </script>
@@ -163,6 +172,25 @@ <script> $(document).ready(function() { $('.commit > div').popover({placement:'left'}) + + // we load cookies for the column display$ + save = $.cookie('_displaycols_{{objectname}}'); + if (save != undefined) { + setting = save.split(';'); + for ( i = 0; i < setting.length; i++) { + if (setting[i].length > 0) { + splitlist = setting[i].split(':'); + id = splitlist[0], v = splitlist[1]; + if (v == 'true') { + $('.chbxtoggle#'+id).prop('checked', true); + } + else { + $('.chbxtoggle#'+id).prop('checked', false); + } + } + } + } + $('.chbxtoggle').each(function () { showhideTableColumn($(this).attr('id'), $(this).is(':checked')) });
Signature · 1 line
1.9.1
PATCH 7/9 error-report: sort table by 'Submitted on' column
In reply to Roxana CiobanuThe information in the table needs to be sorted by "Submitted on", in inverse chronological order (the most recent error on top).
[YOCTO #6538]
--- Post/views.py | 1 + 1 file changed, 1 insertion(+)
Post/views.py +1 -0
@@ -61,6 +61,7 @@ def search(request, template_name, items = None, page = None, query = None): if query == "" or query.isspace(): query = "all" elems = Info().getSearchResult(query.strip()) + elems.sort(key=lambda r : r.BUILD.DATE, reverse=True) no = len(elems) if no == 0: return render_to_response("error-page.html", {"query" : query}, RequestContext(request))
Signature · 1 line
1.9.1
PATCH 8/9 error-report: add css customization
In reply to Roxana CiobanuAdd css customization for navbar-inner and
dropdown-menu.
[YOCTO #6538]
--- Post/static/css/custom.css | 8 ++++++++ 1 file changed, 8 insertions(+)
Post/static/css/custom.css +8 -0
@@ -55,3 +55,11 @@ td a:visited { .no-results { margin: 10px 0 0; } + +.navbar-inner form { + margin: 5px 0 0; +} + +.dropdown-menu { + padding: 10px; +}
Signature · 1 line
1.9.1
PATCH 9/9 error-report: add top 'Show rows' menu
In reply to Roxana Ciobanu[YOCTO #6538]
--- templates/search-details.html | 50 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)
templates/search-details.html +46 -4
@@ -34,6 +34,49 @@ </div> <div class="navbar"> <div class="navbar-inner"> + <form class="form-inline pull-right"> + {% if no > 10 %} + <label>Show rows:</label> + <select class="paginationLimit input-mini" onchange="javascript:window.open('{% url entry_args %}?items='+this.value+'&page={{ details.number }}&query={{ d }}', '_self')"> + {% ifequal items "10" %} + <option selected="selected" value = "10">10</option> + <option value = "25">25</option> + <option value = "50">50</option> + <option value = "100">100</option> + <option value = "150">150</option> + {%endifequal%} + {% ifequal items "25"%} + <option value = "10">10</option> + <option selected="selected" value = "25">25</option> + <option value = "50">50</option> + <option value = "100">100</option> + <option value = "150">150</option> + {%endifequal%} + {% ifequal items "50"%} + <option value = "10">10</option> + <option value = "25">25</option> + <option selected="selected" value = "50">50</option> + <option value = "100">100</option> + <option value = "150">150</option> + {%endifequal%} + {% ifequal items "100"%} + <option value = "10">10</option> + <option value = "25">25</option> + <option value = "50">50</option> + <option selected="selected" value = "100">100</option> + <option value = "150">150</option> + {%endifequal%} + {% ifequal items "150"%} + <option value = "10">10</option> + <option value = "25">25</option> + <option value = "50">50</option> + <option value = "100">100</option> + <option selected="selected" value = "150">150</option> + {%endifequal%} + </select> + </form> + <span class="divider-vertical pull-right"></span> + {% endif %} {% if tablecols %} <div class="btn-group pull-right"> <button class="btn dropdown-toggle" data-toggle="dropdown">Edit columns
@@ -95,9 +138,9 @@ </tbody> </table> <div class="pagination pagination-centered"> + <form class="form-inline pull-right"> {% if no > 10 %} - <div class="pull-right"> - <span class="help-inline">Show rows:</span> + <label>Show rows:</label> <form> <select class="paginationLimit" style="margin-top:5px;margin-bottom:0px;width:60px;" onchange="javascript:window.open('{% url entry_args %}?items='+this.value+'&page={{ details.number }}&query={{ d }}', '_self')"> {% ifequal items "10" %}
@@ -137,8 +180,7 @@ {%endifequal%} </select> </form> - </span> - </div> + </form> {% endif %} <ul> {% if details.has_previous %}
Signature · 1 line
1.9.1
Paul Eggleton
AppliedHi Roxana,
Quoted 9 lines · On Friday 22 August 2014 11:49:36 Roxana Ciobanu wrote:
The following changes since commit
c1ee6cdfde5d1fe5f38a1e8eef5b7b0dd086df95:README: add required version for django-nvd3 (2014-03-06 13:43:30 +0200)
are available in the git repository at:
git://git.yoctoproject.org/poky-contribroxana/YB6538
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=roxana/YB6538
Quoted 10 lines
Roxana Ciobanu (9):
error-report: add 'Submitted on' column
error-report: add 'Submitted on' detail
error-report: add 'Submitter' column
error-report: add 'Edit columns' menu jquery.cookie.js: add the Cookie Plugin
error-report: remember state of the menu
error-report: sort table by 'Submitted on' column
error-report: add css customization
error-report: add top 'Show rows' menu
Merged, thanks. In future if you could send patches to the [email protected] mailing list rather than this one that would be great (I noticed this wasn't mentioned in the README file so I've just added it.)
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre