Skip to contentSkip to conversation

bitbake: toaster: Add cancel build to latest build section

PATCH In review Michael Wood 3 participants 3 messages Mar 13, 2015 – Mar 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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]

---
 .../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(-)
bitbake/lib/toaster/toastergui/static/js/libtoaster.js +28 -0
index 3832066..fcf82ac 100644
@@ -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,
bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +16 -26

65 lines not on this page · raw message

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -39
index 432955a..c7bddf0 100644
@@ -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%}
 
bitbake/lib/toaster/toastergui/templates/projects.html +1 -1
index 88d5bd3..88ee4bc 100644
@@ -7,7 +7,7 @@
 {% block pagecontent %}
 
 
-  {% include "mrb_section.html" %}
+  {% include "managed_mrb_section.html" %}
 
 
   <div class="page-header top-air">
bitbake/lib/toaster/toastergui/views.py +8 -3
index 8034cfc..4a334f9 100755
@@ -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 = {};
Signature · 1 line
2.1.0
#1 lore raw
Quoted 5 lines · Michael Wood

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

Quoted 285 lines

---
.../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(-)
bitbake/lib/toaster/toastergui/static/js/libtoaster.js +28 -0
index 3832066..fcf82ac 100644
@@ -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,
(quoted diff) +0 -0

a/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html b/bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html index d6e32f8..471df1c 100644

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +1 -0
@@ -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

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -0
@@ -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 %}
bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -0
@@ -156,37 +158,25 @@
 

<script>

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +5 -19
-/* 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(){

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -3
-function scheduleBuild(url, projectName, projectUrl, buildlist) {
-  console.log("scheduleBuild");
-  _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function

(_data) {

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +4 -1
+  $(".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\">" +

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -2
-  "<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>");

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +4 -1
+    libtoaster.cancelABuild(url, buildIds, function(){
+      btn.parents(".alert").fadeOut();
+    }, null);
  });
-}
+});

</script>

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -0
index 432955a..c7bddf0 100644
@@ -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>
bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -2
-          {% 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>

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -30
-          {% 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">' +

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -2
-  '<div class="span4 lead">' + buildlist.join(" ") +
-  '</div><div class="span4 lead pull-right">Build queued. Your build

will start shortly.</div></div></div>');

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -5
-  });
-}
-
-</script>
-

{%endif%}

bitbake/lib/toaster/toastergui/templates/projects.html +1 -1
index 88d5bd3..88ee4bc 100644
@@ -7,7 +7,7 @@
 {% block pagecontent %}
 
 
-  {% include "mrb_section.html" %}
+  {% include "managed_mrb_section.html" %}
 
 
  <div class="page-header top-air">
bitbake/lib/toaster/toastergui/views.py +0 -0
index 8034cfc..4a334f9 100755
@@ -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

bitbake/lib/toaster/toastergui/views.py +0 -2
-        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])

bitbake/lib/toaster/toastergui/views.py +6 -0
+        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])

bitbake/lib/toaster/toastergui/views.py +2 -1
+        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 = {};
Signature · 7 lines
2.1.0

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
#2 lore raw

Taken for submission,

Thank you,
Alex

Quoted 308 lines · Belen
Quoted 5 lines · Michael Wood

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

Quoted 280 lines

---
.../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(-)
bitbake/lib/toaster/toastergui/static/js/libtoaster.js +28 -0
index 3832066..fcf82ac 100644
@@ -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

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +1 -0
@@ -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

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -0
@@ -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 %}
bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -0
@@ -156,37 +158,25 @@
 

<script>

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +5 -19
-/* 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(){

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -3
-function scheduleBuild(url, projectName, projectUrl, buildlist) {
-  console.log("scheduleBuild");
-  _makeXHRBuildCall(url, {targets: buildlist.join(" ")}, function

(_data) {

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +4 -1
+  $(".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\">" +

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +0 -2
-  "<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>");

bitbake/lib/toaster/toastergui/templates/managed_mrb_section.html +4 -1
+    libtoaster.cancelABuild(url, buildIds, function(){
+      btn.parents(".alert").fadeOut();
+    }, null);
  });
-}
+});

</script>

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -0
index 432955a..c7bddf0 100644
@@ -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>
bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -2
-          {% 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>

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -30
-          {% 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">' +

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -2
-  '<div class="span4 lead">' + buildlist.join(" ") +
-  '</div><div class="span4 lead pull-right">Build queued. Your build

will start shortly.</div></div></div>');

bitbake/lib/toaster/toastergui/templates/mrb_section.html +0 -5
-  });
-}
-
-</script>
-

{%endif%}

bitbake/lib/toaster/toastergui/templates/projects.html +1 -1
index 88d5bd3..88ee4bc 100644
@@ -7,7 +7,7 @@
 {% block pagecontent %}
 
 
-  {% include "mrb_section.html" %}
+  {% include "managed_mrb_section.html" %}
 
 
  <div class="page-header top-air">
bitbake/lib/toaster/toastergui/views.py +0 -0
index 8034cfc..4a334f9 100755
@@ -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

bitbake/lib/toaster/toastergui/views.py +0 -2
-        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])

bitbake/lib/toaster/toastergui/views.py +6 -0
+        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])

bitbake/lib/toaster/toastergui/views.py +2 -1
+        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
Quoted 5 lines

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Alex Damian
Yocto Project
SSG / OTC