Skip to content

Commit 5007d28

Browse files
authored
CSP support for DockerManagementServer (#1107)
* CSP support for `DockerManagementServer` * Spotless
1 parent 94b7439 commit 5007d28

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

src/main/java/com/nirima/jenkins/plugins/docker/DockerManagementServer.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.nirima.jenkins.plugins.docker;
22

33
import com.github.dockerjava.api.DockerClient;
4-
import com.nirima.jenkins.plugins.docker.utils.Consts;
54
import com.nirima.jenkins.plugins.docker.utils.JenkinsUtils;
65
import hudson.Extension;
76
import hudson.model.Describable;
@@ -72,10 +71,6 @@ public String asTime(Long time) {
7271
return dt.toString();
7372
}
7473

75-
public String getJsUrl(String jsName) {
76-
return Consts.PLUGIN_JS_URL + jsName;
77-
}
78-
7974
@SuppressWarnings("unused")
8075
@RequirePOST
8176
public void doControlSubmit(@QueryParameter("stopId") String stopId, StaplerRequest req, StaplerResponse rsp)

src/main/java/com/nirima/jenkins/plugins/docker/utils/Consts.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,4 @@ public final class Consts {
1010
* The base URL of the plugin images.
1111
*/
1212
public static final String PLUGIN_IMAGES_URL = PLUGIN_URL + "images/";
13-
14-
/**
15-
* The base URL of the plugin javascripts.
16-
*/
17-
public static final String PLUGIN_JS_URL = PLUGIN_URL + "js/";
1813
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function stop(theId) {
2+
var input = document.getElementById('stopId');
3+
if (input != null) {
4+
input.value = theId;
5+
}
6+
7+
var form = document.getElementById('control');
8+
form.submit();
9+
}
10+
11+
document.addEventListener('DOMContentLoaded', () => {
12+
const stopContainerButtons = document.querySelectorAll('#control .stop-container');
13+
stopContainerButtons.forEach((button) =>
14+
button.addEventListener('click', () => {
15+
stop(button.dataset.id);
16+
}),
17+
);
18+
});

src/main/resources/com/nirima/jenkins/plugins/docker/DockerManagementServer/index.jelly

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?jelly escape-by-default='true'?>
2-
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:f="/lib/form"
2+
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:f="/lib/form"
33
>
44
<l:layout title="${%Docker hosts}" norefresh="true" permission="${it.requiredPermission}">
55
<l:header>
6-
<script src="${rootURL}${it.getJsUrl('docker-manage.js')}" type="text/javascript"></script>
6+
<st:adjunct includes="com.nirima.jenkins.plugins.docker.DockerManagementServer.docker-manage"/>
77
<style type="text/css">
88
tr.disablehover:hover {
99
background-color: white;
@@ -52,7 +52,7 @@
5252
</j:forEach>
5353
</td>
5454
<td>
55-
<input type="button" value="stop" onclick="stop('${res.id}')"></input>
55+
<input type="button" class="stop-container" value="stop" data-id="${res.id}"></input>
5656
</td>
5757
</tr>
5858
</j:forEach>

src/main/webapp/js/docker-manage.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)