Hide all projects except command-line builds in analysis mode
cover Hide all projects except command-line builds in analysis mode
The UI currently shows all the navigation elements in both analysis and build modes, even if they are irrelevant or broken.
As a temporary measure (until we merge the two modes), hide most of the navigation and UI elements when in analysis mode, so the user only gets to see the command-line builds project.
Changes since a9053ac0829eb01f6f002587854d01e47a78e6f0 (poky master) are ingit://git.yoctoproject.org/poky-contrib, elliot/toaster/hide_new_project_buttons-8514
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/hide_new_project_buttons-8514
Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8514
Elliot Smith (6):
toaster: Add BUILD_MODE flag to context
toaster: Show mode-appropriate landing page
toaster: Hide top bar buttons in analysis mode
toaster: Hide builds for non-cli projects in analysis mode
toaster: Run tests in build mode
toaster: Remove all navigation when not in build mode
bitbake/lib/toaster/toastergui/templates/base.html | 22 +++-- .../lib/toaster/toastergui/templates/landing.html | 103 ++++++++++++--------- bitbake/lib/toaster/toastergui/tests.py | 6 ++ bitbake/lib/toaster/toastergui/views.py | 36 ++++++- bitbake/lib/toaster/toastermain/settings.py | 6 +- bitbake/lib/toaster/toastermain/urls.py | 2 +- 6 files changed, 113 insertions(+), 62 deletions(-)
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 3/6 toaster: Hide top bar buttons in analysis mode
The "new build" and "new project" buttons are irrelevant in analysis mode, as you can't start a build or a project.
Hide these buttons if not in BUILD_MODE.
[YOCTO #8514]
--- bitbake/lib/toaster/toastergui/templates/base.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
bitbake/lib/toaster/toastergui/templates/base.html +13 -5
@@ -120,11 +120,19 @@ </li> </ul> <span class="pull-right divider-vertical"></span> - <div class="btn-group pull-right"> - <a class="btn" id="new-project-button" href="{% url 'newproject' %}">New project</a> - </div> - <!-- New build popover; only shown if there is at least one user-created project --> - {% if non_cli_projects.count > 0 %} + + <!-- new project button; only show in build mode --> + {% if BUILD_MODE %} + <div class="btn-group pull-right"> + <a class="btn" id="new-project-button" href="{% url 'newproject' %}">New project</a> + </div> + {% endif %} + + <!-- + New build popover; only shown if there is at least one user-created project + and we're in build mode + --> + {% if BUILD_MODE and non_cli_projects.count > 0 %} <div class="btn-group pull-right" id="new-build-button" style="display:none"> <button class="btn dropdown-toggle" data-toggle="dropdown"> New build
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 1/6 toaster: Add BUILD_MODE flag to context
In reply to Elliot SmithWe set a TOASTER_MANAGED env variable in the startup script, which has a value of "1" if Toaster should run in build mode.
Add a BUILD_MODE variable to settings.py which is True if TOASTER_MANAGED is set to "1", False otherwise.
Add this to the context for every template, so we can use this information to conditionally alter the content of pages according to the mode we're in.
[YOCTO #8514]
--- bitbake/lib/toaster/toastergui/views.py | 4 ++++ bitbake/lib/toaster/toastermain/settings.py | 6 ++---- bitbake/lib/toaster/toastermain/urls.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
bitbake/lib/toaster/toastergui/views.py +4 -0
@@ -1880,6 +1880,10 @@ def managedcontextprocessor(request): "projects": projects, "non_cli_projects": projects.exclude(is_default=True), "DEBUG" : toastermain.settings.DEBUG, + + # True if Toaster is in build mode, False otherwise + "BUILD_MODE": toastermain.settings.BUILD_MODE, + "CUSTOM_IMAGE" : toastermain.settings.CUSTOM_IMAGE, "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH, "TOASTER_REVISION" : toastermain.settings.TOASTER_REVISION,
bitbake/lib/toaster/toastermain/settings.py +2 -4
@@ -92,11 +92,9 @@ if 'DATABASE_URL' in os.environ: else: raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) - +BUILD_MODE = False if 'TOASTER_MANAGED' in os.environ and os.environ['TOASTER_MANAGED'] == "1": - MANAGED = True -else: - MANAGED = False + BUILD_MODE = True # Allows current database settings to be exported as a DATABASE_URL environment variable value
bitbake/lib/toaster/toastermain/urls.py +1 -1
@@ -60,7 +60,7 @@ if toastermain.settings.DEBUG_PANEL_ENABLED: #logger.info("Enabled django_toolbar extension") -if toastermain.settings.MANAGED: +if toastermain.settings.BUILD_MODE: urlpatterns = [ # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)),
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 4/6 toaster: Hide builds for non-cli projects in analysis mode
In reply to Elliot SmithThe "latest builds" sections of the "all builds" page show builds for all projects. This is not appropriate for analysis mode, where we can only affect the command-line builds project.
Modify the "latest builds" section to only show builds for the command line builds project if in analysis mode.
Also rationalise where we get the queryset of latest builds from:
we have a _get_latest_builds() function which was being used to get the latest builds in most places, but not all.
Also modify _get_latest_builds() to sort by started_on, rather than primary key, as assuming that a higher primary key value equates with later start time is incorrect.
[YOCTO #8514]
--- bitbake/lib/toaster/toastergui/views.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
bitbake/lib/toaster/toastergui/views.py +15 -3
@@ -92,9 +92,12 @@ def _get_latest_builds(prj=None): if prj is not None: queryset = queryset.filter(project = prj) + if not toastermain.settings.BUILD_MODE: + queryset = queryset.exclude(project__is_default=False) + return list(itertools.chain( - queryset.filter(outcome=Build.IN_PROGRESS).order_by("-pk"), - queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-pk")[:3] )) + queryset.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"), + queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-started_on")[:3] )) # a JSON-able dict of recent builds; for use in the Project page, xhr_ updates, and other places, as needed
@@ -1926,6 +1929,11 @@ if True: queryset = Build.objects.all() + # if in analysis mode, exclude builds for all projects except + # command line builds + if not toastermain.settings.BUILD_MODE: + queryset = queryset.exclude(project__is_default=False) + redirect_page = resolve(request.path_info).url_name context, pagesize, orderby = _build_list_helper(request,
@@ -2000,7 +2008,7 @@ if True: build_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) - build_mru = Build.objects.order_by("-started_on")[:3] + build_mru = _get_latest_builds()[:3] # calculate the exact begining of local today and yesterday, append context context_date,today_begin,yesterday_begin = _add_daterange_context(queryset_all, request, {'started_on','completed_on'})
@@ -3030,6 +3038,10 @@ if True: queryset_all = queryset_all.filter(Q(is_default=False) | q_default_with_builds) + # if in BUILD_MODE, exclude everything but the command line builds project + if not toastermain.settings.BUILD_MODE: + queryset_all = queryset_all.exclude(is_default=False) + # boilerplate code that takes a request for an object type and returns a queryset # for that object type. copypasta for all needed table searches (filter_string, search_term, ordering_string) = _search_tuple(request, Project)
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 2/6 toaster: Show mode-appropriate landing page
In reply to Elliot SmithThe same landing page is shown for both analysis and build modes. This means that users in analysis mode can see options which are not available or broken in that mode.
Modify the landing page template to show a simple "run a build" message if the user is in analysis mode and has no builds yet.
Also clean up the landing page HTML, because the indentation was a mess and the HTML was invalid.
[YOCTO #8514]
--- .../lib/toaster/toastergui/templates/landing.html | 103 ++++++++++++--------- 1 file changed, 58 insertions(+), 45 deletions(-)
bitbake/lib/toaster/toastergui/templates/landing.html +58 -45
@@ -6,53 +6,66 @@ {% block pagecontent %} - <div class="container-fluid"> - <div class="row-fluid"> - <!-- Empty - no data in database --> - <div class="hero-unit span12 well-transparent"> - <div class="row-fluid"> - <div class="span6"> - <h1> - This is Toaster - </h1> - <p>A web interface to <a href="http://www.openembedded.org">OpenEmbedded</a> and <a href="http://www.yoctoproject.org/tools-resources/projects/bitbake">BitBake</a>, the <a href="http://www.yoctoproject.org">Yocto Project</a> build system.</p> - - - {% if lvs_nos %} - <p class="hero-actions"> - <a class="btn btn-primary btn-large" href="{% url 'newproject' %}"> - To start building, create your first Toaster project - </a> - </p> - {% else %} - <div class="alert alert-info lead air"> - Toaster has no layer information. Without layer information, you cannot run builds. To generate layer information you can: - <ul> - <li> - <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a> - </li> - <li> - <a href="{% url 'newproject' %}">Create a project</a>, then import layers - </li> - </ul> - </div> - {% endif %} - - <ul class="unstyled"> - <li> - <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html">Read the Toaster manual</a> - </li> - <li> - <a href="https://wiki.yoctoproject.org/wiki/Contribute_to_Toaster">Contribute to Toaster</a> - </li> - </ul> + {% if BUILD_MODE %} + <!-- build mode --> + <div class="container-fluid"> + <div class="row-fluid"> + <div class="hero-unit span12 well-transparent"> + <div class="row-fluid"> + <div class="span6"> + <h1>This is Toaster</h1> + + <p>A web interface to <a href="http://www.openembedded.org">OpenEmbedded</a> and <a href="http://www.yoctoproject.org/tools-resources/projects/bitbake">BitBake</a>, the <a href="http://www.yoctoproject.org">Yocto Project</a> build system.</p> + + {% if lvs_nos %} + <p class="hero-actions"> + <a class="btn btn-primary btn-large" href="{% url 'newproject' %}"> + To start building, create your first Toaster project + </a> + </p> + {% else %} + <div class="alert alert-info lead air"> + Toaster has no layer information. Without layer information, you cannot run builds. To generate layer information you can: + <ul> + <li> + <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html#layer-source">Configure a layer source</a> + </li> + <li> + <a href="{% url 'newproject' %}">Create a project</a>, then import layers + </li> + </ul> + </div> + {% endif %} + + <ul class="unstyled"> + <li> + <a href="http://www.yoctoproject.org/docs/latest/toaster-manual/toaster-manual.html"> + Read the Toaster manual + </a> + </li> + + <li> + <a href="https://wiki.yoctoproject.org/wiki/Contribute_to_Toaster"> + Contribute to Toaster + </a> + </li> + </ul> + </div> + + <div class="span6"> + <img alt="Yocto Project" class="thumbnail" src="{% static 'img/toaster_bw.png' %}"/> + </div> + + </div> + </div> </div> - <div class="span6"> - <img alt="Yocto Project" class="thumbnail" src="{% static 'img/toaster_bw.png' %}"/> - </div> - </div> </div> - </div> + {% else %} + <!-- analysis mode --> + <div class="alert alert-info lead top-air"> + Toaster has not recorded any builds yet. Run a build from the command line to see it here. + </div> + {% endif %} {% endblock %}
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 5/6 toaster: Run tests in build mode
In reply to Elliot SmithNow that the UI content is conditional on whether BUILD_MODE is active, modify the existing tests so that they run in this mode by default.
[YOCTO #8514]
--- bitbake/lib/toaster/toastergui/tests.py | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/lib/toaster/toastergui/tests.py +6 -0
@@ -32,6 +32,8 @@ from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target from orm.models import CustomImageRecipe, ProjectVariable from orm.models import Branch +import toastermain + from toastergui.tables import SoftwareRecipesTable import json from bs4 import BeautifulSoup
@@ -40,6 +42,10 @@ import re PROJECT_NAME = "test project" CLI_BUILDS_PROJECT_NAME = 'Command line builds' +# by default, tests are run in build mode; to run in analysis mode, +# set this to False in individual test cases +toastermain.settings.BUILD_MODE = True + class ViewTests(TestCase): """Tests to verify view APIs."""
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
PATCH 6/6 toaster: Remove all navigation when not in build mode
In reply to Elliot SmithThe user is redirected to the all builds page or all projects page from the landing page, regardless of mode.
In build mode, this makes sense; but in analysis mode, we are restricting the view to just the cli builds project. This means that "all projects" and "all builds" only contains items relating to this one project.
Modify the landing page so it redirects to the project builds page for the cli builds project when not in build mode. Also remove navigation elements which are irrelevant when not in build mode.
[YOCTO #8514]
--- bitbake/lib/toaster/toastergui/templates/base.html | 4 ++-- bitbake/lib/toaster/toastergui/views.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/templates/base.html +2 -2
@@ -91,9 +91,9 @@ <i class="icon-info-sign" title="<strong>Toaster version information</strong>" data-content="<dl><dt>Branch</dt><dd>{{TOASTER_BRANCH}}</dd><dt>Revision</dt><dd>{{TOASTER_REVISION}}</dd></dl>"></i> {% endif %} </span> - {% if request.resolver_match.url_name != 'landing' and request.resolver_match.url_name != 'newproject' %} + {% if BUILD_MODE and request.resolver_match.url_name != 'landing' and request.resolver_match.url_name != 'newproject' %} <ul class="nav"> - <li {% if request.resolver_match.url_name == 'all-builds' %} + <li {% if request.resolver_match.url_name == 'all-builds' %} class="active" {% endif %}> <a href="{% url 'all-builds' %}">
bitbake/lib/toaster/toastergui/views.py +12 -2
@@ -71,14 +71,24 @@ class MimeTypeFinder(object): # all new sessions should come through the landing page; # determine in which mode we are running in, and redirect appropriately def landing(request): + # in build mode, we redirect to the command-line builds page + # if there are any builds for the default (cli builds) project + default_project = Project.objects.get_default_project() + default_project_builds = Build.objects.filter(project = default_project) + + if (not toastermain.settings.BUILD_MODE) and default_project_builds.count() > 0: + args = (default_project.id,) + return redirect(reverse('projectbuilds', args = args), permanent = False) + # we only redirect to projects page if there is a user-generated project + num_builds = Build.objects.all().count() user_projects = Project.objects.filter(is_default = False) has_user_project = user_projects.count() > 0 - if Build.objects.count() == 0 and has_user_project: + if num_builds == 0 and has_user_project: return redirect(reverse('all-projects'), permanent = False) - if Build.objects.all().count() > 0: + if num_builds > 0: return redirect(reverse('all-builds'), permanent = False) context = {'lvs_nos' : Layer_Version.objects.all().count()}
Signature · 14 lines
Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Quoted 11 lines · On 16/10/2015 15:32, "[email protected] on behalf of Elliot…
The UI currently shows all the navigation elements in both analysis and build modes, even if they are irrelevant or broken.
As a temporary measure (until we merge the two modes), hide most of the navigation and UI elements when in analysis mode, so the user only gets to see the command-line builds project.
Changes since
a9053ac0829eb01f6f002587854d01e47a78e6f0(poky master) are ingit://git.yoctoproject.org/poky-contrib,
elliot/toaster/hide_new_project_buttons-8514
This works for me. Thanks!
Belén
Quoted 43 lines
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/hi
de_new_project_buttons-8514Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8514
Elliot Smith (6):
toaster: AddBUILD_MODEflag to context
toaster: Show mode-appropriate landing page
toaster: Hide top bar buttons in analysis mode
toaster: Hide builds for non-cli projects in analysis mode
toaster: Run tests in build mode
toaster: Remove all navigation when not in build modebitbake/lib/toaster/toastergui/templates/base.html | 22 +++-- .../lib/toaster/toastergui/templates/landing.html | 103
++++++++++++---------bitbake/lib/toaster/toastergui/tests.py | 6 ++ bitbake/lib/toaster/toastergui/views.py | 36 ++++++- bitbake/lib/toaster/toastermain/settings.py | 6 +- bitbake/lib/toaster/toastermain/urls.py | 2 +- 6 files changed, 113 insertions(+), 62 deletions(-)--
Elliot Smith
Software Engineer
Intel OTC---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Signature · 4 lines
_______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
me too. even when I tried to trick it :)
Upstreamed and pushed to toaster-next
-b
Quoted 69 lines · Belen
Quoted 11 lines · On 16/10/2015 15:32, "[email protected] on behalf of Elliot…
The UI currently shows all the navigation elements in both analysis and build modes, even if they are irrelevant or broken.
As a temporary measure (until we merge the two modes), hide most of the navigation and UI elements when in analysis mode, so the user only gets to see the command-line builds project.
Changes since
a9053ac0829eb01f6f002587854d01e47a78e6f0(poky master) are ingit://git.yoctoproject.org/poky-contrib,
elliot/toaster/hide_new_project_buttons-8514This works for me. Thanks!
Belén
Quoted 38 lines
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/hi
de_new_project_buttons-8514Related bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8514
Elliot Smith (6):
toaster: AddBUILD_MODEflag to context
toaster: Show mode-appropriate landing page
toaster: Hide top bar buttons in analysis mode
toaster: Hide builds for non-cli projects in analysis mode
toaster: Run tests in build mode
toaster: Remove all navigation when not in build modebitbake/lib/toaster/toastergui/templates/base.html | 22 +++-- .../lib/toaster/toastergui/templates/landing.html | 103
++++++++++++---------bitbake/lib/toaster/toastergui/tests.py | 6 ++ bitbake/lib/toaster/toastergui/views.py | 36 ++++++- bitbake/lib/toaster/toastermain/settings.py | 6 +- bitbake/lib/toaster/toastermain/urls.py | 2 +- 6 files changed, 113 insertions(+), 62 deletions(-)--
Elliot Smith
Software Engineer
Intel OTC---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Quoted 5 lines
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster