From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 0EECCE00BB9; Wed, 23 Mar 2016 03:36:54 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.24 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 99C02E00AAB for ; Wed, 23 Mar 2016 03:36:35 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 23 Mar 2016 03:36:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,382,1455004800"; d="scan'208";a="917103246" Received: from linux.intel.com ([10.23.219.25]) by orsmga001.jf.intel.com with ESMTP; 23 Mar 2016 03:36:35 -0700 Received: from vmed.fi.intel.com (vmed.fi.intel.com [10.237.72.51]) by linux.intel.com (Postfix) with ESMTP id 8DECC6A4002 for ; Wed, 23 Mar 2016 04:24:18 -0700 (PDT) From: Ed Bartosh To: toaster@yoctoproject.org Date: Wed, 23 Mar 2016 10:15:19 +0200 Message-Id: <2459df229e5b95249d4b0fd6eca02368e2dff5d5.1458720709.git.ed.bartosh@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v6 28/41] toaster: mrb_section template Add build cancel button X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2016 10:36:54 -0000 From: Michael Wood 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 Signed-off-by: Michael Wood Signed-off-by: Ed Bartosh --- .../lib/toaster/toastergui/static/js/mrbsection.js | 95 +++++++++++++ .../toaster/toastergui/templates/mrb_section.html | 148 ++++++++------------- 2 files changed, 149 insertions(+), 94 deletions(-) create mode 100644 bitbake/lib/toaster/toastergui/static/js/mrbsection.js 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 0000000..09117e1 --- /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); + } +} + diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html index 551e341..b5e798d 100644 --- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html @@ -2,6 +2,21 @@ {% load projecttags %} {% load project_url_tag %} {% load humanize %} + + {%if mru and mru.count > 0%} @@ -99,7 +114,7 @@ " title="Builds in this project cannot be started from Toaster: they are started from the command line"> {% else %} - @@ -119,100 +133,46 @@ {%endif%} {%if build.outcome == build.IN_PROGRESS %} -
-
-
-
-
-
{{build.completeper}}% of tasks complete
- {%endif%} - + +
+
+
+
+
+
{{build.completeper}}% of tasks complete
+ {# No build cancel for command line builds project #} + {% if build.project.is_default %} + + {% else %} +
+ +
+ {% endif %} - {% endfor %} - - - + {% endfor %} + {%endif%} -- 2.1.4