summaryrefslogtreecommitdiffstats
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)
downloadpoky-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 @@
1
2function mrbSectionInit(ctx){
3
4 var projectBuilds;
5
6 if (ctx.mrbType === 'project')
7 projectBuilds = true;
8
9 $(".cancel-build-btn").click(function(e){
10 e.preventDefault();
11
12 var url = $(this).data('request-url');
13 var buildReqIds = $(this).data('buildrequest-id');
14 var banner = $(this).parents(".alert");
15
16 banner.find(".progress-info").fadeOut().promise().done(function(){
17 $("#cancelling-msg-" + buildReqIds).show();
18 console.log("cancel build");
19 libtoaster.cancelABuild(url, buildReqIds, function(){
20 if (projectBuilds == false){
21 /* the all builds page is not 'self updating' like thei
22 * project Builds
23 */
24 window.location.reload();
25 }
26 }, null);
27 });
28 });
29
30 $(".run-again-btn").click(function(e){
31 e.preventDefault();
32
33 var url = $(this).data('request-url');
34 var target = $(this).data('target');
35
36 libtoaster.startABuild(url, target, function(){
37 window.location.reload();
38 }, null);
39 });
40
41
42 var progressTimer;
43
44 if (projectBuilds === true){
45 progressTimer = window.setInterval(function() {
46 libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
47 function(prjInfo){
48 /* These two are needed because a build can be 100% and still
49 * in progress due to the fact that the % done is updated at the
50 * start of a task so it can be doing the last task at 100%
51 */
52 var inProgress = 0;
53 var allPercentDone = 0;
54 if (prjInfo.builds.length === 0)
55 return
56
57 for (var i in prjInfo.builds){
58 var build = prjInfo.builds[i];
59
60 if (build.outcome === "In Progress" ||
61 $(".progress .bar").length > 0){
62 /* Update the build progress */
63 var percentDone;
64
65 if (build.outcome !== "In Progress"){
66 /* We have to ignore the value when it's Succeeded because it
67 * goes back to 0
68 */
69 percentDone = 100;
70 } else {
71 percentDone = build.percentDone;
72 inProgress++;
73 }
74
75 $("#build-pc-done-" + build.id).text(percentDone);
76 $("#build-pc-done-title-" + build.id).attr("title", percentDone);
77 $("#build-pc-done-bar-" + build.id).css("width",
78 String(percentDone) + "%");
79
80 allPercentDone += percentDone;
81 }
82 }
83
84 if (allPercentDone === (100 * prjInfo.builds.length) && !inProgress)
85 window.location.reload();
86
87 /* Our progress bar is not still showing so shutdown the polling. */
88 if ($(".progress .bar").length === 0)
89 window.clearInterval(progressTimer);
90
91 });
92 }, 1500);
93 }
94}
95