blob: bd8f99178f7dfe223301937fce846518590ad2ff [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001{% load static %}
2{% load projecttags %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -05003{% load project_url_tag %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004{% load humanize %}
5
Patrick Williamsf1e5d692016-03-30 15:21:19 -05006{%if mru and mru.count > 0%}
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
Patrick Williamsf1e5d692016-03-30 15:21:19 -05008 {%if mrb_type == 'project' %}
9 <h2>
10 Latest project builds
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
Patrick Williamsf1e5d692016-03-30 15:21:19 -050012 {% if project.is_default %}
13 <i class="icon-question-sign get-help heading-help" title="" data-original-title="Builds in this project cannot be started from Toaster: they are started from the command line"></i>
14 {% endif %}
15 </h2>
16 {% else %}
17 <div class="page-header">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 <h1>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050019 Latest builds
20 </h1>
21 </div>
22 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 <div id="latest-builds">
24 {% for build in mru %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050025 <div data-latest-build-result="{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}{% if mrb_type != 'project' %} project-name{% endif %}">
26 {% if mrb_type != 'project' %}
27 <span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
28 <a href={% project_url build.project %}>
29 {{build.project.name}}
30 </a>
31 </span>
32 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 <div class="row-fluid">
Patrick Williamsf1e5d692016-03-30 15:21:19 -050034 <div class="span3 lead">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035 {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050036 <a href="{%url 'builddashboard' build.pk%}" class="{%if build.outcome == build.SUCCEEDED %}success{%else%}error{%endif%}">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 {% endif %}
38 {% if build.target_set.all.count > 0 %}
39 <span data-toggle="tooltip"
Patrick Williamsf1e5d692016-03-30 15:21:19 -050040 {% if build.target_set.all.count > 1 %}
41 title="Targets:
42 {% for target in build.target_set.all %}
43 {% if target.task %}
44 {{target.target}}:{{target.task}}
45 {% else %}
46 {{target.target}}
47 {% endif %}
48 {% endfor %}"
49 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 >
Patrick Williamsf1e5d692016-03-30 15:21:19 -050051 {% if build.target_set.all.0.task %}
52 {{build.target_set.all.0.target}}:{{build.target_set.all.0.task}}
53 {% else %}
54 {{build.target_set.all.0.target}}
55 {% endif %}
56 {% if build.target_set.all.count > 1 %}
57 (+ {{build.target_set.all.count|add:"-1"}})
58 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 </span>
60 {% endif %}
61 {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
62 </a>
63 {% endif %}
64 </div>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050065 {% if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066 <div class="span2 lead">
67 {% if build.completed_on|format_build_date %}
68 {{ build.completed_on|date:'d/m/y H:i' }}
69 {% else %}
70 {{ build.completed_on|date:'H:i' }}
71 {% endif %}
72 </div>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050073 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
75 <div class="span2 lead">
76 {% if build.errors.count %}
77 <i class="icon-minus-sign red"></i> <a href="{%url 'builddashboard' build.pk%}#errors" class="error">{{build.errors.count}} error{{build.errors.count|pluralize}}</a>
78 {% endif %}
79 </div>
80 <div class="span2 lead">
81 {% if build.warnings.count %}
82 <i class="icon-warning-sign yellow"></i> <a href="{%url 'builddashboard' build.pk%}#warnings" class="warning">{{build.warnings.count}} warning{{build.warnings.count|pluralize}}</a>
83 {% endif %}
84 </div>
85 <div class="lead ">
86 <span class="lead">
Patrick Williamsf1e5d692016-03-30 15:21:19 -050087 Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent_seconds|sectohms }}</a>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 </span>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050089 {% if build.project.is_default %}
90 <i class="pull-right icon-question-sign get-help
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 {% if build.outcome == build.SUCCEEDED %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050092 get-help-green
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 {% elif build.outcome == build.FAILED %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050094 get-help-red
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 {% else %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050096 get-help-blue
97 {% endif %}
98 " title="Builds in this project cannot be started from Toaster: they are started from the command line">
99 </i>
100 {% else %}
101 <button class="btn
102 {% if build.outcome == build.SUCCEEDED %}
103 btn-success
104 {% elif build.outcome == build.FAILED %}
105 btn-danger
106 {% else %}
107 btn-info
108 {%endif%}
109 pull-right"
110 onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
111 {{build.project.name|json}},
112 {% url 'project' build.project.id as purl %}{{purl|json}},
113 {{build.target_set.all|get_tasks|json}})'>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500115 Run again
116 </button>
117 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 </div>
119 {%endif%}
120 {%if build.outcome == build.IN_PROGRESS %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500121 <div class="span4 offset1">
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122 <div class="progress" style="margin-top:5px;" data-toggle="tooltip" title="{{build.completeper}}% of tasks complete">
123 <div style="width: {{build.completeper}}%;" class="bar"></div>
124 </div>
125 </div>
126 <div class="lead pull-right">{{build.completeper}}% of tasks complete</div>
127 {%endif%}
128 </div>
129 </div>
130
131 {% endfor %}
132 </div>
133
134<script>
135
136function scheduleBuild(url, projectName, projectUrl, buildlist) {
137 console.log("scheduleBuild");
138 libtoaster.startABuild(url, null, buildlist.join(" "), function(){
139 console.log("reloading page");
140 window.location.reload();
141 }, null);
142}
143
144$(document).ready(function(){
145
146 $(".cancel-build-btn").click(function (){
147 var url = $(this).data('request-url');
148 var buildIds = $(this).data('build-id');
149 var btn = $(this);
150
151 libtoaster.cancelABuild(url, buildIds, function(){
152 btn.parents(".alert").fadeOut();
153 }, null);
154 });
155});
156
157</script>
158
159{%endif%}
160