1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
{% load static %}
{% load projecttags %}
{% load humanize %}
{%if mru|length > 0%}
<div class="page-header top-air">
<h1>
Latest builds
</h1>
</div>
<div id="latest-builds">
{% for buildrequest in mru %}{% with build=buildrequest.build %}
{% if build %} {# if we have a build, just display it #}
<div class="alert {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%} {% if MANAGED and build.project %}project-name{% endif %} ">
{% if MANAGED and build.project %}
<span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
<a href="{% url 'project' build.project.id %}"> {{build.project.name}} </a>
</span>
{% endif %}
<div class="row-fluid">
<div class="span3 lead">
{%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
<a href="{%url 'builddashboard' build.pk%}" class="{%if build.outcome == build.SUCCEEDED %}success{%else%}error{%endif%}">
{% endif %}
<span data-toggle="tooltip" {%if build.target_set.all.count > 1%}title="Targets: {%for target in build.target_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{build.target_set.all.0.target}} {%if build.target_set.all.count > 1%}(+ {{build.target_set.all.count|add:"-1"}}){%endif%}
</span>
{%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
</a>
{% endif %}
</div>
{%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
<div class="span2 lead">
{% if build.completed_on|format_build_date %}
{{ build.completed_on|date:'d/m/y H:i' }}
{% else %}
{{ build.completed_on|date:'H:i' }}
{% endif %}
</div>
<div class="span2 lead">
{% if build.errors_no %}
<i class="icon-minus-sign red"></i> <a href="{%url 'builddashboard' build.pk%}#errors" class="error">{{build.errors_no}} error{{build.errors_no|pluralize}}</a>
{% endif %}
</div>
<div class="span2 lead">
{% if build.warnings_no %}
<i class="icon-warning-sign yellow"></i> <a href="{%url 'builddashboard' build.pk%}#warnings" class="warning">{{build.warnings_no}} warning{{build.warnings_no|pluralize}}</a>
{% endif %}
</div>
<div class="lead ">
<span class="lead{%if not MANAGED or not build.project%} pull-right{%endif%}">
Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent|sectohms }}</a>
</span>
{% if build.project %}
<button class="btn {%if build.outcome == build.SUCCEEDED%}btn-success{%elif build.outcome == build.FAILED%}btn-danger{%else%}btn-info{%endif%} pull-right" onclick='scheduleBuild({% url 'xhr_projectbuild' build.project.id as bpi%}{{bpi|json}}, {{build.project.name|json}},
{% url 'project' buildrequest.project.id as bpurl%}{{bpurl|json}}, {{build.get_sorted_target_list|mapselect:'target'|json}})'>Run again</button>
{% endif %}
</div>
{%endif%}
{%if build.outcome == build.IN_PROGRESS %}
<div class="span4 offset1">
<div class="progress" style="margin-top:5px;" data-toggle="tooltip" title="{{build.completeper}}% of tasks complete">
<div style="width: {{build.completeper}}%;" class="bar"></div>
</div>
</div>
<div class="lead pull-right">ETA: in {{build.eta|naturaltime}}</div>
{%endif%}
</div>
</div>
{% else %} {# we use the project's page recent build design #}
<div class="alert {% if buildrequest.state == buildrequest.REQ_FAILED %}alert-error{% else %}alert-info{% endif %} project-name">
<span class="label {% if buildrequest.state == buildrequest.REQ_FAILED %}label-important{% else%}label-info{% endif %}">
<a href="{% url 'project' buildrequest.project.id %}"> {{buildrequest.project.name}} </a>
</span>
<div class="row-fluid">
{% if buildrequest.state == buildrequest.REQ_FAILED %}
<div class="span3 lead">
<a href="{%url 'buildrequestdetails' buildrequest.project.id buildrequest.pk%}" class="error">
<span data-toggle="tooltip" {%if buildrequest.brtarget_set.all.count > 1%}title="Targets: {%for target in buildrequest.brtarget_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{buildrequest.brtarget_set.all.0.target}} {%if buildrequest.brtarget_set.all.count > 1%}(+ {{buildrequest.brtarget_set.all.count|add:"-1"}}){%endif%} </span>
</a>
</div>
<div class="span2 lead">
{% if buildrequest.updated|format_build_date %}
{{ buildrequest.updated|date:'d/m/y H:i' }}
{% else %}
{{ buildrequest.updated|date:'H:i' }}
{% endif %}
</div>
<div class="span2 lead">
{% if buildrequest.brerror_set.all.count %}
<i class="icon-minus-sign red"></i> <a href="{%url 'buildrequestdetails' buildrequest.project.id buildrequest.pk %}#errors" class="error">{{buildrequest.brerror_set.all.count}} error{{buildrequest.brerror_set.all.count|pluralize}}</a>
{% endif %}
</div>
<div class="span2 lead"> {# there are no warnings for buildrequests #}
</div>
<div class="lead ">
<span class="lead{%if not MANAGED or not buildrequest.project%} pull-right{%endif%}">
Build time: {{ buildrequest.get_duration|sectohms }}
</span>
<button class="btn btn-danger pull-right" onclick='scheduleBuild({% url 'xhr_projectbuild' buildrequest.project.id as bpi%}{{bpi|json}}, {{buildrequest.project.name|json}}, {% url 'project' buildrequest.project.id as bpurl%}|{{bpurl|json}}, {{buildrequest.get_sorted_target_list|mapselect:'target'|json}})'>Run again</button>
</div>
{% elif buildrequest.state == buildrequest.REQ_QUEUED %}
<div class="lead span5">
<span data-toggle="tooltip" {%if buildrequest.brtarget_set.all.count > 1%}title="Targets: {%for target in buildrequest.brtarget_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{buildrequest.brtarget_set.all.0.target}} {%if buildrequest.brtarget_set.all.count > 1%}(+ {{buildrequest.brtarget_set.all.count|add:"-1"}}){%endif%} </span>
</div>
<div class="span4 lead">Build queued
<i title="This build will start as soon as a build server is available" class="icon-question-sign get-help get-help-blue heading-help" data-toggle="tooltip"></i>
</div>
{% elif buildrequest.state == buildrequest.REQ_CREATED %}
<div class="lead span3">
<span data-toggle="tooltip" {%if buildrequest.brtarget_set.all.count > 1%}title="Targets: {%for target in buildrequest.brtarget_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{buildrequest.brtarget_set.all.0.target}} {%if buildrequest.brtarget_set.all.count > 1%}(+ {{buildrequest.brtarget_set.all.count|add:"-1"}}){%endif%} </span>
</div>
<div class="span6" >
<span class="lead">Creating build</span>
</div>
{% elif buildrequest.state == buildrequest.REQ_INPROGRESS %}
<div class="lead span5">
<span data-toggle="tooltip" {%if buildrequest.brtarget_set.all.count > 1%}title="Targets: {%for target in buildrequest.brtarget_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{buildrequest.brtarget_set.all.0.target}} {%if buildrequest.brtarget_set.all.count > 1%}(+ {{buildrequest.brtarget_set.all.count|add:"-1"}}){%endif%} </span>
</div>
<div class="span4 lead">
Checking out layers
</div>
{% else %}
<div>FIXME!</div>
{% endif %}
<div class="lead pull-right">
</div>
</div>
</div>
{% endif %} {# this ends the build request most recent build section #}
{%endwith%}{% endfor %}
</div>
<script>
/* ensure csrf cookie exists {% csrf_token %} */
function _makeXHRBuildCall(url, data, onsuccess, onfail) {
$.ajax( {
type: "POST",
url: url,
data: data,
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
success: function (_data) {
if (_data.error != "ok") {
alert(_data.error);
} else {
if (onsuccess != undefined) onsuccess(_data);
}
},
error: function (_data) {
alert("Call failed");
console.log(_data);
if (onfail) onfail(data);
} });
}
function scheduleBuild(url, projectName, projectUrl, buildlist) {
console.log("scheduleBuild");
_makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) {
$('#latest-builds').prepend("<div class=\"alert alert-info project-name\"><span class=\"label label-info\"><a href=\""+projectUrl+"\">"+projectName+"</a></span><div class=\"row-fluid\">" +
"<div class=\"span5 lead\">" + buildlist.join(" ") +
"</div><div class=\"span4 lead\">Build queued <i title=\"This build will start as soon as a build server is available\" class=\"icon-question-sign get-help get-help-blue heading-help\"></i></div></div></div>");
});
}
</script>
{%endif%}
|