diff options
Diffstat (limited to 'yocto-poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js')
-rw-r--r-- | yocto-poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/yocto-poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js b/yocto-poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js new file mode 100644 index 000000000..935b21ede --- /dev/null +++ b/yocto-poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage.js @@ -0,0 +1,49 @@ +"use strict"; + +function newCustomImagePageInit(ctx){ + + var newCustomImgBtn = $("#create-new-custom-image-btn"); + var imgCustomModal = $("#new-custom-image-modal"); + + newCustomImgBtn.click(function(e){ + e.preventDefault(); + + var name = imgCustomModal.find('input').val(); + var baseRecipeId = imgCustomModal.data('recipe'); + + if (name.length > 0) { + createCustomRecipe(name, baseRecipeId); + imgCustomModal.modal('hide'); + } else { + console.warn("TODO No name supplied"); + } + }); + + function createCustomRecipe(name, baseRecipeId){ + var data = { + 'name' : name, + 'project' : libtoaster.ctx.projectId, + 'base' : baseRecipeId, + }; + + $.ajax({ + type: "POST", + url: ctx.xhrCustomRecipeUrl, + data: data, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function (ret) { + if (ret.error !== "ok") { + console.warn(ret.error); + } else { + window.location.replace(ret.url + '?notify=new'); + } + }, + error: function (ret) { + console.warn("Call failed"); + console.warn(ret); + } + }); + } + + +} |