提交 1e124eb3 编写于 作者: D Daniel Beck

[JENKINS-38391] Further admin monitor refinements

- Add tooltip to notification button
- Move CSS/JS into an adjunct
- Check adcitve admin monitors status last
- Don't show on /configure URL
上级 a11d9ce9
......@@ -28,12 +28,16 @@ import hudson.Functions;
import hudson.diagnosis.ReverseProxySetupMonitor;
import hudson.model.AdministrativeMonitor;
import hudson.model.PageDecorator;
import hudson.util.HttpResponses;
import hudson.util.HudsonIsLoading;
import hudson.util.HudsonIsRestarting;
import jenkins.model.Jenkins;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
......@@ -57,6 +61,9 @@ public class AdministrativeMonitorsDecorator extends PageDecorator {
// otherwise this would be added to every internal context menu building request
ignoredJenkinsRestOfUrls.add("contextMenu");
// don't show here to allow admins to disable malfunctioning monitors via AdministrativeMonitorsDecorator
ignoredJenkinsRestOfUrls.add("configure");
}
@Override
......@@ -94,10 +101,6 @@ public class AdministrativeMonitorsDecorator extends PageDecorator {
return false;
}
if (getActiveAdministrativeMonitorsCount() == 0) {
return false;
}
StaplerRequest req = Stapler.getCurrentRequest();
if (req == null) {
......@@ -131,6 +134,10 @@ public class AdministrativeMonitorsDecorator extends PageDecorator {
}
}
if (getActiveAdministrativeMonitorsCount() == 0) {
return false;
}
return true;
}
}
\ No newline at end of file
......@@ -24,121 +24,9 @@ THE SOFTWARE.
<?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">
<j:if test="${it.shouldDisplay()}">
<style type="text/css">
#visible-am-container {
float: right;
}
#visible-am-button {
text-align: center;
font-size: 20px;
font-weight: bold;
background-color: #e01716;
color: #fff;;
margin: 0;
line-height: 40px;
text-decoration: none;
min-width: 2em;
display: inline-block;
position: relative;
transition: all .1s;
}
#visible-am-button:hover, #visible-am-button:focus, #visible-am-button:active {
background: #e23635;
}
#visible-am-container.visible #visible-am-button {
box-shadow: inset 0px 1px 14px rgba(0,0,0,.5);
}
#visible-am-container div#visible-am-list {
position: absolute;
top: 35px;
right: 2%;
margin-left:2%;
height: auto;
z-index: 0;
padding: 2em;
border: 1px solid #aa;
text-align: left;
display: block;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 7px 20px rgba(0,0,0,.1);
transition: all .15s cubic-bezier(.84,.03,.21,.96);
opacity: 0;
transform: scale(0);
}
#visible-am-container.visible div#visible-am-list {
opacity: 1;
transform: scale(1);
z-index: 1000;
}
#visible-am-container #visible-am-button:after {
content: '';
display: inline-block;
position: absolute;
bottom: -5px;
left: 32%;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #fff;
opacity: 0;
transition: all .05s;
}
#visible-am-container.visible #visible-am-button:after {
opacity: 1;
bottom: 4px;
transition: all .25s;
}
#visible-am-container .am-message {
display: block;
line-height: 1.4em;
margin-bottom: 1.4em;
}
</style>
<script>
function amCloser(e) {
var list = document.getElementById('visible-am-list');
var el = e.target;
while (el) {
if (el === list) {
return; // clicked in the list
}
el = el.parentElement;
}
hideVisibleAmList();
};
function amEscCloser(e) {
if (e.keyCode == 27) {
amCloser(e);
}
};
function amContainer() {
return document.getElementById('visible-am-container');
};
function hideVisibleAmList(e) {
amContainer().classList.remove('visible');
document.removeEventListener('click', amCloser);
document.removeEventListener('keydown', amEscCloser);
}
function showVisibleAmList(e) {
amContainer().classList.add('visible');
setTimeout(function() {
document.addEventListener('click', amCloser);
document.addEventListener('keydown', amEscCloser);
}, 1);
}
function toggleVisibleAmList(e) {
if (amContainer().classList.contains('visible')) {
hideVisibleAmList(e);
} else {
showVisibleAmList(e);
}
e.preventDefault();
}
</script>
<st:adjunct includes="jenkins.management.AdministrativeMonitorsDecorator.resources"/>
<div id="visible-am-container">
<a id="visible-am-button" href="#" onclick="toggleVisibleAmList(event)">
<a id="visible-am-button" href="#" onclick="toggleVisibleAmList(event)" title="${%tooltip(it.activeAdministrativeMonitorsCount)}">
${it.activeAdministrativeMonitorsCount}
</a>
<div id="visible-am-list">
......
tooltip=There are {0} active administrative monitors.
\ No newline at end of file
#visible-am-container {
float: right;
}
#visible-am-button {
text-align: center;
font-size: 20px;
font-weight: bold;
background-color: #e01716;
color: #fff;;
margin: 0;
line-height: 40px;
text-decoration: none;
min-width: 2em;
display: inline-block;
position: relative;
transition: all .1s;
}
#visible-am-button:hover, #visible-am-button:focus, #visible-am-button:active {
background: #e23635;
}
#visible-am-container.visible #visible-am-button {
box-shadow: inset 0px 1px 14px rgba(0,0,0,.5);
}
#visible-am-container div#visible-am-list {
position: absolute;
top: 35px;
right: 2%;
margin-left:2%;
height: auto;
z-index: 0;
padding: 2em;
border: 1px solid #aa;
text-align: left;
display: block;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 7px 20px rgba(0,0,0,.1);
transition: all .15s cubic-bezier(.84,.03,.21,.96);
opacity: 0;
transform: scale(0);
}
#visible-am-container.visible div#visible-am-list {
opacity: 1;
transform: scale(1);
z-index: 1000;
}
#visible-am-container #visible-am-button:after {
content: '';
display: inline-block;
position: absolute;
bottom: -5px;
left: 32%;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #fff;
opacity: 0;
transition: all .05s;
}
#visible-am-container.visible #visible-am-button:after {
opacity: 1;
bottom: 4px;
transition: all .25s;
}
#visible-am-container .am-message {
display: block;
line-height: 1.4em;
margin-bottom: 1.4em;
}
\ No newline at end of file
function amCloser(e) {
var list = document.getElementById('visible-am-list');
var el = e.target;
while (el) {
if (el === list) {
return; // clicked in the list
}
el = el.parentElement;
}
hideVisibleAmList();
};
function amEscCloser(e) {
if (e.keyCode == 27) {
amCloser(e);
}
};
function amContainer() {
return document.getElementById('visible-am-container');
};
function hideVisibleAmList(e) {
amContainer().classList.remove('visible');
document.removeEventListener('click', amCloser);
document.removeEventListener('keydown', amEscCloser);
}
function showVisibleAmList(e) {
amContainer().classList.add('visible');
setTimeout(function() {
document.addEventListener('click', amCloser);
document.addEventListener('keydown', amEscCloser);
}, 1);
}
function toggleVisibleAmList(e) {
if (amContainer().classList.contains('visible')) {
hideVisibleAmList(e);
} else {
showVisibleAmList(e);
}
e.preventDefault();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册