From c89fd793986878a426ebc96d4df22257252f8934 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Mon, 8 Dec 2014 15:29:01 +0000 Subject: bitbake: toaster: projectapp Add links to the imported layers notify Adds links to layer details for each of the layers that has been added to the project. (Bitbake rev: 07e5c7c82519604501feb7d892db330c610978e9) Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- .../toaster/toastergui/static/js/importlayer.js | 3 +-- .../lib/toaster/toastergui/static/js/projectapp.js | 29 ++++++++++++++++------ .../lib/toaster/toastergui/templates/project.html | 3 ++- bitbake/lib/toaster/toastergui/views.py | 4 +-- 4 files changed, 26 insertions(+), 13 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index 34dbcd9ed7..5748efd8ce 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -152,9 +152,8 @@ 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 */ - $.cookie('layer-imported-alert', JSON.stringify(layerData), { path: '/'}); + $.cookie('layer-imported-alert', JSON.stringify(data), { path: '/'}); window.location.replace(ctx.projectPageUrl+'#/layerimported'); } }, diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index 94c24f4a56..741038df27 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js @@ -578,18 +578,31 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc if (!imported) return; - if (imported.layersAdded.length == 0) { - text = "You have imported "+imported.name+ - " and added it to your project."; + if (imported.deps_added.length == 0) { + text = "You have imported "+imported.imported_layer.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(", ")+""; + var links = ""+imported.imported_layer.name+ + ", "; + + imported.deps_added.map (function(item, index){ + links +=""+item.name+ + ""; + /*If we're at the last element we don't want the trailing comma */ + if (imported.deps_added[index+1] != undefined) + links += ", "; + }); + + /* Length + 1 here to do deps + the imported layer */ + text = "You have imported "+imported.imported_layer.name+ + " and added "+(imported.deps_added.length+1)+ + " layers to your project. "+links+""; } $scope.displayAlert($scope.zone2alerts, text, "alert-info"); - // This doesn't work $cookieStore.remove("layer-imported-alert"); //use jquery plugin instead diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index 113e382d45..2979db74ed 100644 --- a/bitbake/lib/toaster/toastergui/templates/project.html +++ b/bitbake/lib/toaster/toastergui/templates/project.html @@ -382,7 +382,8 @@ angular.element(document).ready(function() { scope.urls.xhr_datatypeahead = "{% url 'xhr_datatypeahead' %}"; scope.urls.layers = "{% url 'layers' %}"; scope.urls.targets = "{% url 'targets' %}"; - scope.urls.importlayer = "{% url 'importlayer'%}" + scope.urls.importlayer = "{% url 'importlayer'%}"; + scope.urls.layer = "{% url 'layerdetails' %}"; scope.project = {{prj|json}}; scope.builds = {{builds|json}}; scope.layers = {{layers|json}}; diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index dd430805b1..679c1e9430 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2322,7 +2322,7 @@ if toastermain.settings.MANAGED: continue if prj_layer_created: - layers_added.append(Layer.objects.get(id=layer_dep_obj.layer_id).name) + layers_added.append({'id': layer_dep_obj.id, 'name': Layer.objects.get(id=layer_dep_obj.layer_id).name}) # If an old layer version exists in our project then remove it @@ -2342,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", "layers_added": layers_added}), content_type = "application/json") + return HttpResponse(jsonfilter({"error": "ok", "imported_layer" : { "name" : layer.name, "id": layer_version.id }, "deps_added": layers_added }), content_type = "application/json") -- cgit v1.2.3-54-g00ecf