summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-04-06 17:46:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-06 23:10:29 +0100
commit0db62c54a4b2d89a42028d9263cb3f8a9fe93be0 (patch)
treec8c8789074d1bd2a483bfe4457783a9a38089cf0 /bitbake
parentafab95c649c6e478f462a32e3d9831cb9007b0e4 (diff)
downloadpoky-0db62c54a4b2d89a42028d9263cb3f8a9fe93be0.tar.gz
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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/customrecipe.js4
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerBtn.js3
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js41
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectpage.js4
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projecttopbar.js6
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/recipedetails.js4
-rw-r--r--bitbake/lib/toaster/toastergui/templates/base.html1
7 files changed, 34 insertions, 29 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
index f1b8afbf2f..a31c26834e 100644
--- a/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
+++ b/bitbake/lib/toaster/toastergui/static/js/customrecipe.js
@@ -267,9 +267,7 @@ function customRecipePageInit(ctx) {
267 267
268 /* Trigger a build of your custom image */ 268 /* Trigger a build of your custom image */
269 $(".build-custom-image").click(function(){ 269 $(".build-custom-image").click(function(){
270 libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, 270 libtoaster.startABuild(null, ctx.recipe.name,
271 libtoaster.ctx.projectId,
272 ctx.recipe.name,
273 function(){ 271 function(){
274 window.location.replace(libtoaster.ctx.projectBuildsUrl); 272 window.location.replace(libtoaster.ctx.projectBuildsUrl);
275 }); 273 });
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
index b2666ab92c..aa43284396 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
@@ -60,8 +60,7 @@ function layerBtnsInit() {
60 e.preventDefault(); 60 e.preventDefault();
61 var recipe = $(this).data('recipe-name'); 61 var recipe = $(this).data('recipe-name');
62 62
63 libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, 63 libtoaster.startABuild(null, recipe,
64 libtoaster.ctx.projectId, recipe,
65 function(){ 64 function(){
66 /* Success */ 65 /* Success */
67 window.location.replace(libtoaster.ctx.projectBuildsUrl); 66 window.location.replace(libtoaster.ctx.projectBuildsUrl);
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index b6b49b6b4d..8d1d20f133 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -90,27 +90,35 @@ var libtoaster = (function (){
90 jQElement.data('typeahead').render = customRenderFunc; 90 jQElement.data('typeahead').render = customRenderFunc;
91 } 91 }
92 92
93 /* 93 /* startABuild:
94 * url - the url of the xhr build */ 94 * url: xhr_buildrequest or null for current project
95 function _startABuild (url, project_id, targets, onsuccess, onfail) { 95 * targets: an array or space separated list of targets to build
96 * onsuccess: callback for successful execution
97 * onfail: callback for failed execution
98 */
99 function _startABuild (url, targets, onsuccess, onfail) {
96 100
97 var data = { 101 if (!url)
98 project_id : project_id, 102 url = libtoaster.ctx.xhrBuildRequestUrl;
99 targets : targets, 103
104 /* Flatten the array of targets into a space spearated list */
105 if (targets instanceof Array){
106 targets = targets.reduce(function(prevV, nextV){
107 return prev + ' ' + next;
108 });
100 } 109 }
101 110
102 $.ajax( { 111 $.ajax( {
103 type: "POST", 112 type: "POST",
104 url: url, 113 url: url,
105 data: data, 114 data: { 'targets' : targets },
106 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 115 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
107 success: function (_data) { 116 success: function (_data) {
108 /* No proper reponse YOCTO #7995
109 if (_data.error !== "ok") { 117 if (_data.error !== "ok") {
110 console.warn(_data.error); 118 console.warn(_data.error);
111 } else { */ 119 } else {
112 if (onsuccess !== undefined) onsuccess(_data); 120 if (onsuccess !== undefined) onsuccess(_data);
113 // } 121 }
114 }, 122 },
115 error: function (_data) { 123 error: function (_data) {
116 console.warn("Call failed"); 124 console.warn("Call failed");
@@ -120,22 +128,25 @@ var libtoaster = (function (){
120 } 128 }
121 129
122 /* cancelABuild: 130 /* cancelABuild:
123 * url: projectbuilds 131 * url: xhr_buildrequest url or null for current project
124 * builds_ids: space separated list of build request ids 132 * buildRequestIds: space separated list of build request ids
125 * onsuccess: callback for successful execution 133 * onsuccess: callback for successful execution
126 * onfail: callback for failed execution 134 * onfail: callback for failed execution
127 */ 135 */
128 function _cancelABuild(url, build_ids, onsuccess, onfail){ 136 function _cancelABuild(url, buildRequestIds, onsuccess, onfail){
137 if (!url)
138 url = libtoaster.ctx.xhrBuildRequestUrl;
139
129 $.ajax( { 140 $.ajax( {
130 type: "POST", 141 type: "POST",
131 url: url, 142 url: url,
132 data: { 'buildCancel': build_ids }, 143 data: { 'buildCancel': buildRequestIds },
133 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 144 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
134 success: function (_data) { 145 success: function (_data) {
135 if (_data.error !== "ok") { 146 if (_data.error !== "ok") {
136 console.warn(_data.error); 147 console.warn(_data.error);
137 } else { 148 } else {
138 if (onsuccess !== undefined) onsuccess(_data); 149 if (onsuccess) onsuccess(_data);
139 } 150 }
140 }, 151 },
141 error: function (_data) { 152 error: function (_data) {
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
index 6655a189a1..3013416dd1 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
@@ -232,9 +232,7 @@ function projectPageInit(ctx) {
232 232
233 toBuild = toBuild.trim(); 233 toBuild = toBuild.trim();
234 234
235 libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, 235 libtoaster.startABuild(null, toBuild,
236 libtoaster.ctx.projectId,
237 toBuild,
238 function(){ 236 function(){
239 /* Build request started */ 237 /* Build request started */
240 window.location.replace(libtoaster.ctx.projectBuildsUrl); 238 window.location.replace(libtoaster.ctx.projectBuildsUrl);
diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
index 58a32a056e..b09f974e47 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
@@ -82,9 +82,9 @@ function projectTopBarInit(ctx) {
82 selectedTarget = { name: newBuildTargetInput.val() }; 82 selectedTarget = { name: newBuildTargetInput.val() };
83 83
84 /* Fire off the build */ 84 /* Fire off the build */
85 libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, 85 libtoaster.startABuild(null, selectedTarget.name,
86 null, selectedTarget.name, function(){ 86 function(){
87 window.location.replace(libtoaster.ctx.projectBuildsUrl); 87 window.location.replace(libtoaster.ctx.projectBuildsUrl);
88 }, null); 88 }, null);
89 }); 89 });
90} 90}
diff --git a/bitbake/lib/toaster/toastergui/static/js/recipedetails.js b/bitbake/lib/toaster/toastergui/static/js/recipedetails.js
index 2bfd0a4b2c..d5f9eacdce 100644
--- a/bitbake/lib/toaster/toastergui/static/js/recipedetails.js
+++ b/bitbake/lib/toaster/toastergui/static/js/recipedetails.js
@@ -42,9 +42,7 @@ function recipeDetailsPageInit(ctx){
42 42
43 /* Trigger a build of your custom image */ 43 /* Trigger a build of your custom image */
44 $(".build-recipe-btn").click(function(){ 44 $(".build-recipe-btn").click(function(){
45 libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, 45 libtoaster.startABuild(null, ctx.recipe.name,
46 libtoaster.ctx.projectId,
47 ctx.recipe.name,
48 function(){ 46 function(){
49 window.location.replace(libtoaster.ctx.projectBuildsUrl); 47 window.location.replace(libtoaster.ctx.projectBuildsUrl);
50 }); 48 });
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html
index 121a75c49a..192f9fb556 100644
--- a/bitbake/lib/toaster/toastergui/templates/base.html
+++ b/bitbake/lib/toaster/toastergui/templates/base.html
@@ -47,6 +47,7 @@
47 projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}}, 47 projectBuildsUrl: {% url 'projectbuilds' project.id as pburl %}{{pburl|json}},
48 xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}", 48 xhrCustomRecipeUrl : "{% url 'xhr_customrecipe' %}",
49 projectId : {{project.id}}, 49 projectId : {{project.id}},
50 xhrBuildRequestUrl: "{% url 'xhr_buildrequest' project.id %}",
50 {% else %} 51 {% else %}
51 projectId : undefined, 52 projectId : undefined,
52 projectPageUrl : undefined, 53 projectPageUrl : undefined,