This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new 2a0765b Move some admin JS into a shared file
2a0765b is described below
commit 2a0765bdb40128c11e8738b31cc4cd98f463e1a0
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue Dec 9 20:46:53 2025 +0000
Move some admin JS into a shared file
---
atr/admin/templates/update-keys.html | 63 +++-----------------------------
atr/admin/templates/update-projects.html | 63 +++-----------------------------
atr/static/js/admin-update-form.js | 55 ++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 116 deletions(-)
diff --git a/atr/admin/templates/update-keys.html
b/atr/admin/templates/update-keys.html
index 6fd31b6..8319ba7 100644
--- a/atr/admin/templates/update-keys.html
+++ b/atr/admin/templates/update-keys.html
@@ -87,62 +87,9 @@
<h2>Previous output</h2>
<pre>{{ previous_output }}</pre>
{% endif %}
-
- <script>
- document.addEventListener('DOMContentLoaded', () => {
- const form = document.querySelector('form');
- const button = form.querySelector('button[type="submit"]');
-
- form.addEventListener('submit', async (e) => {
- e.preventDefault();
-
- button.disabled = true;
- document.body.style.cursor = "wait";
-
- const statusElement = document.getElementById("status");
- while (statusElement.firstChild) {
- statusElement.firstChild.remove();
- }
-
- const csrfToken =
document.querySelector("input[name='csrf_token']").value;
-
- try {
- const response = await fetch(window.location.href, {
- method: "POST",
- headers: {
- "X-CSRFToken": csrfToken
- }
- });
-
- if (!response.ok) {
- addStatusMessage(statusElement, "Could not make
network request", "error");
- return
- }
-
- const data = await response.json();
- addStatusMessage(statusElement, data.message,
data.category)
- } catch (error) {
- addStatusMessage(statusElement, error, "error")
- } finally {
- button.disabled = false;
- document.body.style.cursor = "default";
- }
- });
- });
-
- function addStatusMessage(parentElement, message, category) {
- const divElement = document.createElement("div");
- divElement.classList.add("page-status-message");
- divElement.classList.add(category);
- if (category === "error") {
- const prefixElement = document.createElement("strong");
- const textElement = document.createTextNode("Error: ");
- prefixElement.appendChild(textElement);
- divElement.appendChild(prefixElement);
- }
- const textNode = document.createTextNode(message);
- divElement.appendChild(textNode);
- parentElement.appendChild(divElement);
- }
- </script>
{% endblock content %}
+
+{% block javascripts %}
+ {{ super() }}
+ <script src="{{ static_url('js/admin-update-form.js') }}"></script>
+{% endblock javascripts %}
diff --git a/atr/admin/templates/update-projects.html
b/atr/admin/templates/update-projects.html
index dcda398..f582e9c 100644
--- a/atr/admin/templates/update-projects.html
+++ b/atr/admin/templates/update-projects.html
@@ -87,62 +87,9 @@
<div id="status"></div>
{{ empty_form }}
-
- <script>
- document.addEventListener('DOMContentLoaded', () => {
- const form = document.querySelector('form');
- const button = form.querySelector('button[type="submit"]');
-
- form.addEventListener('submit', async (e) => {
- e.preventDefault();
-
- button.disabled = true;
- document.body.style.cursor = "wait";
-
- const statusElement = document.getElementById("status");
- while (statusElement.firstChild) {
- statusElement.firstChild.remove();
- }
-
- const csrfToken =
document.querySelector("input[name='csrf_token']").value;
-
- try {
- const response = await fetch(window.location.href, {
- method: "POST",
- headers: {
- "X-CSRFToken": csrfToken
- }
- });
-
- if (!response.ok) {
- addStatusMessage(statusElement, "Could not make
network request", "error");
- return
- }
-
- const data = await response.json();
- addStatusMessage(statusElement, data.message,
data.category)
- } catch (error) {
- addStatusMessage(statusElement, error, "error")
- } finally {
- button.disabled = false;
- document.body.style.cursor = "default";
- }
- });
- });
-
- function addStatusMessage(parentElement, message, category) {
- const divElement = document.createElement("div");
- divElement.classList.add("page-status-message");
- divElement.classList.add(category);
- if (category === "error") {
- const prefixElement = document.createElement("strong");
- const textElement = document.createTextNode("Error: ");
- prefixElement.appendChild(textElement);
- divElement.appendChild(prefixElement);
- }
- const textNode = document.createTextNode(message);
- divElement.appendChild(textNode);
- parentElement.appendChild(divElement);
- }
- </script>
{% endblock content %}
+
+{% block javascripts %}
+ {{ super() }}
+ <script src="{{ static_url('js/admin-update-form.js') }}"></script>
+{% endblock javascripts %}
diff --git a/atr/static/js/admin-update-form.js
b/atr/static/js/admin-update-form.js
new file mode 100644
index 0000000..f73ff88
--- /dev/null
+++ b/atr/static/js/admin-update-form.js
@@ -0,0 +1,55 @@
+document.addEventListener("DOMContentLoaded", () => {
+ const form = document.querySelector("form");
+ const button = form.querySelector("button[type='submit']");
+
+ form.addEventListener("submit", async (e) => {
+ e.preventDefault();
+
+ button.disabled = true;
+ document.body.style.cursor = "wait";
+
+ const statusElement = document.getElementById("status");
+ while (statusElement.firstChild) {
+ statusElement.firstChild.remove();
+ }
+
+ const csrfToken =
document.querySelector("input[name='csrf_token']").value;
+
+ try {
+ const response = await fetch(window.location.href, {
+ method: "POST",
+ headers: {
+ "X-CSRFToken": csrfToken
+ }
+ });
+
+ if (!response.ok) {
+ addStatusMessage(statusElement, "Could not make network
request", "error");
+ return;
+ }
+
+ const data = await response.json();
+ addStatusMessage(statusElement, data.message, data.category);
+ } catch (error) {
+ addStatusMessage(statusElement, error, "error");
+ } finally {
+ button.disabled = false;
+ document.body.style.cursor = "default";
+ }
+ });
+});
+
+function addStatusMessage(parentElement, message, category) {
+ const divElement = document.createElement("div");
+ divElement.classList.add("page-status-message");
+ divElement.classList.add(category);
+ if (category === "error") {
+ const prefixElement = document.createElement("strong");
+ const textElement = document.createTextNode("Error: ");
+ prefixElement.appendChild(textElement);
+ divElement.appendChild(prefixElement);
+ }
+ const textNode = document.createTextNode(message);
+ divElement.appendChild(textNode);
+ parentElement.appendChild(divElement);
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]