bitbake: toaster: Add cancel build to latest build section
Add this functionality to the common managed_mrb_section Make sure we are using the correct version of this template in the projects template and remove now redundant code. [YOCTO #7351] (Bitbake rev: 23f1439a5d3e8f4053826794c6502eca20189054) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
2f684f1bdc
commit
3c5e291760
|
@ -93,6 +93,33 @@ var libtoaster = (function (){
|
|||
} });
|
||||
}
|
||||
|
||||
/* cancelABuild:
|
||||
* url: xhr_projectbuild
|
||||
* builds_ids: space separated list of build request ids
|
||||
* onsuccess: callback for successful execution
|
||||
* onfail: callback for failed execution
|
||||
*/
|
||||
function _cancelABuild(url, build_ids, onsuccess, onfail){
|
||||
$.ajax( {
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: { 'buildCancel': build_ids },
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (_data) {
|
||||
if (_data.error !== "ok") {
|
||||
console.warn(_data.error);
|
||||
} else {
|
||||
if (onsuccess !== undefined) onsuccess(_data);
|
||||
}
|
||||
},
|
||||
error: function (_data) {
|
||||
console.warn("Call failed");
|
||||
console.warn(_data);
|
||||
if (onfail) onfail(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Get a project's configuration info */
|
||||
function _getProjectInfo(url, projectId, onsuccess, onfail){
|
||||
$.ajax({
|
||||
|
@ -197,6 +224,7 @@ var libtoaster = (function (){
|
|||
return {
|
||||
reload_params : reload_params,
|
||||
startABuild : _startABuild,
|
||||
cancelABuild : _cancelABuild,
|
||||
makeTypeahead : _makeTypeahead,
|
||||
getProjectInfo: _getProjectInfo,
|
||||
getLayerDepsForProject : _getLayerDepsForProject,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% load humanize %}
|
||||
|
||||
{%if mru|length > 0%}
|
||||
{# Template provides the latest builds section requires mru in the context which can be added from _managed_get_latest_builds #}
|
||||
<div class="page-header top-air">
|
||||
<h1>
|
||||
Latest builds
|
||||
|
@ -118,6 +119,7 @@
|
|||
<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>
|
||||
<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>
|
||||
|
||||
{% elif buildrequest.state == buildrequest.REQ_CREATED %}
|
||||
|
||||
|
@ -155,38 +157,26 @@
|
|||
|
||||
<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>");
|
||||
});
|
||||
libtoaster.startABuild(url, null, buildlist.join(" "), function(){
|
||||
window.location.reload();
|
||||
}, null);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$(".cancel-build-btn").click(function (){
|
||||
var url = $(this).data('request-url');
|
||||
var buildIds = $(this).data('build-id');
|
||||
var btn = $(this);
|
||||
|
||||
libtoaster.cancelABuild(url, buildIds, function(){
|
||||
btn.parents(".alert").fadeOut();
|
||||
}, null);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{%endif%}
|
||||
|
|
|
@ -50,9 +50,6 @@
|
|||
<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 MANAGED and build.project %}
|
||||
<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>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%endif%}
|
||||
{%if build.outcome == build.IN_PROGRESS %}
|
||||
|
@ -68,41 +65,5 @@
|
|||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
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") {
|
||||
console.warn(_data.error);
|
||||
} else {
|
||||
if (onsuccess != undefined) onsuccess(_data);
|
||||
}
|
||||
},
|
||||
error: function (_data) {
|
||||
console.warn("Call failed");
|
||||
console.warn(_data);
|
||||
if (onfail) onfail(data);
|
||||
} });
|
||||
}
|
||||
|
||||
|
||||
function scheduleBuild(url, projectName, buildlist) {
|
||||
console.warn("scheduleBuild");
|
||||
_makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function (_data) {
|
||||
|
||||
$('#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">' +
|
||||
'<div class="span4 lead">' + buildlist.join(" ") +
|
||||
'</div><div class="span4 lead pull-right">Build queued. Your build will start shortly.</div></div></div>');
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{%endif%}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{% block pagecontent %}
|
||||
|
||||
|
||||
{% include "mrb_section.html" %}
|
||||
{% include "managed_mrb_section.html" %}
|
||||
|
||||
|
||||
<div class="page-header top-air">
|
||||
|
|
|
@ -1871,8 +1871,7 @@ if toastermain.settings.MANAGED:
|
|||
|
||||
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
|
||||
# most recent build is like projects' most recent builds, but across all projects
|
||||
build_mru = BuildRequest.objects.all()
|
||||
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])
|
||||
build_mru = _managed_get_latest_builds()
|
||||
|
||||
fstypes_map = {};
|
||||
for build_request in build_info:
|
||||
|
@ -3130,6 +3129,12 @@ if toastermain.settings.MANAGED:
|
|||
}
|
||||
return render(request, "unavailable_artifact.html", context)
|
||||
|
||||
# This returns the mru object that is needed for the
|
||||
# managed_mrb_section.html template
|
||||
def _managed_get_latest_builds():
|
||||
build_mru = BuildRequest.objects.all()
|
||||
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])
|
||||
return build_mru
|
||||
|
||||
|
||||
def projects(request):
|
||||
|
@ -3153,7 +3158,7 @@ if toastermain.settings.MANAGED:
|
|||
project_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
|
||||
|
||||
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
|
||||
build_mru = Build.objects.order_by("-started_on")[:3]
|
||||
build_mru = _managed_get_latest_builds()
|
||||
|
||||
# translate the project's build target strings
|
||||
fstypes_map = {};
|
||||
|
|
Loading…
Reference in New Issue