-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins.html
106 lines (90 loc) · 3.26 KB
/
jenkins.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<title>Lancer des pipelines Jenkins</title>
<link rel="stylesheet" href="https://p.trellocdn.com/power-up.min.css" />
<style>
body {
font-family: Arial, sans-serif;
padding: 10px;
max-width: 300px;
}
.checkbox-group {
margin-bottom: 10px;
}
button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
</style>
<script src="https://p.trellocdn.com/power-up.min.js"></script>
<script>
function getQueryParams() {
const params = {};
const queryString = window.location.search.substring(1);
const queryArray = queryString.split("&");
for (const query of queryArray) {
const [key, value] = query.split("=");
if (key) {
params[decodeURIComponent(key)] = decodeURIComponent(value);
}
}
return params;
}
function createCheckboxes() {
const params = getQueryParams();
const repositories = params.repositories ? params.repositories.split(",") : [];
const form = document.getElementById("pipelines");
const submitButton = document.querySelector('button[type="submit"]');
repositories.forEach(repository => {
const div = document.createElement("div");
div.className = "checkbox-group";
const label = document.createElement("label");
const input = document.createElement("input");
input.type = "checkbox";
input.id = repository;
input.name = repository;
input.checked = true;
input.addEventListener("change", () => {
checkSubmitButtonState();
});
label.appendChild(input);
label.appendChild(document.createTextNode(" " + repository));
div.appendChild(label);
form.insertBefore(div, submitButton);
});
checkSubmitButtonState(); // Initial check for button state
}
function checkSubmitButtonState() {
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
const submitButton = document.querySelector('button[type="submit"]');
const isChecked = Array.from(checkboxes).some(checkbox => checkbox.checked);
submitButton.disabled = !isChecked;
}
window.onload = createCheckboxes;
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById("pipelines");
form.addEventListener("submit", async function (event) {
event.preventDefault(); // Prevent the default form submission
const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
const selectedRepositories = Array.from(checkboxes).map(checkbox => checkbox.name);
const params = getQueryParams();
if (selectedRepositories.length > 0) {
// Create a POST request with the selected repositories
return fetch(`https://n8n.tools.i-we.io/webhook/2484baa2-311b-4921-a2dd-96ab6c6d49e5?branch=${params.branch}&repositories=${selectedRepositories.join(',')}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
})
}
});
});
</script>
</head>
<body>
<form id="pipelines">
<button type="submit">Lancer les pipelines</button>
</form>
</body>
</html>