From 23f1439a5d3e8f4053826794c6502eca20189054 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Fri, 13 Mar 2015 14:34:41 +0000 Subject: [PATCH] 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] Signed-off-by: Michael Wood --- .../toastergui/static/js/libtoaster.js | 28 +++++++++++++ .../templates/managed_mrb_section.html | 42 +++++++------------ .../toastergui/templates/mrb_section.html | 39 ----------------- .../toastergui/templates/projects.html | 2 +- lib/toaster/toastergui/views.py | 11 +++-- 5 files changed, 53 insertions(+), 69 deletions(-) diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js index 38320667dce..fcf82ac65b1 100644 --- a/lib/toaster/toastergui/static/js/libtoaster.js +++ b/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/lib/toaster/toastergui/templates/managed_mrb_section.html b/lib/toaster/toastergui/templates/managed_mrb_section.html index 51610e4ab3f..a6d4ac66fc8 100644 --- a/lib/toaster/toastergui/templates/managed_mrb_section.html +++ b/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 #} {%endif%} {%if build.outcome == build.IN_PROGRESS %} @@ -68,41 +65,5 @@ {% endfor %} - - - {%endif%} diff --git a/lib/toaster/toastergui/templates/projects.html b/lib/toaster/toastergui/templates/projects.html index 88d5bd32df8..88ee4bcd66f 100644 --- a/lib/toaster/toastergui/templates/projects.html +++ b/lib/toaster/toastergui/templates/projects.html @@ -7,7 +7,7 @@ {% block pagecontent %} - {% include "mrb_section.html" %} + {% include "managed_mrb_section.html" %}