]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: projectapp Add links to the imported layers notify
authorMichael Wood <michael.g.wood@intel.com>
Mon, 8 Dec 2014 15:29:01 +0000 (15:29 +0000)
committerAlexandru DAMIAN <alexandru.damian@intel.com>
Fri, 12 Dec 2014 11:40:47 +0000 (11:40 +0000)
Adds links to layer details for each of the layers that has been added
to the project.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
lib/toaster/toastergui/static/js/importlayer.js
lib/toaster/toastergui/static/js/projectapp.js
lib/toaster/toastergui/templates/project.html
lib/toaster/toastergui/views.py

index 34dbcd9ed76674fae9f500ea86814019697e130d..5748efd8ceb01a4e410f702620bd75de2e45f492 100644 (file)
@@ -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');
             }
           },
index 94c24f4a56ce771924ce041a075f4464a73a8f92..741038df2760684c46153df3dadffd56e8f29dc4 100644 (file)
@@ -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 <strong>"+imported.name+
-              "</strong> and added it to your project.";
+          if (imported.deps_added.length == 0) {
+            text = "You have imported <strong><a href=\""+$scope.urls.layer+
+              imported.imported_layer.id+"\">"+imported.imported_layer.name+
+              "</a></strong> and added it to your project.";
           } else {
-            text = "You have imported <strong>"+imported.name+
-              "</strong> and added <strong>"+imported.layersAdded.length+
-              "</strong> layers to your project. <strong>"+
-              imported.layersAdded.join(", ")+"</strong>";
+            var links = "<a href=\""+$scope.urls.layer+
+              imported.imported_layer.id+"\">"+imported.imported_layer.name+
+              "</a>, ";
+
+            imported.deps_added.map (function(item, index){
+              links +="<a href=\""+$scope.urls.layer+item.id+"\" >"+item.name+
+                "</a>";
+              /*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 <strong><a href=\""+$scope.urls.layer+
+              imported.imported_layer.id+"\">"+imported.imported_layer.name+
+              "</a></strong> and added <strong>"+(imported.deps_added.length+1)+
+              "</strong> layers to your project. <strong>"+links+"</strong>";
           }
 
             $scope.displayAlert($scope.zone2alerts, text, "alert-info");
-
             // This doesn't work
             $cookieStore.remove("layer-imported-alert");
             //use jquery plugin instead
index 113e382d454d7faed293ae67f5cead2789696d28..2979db74edd3118550e7e9d8cd4d250fb5cedd09 100644 (file)
@@ -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}};
index dd430805b194799175434bc07d453fb071a283ec..679c1e94304fbd57b598d00217e2038ff37e27cf 100755 (executable)
@@ -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")