Skip to contentSkip to conversation

bitbake: toastergui: layerBtn Fix build trigger mechanism

PATCH In review Michael Wood 2 participants 2 messages Aug 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: toastergui: layerBtn Fix build trigger mechanism

The new project page is no longer responsible for triggering the build so add a handler for this in layerBtn which is used in the layerdetails and layers pages. This also removes the conflicting and redundant handler for this in the layerdetails.

---
 bitbake/lib/toaster/toastergui/static/js/layerBtn.js     | 13 +++++++++++++
 bitbake/lib/toaster/toastergui/static/js/layerdetails.js |  8 --------
 bitbake/lib/toaster/toastergui/tables.py                 |  2 +-
 bitbake/lib/toaster/toastergui/templates/recipe_btn.html |  4 ++--
 4 files changed, 16 insertions(+), 11 deletions(-)
bitbake/lib/toaster/toastergui/static/js/layerBtn.js +13 -0
index 4243c2b..a0509f9 100644
@@ -55,6 +55,19 @@ function layerBtnsInit(ctx) {
     });
   });
 
+  $(".build-recipe-btn").unbind('click');
+  $(".build-recipe-btn").click(function(e){
+    e.preventDefault();
+    var recipe = $(this).data('recipe-name');
+
+    libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
+      libtoaster.ctx.projectId, recipe,
+      function(){
+        /* Success */
+        window.location.replace(libtoaster.ctx.projectBuildsUrl);
+      });
+  });
+
   /* Setup the initial state of the buttons */
 
   for (var i in ctx.projectLayers){
bitbake/lib/toaster/toastergui/static/js/layerdetails.js +0 -8
index be6bbcd..d38a26a 100644
@@ -179,14 +179,6 @@ function layerDetailsPageInit (ctx) {
       /* re run the machinesTabShow to update the text */
       targetsTabShow();
     }
-
-    $(".build-target-btn").unbind('click');
-    $(".build-target-btn").click(function(){
-      /* fire a build */
-      var target = $(this).data('target-name');
-      libtoaster.startABuild(ctx.projectBuildsUrl, libtoaster.ctx.projectId, target, null, null);
-      window.location.replace(libtoaster.ctx.projectPageUrl);
-    });
   });
 
   $("#machinestable").on('table-done', function(e, total, tableParams){
bitbake/lib/toaster/toastergui/tables.py +1 -1
index 8d5166be..1d5f5ea 100644
@@ -465,7 +465,7 @@ class LayerRecipesTable(RecipesTable):
                         field_name="get_description_or_summary")
 
 
-        build_recipe_template ='<button class="btn btn-block build-target-btn" data-target-name="{{data.name}}" {%if extra.in_prj == 0 %}disabled="disabled"{%endif%}>Build recipe</button>'
+        build_recipe_template ='<button class="btn btn-block build-recipe-btn" data-recipe-name="{{data.name}}" {%if extra.in_prj == 0 %}disabled="disabled"{%endif%}>Build recipe</button>'
 
         self.add_column(title="Build recipe",
                         static_data_name="add-del-layers",
bitbake/lib/toaster/toastergui/templates/recipe_btn.html +2 -2
index d9ec3fa..77c1b23 100644
@@ -1,6 +1,6 @@
-<a href="{% url 'project' extra.pid %}#/targetbuild={{data.name}}" class="btn btn-block layer-exists-{{data.layer_version.pk}}" style="display:none; margin-top: 5px;" >
+<button data-recipe-name="{{data.name}}" class="btn btn-block layer-exists-{{data.layer_version.pk}} build-recipe-btn" style="display:none; margin-top: 5px;" >
   Build recipe
-</a>
+</button>
 <button class="btn btn-block layerbtn layer-add-{{data.layer_version.pk}}" data-layer='{ "id": {{data.layer_version.pk}}, "name":  "{{data.layer_version.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.pk%}"}' data-directive="add">
   <i class="icon-plus"></i>
   Add layer
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · On 06/08/2015 11:15, "[email protected] on behalf of Michael…

The new project page is no longer responsible for triggering the build so add a handler for this in layerBtn which is used in the layerdetails and layers pages. This also removes the conflicting and redundant handler for this in the layerdetails.

Tested this extensively this morning as part of some opportunistic user
testing: it seems to be working.

Thanks

Belén

Quoted 104 lines

---
bitbake/lib/toaster/toastergui/static/js/layerBtn.js | 13
+++++++++++++

bitbake/lib/toaster/toastergui/static/js/layerdetails.js |  8 --------
bitbake/lib/toaster/toastergui/tables.py                 |  2 +-
bitbake/lib/toaster/toastergui/templates/recipe_btn.html |  4 ++--
4 files changed, 16 insertions(+), 11 deletions(-)
bitbake/lib/toaster/toastergui/static/js/layerBtn.js +13 -0
index 4243c2b..a0509f9 100644
@@ -55,6 +55,19 @@ function layerBtnsInit(ctx) {
    });
  });
 
+  $(".build-recipe-btn").unbind('click');
+  $(".build-recipe-btn").click(function(e){
+    e.preventDefault();
+    var recipe = $(this).data('recipe-name');
+
+    libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
+      libtoaster.ctx.projectId, recipe,
+      function(){
+        /* Success */
+        window.location.replace(libtoaster.ctx.projectBuildsUrl);
+      });
+  });
+
  /* Setup the initial state of the buttons */
 
  for (var i in ctx.projectLayers){
bitbake/lib/toaster/toastergui/static/js/layerdetails.js +0 -8
index be6bbcd..d38a26a 100644
@@ -179,14 +179,6 @@ function layerDetailsPageInit (ctx) {
      /* re run the machinesTabShow to update the text */
      targetsTabShow();
    }
-
-    $(".build-target-btn").unbind('click');
-    $(".build-target-btn").click(function(){
-      /* fire a build */
-      var target = $(this).data('target-name');
-      libtoaster.startABuild(ctx.projectBuildsUrl,
 libtoaster.ctx.projectId, target, null, null);
-      window.location.replace(libtoaster.ctx.projectPageUrl);
-    });
  });
 
  $("#machinestable").on('table-done', function(e, total, tableParams){
bitbake/lib/toaster/toastergui/tables.py +0 -1
index 8d5166be..1d5f5ea 100644
@@ -465,7 +465,7 @@ class LayerRecipesTable(RecipesTable):
                        field_name="get_description_or_summary")
 
 
-        build_recipe_template ='<button class="btn btn-block

build-target-btn" data-target-name="{{data.name}}" {%if extra.in_prj == 0 %}disabled="disabled"{%endif%}>Build recipe</button>'
+ build_recipe_template ='<button class="btn btn-block
build-recipe-btn" data-recipe-name="{{data.name}}" {%if extra.in_prj == 0 %}disabled="disabled"{%endif%}>Build recipe</button>'

self.add_column(title="Build recipe",
static_data_name="add-del-layers",

bitbake/lib/toaster/toastergui/templates/recipe_btn.html +0 -1
index d9ec3fa..77c1b23 100644
@@ -1,6 +1,6 @@
-<a href="{% url 'project' extra.pid %}#/targetbuild={{data.name}}"

class="btn btn-block layer-exists-{{data.layer_version.pk}}" style="display:none; margin-top: 5px;" >
+<button data-recipe-name="{{data.name}}" class="btn btn-block layer-exists-{{data.layer_version.pk}} build-recipe-btn" style="display:none; margin-top: 5px;" >
Build recipe
-</a>
+</button>
<button class="btn btn-block layerbtn layer-add-{{data.layer_version.pk}}" data-layer='{ "id":
{{data.layer_version.pk}}, "name": "{{data.layer_version.layer.name}}", "layerdetailurl": "{%url 'layerdetails' extra.pid data.layer_version.pk%}"}' data-directive="add">
<i class="icon-plus"></i>
Add layer

Signature · 7 lines
2.1.4

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster