diff options
Diffstat (limited to 'lib/toaster/toastergui/templates')
-rw-r--r-- | lib/toaster/toastergui/templates/managed_mrb_section.html | 42 | ||||
-rw-r--r-- | lib/toaster/toastergui/templates/mrb_section.html | 39 | ||||
-rw-r--r-- | lib/toaster/toastergui/templates/projects.html | 2 |
3 files changed, 17 insertions, 66 deletions
diff --git a/lib/toaster/toastergui/templates/managed_mrb_section.html b/lib/toaster/toastergui/templates/managed_mrb_section.html index 51610e4ab..a6d4ac66f 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 #} <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,37 +157,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/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html index 432955ab8..c7bddf037 100644 --- a/lib/toaster/toastergui/templates/mrb_section.html +++ b/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/lib/toaster/toastergui/templates/projects.html b/lib/toaster/toastergui/templates/projects.html index 88d5bd32d..88ee4bcd6 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" %} <div class="page-header top-air"> |