diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templates')
3 files changed, 17 insertions, 66 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html index 51610e4ab3..a6d4ac66fc 100644 --- a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html | |||
@@ -3,6 +3,7 @@ | |||
3 | {% load humanize %} | 3 | {% load humanize %} |
4 | 4 | ||
5 | {%if mru|length > 0%} | 5 | {%if mru|length > 0%} |
6 | {# Template provides the latest builds section requires mru in the context which can be added from _managed_get_latest_builds #} | ||
6 | <div class="page-header top-air"> | 7 | <div class="page-header top-air"> |
7 | <h1> | 8 | <h1> |
8 | Latest builds | 9 | Latest builds |
@@ -118,6 +119,7 @@ | |||
118 | <div class="span4 lead">Build queued | 119 | <div class="span4 lead">Build queued |
119 | <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> | 120 | <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> |
120 | </div> | 121 | </div> |
122 | <button class="btn btn-info pull-right cancel-build-btn" data-build-id="{{buildrequest.id}}" data-request-url="{% url 'xhr_projectbuild' buildrequest.project.id %}" >Cancel</button> | ||
121 | 123 | ||
122 | {% elif buildrequest.state == buildrequest.REQ_CREATED %} | 124 | {% elif buildrequest.state == buildrequest.REQ_CREATED %} |
123 | 125 | ||
@@ -155,37 +157,25 @@ | |||
155 | 157 | ||
156 | <script> | 158 | <script> |
157 | 159 | ||
158 | /* ensure csrf cookie exists {% csrf_token %} */ | 160 | function scheduleBuild(url, projectName, projectUrl, buildlist) { |
159 | function _makeXHRBuildCall(url, data, onsuccess, onfail) { | 161 | console.log("scheduleBuild"); |
160 | $.ajax( { | 162 | libtoaster.startABuild(url, null, buildlist.join(" "), function(){ |
161 | type: "POST", | 163 | window.location.reload(); |
162 | url: url, | 164 | }, null); |
163 | data: data, | ||
164 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
165 | success: function (_data) { | ||
166 | if (_data.error != "ok") { | ||
167 | alert(_data.error); | ||
168 | } else { | ||
169 | if (onsuccess != undefined) onsuccess(_data); | ||
170 | } | ||
171 | }, | ||
172 | error: function (_data) { | ||
173 | alert("Call failed"); | ||
174 | console.log(_data); | ||
175 | if (onfail) onfail(data); | ||
176 | } }); | ||
177 | } | 165 | } |
178 | 166 | ||
167 | $(document).ready(function(){ | ||
179 | 168 | ||
180 | function scheduleBuild(url, projectName, projectUrl, buildlist) { | 169 | $(".cancel-build-btn").click(function (){ |
181 | console.log("scheduleBuild"); | 170 | var url = $(this).data('request-url'); |
182 | _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) { | 171 | var buildIds = $(this).data('build-id'); |
172 | var btn = $(this); | ||
183 | 173 | ||
184 | $('#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\">" + | 174 | libtoaster.cancelABuild(url, buildIds, function(){ |
185 | "<div class=\"span5 lead\">" + buildlist.join(" ") + | 175 | btn.parents(".alert").fadeOut(); |
186 | "</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>"); | 176 | }, null); |
187 | }); | 177 | }); |
188 | } | 178 | }); |
189 | 179 | ||
190 | </script> | 180 | </script> |
191 | 181 | ||
diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html index 432955ab88..c7bddf0372 100644 --- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html | |||
@@ -50,9 +50,6 @@ | |||
50 | <span class="lead{%if not MANAGED or not build.project%} pull-right{%endif%}"> | 50 | <span class="lead{%if not MANAGED or not build.project%} pull-right{%endif%}"> |
51 | Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent|sectohms }}</a> | 51 | Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent|sectohms }}</a> |
52 | </span> | 52 | </span> |
53 | {% if MANAGED and build.project %} | ||
54 | <a 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}}, {{build.get_sorted_target_list|mapselect:'target'|json}})">Run again</a> | ||
55 | {% endif %} | ||
56 | </div> | 53 | </div> |
57 | {%endif%} | 54 | {%endif%} |
58 | {%if build.outcome == build.IN_PROGRESS %} | 55 | {%if build.outcome == build.IN_PROGRESS %} |
@@ -68,41 +65,5 @@ | |||
68 | 65 | ||
69 | {% endfor %} | 66 | {% endfor %} |
70 | </div> | 67 | </div> |
71 | |||
72 | <script> | ||
73 | |||
74 | function _makeXHRBuildCall(url, data, onsuccess, onfail) { | ||
75 | $.ajax( { | ||
76 | type: "POST", | ||
77 | url: url, | ||
78 | data: data, | ||
79 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
80 | success: function (_data) { | ||
81 | if (_data.error != "ok") { | ||
82 | console.warn(_data.error); | ||
83 | } else { | ||
84 | if (onsuccess != undefined) onsuccess(_data); | ||
85 | } | ||
86 | }, | ||
87 | error: function (_data) { | ||
88 | console.warn("Call failed"); | ||
89 | console.warn(_data); | ||
90 | if (onfail) onfail(data); | ||
91 | } }); | ||
92 | } | ||
93 | |||
94 | |||
95 | function scheduleBuild(url, projectName, buildlist) { | ||
96 | console.warn("scheduleBuild"); | ||
97 | _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) { | ||
98 | |||
99 | $('#latest-builds').prepend('<div class="alert alert-info" style="padding-top:0px">' + '<span class="label label-info" style="font-weight: normal; margin-bottom: 5px; margin-left:-15px; padding-top:5px;">'+projectName+'</span><div class="row-fluid">' + | ||
100 | '<div class="span4 lead">' + buildlist.join(" ") + | ||
101 | '</div><div class="span4 lead pull-right">Build queued. Your build will start shortly.</div></div></div>'); | ||
102 | }); | ||
103 | } | ||
104 | |||
105 | </script> | ||
106 | |||
107 | {%endif%} | 68 | {%endif%} |
108 | 69 | ||
diff --git a/bitbake/lib/toaster/toastergui/templates/projects.html b/bitbake/lib/toaster/toastergui/templates/projects.html index 88d5bd32df..88ee4bcd66 100644 --- a/bitbake/lib/toaster/toastergui/templates/projects.html +++ b/bitbake/lib/toaster/toastergui/templates/projects.html | |||
@@ -7,7 +7,7 @@ | |||
7 | {% block pagecontent %} | 7 | {% block pagecontent %} |
8 | 8 | ||
9 | 9 | ||
10 | {% include "mrb_section.html" %} | 10 | {% include "managed_mrb_section.html" %} |
11 | 11 | ||
12 | 12 | ||
13 | <div class="page-header top-air"> | 13 | <div class="page-header top-air"> |