From 8b1d0438bc1dd6aeea37fb039897f8c3e023f5ce Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Mon, 7 Dec 2015 18:43:15 +0000 Subject: bitbake: toaster: libtoaster Add createCustomRecipe method This adds the function to call the ReSt API to create a custom image recipe. (Bitbake rev: 03e7949f538733f682a05d0c318cf2f4cd64cbf5) Signed-off-by: Michael Wood Signed-off-by: brian avery Signed-off-by: Richard Purdie --- .../lib/toaster/toastergui/static/js/libtoaster.js | 27 ++++++++++++++++++++++ bitbake/lib/toaster/toastergui/templates/base.html | 1 + 2 files changed, 28 insertions(+) (limited to 'bitbake/lib/toaster') diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 1012034404..e81f567057 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 e56bb34e38..6994bcc9ad 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, -- cgit v1.2.3-54-g00ecf