diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js index 505a81ce60..9ea9602881 100644 --- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js +++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js @@ -281,4 +281,36 @@ function customRecipePageInit(ctx) { window.location.replace(libtoaster.ctx.projectBuildsUrl); }); }); + + $("#delete-custom-recipe-confirmed").click(function(e){ + e.preventDefault(); + libtoaster.disableAjaxLoadingTimer(); + $(this).find('[data-role="submit-state"]').hide(); + $(this).find('[data-role="loading-state"]').show(); + $(this).attr("disabled", "disabled"); + + $.ajax({ + type: 'DELETE', + url: ctx.recipe.xhrCustomRecipeUrl, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function (data) { + if (data.error !== "ok") { + console.warn(data.error); + } else { + var msg = $('You have deleted 1 custom image: '); + msg.find("#deleted-custom-image-name").text(ctx.recipe.name); + + libtoaster.setNotification("custom-image-recipe-deleted", + msg.html()); + + window.location.replace(data.gotoUrl); + } + }, + error: function (data) { + console.warn(data); + } + }); + }); + + } diff --git a/bitbake/lib/toaster/toastergui/templates/customrecipe.html b/bitbake/lib/toaster/toastergui/templates/customrecipe.html index 8b61fb7f7c..945fc97977 100644 --- a/bitbake/lib/toaster/toastergui/templates/customrecipe.html +++ b/bitbake/lib/toaster/toastergui/templates/customrecipe.html @@ -28,6 +28,7 @@ includedPackagesCount: {{recipe.includes_set.count}}, baseRecipeId: {{recipe.base_recipe.pk}}, xhrPackageListUrl: "{% url 'xhr_customrecipe_packages' recipe.pk %}", + xhrCustomRecipeUrl: "{% url 'xhr_customrecipe_id' recipe.pk %}", } }; @@ -39,6 +40,32 @@ } }); + + + + +