summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js28
-rw-r--r--bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html42
-rw-r--r--bitbake/lib/toaster/toastergui/templates/mrb_section.html39
-rw-r--r--bitbake/lib/toaster/toastergui/templates/projects.html2
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py11
5 files changed, 53 insertions, 69 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 38320667dc..fcf82ac65b 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -93,6 +93,33 @@ var libtoaster = (function (){
93 } }); 93 } });
94 } 94 }
95 95
96 /* cancelABuild:
97 * url: xhr_projectbuild
98 * builds_ids: space separated list of build request ids
99 * onsuccess: callback for successful execution
100 * onfail: callback for failed execution
101 */
102 function _cancelABuild(url, build_ids, onsuccess, onfail){
103 $.ajax( {
104 type: "POST",
105 url: url,
106 data: { 'buildCancel': build_ids },
107 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
108 success: function (_data) {
109 if (_data.error !== "ok") {
110 console.warn(_data.error);
111 } else {
112 if (onsuccess !== undefined) onsuccess(_data);
113 }
114 },
115 error: function (_data) {
116 console.warn("Call failed");
117 console.warn(_data);
118 if (onfail) onfail(data);
119 }
120 });
121 }
122
96 /* Get a project's configuration info */ 123 /* Get a project's configuration info */
97 function _getProjectInfo(url, projectId, onsuccess, onfail){ 124 function _getProjectInfo(url, projectId, onsuccess, onfail){
98 $.ajax({ 125 $.ajax({
@@ -197,6 +224,7 @@ var libtoaster = (function (){
197 return { 224 return {
198 reload_params : reload_params, 225 reload_params : reload_params,
199 startABuild : _startABuild, 226 startABuild : _startABuild,
227 cancelABuild : _cancelABuild,
200 makeTypeahead : _makeTypeahead, 228 makeTypeahead : _makeTypeahead,
201 getProjectInfo: _getProjectInfo, 229 getProjectInfo: _getProjectInfo,
202 getLayerDepsForProject : _getLayerDepsForProject, 230 getLayerDepsForProject : _getLayerDepsForProject,
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 %} */ 160function scheduleBuild(url, projectName, projectUrl, buildlist) {
159function _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
180function 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
74function _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
95function 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">
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 661023e523..26c876080d 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1871,8 +1871,7 @@ if toastermain.settings.MANAGED:
1871 1871
1872 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) 1872 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
1873 # most recent build is like projects' most recent builds, but across all projects 1873 # most recent build is like projects' most recent builds, but across all projects
1874 build_mru = BuildRequest.objects.all() 1874 build_mru = _managed_get_latest_builds()
1875 build_mru = list(build_mru.filter(Q(state__lt=BuildRequest.REQ_COMPLETED) or Q(state=BuildRequest.REQ_DELETED)).order_by("-pk")) + list(build_mru.filter(state__in=[BuildRequest.REQ_COMPLETED, BuildRequest.REQ_FAILED]).order_by("-pk")[:3])
1876 1875
1877 fstypes_map = {}; 1876 fstypes_map = {};
1878 for build_request in build_info: 1877 for build_request in build_info:
@@ -3130,6 +3129,12 @@ if toastermain.settings.MANAGED:
3130 } 3129 }
3131 return render(request, "unavailable_artifact.html", context) 3130 return render(request, "unavailable_artifact.html", context)
3132 3131
3132 # This returns the mru object that is needed for the
3133 # managed_mrb_section.html template
3134 def _managed_get_latest_builds():
3135 build_mru = BuildRequest.objects.all()
3136 build_mru = list(build_mru.filter(Q(state__lt=BuildRequest.REQ_COMPLETED) or Q(state=BuildRequest.REQ_DELETED)).order_by("-pk")) + list(build_mru.filter(state__in=[BuildRequest.REQ_COMPLETED, BuildRequest.REQ_FAILED]).order_by("-pk")[:3])
3137 return build_mru
3133 3138
3134 3139
3135 def projects(request): 3140 def projects(request):
@@ -3153,7 +3158,7 @@ if toastermain.settings.MANAGED:
3153 project_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1)) 3158 project_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
3154 3159
3155 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) 3160 # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
3156 build_mru = Build.objects.order_by("-started_on")[:3] 3161 build_mru = _managed_get_latest_builds()
3157 3162
3158 # translate the project's build target strings 3163 # translate the project's build target strings
3159 fstypes_map = {}; 3164 fstypes_map = {};