未验证 提交 18c154d3 编写于 作者: R Raihaan Shouhell 提交者: GitHub

Merge pull request #5030 from Wadeck/JENKINS-60866_load_statistics

[JENKINS-60866] Un-inline LoadStatistics
......@@ -24,7 +24,8 @@ THE SOFTWARE.
<!-- renders an HTML fragment that shows trend graph -->
<?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" xmlns:i="jelly:fmt">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<st:adjunct includes="hudson.model.LoadStatistics.resources"/>
<h1>
<l:icon class="icon-monitor icon-xlg"/>
${%title(it.displayName)}
......@@ -43,39 +44,41 @@ THE SOFTWARE.
${%Timespan}:
<j:choose>
<j:when test="${type != 'sec10'}">
<a href="?type=sec10">${%Short}</a>
<a href="?type=sec10" tooltip="${%timeScale10sec}">${%Short}</a>
</j:when>
<j:otherwise>
${%Short}
<span tooltip="${%timeScale10sec}">${%Short}</span>
</j:otherwise>
</j:choose>
<st:nbsp />
<j:choose>
<j:when test="${type != 'min'}">
<a href="?type=min">${%Medium}</a>
<a href="?type=min" tooltip="${%timeScaleMinute}">${%Medium}</a>
</j:when>
<j:otherwise>
${%Medium}
<span tooltip="${%timeScaleMinute}">${%Medium}</span>
</j:otherwise>
</j:choose>
<st:nbsp />
<j:choose>
<j:when test="${type != 'hour'}">
<a href="?type=hour">${%Long}</a>
<a href="?type=hour" tooltip="${%timeScaleHour}">${%Long}</a>
</j:when>
<j:otherwise>
${%Long}
<span tooltip="${%timeScaleHour}">${%Long}</span>
</j:otherwise>
</j:choose>
</div>
<script type="text/javascript">
var w = document.getElementById('main-panel').offsetWidth - 30;
document.write('<img src="${prefix?:'loadStatistics'}/graph?type=${type}&amp;width=' + w + '&amp;height=500" alt="[${%Load statistics graph}]" />');
</script>
<div class="js-load-graph"
data-graph-type="${type}" data-graph-parent-selector="#main-panel"
data-graph-base-url="${prefix?:'loadStatistics'}" data-graph-alt="${%Load statistics graph}">
<!-- The graph will be loaded dynamically by JS -->
</div>
<noscript>
<!-- The noscript alternative does not have the possibility to adjust the image to the available space -->
<img src="${prefix?:'loadStatistics'}/graph?type=${type}&amp;width=500&amp;height=300" alt="[${%Load statistics graph}]" />
</noscript>
<div style="margin-top: 2em;">
<p>
${%blurb}
</div>
</p>
</j:jelly>
......@@ -21,6 +21,9 @@
# THE SOFTWARE.
title=Load statistics: {0}
timeScale10sec=Every tick is 10 seconds
timeScaleMinute=Every tick is one minute
timeScaleHour=Every tick is one hour
blurb=\
Load statistics keep track of four key metrics of resource utilization: \
<dl> \
......
/*
* The MIT License
*
* Copyright (c) 2020, CloudBees, Inc.
*
* 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.
*/
(function(){
document.addEventListener("DOMContentLoaded", function() {
var graphLocation = document.querySelector('.js-load-graph');
if (graphLocation) {
var type = graphLocation.getAttribute("data-graph-type");
var parentSelector = graphLocation.getAttribute("data-graph-parent-selector");
var baseUrl = graphLocation.getAttribute("data-graph-base-url");
var graphAlt = graphLocation.getAttribute("data-graph-alt");
var parent = document.querySelector(parentSelector);
if (parent) {
var availableWidth = parent.offsetWidth;
var padding = 30;
// for some browsers, the perfect width is not enough
var quirkyBrowserAdjustment = 15;
var graphWidth = availableWidth - padding - quirkyBrowserAdjustment;
// type in {sec10, min, hour}
var graphUrl = baseUrl + "/graph?type" + type + "&width=" + graphWidth + "&height=500";
var graphImgTag = document.createElement("img");
graphImgTag.src = graphUrl;
graphImgTag.alt = graphAlt;
graphLocation.appendChild(graphImgTag);
}
}
});
})();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册