mirror of
https://git.yoctoproject.org/poky
synced 2026-04-30 12:32:12 +02:00
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>
49 lines
1.2 KiB
JavaScript
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);
|
|
}
|
|
});
|
|
}
|
|
}
|