diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-11-04 15:44:00 +0000 |
---|---|---|
committer | Michael Wood <michael.g.wood@intel.com> | 2016-02-08 17:35:46 +0000 |
commit | c310bc6bab1a33124906dd57b3c63462a773ff25 (patch) | |
tree | a2846a8eefc6f5764dd474b795ff2611425d532e /lib/toaster/toastergui/static/js/newcustomimage_modal.js | |
parent | a656756a9255ec5882686ce9563d17f2eb3136e3 (diff) | |
download | openembedded-core-contrib-c310bc6bab1a33124906dd57b3c63462a773ff25.tar.gz |
toaster: newcustomimage Move modal dialog out of newcustomimage template
Move the modal template and JS out of the newcustomimage page so that it
can also be used by the image details page.
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Diffstat (limited to 'lib/toaster/toastergui/static/js/newcustomimage_modal.js')
-rw-r--r-- | lib/toaster/toastergui/static/js/newcustomimage_modal.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/lib/toaster/toastergui/static/js/newcustomimage_modal.js new file mode 100644 index 0000000000..71a28f7b2a --- /dev/null +++ b/lib/toaster/toastergui/static/js/newcustomimage_modal.js @@ -0,0 +1,48 @@ +"use strict"; + +/* Used for the newcustomimage_modal actions */ +function newCustomImageModalInit(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); + } + }); + } +} |