Remove the new build input
cover Remove the new build input
Remove the new build input from the templates, and all supporting code which maintained its state.
The following changes since commit aa7690e182c9c307785e6e9679f3490583176421 (contrib/toaster-next):
toaster: builds pages Fix the download cooker log link (2015-11-10 17:04:19 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib elliot/submit/michaelw/toaster/remove-new-build-form
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/submit/michaelw/toaster/remove-new-build-form
Michael Wood (4):
toaster: orm Fix get_number_of_builds to count all apart from
IN_PROGRESS
toaster: projectpage Disable/Enable build input if we have 0 layers
toaster: projecttopbar Use the project in context to get num builds
toaster: Remove the new-build-input button widget
lib/toaster/orm/models.py | 9 +- lib/toaster/toastergui/static/js/base.js | 229 --------------------- lib/toaster/toastergui/static/js/projectpage.js | 13 +- lib/toaster/toastergui/static/js/projecttopbar.js | 81 ++++++++ lib/toaster/toastergui/templates/base.html | 133 +++--------- .../toastergui/templates/projecttopbar.html | 20 +- 6 files changed, 147 insertions(+), 338 deletions(-) delete mode 100644 bitbake/lib/toaster/toastergui/static/js/base.js create mode 100644 bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
--
1.9.3
---------------------------------------------------------------------
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/4 toaster: orm Fix get_number_of_builds to count all apart from IN_PROGRESS
From: Michael Wood <[email protected]>
The count of a project's builds should not include those which are currently in progress.
--- lib/toaster/orm/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
lib/toaster/orm/models.py +4 -5
@@ -130,13 +130,12 @@ class Project(models.Model): try: return self.projectvariable_set.get(name="MACHINE").value except (ProjectVariable.DoesNotExist,IndexError): - return( "None" ); + return None; def get_number_of_builds(self): - try: - return len(Build.objects.filter( project = self.id )) - except (Build.DoesNotExist,IndexError): - return( 0 ) + """Return the number of builds which have ended""" + + return self.build_set.filter(~Q(outcome=Build.IN_PROGRESS)).count() def get_last_build_id(self): try:
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- 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/4 toaster: projectpage Disable/Enable build input if we have 0 layers
From: Michael Wood <[email protected]>
If we've removed all the layers in the configuration, disable the build button and build input.
--- lib/toaster/toastergui/static/js/projectpage.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
lib/toaster/toastergui/static/js/projectpage.js +10 -3
@@ -175,11 +175,18 @@ function projectPageInit(ctx) { function updateLayersCount(){ var count = $("#layers-in-project-list").children().length; + var noLayerMsg = $("#no-layers-in-project"); + var buildInput = $("#build-input"); - if (count === 0) + + if (count === 0) { + noLayerMsg.fadeIn(); $("#no-layers-in-project").fadeIn(); - else - $("#no-layers-in-project").hide(); + buildInput.attr("disabled", "disabled"); + } else { + noLayerMsg.hide(); + buildInput.removeAttr("disabled"); + } $("#project-layers-count").text(count);
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- 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/4 toaster: projecttopbar Use the project in context to get num builds
In reply to Elliot SmithFrom: Michael Wood <[email protected]>
Use the project in the template context rather than ajax request to get the number of ended builds.
--- lib/toaster/toastergui/templates/projecttopbar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/toaster/toastergui/templates/projecttopbar.html +1 -1
@@ -28,7 +28,7 @@ <ul class="nav nav-pills"> <li> <a href="{% url 'projectbuilds' project.id %}"> - Builds (<span class="total-builds">0</span>) + Builds ({{project.get_number_of_builds}}) </a> </li> <li id="topbar-configuration-tab">
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- 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/4 toaster: Remove the new-build-input button widget
In reply to Elliot SmithFrom: Michael Wood <[email protected]>
The button required a lot of state maintenance to make sure it showed up when the project was configured properly, showed correctly according to the projects known to Toaster, displayed correctly according to the mode Toaster was in, and was able to be used to change the current project.
--- lib/toaster/toastergui/static/js/base.js | 229 --------------------- lib/toaster/toastergui/static/js/projecttopbar.js | 81 ++++++++ lib/toaster/toastergui/templates/base.html | 133 +++--------- .../toastergui/templates/projecttopbar.html | 18 ++ 4 files changed, 132 insertions(+), 329 deletions(-) delete mode 100644 bitbake/lib/toaster/toastergui/static/js/base.js create mode 100644 bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
lib/toaster/toastergui/static/js/base.js deleted +0 -229
@@ -1,229 +0,0 @@ -'use strict'; - -function basePageInit(ctx) { - - var newBuildButton = $("#new-build-button"); - var newBuildTargetInput; - var newBuildTargetBuildBtn; - var projectNameForm = $("#project-name-change-form"); - var projectNameContainer = $("#project-name-container"); - var projectName = $("#project-name"); - var projectNameFormToggle = $("#project-change-form-toggle"); - var projectNameChangeCancel = $("#project-name-change-cancel"); - - /* initially the current project is used unless overridden by the new build - * button in top right nav - */ - var selectedProject = libtoaster.ctx; - - var selectedTarget; - - var newBuildProjectInput = $("#new-build-button #project-name-input"); - var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); - - /* Project name change functionality */ - projectNameFormToggle.click(function(e){ - e.preventDefault(); - projectNameContainer.hide(); - projectNameForm.fadeIn(); - }); - - projectNameChangeCancel.click(function(e){ - e.preventDefault(); - projectNameForm.hide(); - projectNameContainer.fadeIn(); - }); - - $("#project-name-change-btn").click(function(e){ - var newProjectName = $("#project-name-change-input").val(); - - libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ - projectName.html(newProjectName); - libtoaster.ctx.projectName = newProjectName; - projectNameChangeCancel.click(); - }); - }); - - _checkProjectBuildable(); - - $("#project-topbar .nav li a").each(function(){ - if (window.location.pathname === $(this).attr('href')) - $(this).parent().addClass('active'); - else - $(this).parent().removeClass('active'); - }); - - if ($(".total-builds").length !== 0){ - libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(prjInfo){ - if (prjInfo.completedbuilds) - $(".total-builds").text(prjInfo.completedbuilds.length); - }); - } - - /* Hide the button if we're on the project,newproject or importlyaer page - * or if there are no projects yet defined - * only show if there isn't already a build-target-input already - */ - if (ctx.numProjects > 0 && - ctx.currentUrl.search('newproject') < 0 && - $(".build-target-input").length === 1) { - - newBuildTargetInput = $("#new-build-button .build-target-input"); - newBuildTargetBuildBtn = $("#new-build-button").find(".build-button"); - - _setupNewBuildButton(); - newBuildButton.show(); - } else if ($(".build-target-input").length > 0) { - newBuildTargetInput = $("#project-topbar .build-target-input"); - newBuildTargetBuildBtn = $("#project-topbar .build-button"); - } else { - return; - } - - /* Hide the change project icon when there is only one project */ - if (ctx.numProjects === 1) { - $('#project .icon-pencil').hide(); - } - - /* If we have a project setup the typeahead */ - if (selectedProject.recipesTypeAheadUrl){ - libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) { - selectedTarget = item; - newBuildTargetBuildBtn.removeAttr("disabled"); - }); - } - - newBuildTargetInput.on('input', function () { - if ($(this).val().length === 0) { - newBuildTargetBuildBtn.attr("disabled", "disabled"); - } else { - newBuildTargetBuildBtn.removeAttr("disabled"); - } - }); - - newBuildTargetBuildBtn.click(function (e) { - e.preventDefault(); - - if (!newBuildTargetInput.val()) { - return; - } - - /* We use the value of the input field so as to maintain any command also - * added e.g. core-image-minimal:clean - */ - selectedTarget = { name: newBuildTargetInput.val() }; - - /* Fire off the build */ - libtoaster.startABuild(selectedProject.projectBuildsUrl, - selectedProject.projectId, selectedTarget.name, function(){ - window.location.replace(selectedProject.projectBuildsUrl); - }, null); - }); - - function _checkProjectBuildable() { - if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) { - return; - } - - libtoaster.getProjectInfo(selectedProject.projectPageUrl, - function (data) { - if (data.machine === null || data.machine.name === undefined || data.layers.length === 0) { - /* we can't build anything without a machine and some layers */ - $("#new-build-button #targets-form").hide(); - $("#new-build-button .alert").show(); - } else { - $("#new-build-button #targets-form").show(); - $("#new-build-button .alert").hide(); - - /* we can build this project; enable input fields */ - newBuildTargetInput.removeAttr("disabled"); - } - }, null); - } - - /* Setup New build button in the top nav bar */ - function _setupNewBuildButton() { - - /* If we don't have a current project then present the set project - * form. - */ - if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) { - $('#change-project-form').show(); - $('#project .icon-pencil').hide(); - } - - libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsTypeAheadUrl, { format : "json" }, function (item) { - /* successfully selected a project */ - newBuildProjectSaveBtn.removeAttr("disabled"); - selectedProject = item; - }); - - /* Any typing in the input apart from enter key is going to invalidate - * the value that has been set by selecting a suggestion from the typeahead - */ - newBuildProjectInput.on('input', function (event) { - if (event.keyCode === 13) { - return; - } - newBuildProjectSaveBtn.attr("disabled", "disabled"); - }); - - - newBuildProjectSaveBtn.click(function () { - selectedProject.projectId = selectedProject.id; - /* Update the typeahead project_id paramater */ - _checkProjectBuildable(); - - newBuildTargetInput.removeAttr("disabled"); - - /* We've got a new project so now we need to update the - * target urls. We can get this from the new project's info - */ - $.getJSON(selectedProject.projectPageUrl, { format: "json" }, - function(projectInfo){ - /* Update the typeahead to use the new selectedProject */ - selectedProject = projectInfo; - - libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.recipesTypeAheadUrl, { format: "json" }, function (item) { - /* successfully selected a target */ - selectedTarget = item; - newBuildTargetBuildBtn.removeAttr("disabled"); - }); - - }); - newBuildTargetInput.val(""); - - /* set up new form aspect */ - $("#new-build-button #project a").text(selectedProject.name).attr('href', selectedProject.projectPageUrl); - $("#new-build-button .alert a").attr('href', selectedProject.projectPageUrl); - $("#project .icon-pencil").show(); - - $("#change-project-form").slideUp({ 'complete' : function () { - $("#new-build-button #project").show(); - }}); - }); - - $('#new-build-button #project .icon-pencil').click(function () { - newBuildProjectSaveBtn.attr("disabled", "disabled"); - newBuildProjectInput.val($("#new-build-button #project a").text()); - $("#cancel-change-project").show(); - $(this).parent().hide(); - $("#change-project-form").slideDown(); - }); - - $("#new-build-button #cancel-change-project").click(function () { - $("#change-project-form").hide(function () { - $('#new-build-button #project').show(); - }); - - newBuildProjectInput.val(""); - newBuildProjectSaveBtn.attr("disabled", "disabled"); - }); - - /* Keep the dropdown open even unless we click outside the dropdown area */ - $(".new-build").click (function (event) { - event.stopPropagation(); - }); - }; - -}
lib/toaster/toastergui/static/js/projecttopbar.js new file +81 -0
81 lines not on this page · raw message
lib/toaster/toastergui/templates/base.html +33 -100
164 lines not on this page · raw message
lib/toaster/toastergui/templates/projecttopbar.html +18 -0
@@ -1,3 +1,21 @@ +{% load static %} +<script src="{% static 'js/projecttopbar.js' %}"></script> +<script> + $(document).ready(function () { + var ctx = { + numProjectLayers : {{project.get_project_layer_versions.count}}, + machine : "{{project.get_current_machine_name|default_if_none:""}}", + } + + try { + projectTopBarInit(ctx); + } catch (e) { + document.write("Sorry, An error has occurred loading this page"); + console.warn(e); + } + }); +</script> + <div class="alert alert-success lead" id="project-created-notification" style="margin-top:15px; display:none"> <button type="button" class="close" data-dismiss="alert">×</button> Your project <strong>{{project.name}}</strong> has been created. You can now <a href="{% url 'projectmachines' project.id %}">select your target machine</a> and <a href="{% url 'projectimagerecipes' project.id %}">choose image recipes</a> to build.
Signature · 12 lines
1.9.3 --------------------------------------------------------------------- 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.