Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 80C3BE00B2C; Tue, 10 Nov 2015 04:39:29 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 88EA1E00B21 for ; Tue, 10 Nov 2015 04:39:24 -0800 (PST) Received: by wmww144 with SMTP id w144so115780946wmw.1 for ; Tue, 10 Nov 2015 04:39:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=GF6hbqsnEpyPTQ54h/dFEKSnPe2xZmWW+in9kxZN5OE=; b=0to3Tv9vew0n3fTt8qRl6X59MTc7S9UEKyDOcXnW+vfOC8GQ3T4CkC3DTT/Jx/KyO9 OtOvN9r04/XG/YN1PXH2BkuYHlew6phNVdQIX2qG2xQYr1sX7ZuAyVN7diDSstVRvT7v k6Mft6RZaj1cguBrfZ03ey6eLZYJLy8hVaAmf0Y9udphbPUPrGMSgZzWDJ0uxE2vkjzJ JRMsvhmyvEsIoy36539+stxvcigl3xz0HdQAW+wdqqpPYn803hBDwF9g4euOlhE1STX8 EW4iHMtr1z4P4DK7TouxveUyrr1ZxVIjM4cXXkSVEOT6b4L71DFPAB+ygtz1/Sd6I7jo jiWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=GF6hbqsnEpyPTQ54h/dFEKSnPe2xZmWW+in9kxZN5OE=; b=IEAHqz2UwM2q+z6vvyZ+4n6Jn3mdEipnUH1SAvnphVjNyqCg8tH9UmytbfVSCSdCSC RsfqhnJuNnBW0b+4Z11l94rexP84GWM/85DmAiBDVAsQ8p8WCybYvgs1Fi6qeFL3C1Bk 0+3SrTX1XKdknDzQ2nzaWFJD+9GWTwuRl3+ailg4w11yTGPHV1P6yr2YIaUr4SeL1x5R YkZs2PzOy8uLbePkyBo9vL1GxZ9Y3IWnMyteFaNi0lgYhS8wwcH1gZVwKlzdei+5u1xY p8nKMOJ0KePrttJ1Fd0FwdbYvrgGcha4CHCQhb2xo15xJnNPuzeCsXxm9NaXIrGUUC7Q VuOg== X-Gm-Message-State: ALoCoQmuOnlF7Nn2HjKoergn7t7zfQEHJPoYyBjGfdzCh64IWAILPmwuKK/KqWtc0U9WMo28434u X-Received: by 10.28.147.148 with SMTP id v142mr34607954wmd.62.1447159163438; Tue, 10 Nov 2015 04:39:23 -0800 (PST) Received: from dorado.Home ([90.199.203.61]) by smtp.gmail.com with ESMTPSA id os9sm3320075wjc.26.2015.11.10.04.39.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Nov 2015 04:39:22 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 10 Nov 2015 12:39:06 +0000 Message-Id: <1447159146-18082-4-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1447159146-18082-1-git-send-email-michael.g.wood@intel.com> References: <1447159146-18082-1-git-send-email-michael.g.wood@intel.com> MIME-Version: 1.0 Subject: [PATCH 4/4] toaster: Remove new-build-input form X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2015 12:39:29 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the new-build-input button widget. The button isn't particularly useful and requires a lot of state maintenance to make sure it showed up when the project was configured properly or if there were any projects and what mode toaster was in and then to be able to change project using it. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/static/js/base.js | 229 --------------------- .../toaster/toastergui/static/js/projecttopbar.js | 81 ++++++++ bitbake/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 diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js deleted file mode 100644 index ed22a4e..0000000 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ /dev/null @@ -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(); - }); - }; - -} diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js new file mode 100644 index 0000000..b6ad380 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js @@ -0,0 +1,81 @@ +'use strict'; + +function projectTopBarInit(ctx) { + + 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"); + var newBuildTargetInput = $("#build-input"); + var newBuildTargetBuildBtn = $("#build-button"); + var selectedTarget; + + /* 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(){ + var newProjectName = $("#project-name-change-input").val(); + + libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ + projectName.html(newProjectName); + libtoaster.ctx.projectName = newProjectName; + projectNameChangeCancel.click(); + }); + }); + + /* Nav bar activate state switcher */ + $("#project-topbar .nav li a").each(function(){ + if (window.location.pathname === $(this).attr('href')) + $(this).parent().addClass('active'); + else + $(this).parent().removeClass('active'); + }); + + /* Recipe build input functionality */ + if (ctx.numProjectLayers > 0 && ctx.machine){ + newBuildTargetInput.removeAttr("disabled"); + } + + libtoaster.makeTypeahead(newBuildTargetInput, + libtoaster.ctx.recipesTypeAheadUrl, {}, 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 and because we can build targets + * that toaster doesn't yet know about + */ + selectedTarget = { name: newBuildTargetInput.val() }; + + /* Fire off the build */ + libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, + null, selectedTarget.name, function(){ + window.location.replace(libtoaster.ctx.projectBuildsUrl); + }, null); + }); +} diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index 11ac2a0..e0b15ce 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -3,15 +3,15 @@ {% load projecttags %} {% load project_url_tag %} - - - {% block title %} Toaster {% endblock %} - - - - - - + + + {% block title %} Toaster {% endblock %} + + + + + + @@ -40,7 +40,6 @@ projectId : {{project.id}}, projectPageUrl : {% url 'project' project.id as purl %}{{purl|json}}, projectName : {{project.name|json}}, - projectIsDefault: {% if project.is_default %}true{% else %}false{% endif %}, recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}}, layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}}, machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}}, @@ -51,37 +50,24 @@ projectId : undefined, projectPageUrl : undefined, projectName : undefined, - projectIsDefault: false, {% endif %} }; - - + {% block extraheadcontent %} + {% endblock %} + -{% block extraheadcontent %} -{% endblock %} - + - - - {% csrf_token %} - + {% csrf_token %} + - + - - -
-
-{% block pagecontent %} -{% endblock %} -
-
- +
+
+ {% block pagecontent %} + {% endblock %} +
+
+ - diff --git a/bitbake/lib/toaster/toastergui/templates/projecttopbar.html b/bitbake/lib/toaster/toastergui/templates/projecttopbar.html index d8f7cbd..8b44acc 100644 --- a/bitbake/lib/toaster/toastergui/templates/projecttopbar.html +++ b/bitbake/lib/toaster/toastergui/templates/projecttopbar.html @@ -1,3 +1,21 @@ +{% load static %} + + +