Use libtoaster.createCustomRecipe rather than own implementation of this
function.

Signed-off-by: Michael Wood <[email protected]>
---
 .../toastergui/static/js/newcustomimage_modal.js   | 36 +++++-----------------
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js 
b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
index 71a28f7..16e42b3 100644
--- a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
+++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
@@ -1,7 +1,7 @@
 "use strict";
 
 /* Used for the newcustomimage_modal actions */
-function newCustomImageModalInit(ctx){
+function newCustomImageModalInit(){
 
   var newCustomImgBtn = $("#create-new-custom-image-btn");
   var imgCustomModal = $("#new-custom-image-modal");
@@ -13,36 +13,16 @@ function newCustomImageModalInit(ctx){
     var baseRecipeId = imgCustomModal.data('recipe');
 
     if (name.length > 0) {
-      createCustomRecipe(name, baseRecipeId);
       imgCustomModal.modal('hide');
+      libtoaster.createCustomRecipe(name, baseRecipeId, function(ret) {
+        if (ret.error !== "ok") {
+          console.warn(ret.error);
+        } else {
+          window.location.replace(ret.url + '?notify=new');
+        }
+      });
     } else {
       console.warn("TODO No name supplied");
     }
   });
-
-  function createCustomRecipe(name, baseRecipeId){
-    var data = {
-      'name' : name,
-      'project' : libtoaster.ctx.projectId,
-      'base' : baseRecipeId,
-    };
-
-    $.ajax({
-        type: "POST",
-        url: ctx.xhrCustomRecipeUrl,
-        data: data,
-        headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
-        success: function (ret) {
-          if (ret.error !== "ok") {
-            console.warn(ret.error);
-          } else {
-            window.location.replace(ret.url + '?notify=new');
-          }
-        },
-        error: function (ret) {
-          console.warn("Call failed");
-          console.warn(ret);
-        }
-    });
-  }
 }
-- 
2.1.4

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

Reply via email to