From 1c9ce1ca73837ea77b8a1acbb31ad83cf13a2992 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Mon, 7 Dec 2015 18:44:37 +0000 Subject: bitbake: toaster: newcustomimage_modal use libtoaster method for new CustomRecipe Use libtoaster.createCustomRecipe rather than own implementation of this function. (Bitbake rev: 74fa98752b1cf1ad18d35ab6dd25fe7e409133c5) Signed-off-by: Michael Wood Signed-off-by: brian avery Signed-off-by: Richard Purdie --- .../toastergui/static/js/newcustomimage_modal.js | 36 +++++----------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'bitbake/lib') 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 @@ "use strict"; /* Used for the newcustomimage_modal actions */ -function newCustomImageModalInit(ctx){ +function newCustomImageModalInit(){ var newCustomImgBtn = $("#create-new-custom-image-btn"); var imgCustomModal = $("#new-custom-image-modal"); @@ -13,36 +13,16 @@ function newCustomImageModalInit(ctx){ var baseRecipeId = imgCustomModal.data('recipe'); if (name.length > 0) { - createCustomRecipe(name, baseRecipeId); imgCustomModal.modal('hide'); + libtoaster.createCustomRecipe(name, baseRecipeId, function(ret) { + if (ret.error !== "ok") { + console.warn(ret.error); + } else { + window.location.replace(ret.url + '?notify=new'); + } + }); } 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); - } - }); - } } -- cgit v1.2.3-54-g00ecf