1{% load static %}
2{% load humanize %}
3{% load project_url_tag %}
4<script src="{% static 'js/mrbsection.js' %}"></script>
5
6{% if mru %}
7  {% if mrb_type == 'project' %}
8    <h2>
9      Latest project builds
10
11      {% if project.is_default %}
12        <span class="glyphicon glyphicon-question-sign get-help heading-help" data-original-title="Builds in this project cannot be started from Toaster: they are started from the command line"></span>
13        {% endif %}
14    </h2>
15  {% else %}
16    <div class="page-header">
17      <h1>Latest builds</h1>
18    </div>
19  {% endif %}
20
21  <div id="latest-builds">
22    {% for build in mru %}
23      <div data-latest-build-result="{{build.id}}" class="alert build-result {% if build.outcome == build.SUCCEEDED %}alert-success{% elif build.outcome == build.FAILED %}alert-danger{% else %}alert-info{% endif %}">
24        <!-- project title -->
25        {% if mrb_type != 'project' %}
26          <div class="row project-name">
27            <div class="col-md-12">
28              <small>
29                <a class="alert-link text-uppercase" href="{% project_url build.project %}">
30                  {{build.project.name}}
31                </a>
32              </small>
33            </div>
34          </div>
35        {% endif %}
36
37        <div class="row" data-role="build-status-container">
38          <div class="col-md-12">
39            Loading...
40          </div>
41        </div>
42      </div>
43    {% endfor %}
44  </div>
45{% endif %}
46
47<!-- build main template -->
48<script id="build-template" type="text/x-jsrender">
49  <div class="col-md-3">
50    <!-- only show link for completed builds -->
51    <%if state == 'Succeeded' || state == 'Failed'%>
52      <a class="alert-link" href="<%:dashboard_url%>">
53        <span data-toggle="tooltip" data-role="targets-text" title="Recipes: <%:targets%>">
54          <%:targets_abbreviated%>
55        </span>
56      </a>
57    <%else targets_abbreviated !== ''%>
58      <span data-toggle="tooltip" data-role="targets-text" title="Recipes: <%:targets%>">
59        <%:targets_abbreviated%>
60      </span>
61    <%else%>
62      Fetching recipe names...
63    <%/if%>
64  </div>
65
66  <div class="build-state" data-build-state="<%:state%>">
67    <%if state == 'Cloning'%>
68      <%include tmpl='#cloning-repos-build-template'/%>
69    <%else state == 'Parsing'%>
70      <%include tmpl='#parsing-recipes-build-template'/%>
71    <%else state == 'Queued'%>
72      <%include tmpl='#queued-build-template'/%>
73    <%else state == 'Succeeded' || state == 'Failed'%>
74      <%include tmpl='#succeeded-or-failed-build-template'/%>
75    <%else state == 'Cancelling'%>
76      <%include tmpl='#cancelling-build-template'/%>
77    <%else state == 'Starting'%>
78      <%include tmpl='#starting-template'/%>
79    <%else state == 'In Progress'%>
80      <%include tmpl='#in-progress-build-template'/%>
81    <%else state == 'Cancelled'%>
82      <%include tmpl='#cancelled-build-template'/%>
83    <%/if%>
84  </div>
85</script>
86
87<!-- queued build -->
88<script id="queued-build-template" type="text/x-jsrender">
89  <div class="col-md-5">
90    <span class="glyphicon glyphicon-question-sign get-help get-help-blue"
91          title="This build is waiting for the build directory to become available">
92    </span>
93
94    Build queued
95  </div>
96
97  <div class="col-md-4">
98    <!-- cancel button -->
99    <%include tmpl='#cancel-template'/%>
100  </div>
101</script>
102
103<!-- cloning repos build -->
104<script id="cloning-repos-build-template" type="text/x-jsrender">
105  <!-- progress bar and parse completion percentage -->
106  <div data-role="build-status" class="col-md-4 col-md-offset-1 progress-info">
107    <!-- progress bar -->
108    <div class="progress">
109      <div id="repos-cloned-percentage-bar-<%:id%>"
110           style="width: <%:repos_cloned_percentage%>%;"
111           class="progress-bar">
112      </div>
113    </div>
114  </div>
115
116  <div class="col-md-4 progress-info">
117    <!-- parse completion percentage -->
118    <span class="glyphicon glyphicon-question-sign get-help get-help-blue"
119          title="Toaster is cloning the repos required for your build">
120    </span>
121
122    Cloning <span id="repos-cloned-percentage-<%:id%>"><%:repos_cloned_percentage%></span>% complete <span id="repos-cloned-progressitem-<%:id%>">(<%:progress_item%>)</span>
123
124    <%include tmpl='#cancel-template'/%>
125  </div>
126</script>
127
128<!-- parsing recipes build -->
129<script id="parsing-recipes-build-template" type="text/x-jsrender">
130  <!-- progress bar and parse completion percentage -->
131  <div data-role="build-status" class="col-md-4 col-md-offset-1 progress-info">
132    <!-- progress bar -->
133    <div class="progress">
134      <div id="recipes-parsed-percentage-bar-<%:id%>"
135           style="width: <%:recipes_parsed_percentage%>%;"
136           class="progress-bar">
137      </div>
138    </div>
139  </div>
140
141  <div class="col-md-4 progress-info">
142    <!-- parse completion percentage -->
143    <span class="glyphicon glyphicon-question-sign get-help get-help-blue"
144          title="BitBake is parsing the layers required for your build">
145    </span>
146
147    Parsing <span id="recipes-parsed-percentage-<%:id%>"><%:recipes_parsed_percentage%></span>% complete
148
149    <%include tmpl='#cancel-template'/%>
150  </div>
151</script>
152
153<!-- in progress build; tasks still starting -->
154<script id="starting-template" type="text/x-jsrender">
155  <div class="col-md-5">
156    <span class="glyphicon glyphicon-question-sign get-help get-help-blue"
157          title="This build is waiting for tasks to start">
158    </span>
159
160    Tasks starting...
161  </div>
162
163  <div class="col-md-4">
164    <!-- cancel button -->
165    <%include tmpl='#cancel-template'/%>
166  </div>
167</script>
168
169<!-- in progress build; at least one task finished -->
170<script id="in-progress-build-template" type="text/x-jsrender">
171  <!-- progress bar and task completion percentage -->
172  <div data-role="build-status" class="col-md-4 col-md-offset-1 progress-info">
173    <!-- progress bar -->
174    <div class="progress" id="build-pc-done-title-<%:id%>">
175      <div id="build-pc-done-bar-<%:id%>"
176           style="width: <%:tasks_complete_percentage%>%;"
177           class="progress-bar">
178      </div>
179    </div>
180  </div>
181
182  <div class="col-md-4 progress-info">
183    <!-- task completion percentage -->
184    <span id="build-pc-done-<%:id%>"><%:tasks_complete_percentage%></span>% of
185    tasks complete
186
187    <!-- cancel button -->
188    <%include tmpl='#cancel-template'/%>
189  </div>
190</script>
191
192<!-- cancelling build -->
193<script id="cancelling-build-template" type="text/x-jsrender">
194  <div class="col-md-9">
195    Cancelling the build ...
196  </div>
197</script>
198
199<!-- succeeded or failed build -->
200<script id="succeeded-or-failed-build-template" type="text/x-jsrender">
201  <!-- completed_on -->
202  <div class="col-md-2">
203    <%:completed_on%>
204  </div>
205
206  <!-- errors -->
207  <div class="col-md-2">
208    <%if errors%>
209      <span class="glyphicon glyphicon-minus-sign"></span>
210      <a href="<%:dashboard_errors_url%>" class="alert-link">
211        <%:errors%> error<%:errors_pluralise%>
212      </a>
213    <%/if%>
214  </div>
215
216  <!-- warnings -->
217  <div class="col-md-2">
218    <%if warnings%>
219      <span class="glyphicon glyphicon-warning-sign build-warnings"></span>
220      <a href="<%:dashboard_warnings_url%>" class="alert-link build-warnings">
221        <%:warnings%> warning<%:warnings_pluralise%>
222      </a>
223    <%/if%>
224  </div>
225
226  <!-- build time -->
227  <div class="col-md-3">
228    Build time:
229
230    <span data-role="data-recent-build-buildtime-field">
231      <%if state == 'Succeeded'%>
232        <a class="alert-link" href="<%:buildtime_url%>"><%:buildtime%></a>
233      <%else%>
234        <%:buildtime%>
235      <%/if%>
236    </span>
237
238    <!-- rebuild button -->
239    <%include tmpl='#rebuild-template'/%>
240  </div>
241</script>
242
243<!-- cancelled build -->
244<script id="cancelled-build-template" type="text/x-jsrender">
245  <!-- build cancelled message -->
246  <div class="col-md-6">
247    Build cancelled
248  </div>
249
250  <!-- rebuild button -->
251  <div class="col-md-3">
252    <%include tmpl='#rebuild-template'/%>
253  </div>
254</script>
255
256<!-- rebuild button or no rebuild icon -->
257<script id="rebuild-template" type="text/x-jsrender">
258  <%if is_default_project_build%>
259    <!-- no rebuild info icon -->
260    <span class="pull-right glyphicon glyphicon-question-sign get-help <%if state == 'Succeeded'%>get-help-green<%else state == 'Failed'%>get-help-red<%else%>get-help-blue<%/if%>"
261    title="Builds in this project cannot be started from Toaster: they are started from the command line">
262    </span>
263  <%else%>
264    <!-- rebuild button -->
265    <span class="rebuild-btn alert-link <%if state == 'Success'%>success<%else state == 'Failed'%>danger<%else%>info<%/if%> pull-right"
266    data-request-url="<%:rebuild_url%>" data-target='<%:build_targets_json%>'>
267      <span class="glyphicon glyphicon-repeat"></span>
268      Rebuild
269    </span>
270  <%/if%>
271</script>
272
273<!-- cancel button or no cancel icon -->
274<script id="cancel-template" type="text/x-jsrender">
275  <%if is_default_project_build%>
276    <!-- no cancel icon -->
277    <span class="glyphicon glyphicon-question-sign get-help get-help-blue pull-right" title="Builds in this project cannot be cancelled from Toaster: they can only be cancelled from the command line"></span>
278  <%else%>
279    <!-- cancel button -->
280    <span class="cancel-build-btn pull-right alert-link"
281    data-buildrequest-id="<%:buildrequest_id%>" data-request-url="<%:cancel_url%>">
282      <span class="glyphicon glyphicon-remove-circle"></span>
283      Cancel
284    </span>
285  <%/if%>
286</script>
287
288<script>
289  $(document).ready(function () {
290    var ctx = {
291      mrbType : "{{mrb_type}}",
292    }
293
294    try {
295      mrbSectionInit(ctx);
296    } catch (e) {
297      document.write("Sorry, An error has occurred loading this page");
298      console.warn(e);
299    }
300  });
301</script>
302