From b8eda5d98504ababf8eb9b2c3815c1891eb4b267 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Thu, 5 Dec 2013 14:20:36 +0000 Subject: [PATCH] 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 Signed-off-by: Richard Purdie --- .../lib/toaster/bldviewer/templates/basetable.html | 22 +++++++++- bitbake/lib/toaster/bldviewer/templates/bfile.html | 6 +-- .../lib/toaster/bldviewer/templates/bpackage.html | 6 +-- bitbake/lib/toaster/bldviewer/templates/build.html | 2 +- .../toaster/bldviewer/templates/configuration.html | 2 +- bitbake/lib/toaster/bldviewer/templates/layer.html | 2 +- .../lib/toaster/bldviewer/templates/package.html | 4 +- .../lib/toaster/bldviewer/templates/recipe.html | 2 +- bitbake/lib/toaster/bldviewer/templates/task.html | 4 +- bitbake/lib/toaster/bldviewer/views.py | 47 ++++++++++++++++------ 10 files changed, 69 insertions(+), 28 deletions(-) diff --git a/bitbake/lib/toaster/bldviewer/templates/basetable.html b/bitbake/lib/toaster/bldviewer/templates/basetable.html index 083bcb8..16628ea 100644 --- a/bitbake/lib/toaster/bldviewer/templates/basetable.html +++ b/bitbake/lib/toaster/bldviewer/templates/basetable.html @@ -26,7 +26,7 @@ function filterTableRows(test) { {% block pagename %} {% endblock %} -
Search: +
Filter:
{% if hideshowcols %}
Show/Hide columns: @@ -36,7 +36,25 @@ function filterTableRows(test) {
{% endif %}
-
+ +
Showing {{objects.start_index}} to {{objects.end_index}} out of {{objects.paginator.count}} entries.  +
    +{%if objects.has_previous %} +
  • «
  • +{%else%} +
  • «
  • +{%endif%} +{% for i in objects.page_range %} + {{i}} +{% endfor %} +{%if objects.has_next%} +
  • »
  • +{%else%} +
  • »
  • +{%endif%} +
+
+ {% block pagetable %} {% endblock %} diff --git a/bitbake/lib/toaster/bldviewer/templates/bfile.html b/bitbake/lib/toaster/bldviewer/templates/bfile.html index d90f4fb..c7f5943 100644 --- a/bitbake/lib/toaster/bldviewer/templates/bfile.html +++ b/bitbake/lib/toaster/bldviewer/templates/bfile.html @@ -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 %}

No files were recorded for this package!

{% else %} @@ -11,7 +11,7 @@ - {% for file in files %} + {% for file in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/bpackage.html b/bitbake/lib/toaster/bldviewer/templates/bpackage.html index 07d0792..67fc65c 100644 --- a/bitbake/lib/toaster/bldviewer/templates/bpackage.html +++ b/bitbake/lib/toaster/bldviewer/templates/bpackage.html @@ -2,7 +2,7 @@ {% block pagetitle %}Packages{% endblock %} {% block pagetable %} - {% if not packages %} + {% if not objects %}

No packages were recorded for this target!

{% else %} @@ -18,12 +18,12 @@ - {% for package in packages %} + {% for package in objects %} - + diff --git a/bitbake/lib/toaster/bldviewer/templates/build.html b/bitbake/lib/toaster/bldviewer/templates/build.html index 5653cca..4fa87d5 100644 --- a/bitbake/lib/toaster/bldviewer/templates/build.html +++ b/bitbake/lib/toaster/bldviewer/templates/build.html @@ -21,7 +21,7 @@ - {% for build in builds %} + {% for build in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/configuration.html b/bitbake/lib/toaster/bldviewer/templates/configuration.html index 8db35e0..521620f 100644 --- a/bitbake/lib/toaster/bldviewer/templates/configuration.html +++ b/bitbake/lib/toaster/bldviewer/templates/configuration.html @@ -10,7 +10,7 @@ - {% for variable in configuration %} + {% for variable in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/layer.html b/bitbake/lib/toaster/bldviewer/templates/layer.html index c5034de..410d766 100644 --- a/bitbake/lib/toaster/bldviewer/templates/layer.html +++ b/bitbake/lib/toaster/bldviewer/templates/layer.html @@ -14,7 +14,7 @@ - {% for layer in layers %} + {% for layer in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/package.html b/bitbake/lib/toaster/bldviewer/templates/package.html index fda9dab..1ba3726 100644 --- a/bitbake/lib/toaster/bldviewer/templates/package.html +++ b/bitbake/lib/toaster/bldviewer/templates/package.html @@ -1,7 +1,7 @@ {% extends "basebuildpage.html" %} {% block pagetable %} - {% if not packages %} + {% if not objects %}

No packages were recorded for this target!

{% else %} @@ -13,7 +13,7 @@ - {% for package in packages %} + {% for package in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/recipe.html b/bitbake/lib/toaster/bldviewer/templates/recipe.html index 7d5fbf4..d7f57eb 100644 --- a/bitbake/lib/toaster/bldviewer/templates/recipe.html +++ b/bitbake/lib/toaster/bldviewer/templates/recipe.html @@ -25,7 +25,7 @@ - {% for recipe in recipes %} + {% for recipe in objects %} diff --git a/bitbake/lib/toaster/bldviewer/templates/task.html b/bitbake/lib/toaster/bldviewer/templates/task.html index 5d9887e..6a9979e 100644 --- a/bitbake/lib/toaster/bldviewer/templates/task.html +++ b/bitbake/lib/toaster/bldviewer/templates/task.html @@ -2,7 +2,7 @@ {% block pagetitle %}Tasks{% endblock %} {% block pagetable %} - {% if not tasks %} + {% if not objects %}

No tasks were executed in this build!

{% else %} @@ -23,7 +23,7 @@ - {% for task in tasks %} + {% for task in objects %} diff --git a/bitbake/lib/toaster/bldviewer/views.py b/bitbake/lib/toaster/bldviewer/views.py index 3eb785b..7cb9b42 100644 --- a/bitbake/lib/toaster/bldviewer/views.py +++ b/bitbake/lib/toaster/bldviewer/views.py @@ -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] } -- 2.7.4
Size (Bytes)
{{file.path}}Dependencies List (all)
{{package.name}} ({{package.filelist_bpackage.count}} files) {{package.version}}-{{package.revision}}{{package.recipe.name}}{{package.package_name}}{%if package.recipe%}{{package.recipe.name}}{{package.package_name}}{%endif%} {{package.summary}} {{package.section}}Bitbake Version Build Name
{{build.get_outcome_display}} {{build.started_on}}Value
{{variable.variable_name}}Known Versions
{{layer.name}}Depends on
{{package.name}}Recipe Dependency
{{recipe.name}}Depends
{{task.order}}