diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index e2bc1ab607..15830dded5 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -78,8 +78,14 @@ function importLayerPageInit (ctx) { }); importAndAddBtn.click(function(){ + /* This is a list of the names from layerDeps for the layer deps + * modal dialog body + */ + var depNames = []; + /* arrray of all layer dep ids includes parent and child deps */ var allDeps = []; + /* temporary object to use to do a reduce on the dependencies for each * layer dependency added */ @@ -96,6 +102,7 @@ function importLayerPageInit (ctx) { depDeps[layer.id] = layer; } } + depNames.push(layerDeps[key].name); allDeps.push(layerDeps[key].id); } @@ -106,10 +113,14 @@ function importLayerPageInit (ctx) { if (depDepsArray.length > 0) { var layer = { name: layerNameInput.val(), url: "#", id: -1 }; - show_layer_deps_modal(ctx.projectId, layer, depDepsArray, function(selected){ + var title = "Layer"; + var body = ""+layer.name+"'s dependencies ("+ + depNames.join(", ")+") require some layers that are not added to your project. Select the ones you want to add:

"; + + show_layer_deps_modal(ctx.projectId, layer, depDepsArray, title, body, false, function(selected){ /* Add the accepted dependencies to the allDeps array */ if (selected.length > 0){ - allDeps.concat (selected); + allDeps = allDeps.concat (selected); } import_and_add (); }); @@ -141,8 +152,10 @@ function importLayerPageInit (ctx) { show_error_message(data, layerData); console.log(data.error); } else { + layerData.layersAdded = data.layers_added; /* Success layer import now go to the project page */ - window.location.replace(ctx.projectPageUrl+'#/layerimported='+layerData.name); + $.cookie('layer-imported-alert', JSON.stringify(layerData), { path: '/'}); + window.location.replace(ctx.projectPageUrl+'#/layerimported'); } }, error: function (data) { diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index 8e3499a94c..94c24f4a56 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js @@ -128,7 +128,7 @@ projectApp.filter('timediff', function() { // main controller for the project page -projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $location, $cookies, $q, $sce, $anchorScroll, $animate, $sanitize) { +projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $location, $cookies, $cookieStore, $q, $sce, $anchorScroll, $animate, $sanitize) { $scope.getSuggestions = function(type, currentValue) { var deffered = $q.defer(); @@ -572,9 +572,28 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc }); _cmdExecuteWithParam("/layerimported", function (layer) { - $scope.displayAlert($scope.zone2alerts, - "You have imported " + layer + - " and added it to your project.", "alert-success"); + var imported = $cookieStore.get("layer-imported-alert"); + var text; + + if (!imported) + return; + + if (imported.layersAdded.length == 0) { + text = "You have imported "+imported.name+ + " and added it to your project."; + } else { + text = "You have imported "+imported.name+ + " and added "+imported.layersAdded.length+ + " layers to your project. "+ + imported.layersAdded.join(", ")+""; + } + + $scope.displayAlert($scope.zone2alerts, text, "alert-info"); + + // This doesn't work + $cookieStore.remove("layer-imported-alert"); + //use jquery plugin instead + $.removeCookie("layer-imported-alert", { path: "/"}); }); _cmdExecuteWithParam("/targetbuild=", function (targets) { diff --git a/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html index 821bbda296..b03fd0b218 100644 --- a/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html +++ b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html @@ -3,10 +3,10 @@
@@ -18,9 +18,20 @@ diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index ec055d392a..dd430805b1 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2253,6 +2253,8 @@ if toastermain.settings.MANAGED: not request.POST.has_key('project_id')): return HttpResponse(jsonfilter({"error": "Missing parameters; requires vcs_url, name, git_ref and project_id"}), content_type = "application/json") + layers_added = []; + # Rudimentary check for any possible html tags if "<" in request.POST: return HttpResponse(jsonfilter({"error": "Invalid character <"}), content_type = "application/json") @@ -2315,9 +2317,12 @@ if toastermain.settings.MANAGED: # if the project now contains the exact # dependency already (like modified on another page) try: - ProjectLayer.objects.get_or_create(layercommit=layer_dep_obj, project=prj) + prj_layer, prj_layer_created = ProjectLayer.objects.get_or_create(layercommit=layer_dep_obj, project=prj) except: - pass + continue + + if prj_layer_created: + layers_added.append(Layer.objects.get(id=layer_dep_obj.layer_id).name) # If an old layer version exists in our project then remove it @@ -2337,7 +2342,7 @@ if toastermain.settings.MANAGED: return HttpResponse(jsonfilter({"error": "Uncaught error: Could not create layer version"}), content_type = "application/json") - return HttpResponse(jsonfilter({"error": "ok"}), content_type = "application/json") + return HttpResponse(jsonfilter({"error": "ok", "layers_added": layers_added}), content_type = "application/json")