summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/mrbsection.js95
-rw-r--r--bitbake/lib/toaster/toastergui/templates/mrb_section.html148
2 files changed, 149 insertions, 94 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
diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
index 551e341a5d..b5e798d7cc 100644
--- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
+++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
@@ -2,6 +2,21 @@
2{% load projecttags %} 2{% load projecttags %}
3{% load project_url_tag %} 3{% load project_url_tag %}
4{% load humanize %} 4{% load humanize %}
5<script src="{% static 'js/mrbsection.js' %}"></script>
6<script>
7 $(document).ready(function () {
8 var ctx = {
9 mrbType : "{{mrb_type}}",
10 }
11
12 try {
13 mrbSectionInit(ctx);
14 } catch (e) {
15 document.write("Sorry, An error has occurred loading this page");
16 console.warn(e);
17 }
18 });
19</script>
5 20
6{%if mru and mru.count > 0%} 21{%if mru and mru.count > 0%}
7 22
@@ -99,7 +114,7 @@
99 " title="Builds in this project cannot be started from Toaster: they are started from the command line"> 114 " title="Builds in this project cannot be started from Toaster: they are started from the command line">
100 </i> 115 </i>
101 {% else %} 116 {% else %}
102 <button class="btn 117 <button class="run-again-btn btn
103 {% if build.outcome == build.SUCCEEDED %} 118 {% if build.outcome == build.SUCCEEDED %}
104 btn-success 119 btn-success
105 {% elif build.outcome == build.FAILED %} 120 {% elif build.outcome == build.FAILED %}
@@ -108,10 +123,9 @@
108 btn-info 123 btn-info
109 {%endif%} 124 {%endif%}
110 pull-right" 125 pull-right"
111 onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}}, 126 data-request-url="{% url 'xhr_buildrequest' build.project.pk %}"
112 {{build.project.name|json}}, 127 data-target='{{build.target_set.all|get_tasks|json}}'>
113 {% url 'project' build.project.id as purl %}{{purl|json}}, 128
114 {{build.target_set.all|get_tasks|json}})'>
115 129
116 Rebuild 130 Rebuild
117 </button> 131 </button>
@@ -119,100 +133,46 @@
119 </div> 133 </div>
120 {%endif%} 134 {%endif%}
121 {%if build.outcome == build.IN_PROGRESS %} 135 {%if build.outcome == build.IN_PROGRESS %}
122 <div class="span4 offset1"> 136 <div class="span4" style="display:none" id="cancelling-msg-{{build.buildrequest.pk}}">
123 <div class="progress" id="build-pc-done-title-{{build.pk}}" style="margin-top:5px;" data-toggle="tooltip" title="{{build.completeper}}% of tasks complete"> 137 <p class="lead">Cancelling the build ...</p>
124 <div id="build-pc-done-bar-{{build.pk}}" style="width: {{build.completeper}}%;" class="bar"></div>
125 </div>
126 </div>
127 <div class="lead pull-right"><span id="build-pc-done-{{build.pk}}">{{build.completeper}}</span>% of tasks complete</div>
128 {%endif%}
129 </div>
130 </div> 138 </div>
139 <div class="span4 offset1 progress-info">
140 <div class="progress" id="build-pc-done-title-{{build.pk}}" style="margin-top:5px;" data-toggle="tooltip" title="{{build.completeper}}% of tasks complete">
141 <div id="build-pc-done-bar-{{build.pk}}" style="width: {{build.completeper}}%;" class="bar"></div>
142 </div>
143 </div>
144 <div class="lead span3 progress-info"><span id="build-pc-done-{{build.pk}}">{{build.completeper}}</span>% of tasks complete</div>
145 {# No build cancel for command line builds project #}
146 {% if build.project.is_default %}
147 <i class="icon-question-sign get-help get-help-blue pull-right" title="" data-original-title="Builds in this project cannot be cancelled from Toaster: they can only be cancalled from the command line"></i>
148 {% else %}
149 <div class="lead pull-right progress-info">
150 <button class="cancel-build-btn btn btn-info pull-right"
151 data-buildrequest-id={{build.buildrequest.pk}}
152 data-request-url="{% url 'xhr_buildrequest' build.project.pk %}" >
153 Cancel
154 </button>
155 </div>
156 {% endif %}
131 157
132 {% endfor %} 158 {%endif%} {# end if in progress #}
133 </div>
134
135<script>
136
137function scheduleBuild(url, projectName, projectUrl, buildlist) {
138 console.log("scheduleBuild");
139 libtoaster.startABuild(url, null, buildlist.join(" "), function(){
140 console.log("reloading page");
141 window.location.reload();
142 }, null);
143}
144
145$(document).ready(function(){
146
147 $(".cancel-build-btn").click(function (){
148 var url = $(this).data('request-url');
149 var buildIds = $(this).data('build-id');
150 var btn = $(this);
151
152 libtoaster.cancelABuild(url, buildIds, function(){
153 btn.parents(".alert").fadeOut();
154 }, null);
155 });
156
157 {%if mrb_type == 'project' %}
158 var projectBuilds = true;
159 {% else %}
160 var projectBuilds = false;
161 {% endif %}
162
163 var progressTimer;
164
165 if (projectBuilds === true){
166 progressTimer = window.setInterval(function() {
167 libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
168 function(prjInfo){
169 /* These two are needed because a build can be 100% and still
170 * in progress due to the fact that the % done is updated at the
171 * start of a task so it can be doing the last task at 100%
172 */
173 var inProgress = 0;
174 var allPercentDone = 0;
175
176 for (var i in prjInfo.builds){
177 var build = prjInfo.builds[i];
178
179 if (build.outcome === "In Progress" ||
180 $(".progress .bar").length > 0){
181 /* Update the build progress */
182 var percentDone;
183
184 if (build.outcome !== "In Progress"){
185 /* We have to ignore the value when it's Succeeded because it
186 * goes back to 0
187 */
188 percentDone = 100;
189 } else {
190 percentDone = build.percentDone;
191 inProgress++;
192 }
193
194 $("#build-pc-done-" + build.id).text(percentDone);
195 $("#build-pc-done-title-" + build.id).attr("title", percentDone);
196 $("#build-pc-done-bar-" + build.id).css("width",
197 String(percentDone) + "%");
198
199 allPercentDone += percentDone;
200 }
201 }
202
203 if (allPercentDone === (100 * prjInfo.builds.length) && !inProgress)
204 window.location.reload();
205 159
206 /* Our progress bar is not still showing so shutdown the polling. */ 160 {% if build.outcome == build.CANCELLED %}
207 if ($(".progress .bar").length === 0) 161 <div class="span4">
208 window.clearInterval(progressTimer); 162 <p class="lead">Build cancelled</p>
163 </div>
164 <button class="btn btn-info pull-right run-again-btn"
165 data-request-url="{% url 'xhr_buildrequest' build.project.pk %}"
166 data-target='{{build.target_set.all|get_tasks|json}}'>
167 Rebuild
209 168
210 }); 169 </button>
211 }, 1500); 170 {% endif %}
212 } 171 </div>
213}); 172</div>
214 173
215</script> 174 {% endfor %}
175 </div>
216 176
217{%endif%} 177{%endif%}
218 178