aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-04-06 17:46:38 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-06 23:10:29 +0100
commit296d3733df0b4da8ac8e793a552da2ecdfa32f20 (patch)
tree5c552e225b2beba24f536da62f9336f5036e32aa /bitbake/lib/toaster/toastergui/static/js/mrbsection.js
parentf1b49dc4b6fd76f88596b87ac5a14e5f3d265eca (diff)
downloadopenembedded-core-contrib-296d3733df0b4da8ac8e793a552da2ecdfa32f20.tar.gz
bitbake: toaster: mrb_section template Add build cancel button
Add the cancel build button to the mrb section template and add the event handlers to cancelABuild. Also clean up the calls to startABuild to use the updated libtoaster methods and to make the code consistent with it's cancelABuild counterpart. Co-Author: Sujith H <sujith.h@gmail.com> (Bitbake rev: 6b82ffca1aa9ca2d0feec64b15466bc8ba160011) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js/mrbsection.js')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/mrbsection.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/mrbsection.js b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
new file mode 100644
index 0000000000..09117e1daf
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
@@ -0,0 +1,95 @@
+
+function mrbSectionInit(ctx){
+
+ var projectBuilds;
+
+ if (ctx.mrbType === 'project')
+ projectBuilds = true;
+
+ $(".cancel-build-btn").click(function(e){
+ e.preventDefault();
+
+ var url = $(this).data('request-url');
+ var buildReqIds = $(this).data('buildrequest-id');
+ var banner = $(this).parents(".alert");
+
+ banner.find(".progress-info").fadeOut().promise().done(function(){
+ $("#cancelling-msg-" + buildReqIds).show();
+ console.log("cancel build");
+ libtoaster.cancelABuild(url, buildReqIds, function(){
+ if (projectBuilds == false){
+ /* the all builds page is not 'self updating' like thei
+ * project Builds
+ */
+ window.location.reload();
+ }
+ }, null);
+ });
+ });
+
+ $(".run-again-btn").click(function(e){
+ e.preventDefault();
+
+ var url = $(this).data('request-url');
+ var target = $(this).data('target');
+
+ libtoaster.startABuild(url, target, function(){
+ window.location.reload();
+ }, null);
+ });
+
+
+ var progressTimer;
+
+ if (projectBuilds === true){
+ progressTimer = window.setInterval(function() {
+ libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
+ function(prjInfo){
+ /* These two are needed because a build can be 100% and still
+ * in progress due to the fact that the % done is updated at the
+ * start of a task so it can be doing the last task at 100%
+ */
+ var inProgress = 0;
+ var allPercentDone = 0;
+ if (prjInfo.builds.length === 0)
+ return
+
+ for (var i in prjInfo.builds){
+ var build = prjInfo.builds[i];
+
+ if (build.outcome === "In Progress" ||
+ $(".progress .bar").length > 0){
+ /* Update the build progress */
+ var percentDone;
+
+ if (build.outcome !== "In Progress"){
+ /* We have to ignore the value when it's Succeeded because it
+ * goes back to 0
+ */
+ percentDone = 100;
+ } else {
+ percentDone = build.percentDone;
+ inProgress++;
+ }
+
+ $("#build-pc-done-" + build.id).text(percentDone);
+ $("#build-pc-done-title-" + build.id).attr("title", percentDone);
+ $("#build-pc-done-bar-" + build.id).css("width",
+ String(percentDone) + "%");
+
+ allPercentDone += percentDone;
+ }
+ }
+
+ if (allPercentDone === (100 * prjInfo.builds.length) && !inProgress)
+ window.location.reload();
+
+ /* Our progress bar is not still showing so shutdown the polling. */
+ if ($(".progress .bar").length === 0)
+ window.clearInterval(progressTimer);
+
+ });
+ }, 1500);
+ }
+}
+