=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/alljobs.html'
@@ -8,32 +8,14 @@
<thead>
<tr>
<th class="id">ID</th>
- <th>Status</th>
- <th>Device</th>
- <th>Description</th>
- <th>Submitter</th>
- <th>Submit Time</th>
+ <th class="status">Status</th>
+ <th class="device">Device</th>
+ <th class="description">Description</th>
+ <th class="submitter">Submitter</th>
+ <th class="submit_time">Submit Time</th>
</tr>
</thead>
<tbody>
- {% for job in jobs %}
- <tr>
- <td><a href="{{ job.get_absolute_url }}">{{ job.id }} </a></td>
- <td>{{ job.get_status_display }}</td>
- {% if job.actual_device %}
- <td><a href="{{ job.actual_device.get_absolute_url }}"
- >{{ job.actual_device }}</a></td>
- {% else %}{% if job.requested_device %}
- <td><a href="{{ job.requested_device.get_absolute_url }}"
- ><i>{{ job.requested_device }}</i></a></td>
- {% else %}
- <td><i>{{ job.requested_device_type|default:'' }}</i></td>
- {% endif %}{% endif %}
- <td>{{ job.description|default:'' }}</td>
- <td>{{ job.submitter }}</td>
- <td>{{ job.submit_time }}</td>
- </tr>
- {% endfor %}
</tbody>
</table>
@@ -41,12 +23,37 @@
$(document).ready(
function() {
$("table.data").dataTable({
- "bJQueryUI": true,
- "aoColumnDefs": [
- { "sType": "num-html", "aTargets": [ "id" ] }
- ],
- "aaSorting": [[0, "desc"]],
- "iDisplayLength": 25
+ bJQueryUI: true,
+ bServerSide: true,
+ bProcessing: true,
+ bFilter: true,
+ sAjaxSource: "{% url lava_scheduler_app.views.alljobs_json %}",
+ aaSorting: [[0, "desc"]],
+ iDisplayLength: 25,
+ aoColumnDefs: [
+ {
+ aTargets: ["id"],
+ fnRender: function (o) { return '<a href="' + o.aData.id.link + '">' + o.aData.id.id + '</a>'; }
+ },
+ {aTargets: ["status"], mDataProp: 'status'},
+ {aTargets: ["description"], mDataProp: 'description'},
+ {aTargets: ["submitter"], mDataProp: 'submitter'},
+ {aTargets: ["submit_time"], mDataProp: 'submit_time'},
+ {
+ aTargets: ["device"],
+ fnRender: function (o) {
+ o = o.aData.device;
+ r = o.name;
+ if (o.requested) {
+ r = '<i>' + r + '</i>';
+ }
+ if (o.link) {
+ return '<a href="' + o.link + '">' + r + '</a>';
+ }
+ return r;
+ }
+ }
+ ]
});
}
);
=== modified file 'lava_scheduler_app/urls.py'
@@ -1,5 +1,6 @@
from django.conf.urls.defaults import url, patterns
+
urlpatterns = patterns(
'lava_scheduler_app.views',
url(r'^$',
@@ -8,6 +9,9 @@
url(r'^alljobs$',
'job_list',
name='lava.scheduler.job.list'),
+ url(r'^alljobs_json$',
+ 'alljobs_json',
+ name='lava.scheduler.job.list_json'),
url(r'^device/(?P<pk>[-_a-zA-Z0-9]+)$',
'device_detail',
name='lava.scheduler.device.detail'),
=== modified file 'lava_scheduler_app/views.py'
@@ -4,19 +4,24 @@
import simplejson
import StringIO
-
+from django.conf import settings
+from django.core.urlresolvers import reverse
from django.http import (
HttpResponse,
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseNotAllowed,
)
-from django.template import RequestContext
from django.shortcuts import (
get_object_or_404,
redirect,
render_to_response,
)
+from django.template import RequestContext
+from django.template import defaultfilters as filters
+
+from lava.utils.data_tables.views import DataTableView
+from lava.utils.data_tables.backends import QuerySetBackend, Column
from lava_server.views import index as lava_index
from lava_server.bread_crumbs import (
@@ -29,7 +34,12 @@
getDispatcherErrors,
getDispatcherLogMessages
)
-from lava_scheduler_app.models import Device, DeviceStateTransition, TestJob
+from lava_scheduler_app.models import (
+ Device,
+ DeviceStateTransition,
+ TestJob,
+ )
+
def post_only(func):
@@ -60,14 +70,58 @@
return render_to_response(
"lava_scheduler_app/alljobs.html",
{
- 'jobs': TestJob.objects.select_related(
- "actual_device", "requested_device", "requested_device_type",
- "submitter").all(),
'bread_crumb_trail': BreadCrumbTrail.leading_to(job_list),
},
RequestContext(request))
+def device_callback(job):
+ if job.actual_device:
+ return dict(
+ name=job.actual_device.pk, requested=False,
+ link=reverse(device_detail, kwargs=dict(pk=job.actual_device.pk)))
+ elif job.requested_device:
+ return dict(
+ name=job.requested_device.pk, requested=True,
+ link=reverse(device_detail, kwargs=dict(pk=job.requested_device.pk)))
+ else:
+ return dict(name=job.requested_device_type.pk, requested=True)
+
+
+def id_callback(job):
+ if job is None:
+ return job
+ else:
+ return dict(id=job.id, link=reverse(job_detail, kwargs=dict(pk=job.id)))
+
+
+alljobs_json = DataTableView.as_view(
+ backend=QuerySetBackend(
+ queryset=TestJob.objects.select_related(
+ "actual_device", "requested_device", "requested_device_type",
+ "submitter").extra(
+ select={
+ 'device_sort': 'coalesce(actual_device_id, requested_device_id, requested_device_type_id)'
+ }).all(),
+ columns=[
+ Column(
+ 'id', 'id', id_callback),
+ Column(
+ 'status', 'status', lambda job: job.get_status_display()),
+ Column(
+ 'device', 'device_sort', device_callback),
+ Column(
+ 'description', 'description', lambda job: job.description),
+ Column(
+ 'submitter', 'submitter', lambda job: job.submitter.username),
+ Column(
+ 'submit_time', 'submit_time',
+ lambda job: filters.date(
+ job.submit_time, settings.DATETIME_FORMAT)),
+ ],
+ searching_columns=['description']))
+
+
@BreadCrumb("Job #{pk}", parent=index, needs=['pk'])
def job_detail(request, pk):
job = get_object_or_404(TestJob, pk=pk)
=== modified file 'setup.py'
@@ -33,7 +33,7 @@
scheduler = lava_scheduler_app.extension:SchedulerExtension
""",
install_requires=[
- "lava-server >= 0.8",
+ "lava-server >= 0.10",
"simplejson",
"south >= 0.7.3",
"twisted",