diff options
| -rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js index 71a28f7b2a..16e42b3d27 100644 --- a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js +++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | 2 | ||
| 3 | /* Used for the newcustomimage_modal actions */ | 3 | /* Used for the newcustomimage_modal actions */ |
| 4 | function newCustomImageModalInit(ctx){ | 4 | function newCustomImageModalInit(){ |
| 5 | 5 | ||
| 6 | var newCustomImgBtn = $("#create-new-custom-image-btn"); | 6 | var newCustomImgBtn = $("#create-new-custom-image-btn"); |
| 7 | var imgCustomModal = $("#new-custom-image-modal"); | 7 | var imgCustomModal = $("#new-custom-image-modal"); |
| @@ -13,36 +13,16 @@ function newCustomImageModalInit(ctx){ | |||
| 13 | var baseRecipeId = imgCustomModal.data('recipe'); | 13 | var baseRecipeId = imgCustomModal.data('recipe'); |
| 14 | 14 | ||
| 15 | if (name.length > 0) { | 15 | if (name.length > 0) { |
| 16 | createCustomRecipe(name, baseRecipeId); | ||
| 17 | imgCustomModal.modal('hide'); | 16 | imgCustomModal.modal('hide'); |
| 17 | libtoaster.createCustomRecipe(name, baseRecipeId, function(ret) { | ||
| 18 | if (ret.error !== "ok") { | ||
| 19 | console.warn(ret.error); | ||
| 20 | } else { | ||
| 21 | window.location.replace(ret.url + '?notify=new'); | ||
| 22 | } | ||
| 23 | }); | ||
| 18 | } else { | 24 | } else { |
| 19 | console.warn("TODO No name supplied"); | 25 | console.warn("TODO No name supplied"); |
| 20 | } | 26 | } |
| 21 | }); | 27 | }); |
| 22 | |||
| 23 | function createCustomRecipe(name, baseRecipeId){ | ||
| 24 | var data = { | ||
| 25 | 'name' : name, | ||
| 26 | 'project' : libtoaster.ctx.projectId, | ||
| 27 | 'base' : baseRecipeId, | ||
| 28 | }; | ||
| 29 | |||
| 30 | $.ajax({ | ||
| 31 | type: "POST", | ||
| 32 | url: ctx.xhrCustomRecipeUrl, | ||
| 33 | data: data, | ||
| 34 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
| 35 | success: function (ret) { | ||
| 36 | if (ret.error !== "ok") { | ||
| 37 | console.warn(ret.error); | ||
| 38 | } else { | ||
| 39 | window.location.replace(ret.url + '?notify=new'); | ||
| 40 | } | ||
| 41 | }, | ||
| 42 | error: function (ret) { | ||
| 43 | console.warn("Call failed"); | ||
| 44 | console.warn(ret); | ||
| 45 | } | ||
| 46 | }); | ||
| 47 | } | ||
| 48 | } | 28 | } |
