summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templates/mrb_section.html
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templates/mrb_section.html')
-rw-r--r--bitbake/lib/toaster/toastergui/templates/mrb_section.html148
1 files changed, 54 insertions, 94 deletions
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