提交 511a533d 编写于 作者: Z Zbynek Konecny 提交者: Oleg Nenashev

[JENKINS-16750] Update build status icon (#3952)

* [JENKINS-16750] update status icon when build is finished

* JENKINS-16750 use Event.fire / Event.observe instead of global function
上级 25f4e719
......@@ -30,7 +30,7 @@ THE SOFTWARE.
<l:layout title="${it.fullDisplayName} ${%Changes}">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<t:buildCaption>${%Changes}</t:buildCaption>
<t:buildCaption autorefresh="true">${%Changes}</t:buildCaption>
<j:choose>
<j:when test="${it.hasChangeSetComputed()}">
<st:include page="index.jelly" it="${it.changeSet}" />
......
......@@ -47,7 +47,7 @@ THE SOFTWARE.
</div>
</div>
<t:buildCaption>
<t:buildCaption autorefresh="true">
${%Build} ${it.displayName}
(<i:formatDate value="${it.timestamp.time}" type="both" dateStyle="medium" timeStyle="medium"/>)
</t:buildCaption>
......
......@@ -56,7 +56,8 @@ THE SOFTWARE.
<div id="spinner">
<img src="${imagesURL}/spinner.gif" alt="" />
</div>
<t:progressiveText href="logText/progressiveHtml" idref="out" spinner="spinner" startOffset="${offset}" />
<t:progressiveText href="logText/progressiveHtml" idref="out" spinner="spinner"
startOffset="${offset}" onFinishEvent="jenkins:consoleFinished"/>
</j:when>
<!-- output is completed now. -->
<j:otherwise>
......
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Copyright (c) 2012, Martin Schroeder, Intel Mobile Communications GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!--
Displays the console output
-->
<?jelly escape-by-default='true'?>
<st:compress xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<st:setHeader name="X-Building" value="${it.building}" />
<l:ajax>
<l:icon alt="${it.iconColor.description}" class="${it.buildStatusIconClassName} icon-xlg" tooltip="${it.iconColor.description}"/>
</l:ajax>
</st:compress>
......@@ -24,6 +24,7 @@ THE SOFTWARE.
<!--
displays a caption for build/externalRun.
<%@attribute name="autorefresh" required="false" description="Whether to reload this component automatically using AJAX" %>
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
......@@ -45,6 +46,35 @@ THE SOFTWARE.
</j:if>
<l:icon alt="${it.iconColor.description}" class="${it.buildStatusIconClassName} icon-xlg" tooltip="${it.iconColor.description}"/>
<script>
(function(autorefresh){
function updateBuildCaptionIcon(){
new Ajax.Request("statusIcon",{
method: "get",
onComplete: function(rsp,_) {
var isBuilding = rsp.getResponseHeader("X-Building");
if (isBuilding == "true") {
setTimeout(updateBuildCaptionIcon, 5000)
} else {
var progressBar = document.querySelector(".build-caption-progress-container");
if (progressBar) {
progressBar.style.display = "none";
}
}
document.querySelector(".build-caption .icon-xlg").outerHTML = rsp.responseText;
}
});
}
window.addEventListener("load", function(){
if (autorefresh) {
updateBuildCaptionIcon()
}
Event.observe(window, "jenkins:consoleFinished", updateBuildCaptionIcon);
});
})(${autorefresh});
</script>
<d:invokeBody />
</h1>
</j:jelly>
......@@ -31,6 +31,7 @@ THE SOFTWARE.
<%@attribute name="idref" required="true" description="ID of the HTML element in which the result is displayed" %>
<%@attribute name="spinner" required="false" description="ID of the HTML element in which the spinner is displayed" %>
<%@attribute name="startOffset" required="false" description="Skip this many bytes rather than showing from start of data" %>
<%@attribute name="onFinishEvent" required="false" description="JS custom event to be fired when progress is finished" %>
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
......@@ -49,16 +50,16 @@ THE SOFTWARE.
@param href
Where to retrieve additional text from
-->
function fetchNext(e,href) {
function fetchNext(e,href,onFinishEvent) {
var headers = {};
if (e.consoleAnnotator!=undefined)
headers["X-ConsoleAnnotator"] = e.consoleAnnotator;
new Ajax.Request(href,{
method: "post",
parameters: {"start":e.fetchedBytes},
requestHeaders: headers,
onComplete: function(rsp,_) {
new Ajax.Request(href,{
method: "post",
parameters: {"start":e.fetchedBytes},
requestHeaders: headers,
onComplete: function(rsp,_) {
<!-- append text and do autoscroll if applicable-->
var stickToBottom = scroller.isSticking();
var text = rsp.responseText;
......@@ -79,17 +80,21 @@ THE SOFTWARE.
e.fetchedBytes = rsp.getResponseHeader("X-Text-Size");
e.consoleAnnotator = rsp.getResponseHeader("X-ConsoleAnnotator");
if(rsp.getResponseHeader("X-More-Data")=="true")
setTimeout(function(){fetchNext(e,href);},1000);
<j:if test="${spinner!=null}">
else
$$("${spinner}").style.display = "none";
</j:if>
}
});
}
</j:if>
$$("${idref}").fetchedBytes = ${empty(startOffset)?0:startOffset};
fetchNext($$("${idref}"),"${href}");
</script>
if(rsp.getResponseHeader("X-More-Data")=="true") {
setTimeout(function(){fetchNext(e,href,onFinishEvent);},1000);
} else {
<j:if test="${spinner!=null}">
$$("${spinner}").style.display = "none";
</j:if>
if (onFinishEvent) {
Event.fire(window, onFinishEvent);
}
}
}
});
}
</j:if>
$$("${idref}").fetchedBytes = ${empty(startOffset)?0:startOffset};
fetchNext($$("${idref}"),"${href}","${empty(onFinishEvent)?"":onFinishEvent}");
</script>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册