From ac5aba6cab06f3a8655eea1e368d28eb1025407e Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Mon, 26 Sep 2016 13:59:36 +0300 Subject: bitbake: toaster: customrecipe Add frontend feature to delete custom image recipe [YOCTO #8132] (Bitbake rev: 19aee3dd7fa290e12216f9a5cf25a8b2c8d80d20) Signed-off-by: Michael Wood Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- .../toaster/toastergui/static/js/customrecipe.js | 32 ++++++++++++++++++++ .../toaster/toastergui/templates/customrecipe.html | 35 +++++++++++++++++++--- 2 files changed, 63 insertions(+), 4 deletions(-) (limited to 'bitbake') 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 @@ } }); + + + + + -- cgit 1.2.3-korg