This adds the function to call the ReSt API to create a custom image
recipe.

Signed-off-by: Michael Wood <[email protected]>
---
 .../lib/toaster/toastergui/static/js/libtoaster.js | 27 ++++++++++++++++++++++
 bitbake/lib/toaster/toastergui/templates/base.html |  1 +
 2 files changed, 28 insertions(+)

diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js 
b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index c04f7ab..d7f0394 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -332,6 +332,32 @@ var libtoaster = (function (){
     $("#change-notification, #change-notification *").fadeIn();
   }
 
+  function _createCustomRecipe(name, baseRecipeId, doneCb){
+    var data = {
+      'name' : name,
+      'project' : libtoaster.ctx.projectId,
+      'base' : baseRecipeId,
+    };
+
+    $.ajax({
+        type: "POST",
+        url: libtoaster.ctx.xhrCustomRecipeUrl,
+        data: data,
+        headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
+        success: function (ret) {
+          if (doneCb){
+            doneCb(ret);
+          } else if (ret.error !== "ok") {
+            console.warn(ret.error);
+          }
+        },
+        error: function (ret) {
+          console.warn("Call failed");
+          console.warn(ret);
+        }
+    });
+  }
+
 
   return {
     reload_params : reload_params,
@@ -347,6 +373,7 @@ var libtoaster = (function (){
     addRmLayer : _addRmLayer,
     makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg,
     showChangeNotification : _showChangeNotification,
+    createCustomRecipe: _createCustomRecipe,
   };
 })();
 
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html 
b/bitbake/lib/toaster/toastergui/templates/base.html
index e56bb34..6994bcc 100644
--- a/bitbake/lib/toaster/toastergui/templates/base.html
+++ b/bitbake/lib/toaster/toastergui/templates/base.html
@@ -45,6 +45,7 @@
         machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as 
paturl%}{{paturl|json}},
 
         projectBuildsUrl: {% url 'projectbuilds' project.id as pburl 
%}{{pburl|json}},
+        xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}",
         projectId : {{project.id}},
         {% else %}
         projectId : undefined,
-- 
2.1.4

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

Reply via email to