mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
bitbake: toaster: libtoaster Update implementation of startABuild and cancelABuild
Update the implementation of startABuild and cancelAbuild to reflect changes to the backend api. We now have a dedicated endpoint to make calls into so add this url to libtoaster.ctx and allow passing null in as a url value to indicate that we want to use the current project Also: - Fix some documentation comments - Add the convenience of passing in an array of targets to startABuild (Bitbake rev: 61a21d96abab113cbd13376cdb8b08a426b50538) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
afab95c649
commit
0db62c54a4
@@ -267,9 +267,7 @@ function customRecipePageInit(ctx) {
|
|||||||
|
|
||||||
/* Trigger a build of your custom image */
|
/* Trigger a build of your custom image */
|
||||||
$(".build-custom-image").click(function(){
|
$(".build-custom-image").click(function(){
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
|
libtoaster.startABuild(null, ctx.recipe.name,
|
||||||
libtoaster.ctx.projectId,
|
|
||||||
ctx.recipe.name,
|
|
||||||
function(){
|
function(){
|
||||||
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ function layerBtnsInit() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var recipe = $(this).data('recipe-name');
|
var recipe = $(this).data('recipe-name');
|
||||||
|
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
|
libtoaster.startABuild(null, recipe,
|
||||||
libtoaster.ctx.projectId, recipe,
|
|
||||||
function(){
|
function(){
|
||||||
/* Success */
|
/* Success */
|
||||||
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
||||||
|
|||||||
@@ -90,27 +90,35 @@ var libtoaster = (function (){
|
|||||||
jQElement.data('typeahead').render = customRenderFunc;
|
jQElement.data('typeahead').render = customRenderFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* startABuild:
|
||||||
* url - the url of the xhr build */
|
* url: xhr_buildrequest or null for current project
|
||||||
function _startABuild (url, project_id, targets, onsuccess, onfail) {
|
* targets: an array or space separated list of targets to build
|
||||||
|
* onsuccess: callback for successful execution
|
||||||
|
* onfail: callback for failed execution
|
||||||
|
*/
|
||||||
|
function _startABuild (url, targets, onsuccess, onfail) {
|
||||||
|
|
||||||
var data = {
|
if (!url)
|
||||||
project_id : project_id,
|
url = libtoaster.ctx.xhrBuildRequestUrl;
|
||||||
targets : targets,
|
|
||||||
|
/* Flatten the array of targets into a space spearated list */
|
||||||
|
if (targets instanceof Array){
|
||||||
|
targets = targets.reduce(function(prevV, nextV){
|
||||||
|
return prev + ' ' + next;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
data: data,
|
data: { 'targets' : targets },
|
||||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||||
success: function (_data) {
|
success: function (_data) {
|
||||||
/* No proper reponse YOCTO #7995
|
|
||||||
if (_data.error !== "ok") {
|
if (_data.error !== "ok") {
|
||||||
console.warn(_data.error);
|
console.warn(_data.error);
|
||||||
} else { */
|
} else {
|
||||||
if (onsuccess !== undefined) onsuccess(_data);
|
if (onsuccess !== undefined) onsuccess(_data);
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
error: function (_data) {
|
error: function (_data) {
|
||||||
console.warn("Call failed");
|
console.warn("Call failed");
|
||||||
@@ -120,22 +128,25 @@ var libtoaster = (function (){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cancelABuild:
|
/* cancelABuild:
|
||||||
* url: projectbuilds
|
* url: xhr_buildrequest url or null for current project
|
||||||
* builds_ids: space separated list of build request ids
|
* buildRequestIds: space separated list of build request ids
|
||||||
* onsuccess: callback for successful execution
|
* onsuccess: callback for successful execution
|
||||||
* onfail: callback for failed execution
|
* onfail: callback for failed execution
|
||||||
*/
|
*/
|
||||||
function _cancelABuild(url, build_ids, onsuccess, onfail){
|
function _cancelABuild(url, buildRequestIds, onsuccess, onfail){
|
||||||
|
if (!url)
|
||||||
|
url = libtoaster.ctx.xhrBuildRequestUrl;
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
data: { 'buildCancel': build_ids },
|
data: { 'buildCancel': buildRequestIds },
|
||||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||||
success: function (_data) {
|
success: function (_data) {
|
||||||
if (_data.error !== "ok") {
|
if (_data.error !== "ok") {
|
||||||
console.warn(_data.error);
|
console.warn(_data.error);
|
||||||
} else {
|
} else {
|
||||||
if (onsuccess !== undefined) onsuccess(_data);
|
if (onsuccess) onsuccess(_data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (_data) {
|
error: function (_data) {
|
||||||
|
|||||||
@@ -232,9 +232,7 @@ function projectPageInit(ctx) {
|
|||||||
|
|
||||||
toBuild = toBuild.trim();
|
toBuild = toBuild.trim();
|
||||||
|
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
|
libtoaster.startABuild(null, toBuild,
|
||||||
libtoaster.ctx.projectId,
|
|
||||||
toBuild,
|
|
||||||
function(){
|
function(){
|
||||||
/* Build request started */
|
/* Build request started */
|
||||||
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ function projectTopBarInit(ctx) {
|
|||||||
selectedTarget = { name: newBuildTargetInput.val() };
|
selectedTarget = { name: newBuildTargetInput.val() };
|
||||||
|
|
||||||
/* Fire off the build */
|
/* Fire off the build */
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
|
libtoaster.startABuild(null, selectedTarget.name,
|
||||||
null, selectedTarget.name, function(){
|
function(){
|
||||||
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
||||||
}, null);
|
}, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ function recipeDetailsPageInit(ctx){
|
|||||||
|
|
||||||
/* Trigger a build of your custom image */
|
/* Trigger a build of your custom image */
|
||||||
$(".build-recipe-btn").click(function(){
|
$(".build-recipe-btn").click(function(){
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl,
|
libtoaster.startABuild(null, ctx.recipe.name,
|
||||||
libtoaster.ctx.projectId,
|
|
||||||
ctx.recipe.name,
|
|
||||||
function(){
|
function(){
|
||||||
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
window.location.replace(libtoaster.ctx.projectBuildsUrl);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
|
projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
|
||||||
xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}",
|
xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}",
|
||||||
projectId : {{project.id}},
|
projectId : {{project.id}},
|
||||||
|
xhrBuildRequestUrl: "{% url 'xhr_buildrequest' project.id %}",
|
||||||
{% else %}
|
{% else %}
|
||||||
projectId : undefined,
|
projectId : undefined,
|
||||||
projectPageUrl : undefined,
|
projectPageUrl : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user