From 8813726f1d5ea1d78fced7fe52abdf826e529e62 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 6 Jul 2016 18:22:38 +0100 Subject: [PATCH] bitbake: toaster: add Layer delete front end feature to layerdetails Add the front end feature to delete a layer from the layer details page. [YOCO #9184] (Bitbake rev: 91815229f60eb9deba7d299f05c69b52ff1df59c) Signed-off-by: Michael Wood Signed-off-by: Elliot Smith Signed-off-by: Richard Purdie --- .../toastergui/static/js/layerdetails.js | 20 +++++++++++++++++++ .../toastergui/static/js/projectpage.js | 18 +++++++++++++++++ .../toastergui/templates/layerdetails.html | 20 ++++++++++++++++++- bitbake/lib/toaster/toastergui/urls.py | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index a56087b738d..683486e53bd 100644 --- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js +++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js @@ -397,6 +397,26 @@ function layerDetailsPageInit (ctx) { $(this).parents("form").submit(); }); + $("#layer-delete-confirmed").click(function(){ + $.cookie("layer-deleted", ctx.layerVersion.name, { path: '/'}); + + $.ajax({ + type: "DELETE", + url: ctx.xhrUpdateLayerUrl, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function(data) { + if (data.error != "ok") { + console.warn(data.error); + } else { + window.location = data.redirect + "?notify=layer-deleted"; + } + }, + error: function(data) { + console.warn("Call failed"); + console.warn(data); + } + }); + }); layerDepsList.find(".glyphicon-trash").click(layerDepRemoveClick); layerDepsList.find("a").tooltip(); diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js index 6d92490ba2f..df79849e37f 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js @@ -58,12 +58,30 @@ function projectPageInit(ctx) { case 'layer-imported': layerImportedNotification(); break; + case 'layer-deleted': + layerDeletedNotification(); default: break; } } })(); + /* Layer deleted notification */ + function layerDeletedNotification(){ + var layer = $.cookie("layer-deleted"); + + if (!layer) + return; + + var message = "You have deleted 1 layer from your "; + message += "project: " + layer + ""; + + libtoaster.showChangeNotification(message); + + $.removeCookie("layer-deleted", { path: "/"}); + } + + /* Layer imported notification */ function layerImportedNotification(){ var imported = $.cookie("layer-imported-alert"); diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html index 143ec25dd70..4b51d1a39c7 100644 --- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html +++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html @@ -6,6 +6,20 @@ {% block title %} {{layerversion.layer.name}} - {{project.name}} - Toaster {% endblock %} {% block pagecontent %} + +
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py index 15b1063c595..1c0ccbb2e13 100644 --- a/bitbake/lib/toaster/toastergui/urls.py +++ b/bitbake/lib/toaster/toastergui/urls.py @@ -191,7 +191,7 @@ urlpatterns = patterns('toastergui.views', url(r'^xhr_importlayer/$', 'xhr_importlayer', name='xhr_importlayer'), - url(r'^xhr_layer/(?P\d+)$', + url(r'^xhr_layer/(?P\d+)/(?P\d+)$', api.XhrLayer.as_view(), name='xhr_layer'), -- 2.47.3