Files
poky/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js
Michael Wood 5f52614a87 bitbake: toaster: newcustomimage Move modal dialog out of newcustomimage template
Move the modal template and JS out of the newcustomimage page so that it
can also be used by the image details page.

(Bitbake rev: c310bc6bab1a33124906dd57b3c63462a773ff25)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-10 13:29:17 +00:00

49 lines
1.2 KiB
JavaScript

"use strict";
/* Used for the newcustomimage_modal actions */
function newCustomImageModalInit(ctx){
var newCustomImgBtn = $("#create-new-custom-image-btn");
var imgCustomModal = $("#new-custom-image-modal");
newCustomImgBtn.click(function(e){
e.preventDefault();
var name = imgCustomModal.find('input').val();
var baseRecipeId = imgCustomModal.data('recipe');
if (name.length > 0) {
createCustomRecipe(name, baseRecipeId);
imgCustomModal.modal('hide');
} 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);
}
});
}
}