bitbake: toaster: add pagination to the Simple UI

In an effort to make the Simple UI more usable and
reponsive, this patch adds pagination support for the
pages with lots of entries: Builds, Configuration and
Tasks.

(Bitbake rev: d4f075c050ad9ecebe750420d49961a7f30d090b)

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexandru DAMIAN 2013-12-05 14:20:36 +00:00 committed by Richard Purdie
parent 415ebb738d
commit 192583a91e
10 changed files with 69 additions and 28 deletions

View File

@ -26,7 +26,7 @@ function filterTableRows(test) {
{% block pagename %}
{% endblock %}
<div align="left" style="display:inline-block; width: 40%; margin-left: 2em"> Search: <input type="search" id="filterstring" style="width: 80%" onkeyup="filterTableRows($('#filterstring').val())" autocomplete="off">
<div align="left" style="display:inline-block; width: 40%; margin-left: 2em"> Filter: <input type="search" id="filterstring" style="width: 80%" onkeyup="filterTableRows($('#filterstring').val())" autocomplete="off">
</div>
{% if hideshowcols %}
<div align="right" style="display: inline-block; width: 40%">Show/Hide columns:
@ -36,7 +36,25 @@ function filterTableRows(test) {
</div>
{% endif %}
</div>
<div>
<div style="display: block; float:right; margin-left: auto; margin-right:5em"><span class="pagination" style="vertical-align: top; margin-right: 3em">Showing {{objects.start_index}} to {{objects.end_index}} out of {{objects.paginator.count}} entries.&nbsp;</span>
<ul class="pagination" style="display: block-inline">
{%if objects.has_previous %}
<li><a href="?page={{objects.previous_page_number}}">&laquo;</a></li>
{%else%}
<li class="disabled"><a href="#">&laquo;</a></li>
{%endif%}
{% for i in objects.page_range %}
<li{%if i == objects.number %} class="active" {%endif%}><a href="?page={{i}}">{{i}}</a></li>
{% endfor %}
{%if objects.has_next%}
<li><a href="?page={{objects.next_page_number}}">&raquo;</a></li>
{%else%}
<li class="disabled"><a href="#">&raquo;</a></li>
{%endif%}
</ul>
</div>
<table class="table table-striped table-condensed" style="width:95%">
{% block pagetable %}
{% endblock %}

View File

@ -1,8 +1,8 @@
{% extends "basebuildpage.html" %}
{% block pagetitle %}Files for package {{files.0.bpackage.name}} {% endblock %}
{% block pagetitle %}Files for package {{objects.0.bpackage.name}} {% endblock %}
{% block pagetable %}
{% if not files %}
{% if not objects %}
<p>No files were recorded for this package!</p>
{% else %}
@ -11,7 +11,7 @@
<th>Size (Bytes)</th>
</tr>
{% for file in files %}
{% for file in objects %}
<tr class="data">
<td>{{file.path}}</td>

View File

@ -2,7 +2,7 @@
{% block pagetitle %}Packages{% endblock %}
{% block pagetable %}
{% if not packages %}
{% if not objects %}
<p>No packages were recorded for this target!</p>
{% else %}
@ -18,12 +18,12 @@
<th>Dependencies List (all)</th>
</tr>
{% for package in packages %}
{% for package in objects %}
<tr class="data">
<td><a name="#{{package.name}}" href="{% url "bfile" build.pk package.pk %}">{{package.name}} ({{package.filelist_bpackage.count}} files)</a></td>
<td>{{package.version}}-{{package.revision}}</td>
<td><a href="{% url "layer_versions_recipes" package.recipe.layer_version_id %}#{{package.recipe.name}}">{{package.recipe.name}}</a>{{package.package_name}}</a></td>
<td>{%if package.recipe%}<a href="{% url "layer_versions_recipes" package.recipe.layer_version_id %}#{{package.recipe.name}}">{{package.recipe.name}}</a>{{package.package_name}}</a>{%endif%}</td>
<td>{{package.summary}}</td>
<td>{{package.section}}</td>

View File

@ -21,7 +21,7 @@
<th>Bitbake Version</th>
<th>Build Name</th>
</tr>
{% for build in builds %}
{% for build in objects %}
<tr class="data">
<td><a href="{% url "configuration" build.id %}">{{build.get_outcome_display}}</a></td>
<td>{{build.started_on}}</td>

View File

@ -10,7 +10,7 @@
<th>Value</th>
</tr>
{% for variable in configuration %}
{% for variable in objects %}
<tr class="data">
<td>{{variable.variable_name}}</td>

View File

@ -14,7 +14,7 @@
<th>Known Versions</th>
</tr>
{% for layer in layers %}
{% for layer in objects %}
<tr class="data">
<td>{{layer.name}}</td>

View File

@ -1,7 +1,7 @@
{% extends "basebuildpage.html" %}
{% block pagetable %}
{% if not packages %}
{% if not objects %}
<p>No packages were recorded for this target!</p>
{% else %}
@ -13,7 +13,7 @@
<th>Depends on</th>
</tr>
{% for package in packages %}
{% for package in objects %}
<tr class="data">
<td><a name="#{{package.name}}">{{package.name}}</a></td>

View File

@ -25,7 +25,7 @@
<th style="width: 30em">Recipe Dependency</th>
{% for recipe in recipes %}
{% for recipe in objects %}
<tr class="data">
<td><a name="{{recipe.name}}">{{recipe.name}}</a></td>

View File

@ -2,7 +2,7 @@
{% block pagetitle %}Tasks{% endblock %}
{% block pagetable %}
{% if not tasks %}
{% if not objects %}
<p>No tasks were executed in this build!</p>
{% else %}
@ -23,7 +23,7 @@
<th>Depends</th>
</tr>
{% for task in tasks %}
{% for task in objects %}
<tr class="data">
<td>{{task.order}}</td>

View File

@ -24,15 +24,38 @@ from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMes
from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency
from orm.models import Target_Installed_Package
from django.views.decorators.cache import cache_control
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
def _build_page_range(paginator, index = 1):
try:
page = paginator.page(index)
except PageNotAnInteger:
page = paginator.page(1)
except EmptyPage:
page = paginator.page(paginator.num_pages)
page.page_range = [page.number]
crt_range = 0
for i in range(1,5):
if (page.number + i) <= paginator.num_pages:
page.page_range = page.page_range + [ page.number + i]
crt_range +=1
if (page.number - i) > 0:
page.page_range = [page.number -i] + page.page_range
crt_range +=1
if crt_range == 4:
break
return page
@cache_control(no_store=True)
def build(request):
template = 'build.html'
build_info = Build.objects.all()
logs = LogMessage.objects.all()
context = {'builds': build_info, 'logs': logs ,
build_info = _build_page_range(Paginator(Build.objects.order_by("-id"), 10),request.GET.get('page', 1))
context = {'objects': build_info, 'logs': logs ,
'hideshowcols' : [
{'name': 'Output', 'order':10},
{'name': 'Log', 'order':11},
@ -61,38 +84,38 @@ def _find_task_provider(task):
def task(request, build_id):
template = 'task.html'
tasks = Task.objects.filter(build=build_id)
tasks = _build_page_range(Paginator(Task.objects.filter(build=build_id), 100),request.GET.get('page', 1))
for t in tasks:
if t.outcome == Task.OUTCOME_COVERED:
t.provider = _find_task_provider(t)
context = {'build': Build.objects.filter(pk=build_id)[0], 'tasks': tasks}
context = {'build': Build.objects.filter(pk=build_id)[0], 'objects': tasks}
return render(request, template, context)
def configuration(request, build_id):
template = 'configuration.html'
variables = Variable.objects.filter(build=build_id)
context = {'build': Build.objects.filter(pk=build_id)[0], 'configuration' : variables}
variables = _build_page_range(Paginator(Variable.objects.filter(build=build_id), 50), request.GET.get('page', 1))
context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : variables}
return render(request, template, context)
def bpackage(request, build_id):
template = 'bpackage.html'
packages = Package.objects.filter(build = build_id)
context = {'build': Build.objects.filter(pk=build_id)[0], 'packages' : packages}
context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : packages}
return render(request, template, context)
def bfile(request, build_id, package_id):
template = 'bfile.html'
files = Package_File.objects.filter(package = package_id)
context = {'build': Build.objects.filter(pk=build_id)[0], 'files' : files}
context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : files}
return render(request, template, context)
def tpackage(request, build_id, target_id):
template = 'package.html'
packages = map(lambda x: x.package, list(Target_Installed_Package.objects.filter(target=target_id)))
context = {'build': Build.objects.filter(pk=build_id)[0], 'packages' : packages}
context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : packages}
return render(request, template, context)
def layer(request):
@ -104,7 +127,7 @@ def layer(request):
for liv in li.versions:
liv.count = Recipe.objects.filter(layer_version__id = liv.id).count()
context = {'layers': layer_info}
context = {'objects': layer_info}
return render(request, template, context)
@ -113,7 +136,7 @@ def layer_versions_recipes(request, layerversion_id):
template = 'recipe.html'
recipes = Recipe.objects.filter(layer_version__id = layerversion_id)
context = {'recipes': recipes,
context = {'objects': recipes,
'layer_version' : Layer_Version.objects.filter( id = layerversion_id )[0]
}