summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2013-12-05 14:20:36 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-10 11:16:14 +0000
commit192583a91e17b15da4668dbacee035def1d68b0c (patch)
tree2dfef54dff47dddfb3005b619ee08d1731b63c2d
parent415ebb738da2a9625d6cc1456f4e99e463797c31 (diff)
downloadpoky-192583a91e17b15da4668dbacee035def1d68b0c.tar.gz
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>
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/basetable.html22
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/bfile.html6
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/bpackage.html6
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/build.html2
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/configuration.html2
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/layer.html2
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/package.html4
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/recipe.html2
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/task.html4
-rw-r--r--bitbake/lib/toaster/bldviewer/views.py47
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 083bcb82e9..16628eafbe 100644
--- a/bitbake/lib/toaster/bldviewer/templates/basetable.html
+++ b/bitbake/lib/toaster/bldviewer/templates/basetable.html
@@ -26,7 +26,7 @@ function filterTableRows(test) {
26 26
27 {% block pagename %} 27 {% block pagename %}
28 {% endblock %} 28 {% endblock %}
29 <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"> 29 <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">
30 </div> 30 </div>
31 {% if hideshowcols %} 31 {% if hideshowcols %}
32 <div align="right" style="display: inline-block; width: 40%">Show/Hide columns: 32 <div align="right" style="display: inline-block; width: 40%">Show/Hide columns:
@@ -36,7 +36,25 @@ function filterTableRows(test) {
36 </div> 36 </div>
37 {% endif %} 37 {% endif %}
38</div> 38</div>
39<div> 39
40 <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>
41 <ul class="pagination" style="display: block-inline">
42{%if objects.has_previous %}
43 <li><a href="?page={{objects.previous_page_number}}">&laquo;</a></li>
44{%else%}
45 <li class="disabled"><a href="#">&laquo;</a></li>
46{%endif%}
47{% for i in objects.page_range %}
48 <li{%if i == objects.number %} class="active" {%endif%}><a href="?page={{i}}">{{i}}</a></li>
49{% endfor %}
50{%if objects.has_next%}
51 <li><a href="?page={{objects.next_page_number}}">&raquo;</a></li>
52{%else%}
53 <li class="disabled"><a href="#">&raquo;</a></li>
54{%endif%}
55 </ul>
56</div>
57
40 <table class="table table-striped table-condensed" style="width:95%"> 58 <table class="table table-striped table-condensed" style="width:95%">
41{% block pagetable %} 59{% block pagetable %}
42{% endblock %} 60{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/bfile.html b/bitbake/lib/toaster/bldviewer/templates/bfile.html
index d90f4fbddb..c7f59434a5 100644
--- a/bitbake/lib/toaster/bldviewer/templates/bfile.html
+++ b/bitbake/lib/toaster/bldviewer/templates/bfile.html
@@ -1,8 +1,8 @@
1{% extends "basebuildpage.html" %} 1{% extends "basebuildpage.html" %}
2 2
3{% block pagetitle %}Files for package {{files.0.bpackage.name}} {% endblock %} 3{% block pagetitle %}Files for package {{objects.0.bpackage.name}} {% endblock %}
4{% block pagetable %} 4{% block pagetable %}
5 {% if not files %} 5 {% if not objects %}
6 <p>No files were recorded for this package!</p> 6 <p>No files were recorded for this package!</p>
7 {% else %} 7 {% else %}
8 8
@@ -11,7 +11,7 @@
11 <th>Size (Bytes)</th> 11 <th>Size (Bytes)</th>
12 </tr> 12 </tr>
13 13
14 {% for file in files %} 14 {% for file in objects %}
15 15
16 <tr class="data"> 16 <tr class="data">
17 <td>{{file.path}}</td> 17 <td>{{file.path}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/bpackage.html b/bitbake/lib/toaster/bldviewer/templates/bpackage.html
index 07d079298e..67fc65ca3e 100644
--- a/bitbake/lib/toaster/bldviewer/templates/bpackage.html
+++ b/bitbake/lib/toaster/bldviewer/templates/bpackage.html
@@ -2,7 +2,7 @@
2 2
3{% block pagetitle %}Packages{% endblock %} 3{% block pagetitle %}Packages{% endblock %}
4{% block pagetable %} 4{% block pagetable %}
5 {% if not packages %} 5 {% if not objects %}
6 <p>No packages were recorded for this target!</p> 6 <p>No packages were recorded for this target!</p>
7 {% else %} 7 {% else %}
8 8
@@ -18,12 +18,12 @@
18 <th>Dependencies List (all)</th> 18 <th>Dependencies List (all)</th>
19 </tr> 19 </tr>
20 20
21 {% for package in packages %} 21 {% for package in objects %}
22 22
23 <tr class="data"> 23 <tr class="data">
24 <td><a name="#{{package.name}}" href="{% url "bfile" build.pk package.pk %}">{{package.name}} ({{package.filelist_bpackage.count}} files)</a></td> 24 <td><a name="#{{package.name}}" href="{% url "bfile" build.pk package.pk %}">{{package.name}} ({{package.filelist_bpackage.count}} files)</a></td>
25 <td>{{package.version}}-{{package.revision}}</td> 25 <td>{{package.version}}-{{package.revision}}</td>
26 <td><a href="{% url "layer_versions_recipes" package.recipe.layer_version_id %}#{{package.recipe.name}}">{{package.recipe.name}}</a>{{package.package_name}}</a></td> 26 <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>
27 27
28 <td>{{package.summary}}</td> 28 <td>{{package.summary}}</td>
29 <td>{{package.section}}</td> 29 <td>{{package.section}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/build.html b/bitbake/lib/toaster/bldviewer/templates/build.html
index 5653cca357..4fa87d5271 100644
--- a/bitbake/lib/toaster/bldviewer/templates/build.html
+++ b/bitbake/lib/toaster/bldviewer/templates/build.html
@@ -21,7 +21,7 @@
21 <th>Bitbake Version</th> 21 <th>Bitbake Version</th>
22 <th>Build Name</th> 22 <th>Build Name</th>
23 </tr> 23 </tr>
24 {% for build in builds %} 24 {% for build in objects %}
25 <tr class="data"> 25 <tr class="data">
26 <td><a href="{% url "configuration" build.id %}">{{build.get_outcome_display}}</a></td> 26 <td><a href="{% url "configuration" build.id %}">{{build.get_outcome_display}}</a></td>
27 <td>{{build.started_on}}</td> 27 <td>{{build.started_on}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/configuration.html b/bitbake/lib/toaster/bldviewer/templates/configuration.html
index 8db35e0d98..521620fdce 100644
--- a/bitbake/lib/toaster/bldviewer/templates/configuration.html
+++ b/bitbake/lib/toaster/bldviewer/templates/configuration.html
@@ -10,7 +10,7 @@
10 <th>Value</th> 10 <th>Value</th>
11 </tr> 11 </tr>
12 12
13 {% for variable in configuration %} 13 {% for variable in objects %}
14 14
15 <tr class="data"> 15 <tr class="data">
16 <td>{{variable.variable_name}}</td> 16 <td>{{variable.variable_name}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/layer.html b/bitbake/lib/toaster/bldviewer/templates/layer.html
index c5034dea83..410d766c60 100644
--- a/bitbake/lib/toaster/bldviewer/templates/layer.html
+++ b/bitbake/lib/toaster/bldviewer/templates/layer.html
@@ -14,7 +14,7 @@
14 <th>Known Versions</th> 14 <th>Known Versions</th>
15 </tr> 15 </tr>
16 16
17 {% for layer in layers %} 17 {% for layer in objects %}
18 18
19 <tr class="data"> 19 <tr class="data">
20 <td>{{layer.name}}</td> 20 <td>{{layer.name}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/package.html b/bitbake/lib/toaster/bldviewer/templates/package.html
index fda9dab0f0..1ba372608d 100644
--- a/bitbake/lib/toaster/bldviewer/templates/package.html
+++ b/bitbake/lib/toaster/bldviewer/templates/package.html
@@ -1,7 +1,7 @@
1{% extends "basebuildpage.html" %} 1{% extends "basebuildpage.html" %}
2 2
3{% block pagetable %} 3{% block pagetable %}
4 {% if not packages %} 4 {% if not objects %}
5 <p>No packages were recorded for this target!</p> 5 <p>No packages were recorded for this target!</p>
6 {% else %} 6 {% else %}
7 7
@@ -13,7 +13,7 @@
13 <th>Depends on</th> 13 <th>Depends on</th>
14 </tr> 14 </tr>
15 15
16 {% for package in packages %} 16 {% for package in objects %}
17 17
18 <tr class="data"> 18 <tr class="data">
19 <td><a name="#{{package.name}}">{{package.name}}</a></td> 19 <td><a name="#{{package.name}}">{{package.name}}</a></td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/recipe.html b/bitbake/lib/toaster/bldviewer/templates/recipe.html
index 7d5fbf4e55..d7f57eb9ea 100644
--- a/bitbake/lib/toaster/bldviewer/templates/recipe.html
+++ b/bitbake/lib/toaster/bldviewer/templates/recipe.html
@@ -25,7 +25,7 @@
25 <th style="width: 30em">Recipe Dependency</th> 25 <th style="width: 30em">Recipe Dependency</th>
26 26
27 27
28 {% for recipe in recipes %} 28 {% for recipe in objects %}
29 29
30 <tr class="data"> 30 <tr class="data">
31 <td><a name="{{recipe.name}}">{{recipe.name}}</a></td> 31 <td><a name="{{recipe.name}}">{{recipe.name}}</a></td>
diff --git a/bitbake/lib/toaster/bldviewer/templates/task.html b/bitbake/lib/toaster/bldviewer/templates/task.html
index 5d9887e848..6a9979e533 100644
--- a/bitbake/lib/toaster/bldviewer/templates/task.html
+++ b/bitbake/lib/toaster/bldviewer/templates/task.html
@@ -2,7 +2,7 @@
2 2
3{% block pagetitle %}Tasks{% endblock %} 3{% block pagetitle %}Tasks{% endblock %}
4{% block pagetable %} 4{% block pagetable %}
5 {% if not tasks %} 5 {% if not objects %}
6 <p>No tasks were executed in this build!</p> 6 <p>No tasks were executed in this build!</p>
7 {% else %} 7 {% else %}
8 8
@@ -23,7 +23,7 @@
23 <th>Depends</th> 23 <th>Depends</th>
24 </tr> 24 </tr>
25 25
26 {% for task in tasks %} 26 {% for task in objects %}
27 27
28 <tr class="data"> 28 <tr class="data">
29 <td>{{task.order}}</td> 29 <td>{{task.order}}</td>
diff --git a/bitbake/lib/toaster/bldviewer/views.py b/bitbake/lib/toaster/bldviewer/views.py
index 3eb785b6c6..7cb9b42379 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
24from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency 24from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency
25from orm.models import Target_Installed_Package 25from orm.models import Target_Installed_Package
26from django.views.decorators.cache import cache_control 26from django.views.decorators.cache import cache_control
27from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
28
29
30def _build_page_range(paginator, index = 1):
31 try:
32 page = paginator.page(index)
33 except PageNotAnInteger:
34 page = paginator.page(1)
35 except EmptyPage:
36 page = paginator.page(paginator.num_pages)
37
38 page.page_range = [page.number]
39 crt_range = 0
40 for i in range(1,5):
41 if (page.number + i) <= paginator.num_pages:
42 page.page_range = page.page_range + [ page.number + i]
43 crt_range +=1
44 if (page.number - i) > 0:
45 page.page_range = [page.number -i] + page.page_range
46 crt_range +=1
47 if crt_range == 4:
48 break
49 return page
27 50
28@cache_control(no_store=True) 51@cache_control(no_store=True)
29def build(request): 52def build(request):
30 template = 'build.html' 53 template = 'build.html'
31 build_info = Build.objects.all()
32
33 logs = LogMessage.objects.all() 54 logs = LogMessage.objects.all()
34 55
35 context = {'builds': build_info, 'logs': logs , 56 build_info = _build_page_range(Paginator(Build.objects.order_by("-id"), 10),request.GET.get('page', 1))
57
58 context = {'objects': build_info, 'logs': logs ,
36 'hideshowcols' : [ 59 'hideshowcols' : [
37 {'name': 'Output', 'order':10}, 60 {'name': 'Output', 'order':10},
38 {'name': 'Log', 'order':11}, 61 {'name': 'Log', 'order':11},
@@ -61,38 +84,38 @@ def _find_task_provider(task):
61def task(request, build_id): 84def task(request, build_id):
62 template = 'task.html' 85 template = 'task.html'
63 86
64 tasks = Task.objects.filter(build=build_id) 87 tasks = _build_page_range(Paginator(Task.objects.filter(build=build_id), 100),request.GET.get('page', 1))
65 88
66 for t in tasks: 89 for t in tasks:
67 if t.outcome == Task.OUTCOME_COVERED: 90 if t.outcome == Task.OUTCOME_COVERED:
68 t.provider = _find_task_provider(t) 91 t.provider = _find_task_provider(t)
69 92
70 context = {'build': Build.objects.filter(pk=build_id)[0], 'tasks': tasks} 93 context = {'build': Build.objects.filter(pk=build_id)[0], 'objects': tasks}
71 94
72 return render(request, template, context) 95 return render(request, template, context)
73 96
74def configuration(request, build_id): 97def configuration(request, build_id):
75 template = 'configuration.html' 98 template = 'configuration.html'
76 variables = Variable.objects.filter(build=build_id) 99 variables = _build_page_range(Paginator(Variable.objects.filter(build=build_id), 50), request.GET.get('page', 1))
77 context = {'build': Build.objects.filter(pk=build_id)[0], 'configuration' : variables} 100 context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : variables}
78 return render(request, template, context) 101 return render(request, template, context)
79 102
80def bpackage(request, build_id): 103def bpackage(request, build_id):
81 template = 'bpackage.html' 104 template = 'bpackage.html'
82 packages = Package.objects.filter(build = build_id) 105 packages = Package.objects.filter(build = build_id)
83 context = {'build': Build.objects.filter(pk=build_id)[0], 'packages' : packages} 106 context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : packages}
84 return render(request, template, context) 107 return render(request, template, context)
85 108
86def bfile(request, build_id, package_id): 109def bfile(request, build_id, package_id):
87 template = 'bfile.html' 110 template = 'bfile.html'
88 files = Package_File.objects.filter(package = package_id) 111 files = Package_File.objects.filter(package = package_id)
89 context = {'build': Build.objects.filter(pk=build_id)[0], 'files' : files} 112 context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : files}
90 return render(request, template, context) 113 return render(request, template, context)
91 114
92def tpackage(request, build_id, target_id): 115def tpackage(request, build_id, target_id):
93 template = 'package.html' 116 template = 'package.html'
94 packages = map(lambda x: x.package, list(Target_Installed_Package.objects.filter(target=target_id))) 117 packages = map(lambda x: x.package, list(Target_Installed_Package.objects.filter(target=target_id)))
95 context = {'build': Build.objects.filter(pk=build_id)[0], 'packages' : packages} 118 context = {'build': Build.objects.filter(pk=build_id)[0], 'objects' : packages}
96 return render(request, template, context) 119 return render(request, template, context)
97 120
98def layer(request): 121def layer(request):
@@ -104,7 +127,7 @@ def layer(request):
104 for liv in li.versions: 127 for liv in li.versions:
105 liv.count = Recipe.objects.filter(layer_version__id = liv.id).count() 128 liv.count = Recipe.objects.filter(layer_version__id = liv.id).count()
106 129
107 context = {'layers': layer_info} 130 context = {'objects': layer_info}
108 131
109 return render(request, template, context) 132 return render(request, template, context)
110 133
@@ -113,7 +136,7 @@ def layer_versions_recipes(request, layerversion_id):
113 template = 'recipe.html' 136 template = 'recipe.html'
114 recipes = Recipe.objects.filter(layer_version__id = layerversion_id) 137 recipes = Recipe.objects.filter(layer_version__id = layerversion_id)
115 138
116 context = {'recipes': recipes, 139 context = {'objects': recipes,
117 'layer_version' : Layer_Version.objects.filter( id = layerversion_id )[0] 140 'layer_version' : Layer_Version.objects.filter( id = layerversion_id )[0]
118 } 141 }
119 142