diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/mrbsection.js | 95 |
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 | |||
2 | function 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 | |||