[Toaster] [review-request][PATCH] bitbake: toaster: Add cancel build to latest build section
Damian, Alexandru
alexandru.damian at intel.com
Tue Mar 17 04:05:43 PDT 2015
Taken for submission,
Thank you,
Alex
On Fri, Mar 13, 2015 at 3:13 PM, Barros Pena, Belen <
belen.barros.pena at intel.com> wrote:
>
>
> On 13/03/2015 14:34, "Michael Wood" <michael.g.wood at intel.com> wrote:
>
> >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]
>
> The UI looks good.
>
> Thanks!
>
> Belén
>
> >
> >Signed-off-by: Michael Wood <michael.g.wood at intel.com>
> >---
> > .../lib/toaster/toastergui/static/js/libtoaster.js | 28 +++++++++++++++
> > .../toastergui/templates/managed_mrb_section.html | 42
> >+++++++++-------------
> > .../toaster/toastergui/templates/mrb_section.html | 39
> >--------------------
> > .../lib/toaster/toastergui/templates/projects.html | 2 +-
> > bitbake/lib/toaster/toastergui/views.py | 11 ++++--
> > 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 3832066..fcf82ac 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 (){
> > } });
> > }
> >
> >+ /* 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,
> >diff --git
> >a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html
> >b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html
> >index d6e32f8..471df1c 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 @@
> > {% 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
> >@@ -119,6 +120,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 %}
> >
> >@@ -156,37 +158,25 @@
> >
> > <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");
> >+ libtoaster.startABuild(url, null, buildlist.join(" "), function(){
> >+ window.location.reload();
> >+ }, null);
> > }
> >
> >+$(document).ready(function(){
> >
> >-function scheduleBuild(url, projectName, projectUrl, buildlist) {
> >- console.log("scheduleBuild");
> >- _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function
> >(_data) {
> >+ $(".cancel-build-btn").click(function (){
> >+ var url = $(this).data('request-url');
> >+ var buildIds = $(this).data('build-id');
> >+ var btn = $(this);
> >
> >- $('#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.cancelABuild(url, buildIds, function(){
> >+ btn.parents(".alert").fadeOut();
> >+ }, null);
> > });
> >-}
> >+});
> >
> > </script>
> >
> >diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
> >b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
> >index 432955a..c7bddf0 100644
> >--- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
> >+++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
> >@@ -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%}
> >
> >diff --git a/bitbake/lib/toaster/toastergui/templates/projects.html
> >b/bitbake/lib/toaster/toastergui/templates/projects.html
> >index 88d5bd3..88ee4bc 100644
> >--- a/bitbake/lib/toaster/toastergui/templates/projects.html
> >+++ b/bitbake/lib/toaster/toastergui/templates/projects.html
> >@@ -7,7 +7,7 @@
> > {% block pagecontent %}
> >
> >
> >- {% include "mrb_section.html" %}
> >+ {% include "managed_mrb_section.html" %}
> >
> >
> > <div class="page-header top-air">
> >diff --git a/bitbake/lib/toaster/toastergui/views.py
> >b/bitbake/lib/toaster/toastergui/views.py
> >index 8034cfc..4a334f9 100755
> >--- a/bitbake/lib/toaster/toastergui/views.py
> >+++ b/bitbake/lib/toaster/toastergui/views.py
> >@@ -1866,8 +1866,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:
> >@@ -3101,6 +3100,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):
> >@@ -3124,7 +3129,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 = {};
> >--
> >2.1.0
> >
> >--
> >_______________________________________________
> >toaster mailing list
> >toaster at yoctoproject.org
> >https://lists.yoctoproject.org/listinfo/toaster
>
> --
> _______________________________________________
> toaster mailing list
> toaster at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>
--
Alex Damian
Yocto Project
SSG / OTC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/toaster/attachments/20150317/338382c3/attachment-0001.html>
More information about the toaster
mailing list