diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-10 15:27:52 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-12 00:01:50 +0100 |
commit | 379a030702c985c6e69831173f765a47dfeb8841 (patch) | |
tree | c003b83cc6a146c2ee0fa671c9a6488e33541d65 /bitbake | |
parent | 4f459fca798d8338e6a84fdd5ce73a9d395a67e8 (diff) | |
download | openembedded-core-contrib-379a030702c985c6e69831173f765a47dfeb8841.tar.gz |
bitbake: toastergui: prevent contamination of libtoaster context
This patch modifies the New Build button to use a local
copy of the default libtoaster project context in order
to prevent page contamination when a different project is
selected in the drop-down menu.
(Bitbake rev: 937665bd57dad04dd6bb46d06488b699f5c54d29)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/base.js | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 06d0676cbf..d079f23994 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js @@ -11,7 +11,8 @@ function basePageInit(ctx) { return; } - var currentProjectId = libtoaster.ctx.projectId; + var selectedProject = libtoaster.ctx; + var selectedTarget; /* Hide the change project icon when there is only one project */ if (ctx.numProjects === 1) { @@ -27,18 +28,16 @@ function basePageInit(ctx) { var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); - var selectedTarget; - _checkProjectBuildable(); _setupNewBuildButton(); function _checkProjectBuildable() { - if (libtoaster.ctx.projectId === undefined) { + if (selectedProject.projectId === undefined) { return; } - libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, + libtoaster.getProjectInfo(selectedProject.projectPageUrl, function (data) { if (data.machine.name === undefined || data.layers.length === 0) { /* we can't build anything with out a machine and some layers */ @@ -52,9 +51,14 @@ function basePageInit(ctx) { newBuildTargetInput.prop("disabled", false); newBuildTargetBuildBtn.prop("disabled", false); - libtoaster.makeTypeahead(newBuildTargetInput, libtoaster.ctx.projectTargetsUrl, { format: "json" }, function (item) { + libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { /* successfully selected a target */ - selectedTarget = item; + selectedProject.projectPageUrl = item.projectPageUrl; + selectedProject.projectName = item.name; + selectedProject.projectId = item.id; + selectedProject.projectBuildsUrl = item.projectBuildsUrl; + + }); } @@ -63,18 +67,17 @@ function basePageInit(ctx) { function _setupNewBuildButton() { /* Setup New build button */ - var selectedProject; /* If we don't have a current project then present the set project * form. */ - if (libtoaster.ctx.projectId === undefined) { + if (selectedProject.projectId === undefined) { $('#change-project-form').show(); $('#project .icon-pencil').hide(); } - libtoaster.makeTypeahead(newBuildProjectInput, libtoaster.ctx.projectsUrl, { format : "json" }, function (item) { + libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) { /* successfully selected a project */ newBuildProjectSaveBtn.removeAttr("disabled"); selectedProject = item; @@ -107,23 +110,18 @@ function basePageInit(ctx) { selectedTarget = { name: newBuildTargetInput.val() }; } /* fire and forget */ - libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); - window.location.replace(libtoaster.ctx.projectPageUrl); + libtoaster.startABuild(selectedProject.projectBuildsUrl, selectedProject.projectId, selectedTarget.name, null, null); + window.location.replace(selectedProject.projectPageUrl); }); newBuildProjectSaveBtn.click(function () { - libtoaster.ctx.projectId = selectedProject.pk; + selectedProject.projectId = selectedProject.pk; /* Update the typeahead project_id paramater */ _checkProjectBuildable(); /* we set the effective context of the page to the currently selected project */ /* TBD: do we override even if we already have a context project ?? */ /* TODO: replace global library context with references to the "selected" project */ - libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; - libtoaster.ctx.projectName = selectedProject.name; - libtoaster.ctx.projectId = selectedProject.id; - - ctx.projectBuildsUrl = selectedProject.projectBuildsUrl; /* we can create a target typeahead only after we have a project selected */ newBuildTargetInput.prop("disabled", false); @@ -137,8 +135,8 @@ function basePageInit(ctx) { newBuildTargetInput.val(""); /* set up new form aspect */ - $("#new-build-button #project a").text(selectedProject.name).attr('href', libtoaster.ctx.projectPageUrl); - $("#new-build-button .alert a").attr('href', libtoaster.ctx.projectPageUrl); + $("#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 () { |