diff options
| -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) { | |||
| 11 | return; | 11 | return; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | var currentProjectId = libtoaster.ctx.projectId; | 14 | var selectedProject = libtoaster.ctx; |
| 15 | var selectedTarget; | ||
| 15 | 16 | ||
| 16 | /* Hide the change project icon when there is only one project */ | 17 | /* Hide the change project icon when there is only one project */ |
| 17 | if (ctx.numProjects === 1) { | 18 | if (ctx.numProjects === 1) { |
| @@ -27,18 +28,16 @@ function basePageInit(ctx) { | |||
| 27 | var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); | 28 | var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); |
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | var selectedTarget; | ||
| 31 | |||
| 32 | _checkProjectBuildable(); | 31 | _checkProjectBuildable(); |
| 33 | _setupNewBuildButton(); | 32 | _setupNewBuildButton(); |
| 34 | 33 | ||
| 35 | 34 | ||
| 36 | function _checkProjectBuildable() { | 35 | function _checkProjectBuildable() { |
| 37 | if (libtoaster.ctx.projectId === undefined) { | 36 | if (selectedProject.projectId === undefined) { |
| 38 | return; | 37 | return; |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, | 40 | libtoaster.getProjectInfo(selectedProject.projectPageUrl, |
| 42 | function (data) { | 41 | function (data) { |
| 43 | if (data.machine.name === undefined || data.layers.length === 0) { | 42 | if (data.machine.name === undefined || data.layers.length === 0) { |
| 44 | /* we can't build anything with out a machine and some layers */ | 43 | /* we can't build anything with out a machine and some layers */ |
| @@ -52,9 +51,14 @@ function basePageInit(ctx) { | |||
| 52 | newBuildTargetInput.prop("disabled", false); | 51 | newBuildTargetInput.prop("disabled", false); |
| 53 | newBuildTargetBuildBtn.prop("disabled", false); | 52 | newBuildTargetBuildBtn.prop("disabled", false); |
| 54 | 53 | ||
| 55 | libtoaster.makeTypeahead(newBuildTargetInput, libtoaster.ctx.projectTargetsUrl, { format: "json" }, function (item) { | 54 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { |
| 56 | /* successfully selected a target */ | 55 | /* successfully selected a target */ |
| 57 | selectedTarget = item; | 56 | selectedProject.projectPageUrl = item.projectPageUrl; |
| 57 | selectedProject.projectName = item.name; | ||
| 58 | selectedProject.projectId = item.id; | ||
| 59 | selectedProject.projectBuildsUrl = item.projectBuildsUrl; | ||
| 60 | |||
| 61 | |||
| 58 | }); | 62 | }); |
| 59 | 63 | ||
| 60 | } | 64 | } |
| @@ -63,18 +67,17 @@ function basePageInit(ctx) { | |||
| 63 | 67 | ||
| 64 | function _setupNewBuildButton() { | 68 | function _setupNewBuildButton() { |
| 65 | /* Setup New build button */ | 69 | /* Setup New build button */ |
| 66 | var selectedProject; | ||
| 67 | 70 | ||
| 68 | /* If we don't have a current project then present the set project | 71 | /* If we don't have a current project then present the set project |
| 69 | * form. | 72 | * form. |
| 70 | */ | 73 | */ |
| 71 | if (libtoaster.ctx.projectId === undefined) { | 74 | if (selectedProject.projectId === undefined) { |
| 72 | $('#change-project-form').show(); | 75 | $('#change-project-form').show(); |
| 73 | $('#project .icon-pencil').hide(); | 76 | $('#project .icon-pencil').hide(); |
| 74 | } | 77 | } |
| 75 | 78 | ||
| 76 | 79 | ||
| 77 | libtoaster.makeTypeahead(newBuildProjectInput, libtoaster.ctx.projectsUrl, { format : "json" }, function (item) { | 80 | libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) { |
| 78 | /* successfully selected a project */ | 81 | /* successfully selected a project */ |
| 79 | newBuildProjectSaveBtn.removeAttr("disabled"); | 82 | newBuildProjectSaveBtn.removeAttr("disabled"); |
| 80 | selectedProject = item; | 83 | selectedProject = item; |
| @@ -107,23 +110,18 @@ function basePageInit(ctx) { | |||
| 107 | selectedTarget = { name: newBuildTargetInput.val() }; | 110 | selectedTarget = { name: newBuildTargetInput.val() }; |
| 108 | } | 111 | } |
| 109 | /* fire and forget */ | 112 | /* fire and forget */ |
| 110 | libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); | 113 | libtoaster.startABuild(selectedProject.projectBuildsUrl, selectedProject.projectId, selectedTarget.name, null, null); |
| 111 | window.location.replace(libtoaster.ctx.projectPageUrl); | 114 | window.location.replace(selectedProject.projectPageUrl); |
| 112 | }); | 115 | }); |
| 113 | 116 | ||
| 114 | newBuildProjectSaveBtn.click(function () { | 117 | newBuildProjectSaveBtn.click(function () { |
| 115 | libtoaster.ctx.projectId = selectedProject.pk; | 118 | selectedProject.projectId = selectedProject.pk; |
| 116 | /* Update the typeahead project_id paramater */ | 119 | /* Update the typeahead project_id paramater */ |
| 117 | _checkProjectBuildable(); | 120 | _checkProjectBuildable(); |
| 118 | 121 | ||
| 119 | /* we set the effective context of the page to the currently selected project */ | 122 | /* we set the effective context of the page to the currently selected project */ |
| 120 | /* TBD: do we override even if we already have a context project ?? */ | 123 | /* TBD: do we override even if we already have a context project ?? */ |
| 121 | /* TODO: replace global library context with references to the "selected" project */ | 124 | /* TODO: replace global library context with references to the "selected" project */ |
| 122 | libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; | ||
| 123 | libtoaster.ctx.projectName = selectedProject.name; | ||
| 124 | libtoaster.ctx.projectId = selectedProject.id; | ||
| 125 | |||
| 126 | ctx.projectBuildsUrl = selectedProject.projectBuildsUrl; | ||
| 127 | 125 | ||
| 128 | /* we can create a target typeahead only after we have a project selected */ | 126 | /* we can create a target typeahead only after we have a project selected */ |
| 129 | newBuildTargetInput.prop("disabled", false); | 127 | newBuildTargetInput.prop("disabled", false); |
| @@ -137,8 +135,8 @@ function basePageInit(ctx) { | |||
| 137 | newBuildTargetInput.val(""); | 135 | newBuildTargetInput.val(""); |
| 138 | 136 | ||
| 139 | /* set up new form aspect */ | 137 | /* set up new form aspect */ |
| 140 | $("#new-build-button #project a").text(selectedProject.name).attr('href', libtoaster.ctx.projectPageUrl); | 138 | $("#new-build-button #project a").text(selectedProject.name).attr('href', selectedProject.projectPageUrl); |
| 141 | $("#new-build-button .alert a").attr('href', libtoaster.ctx.projectPageUrl); | 139 | $("#new-build-button .alert a").attr('href', selectedProject.projectPageUrl); |
| 142 | $("#project .icon-pencil").show(); | 140 | $("#project .icon-pencil").show(); |
| 143 | 141 | ||
| 144 | $("#change-project-form").slideUp({ 'complete' : function () { | 142 | $("#change-project-form").slideUp({ 'complete' : function () { |
