diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/base.js')
| -rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/base.js | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 667c5dff6c..c4c96c80e6 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js | |||
| @@ -6,7 +6,7 @@ function basePageInit (ctx) { | |||
| 6 | /* Hide the button if we're on the project,newproject or importlyaer page | 6 | /* Hide the button if we're on the project,newproject or importlyaer page |
| 7 | * or if there are no projects yet defined | 7 | * or if there are no projects yet defined |
| 8 | */ | 8 | */ |
| 9 | if (ctx.numProjects === 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){ | 9 | if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){ |
| 10 | newBuildButton.hide(); | 10 | newBuildButton.hide(); |
| 11 | return; | 11 | return; |
| 12 | } | 12 | } |
| @@ -18,17 +18,18 @@ function basePageInit (ctx) { | |||
| 18 | 18 | ||
| 19 | newBuildButton.show().removeAttr("disabled"); | 19 | newBuildButton.show().removeAttr("disabled"); |
| 20 | 20 | ||
| 21 | _checkProjectBuildable(); | 21 | _checkProjectBuildable() |
| 22 | _setupNewBuildButton(); | 22 | _setupNewBuildButton(); |
| 23 | 23 | ||
| 24 | var currentProjectId = libtoaster.ctx.projectId; | ||
| 24 | 25 | ||
| 25 | function _checkProjectBuildable(){ | 26 | function _checkProjectBuildable(){ |
| 26 | if (ctx.projectId === undefined) | 27 | if (currentProjectId == undefined) |
| 27 | return; | 28 | return; |
| 28 | 29 | ||
| 29 | libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId, | 30 | libtoaster.getProjectInfo(ctx.projectInfoUrl, currentProjectId, |
| 30 | function(data){ | 31 | function(data){ |
| 31 | if (data.machine.name === undefined || data.layers.length === 0) { | 32 | if (data.machine.name == undefined || data.layers.length == 0) { |
| 32 | /* we can't build anything with out a machine and some layers */ | 33 | /* we can't build anything with out a machine and some layers */ |
| 33 | $("#new-build-button #targets-form").hide(); | 34 | $("#new-build-button #targets-form").hide(); |
| 34 | $("#new-build-button .alert").show(); | 35 | $("#new-build-button .alert").show(); |
| @@ -51,18 +52,18 @@ function basePageInit (ctx) { | |||
| 51 | /* If we don't have a current project then present the set project | 52 | /* If we don't have a current project then present the set project |
| 52 | * form. | 53 | * form. |
| 53 | */ | 54 | */ |
| 54 | if (ctx.projectId === undefined) { | 55 | if (currentProjectId == undefined) { |
| 55 | $('#change-project-form').show(); | 56 | $('#change-project-form').show(); |
| 56 | $('#project .icon-pencil').hide(); | 57 | $('#project .icon-pencil').hide(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | libtoaster.makeTypeahead(newBuildTargetInput, ctx.xhrDataTypeaheadUrl, { type : "targets", project_id: ctx.projectId }, function(item){ | 60 | libtoaster.makeTypeahead(newBuildTargetInput, { type : "targets", project_id: currentProjectId }, function(item){ |
| 60 | /* successfully selected a target */ | 61 | /* successfully selected a target */ |
| 61 | selectedTarget = item; | 62 | selectedTarget = item; |
| 62 | }); | 63 | }); |
| 63 | 64 | ||
| 64 | 65 | ||
| 65 | libtoaster.makeTypeahead(newBuildProjectInput, ctx.xhrDataTypeaheadUrl, { type : "projects" }, function(item){ | 66 | libtoaster.makeTypeahead(newBuildProjectInput, { type : "projects" }, function(item){ |
| 66 | /* successfully selected a project */ | 67 | /* successfully selected a project */ |
| 67 | newBuildProjectSaveBtn.removeAttr("disabled"); | 68 | newBuildProjectSaveBtn.removeAttr("disabled"); |
| 68 | selectedProject = item; | 69 | selectedProject = item; |
| @@ -72,13 +73,13 @@ function basePageInit (ctx) { | |||
| 72 | * the value that has been set by selecting a suggestion from the typeahead | 73 | * the value that has been set by selecting a suggestion from the typeahead |
| 73 | */ | 74 | */ |
| 74 | newBuildProjectInput.on('input', function(event) { | 75 | newBuildProjectInput.on('input', function(event) { |
| 75 | if (event.keyCode === 13) | 76 | if (event.keyCode == 13) |
| 76 | return; | 77 | return; |
| 77 | newBuildProjectSaveBtn.attr("disabled", "disabled"); | 78 | newBuildProjectSaveBtn.attr("disabled", "disabled"); |
| 78 | }); | 79 | }); |
| 79 | 80 | ||
| 80 | newBuildTargetInput.on('input', function() { | 81 | newBuildTargetInput.on('input', function() { |
| 81 | if ($(this).val().length === 0) | 82 | if ($(this).val().length == 0) |
| 82 | newBuildTargetBuildBtn.attr("disabled", "disabled"); | 83 | newBuildTargetBuildBtn.attr("disabled", "disabled"); |
| 83 | else | 84 | else |
| 84 | newBuildTargetBuildBtn.removeAttr("disabled"); | 85 | newBuildTargetBuildBtn.removeAttr("disabled"); |
| @@ -88,21 +89,22 @@ function basePageInit (ctx) { | |||
| 88 | if (!newBuildTargetInput.val()) | 89 | if (!newBuildTargetInput.val()) |
| 89 | return; | 90 | return; |
| 90 | 91 | ||
| 91 | var selectedTargetName = newBuildTargetInput.val(); | 92 | if (!selectedTarget) |
| 93 | selectedTarget = { name: newBuildTargetInput.val() }; | ||
| 92 | /* fire and forget */ | 94 | /* fire and forget */ |
| 93 | libtoaster.startABuild(ctx.projectBuildUrl, ctx.projectId, selectedTargetName, null, null); | 95 | libtoaster.startABuild(ctx.projectBuildUrl, currentProjectId, selectedTarget.name, null, null); |
| 94 | window.location.replace(ctx.projectPageUrl+ctx.projectId); | 96 | window.location.replace(ctx.projectBasePageUrl+currentProjectId); |
| 95 | }); | 97 | }); |
| 96 | 98 | ||
| 97 | newBuildProjectSaveBtn.click(function() { | 99 | newBuildProjectSaveBtn.click(function() { |
| 98 | ctx.projectId = selectedProject.id; | 100 | currentProjectId = selectedProject.id |
| 99 | /* Update the typeahead project_id paramater */ | 101 | /* Update the typeahead project_id paramater */ |
| 100 | _checkProjectBuildable(); | 102 | _checkProjectBuildable(); |
| 101 | newBuildTargetInput.data('typeahead').options.xhrParams.project_id = ctx.projectId; | 103 | newBuildTargetInput.data('typeahead').options.xhrParams.project_id = currentProjectId; |
| 102 | newBuildTargetInput.val(""); | 104 | newBuildTargetInput.val(""); |
| 103 | 105 | ||
| 104 | $("#new-build-button #project a").text(selectedProject.name).attr('href', ctx.projectPageUrl+ctx.projectId); | 106 | $("#new-build-button #project a").text(selectedProject.name).attr('href', ctx.projectBasePageUrl+currentProjectId); |
| 105 | $("#new-build-button .alert a").attr('href', ctx.projectPageUrl+ctx.projectId); | 107 | $("#new-build-button .alert a").attr('href', ctx.projectBasePageUrl+currentProjectId); |
| 106 | 108 | ||
| 107 | 109 | ||
| 108 | $("#change-project-form").slideUp({ 'complete' : function() { | 110 | $("#change-project-form").slideUp({ 'complete' : function() { |
| @@ -130,5 +132,6 @@ function basePageInit (ctx) { | |||
| 130 | $(".new-build").click (function(event) { | 132 | $(".new-build").click (function(event) { |
| 131 | event.stopPropagation(); | 133 | event.stopPropagation(); |
| 132 | }); | 134 | }); |
| 133 | } | 135 | }; |
| 136 | |||
| 134 | } | 137 | } |
