diff options
| author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-10-03 18:03:37 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-10-30 13:39:50 +0000 |
| commit | a1f7a09801c2240b5f9a29683a2b538fcb9991d6 (patch) | |
| tree | cc80a89b15fbac86fb01defc6c789bf582921986 /bitbake/lib/toaster/toastergui/views.py | |
| parent | c7382dbd8bb273062164e7cdb7233b60874c91d3 (diff) | |
| download | poky-a1f7a09801c2240b5f9a29683a2b538fcb9991d6.tar.gz | |
bitbake: toaster: changes to the landing page
This patch brings in a new landing page to be shown
when there are no builds and no projects available.
The builds page now displays only only the builds part,
without the landing page bits.
There is a new projects page that displays the All Projects
table as specified in the design.
[YOCTO #6682]
(Bitbake rev: c6c7c05521daa9bf16c122d7d472330ca4c05e88)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
| -rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 130 |
1 files changed, 129 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 66113cfdf3..38d67e378f 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
| @@ -38,6 +38,51 @@ from datetime import timedelta | |||
| 38 | from django.utils import formats | 38 | from django.utils import formats |
| 39 | import json | 39 | import json |
| 40 | 40 | ||
| 41 | |||
| 42 | # all new sessions should come through the landing page; | ||
| 43 | # determine in which mode we are running in, and redirect appropriately | ||
| 44 | def landing(request): | ||
| 45 | if toastermain.settings.MANAGED and Build.objects.count() == 0 and Project.objects.count() > 0: | ||
| 46 | return redirect(reverse('all-projects'), permanent = False) | ||
| 47 | |||
| 48 | if Build.objects.all().count() > 0: | ||
| 49 | return redirect(reverse('all-builds'), permanent = False) | ||
| 50 | |||
| 51 | return render(request, 'landing.html') | ||
| 52 | |||
| 53 | def _project_recent_build_list(prj): | ||
| 54 | # build requests not yet started | ||
| 55 | return (map(lambda x: { | ||
| 56 | "id": x.pk, | ||
| 57 | "targets" : map(lambda y: {"target": y.target }, x.brtarget_set.all()), | ||
| 58 | "status": x.get_state_display(), | ||
| 59 | }, prj.buildrequest_set.filter(state__lt = BuildRequest.REQ_INPROGRESS).order_by("-pk")) + | ||
| 60 | # build requests started, but with no build yet | ||
| 61 | map(lambda x: { | ||
| 62 | "id": x.pk, | ||
| 63 | "targets" : map(lambda y: {"target": y.target }, x.brtarget_set.all()), | ||
| 64 | "status": x.get_state_display(), | ||
| 65 | }, prj.buildrequest_set.filter(state = BuildRequest.REQ_INPROGRESS, build = None).order_by("-pk")) + | ||
| 66 | # build requests that failed | ||
| 67 | map(lambda x: { | ||
| 68 | "id": x.pk, | ||
| 69 | "targets" : map(lambda y: {"target": y.target }, x.brtarget_set.all()), | ||
| 70 | "status": x.get_state_display(), | ||
| 71 | "errors": map(lambda y: {"type": y.errtype, "msg": y.errmsg, "tb": y.traceback}, x.brerror_set.all()), | ||
| 72 | }, prj.buildrequest_set.filter(state = BuildRequest.REQ_FAILED).order_by("-pk")) + | ||
| 73 | # and already made builds | ||
| 74 | map(lambda x: { | ||
| 75 | "id": x.pk, | ||
| 76 | "targets": map(lambda y: {"target": y.target }, x.target_set.all()), | ||
| 77 | "status": x.get_outcome_display(), | ||
| 78 | "completed_on" : x.completed_on.strftime('%s')+"000", | ||
| 79 | "build_time" : (x.completed_on - x.started_on).total_seconds(), | ||
| 80 | "build_page_url" : reverse('builddashboard', args=(x.pk,)), | ||
| 81 | "completeper": x.completeper(), | ||
| 82 | "eta": x.eta().ctime(), | ||
| 83 | }, prj.build_set.all())) | ||
| 84 | |||
| 85 | |||
| 41 | def _build_page_range(paginator, index = 1): | 86 | def _build_page_range(paginator, index = 1): |
| 42 | try: | 87 | try: |
| 43 | page = paginator.page(index) | 88 | page = paginator.page(index) |
| @@ -219,6 +264,8 @@ def _save_parameters_cookies(response, pagesize, orderby, request): | |||
| 219 | response.set_cookie(key='orderby', value=html_parser.unescape(orderby), path=request.path) | 264 | response.set_cookie(key='orderby', value=html_parser.unescape(orderby), path=request.path) |
| 220 | return response | 265 | return response |
| 221 | 266 | ||
| 267 | |||
| 268 | |||
| 222 | # shows the "all builds" page | 269 | # shows the "all builds" page |
| 223 | def builds(request): | 270 | def builds(request): |
| 224 | template = 'build.html' | 271 | template = 'build.html' |
| @@ -242,7 +289,7 @@ def builds(request): | |||
| 242 | build_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) | 289 | build_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) |
| 243 | 290 | ||
| 244 | # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) | 291 | # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) |
| 245 | build_mru = Build.objects.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).order_by("-started_on")[:3] | 292 | build_mru = Build.objects.order_by("-started_on")[:3] |
| 246 | 293 | ||
| 247 | # set up list of fstypes for each build | 294 | # set up list of fstypes for each build |
| 248 | fstypes_map = {}; | 295 | fstypes_map = {}; |
| @@ -2553,6 +2600,84 @@ if toastermain.settings.MANAGED: | |||
| 2553 | } | 2600 | } |
| 2554 | 2601 | ||
| 2555 | return render(request, template, context) | 2602 | return render(request, template, context) |
| 2603 | |||
| 2604 | |||
| 2605 | |||
| 2606 | def projects(request): | ||
| 2607 | template="projects.html" | ||
| 2608 | |||
| 2609 | (pagesize, orderby) = _get_parameters_values(request, 10, 'updated:-') | ||
| 2610 | mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby } | ||
| 2611 | retval = _verify_parameters( request.GET, mandatory_parameters ) | ||
| 2612 | if retval: | ||
| 2613 | return _redirect_parameters( 'all-projects', request.GET, mandatory_parameters) | ||
| 2614 | |||
| 2615 | queryset_all = Project.objects.all() | ||
| 2616 | |||
| 2617 | # boilerplate code that takes a request for an object type and returns a queryset | ||
| 2618 | # for that object type. copypasta for all needed table searches | ||
| 2619 | (filter_string, search_term, ordering_string) = _search_tuple(request, Project) | ||
| 2620 | queryset_with_search = _get_queryset(Project, queryset_all, None, search_term, ordering_string, 'updated:-') | ||
| 2621 | queryset = _get_queryset(Project, queryset_all, filter_string, search_term, ordering_string, 'updated:-') | ||
| 2622 | |||
| 2623 | # retrieve the objects that will be displayed in the table; projects a paginator and gets a page range to display | ||
| 2624 | project_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) | ||
| 2625 | |||
| 2626 | # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) | ||
| 2627 | build_mru = Build.objects.order_by("-started_on")[:3] | ||
| 2628 | |||
| 2629 | |||
| 2630 | |||
| 2631 | context = { | ||
| 2632 | 'mru' : build_mru, | ||
| 2633 | |||
| 2634 | 'objects' : project_info, | ||
| 2635 | 'objectname' : "projects", | ||
| 2636 | 'default_orderby' : 'id:-', | ||
| 2637 | 'search_term' : search_term, | ||
| 2638 | 'total_count' : queryset_with_search.count(), | ||
| 2639 | 'tablecols': [ | ||
| 2640 | {'name': 'Project', | ||
| 2641 | 'orderfield': _get_toggle_order(request, "name"), | ||
| 2642 | 'ordericon':_get_toggle_order_icon(request, "name"), | ||
| 2643 | 'orderkey' : 'name', | ||
| 2644 | }, | ||
| 2645 | {'name': 'Release', | ||
| 2646 | 'qhelp' : "The version of the build system used by the project", | ||
| 2647 | 'orderfield': _get_toggle_order(request, "release__name"), | ||
| 2648 | 'ordericon':_get_toggle_order_icon(request, "release__name"), | ||
| 2649 | 'orderkey' : 'release__name', | ||
| 2650 | }, | ||
| 2651 | {'name': 'Machine', | ||
| 2652 | 'qhelp': "The hardware currently selected for the project", | ||
| 2653 | }, | ||
| 2654 | {'name': 'Number of builds', | ||
| 2655 | 'qhelp': "How many builds have been run for the project", | ||
| 2656 | }, | ||
| 2657 | {'name': 'Last outcome', 'clclass': 'loutcome', | ||
| 2658 | 'qhelp': "Tells you if the last project build completed successfully or failed", | ||
| 2659 | }, | ||
| 2660 | {'name': 'Last target', 'clclass': 'ltarget', | ||
| 2661 | 'qhelp': "The last project build target(s): one or more recipes or image recipes", | ||
| 2662 | }, | ||
| 2663 | {'name': 'Last errors', 'clclass': 'lerrors', | ||
| 2664 | 'qhelp': "How many errors were encountered during the last project build (if any)", | ||
| 2665 | }, | ||
| 2666 | {'name': 'Last warnings', 'clclass': 'lwarnings', | ||
| 2667 | 'qhelp': "How many warnigns were encountered during the last project build (if any)", | ||
| 2668 | }, | ||
| 2669 | {'name': 'Last image files', 'clclass': 'limagefiles', 'hidden': 1, | ||
| 2670 | 'qhelp': "The root file system types produced by the last project build", | ||
| 2671 | }, | ||
| 2672 | {'name': 'Last updated', 'clclass': 'updated', | ||
| 2673 | 'orderfield': _get_toggle_order(request, "updated"), | ||
| 2674 | 'ordericon':_get_toggle_order_icon(request, "updated"), | ||
| 2675 | 'orderkey' : 'updated', | ||
| 2676 | } | ||
| 2677 | ] | ||
| 2678 | } | ||
| 2679 | return render(request, template, context) | ||
| 2680 | |||
| 2556 | else: | 2681 | else: |
| 2557 | # these are pages that are NOT available in interactive mode | 2682 | # these are pages that are NOT available in interactive mode |
| 2558 | def managedcontextprocessor(request): | 2683 | def managedcontextprocessor(request): |
| @@ -2599,3 +2724,6 @@ else: | |||
| 2599 | 2724 | ||
| 2600 | def projectbuilds(request): | 2725 | def projectbuilds(request): |
| 2601 | raise Exception("page not available in interactive mode") | 2726 | raise Exception("page not available in interactive mode") |
| 2727 | |||
| 2728 | def projects(request): | ||
| 2729 | raise Exception("page not available in interactive mode") | ||
