Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
e5ad9ca8
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e5ad9ca8
编写于
9月 22, 2016
作者:
D
Daniel Beck
提交者:
GitHub
9月 22, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2558 from daniel-beck/JENKINS-38391
[FIX JENKINS-38391] Show admin monitors on most URLs
上级
62854ab6
1e124eb3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
304 addition
and
2 deletion
+304
-2
core/src/main/java/jenkins/management/AdministrativeMonitorsDecorator.java
...a/jenkins/management/AdministrativeMonitorsDecorator.java
+143
-0
core/src/main/resources/hudson/os/solaris/ZFSInstaller/MigrationFailedNotice/message.jelly
.../solaris/ZFSInstaller/MigrationFailedNotice/message.jelly
+1
-1
core/src/main/resources/hudson/util/AdministrativeError/message.jelly
...n/resources/hudson/util/AdministrativeError/message.jelly
+1
-1
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/footer.jelly
...s/management/AdministrativeMonitorsDecorator/footer.jelly
+47
-0
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/footer.properties
...agement/AdministrativeMonitorsDecorator/footer.properties
+1
-0
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.css
.../management/AdministrativeMonitorsDecorator/resources.css
+70
-0
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.js
...s/management/AdministrativeMonitorsDecorator/resources.js
+39
-0
core/src/main/resources/jenkins/management/Messages.properties
...src/main/resources/jenkins/management/Messages.properties
+2
-0
未找到文件。
core/src/main/java/jenkins/management/AdministrativeMonitorsDecorator.java
0 → 100644
浏览文件 @
e5ad9ca8
/*
* The MIT License
*
* Copyright (c) 2016, Daniel Beck, 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.
*/
package
jenkins.management
;
import
hudson.Extension
;
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
;
import
javax.servlet.ServletException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
/**
* Show a notification and popup for active administrative monitors on all pages.
*/
@Extension
@Restricted
(
NoExternalUse
.
class
)
public
class
AdministrativeMonitorsDecorator
extends
PageDecorator
{
private
final
Collection
<
String
>
ignoredJenkinsRestOfUrls
=
new
ArrayList
<>();
public
AdministrativeMonitorsDecorator
()
{
// redundant
ignoredJenkinsRestOfUrls
.
add
(
"manage"
);
// 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
public
String
getDisplayName
()
{
return
Messages
.
AdministrativeMonitorsDecorator_DisplayName
();
}
public
int
getActiveAdministrativeMonitorsCount
()
{
return
getActiveAdministrativeMonitors
().
size
();
}
public
Collection
<
AdministrativeMonitor
>
getActiveAdministrativeMonitors
()
{
Collection
<
AdministrativeMonitor
>
active
=
new
ArrayList
<>();
Collection
<
AdministrativeMonitor
>
ams
=
new
ArrayList
<>(
Jenkins
.
getInstance
().
administrativeMonitors
);
for
(
AdministrativeMonitor
am
:
ams
)
{
if
(
am
instanceof
ReverseProxySetupMonitor
)
{
// TODO make reverse proxy monitor work when shown on any URL
continue
;
}
if
(
am
.
isEnabled
()
&&
am
.
isActivated
())
{
active
.
add
(
am
);
}
}
return
active
;
}
/**
* Whether the administrative monitors notifier should be shown.
* @return true iff the administrative monitors notifier should be shown.
* @throws IOException
* @throws ServletException
*/
public
boolean
shouldDisplay
()
throws
IOException
,
ServletException
{
if
(!
Functions
.
hasPermission
(
Jenkins
.
ADMINISTER
))
{
return
false
;
}
StaplerRequest
req
=
Stapler
.
getCurrentRequest
();
if
(
req
==
null
)
{
return
false
;
}
List
<
Ancestor
>
ancestors
=
req
.
getAncestors
();
if
(
ancestors
==
null
||
ancestors
.
size
()
==
0
)
{
// ???
return
false
;
}
Ancestor
a
=
ancestors
.
get
(
ancestors
.
size
()
-
1
);
Object
o
=
a
.
getObject
();
// don't show while Jenkins is loading
if
(
o
instanceof
HudsonIsLoading
)
{
return
false
;
}
// … or restarting
if
(
o
instanceof
HudsonIsRestarting
)
{
return
false
;
}
// don't show for some URLs served directly by Jenkins
if
(
o
instanceof
Jenkins
)
{
String
url
=
a
.
getRestOfUrl
();
if
(
ignoredJenkinsRestOfUrls
.
contains
(
url
))
{
return
false
;
}
}
if
(
getActiveAdministrativeMonitorsCount
()
==
0
)
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
core/src/main/resources/hudson/os/solaris/ZFSInstaller/MigrationFailedNotice/message.jelly
浏览文件 @
e5ad9ca8
...
...
@@ -26,6 +26,6 @@ THE SOFTWARE.
<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">
<div class="error">
${%ZFS migration failed.}
<a href="${it.url}/">${%See the log for more details}</a>.
<a href="${
rootURL}/${
it.url}/">${%See the log for more details}</a>.
</div>
</j:jelly>
\ No newline at end of file
core/src/main/resources/hudson/util/AdministrativeError/message.jelly
浏览文件 @
e5ad9ca8
...
...
@@ -26,6 +26,6 @@ THE SOFTWARE.
<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">
<div class="error">
<j:out value="${it.message}"/>
<a href="${it.url}/">${%See the log for more details}</a>.
<a href="${
rootURL}/${
it.url}/">${%See the log for more details}</a>.
</div>
</j:jelly>
\ No newline at end of file
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/footer.jelly
0 → 100644
浏览文件 @
e5ad9ca8
<!--
The MIT License
Copyright (c) 2016, Daniel Beck, Keith Zantow, 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.
-->
<?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()}">
<st:adjunct includes="jenkins.management.AdministrativeMonitorsDecorator.resources"/>
<div id="visible-am-container">
<a id="visible-am-button" href="#" onclick="toggleVisibleAmList(event)" title="${%tooltip(it.activeAdministrativeMonitorsCount)}">
${it.activeAdministrativeMonitorsCount}
</a>
<div id="visible-am-list">
<j:forEach var="am" items="${it.activeAdministrativeMonitors}">
<div class="am-message">
<st:include page="message.jelly" it="${am}" />
</div>
</j:forEach>
<p style="text-align: center; margin: 10px 0 0 0;">
<a href="${rootURL}/manage" onclick="document.location.href='${rootURL}/manage';">${%Manage Jenkins}</a>
</p>
</div>
</div>
<script type="text/javascript">
document.getElementById("header").appendChild(document.getElementById("visible-am-container"));
</script>
</j:if>
</j:jelly>
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/footer.properties
0 → 100644
浏览文件 @
e5ad9ca8
tooltip
=
There are {0} active administrative monitors.
\ No newline at end of file
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.css
0 → 100644
浏览文件 @
e5ad9ca8
#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
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.js
0 → 100644
浏览文件 @
e5ad9ca8
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
core/src/main/resources/jenkins/management/Messages.properties
浏览文件 @
e5ad9ca8
...
...
@@ -56,3 +56,5 @@ NodesLink.Description=Add, remove, control and monitor the various nodes that Je
ShutdownLink.DisplayName_prepare
=
Prepare for Shutdown
ShutdownLink.DisplayName_cancel
=
Cancel Shutdown
ShutdownLink.Description
=
Stops executing new builds, so that the system can be eventually shut down safely.
AdministrativeMonitorsDecorator.DisplayName
=
Administrative Monitors Notifier
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录