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 457829a Move project filtering and report status toggling to separate
files
457829a is described below
commit 457829adaf2799234e04097e644dabb55827c1a2
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Dec 10 15:02:53 2025 +0000
Move project filtering and report status toggling to separate files
---
atr/static/js/projects-directory.js | 72 +++++++++++++++++++++++++++
atr/static/js/report-results.js | 83 +++++++++++++++++++++++++++++++
atr/templates/projects.html | 75 +---------------------------
atr/templates/report-selected-path.html | 86 +--------------------------------
4 files changed, 157 insertions(+), 159 deletions(-)
diff --git a/atr/static/js/projects-directory.js
b/atr/static/js/projects-directory.js
new file mode 100644
index 0000000..705cfcd
--- /dev/null
+++ b/atr/static/js/projects-directory.js
@@ -0,0 +1,72 @@
+function filter() {
+ const projectFilter = document.getElementById("project-filter").value;
+ const cards = document.querySelectorAll(".page-project-card");
+ let visibleCount = 0;
+ for (let card of cards) {
+ const nameElement = card.querySelector(".card-title");
+ const name = nameElement.innerHTML;
+ if (!projectFilter) {
+ card.parentElement.hidden = false;
+ visibleCount++;
+ } else {
+ card.parentElement.hidden = !name.match(new RegExp(projectFilter,
"i"));
+ if (!card.parentElement.hidden) {
+ visibleCount++;
+ }
+ }
+ }
+ document.getElementById("project-count").textContent = visibleCount;
+}
+
+// Add event listeners
+document.getElementById("filter-button").addEventListener("click", filter);
+document.getElementById("project-filter").addEventListener("keydown",
function(event) {
+ if (event.key === "Enter") {
+ filter();
+ event.preventDefault();
+ }
+});
+
+// Add click handlers for project cards
+document.querySelectorAll(".page-project-card").forEach(function(card) {
+ card.addEventListener("click", function(event) {
+ // Prevent card navigation if click is inside a form
+ if (event.target.closest("form")) {
+ return;
+ }
+ window.location.href = this.getAttribute("data-project-url");
+ });
+});
+
+// Participant filter logic
+const participantButton = document.getElementById("filter-participant-button");
+participantButton.addEventListener("click", function() {
+ const showing = this.dataset.showing;
+ const cards = document.querySelectorAll(".page-project-card");
+ let visibleCount = 0;
+
+ if (showing === "all") {
+ // Switch to showing only participant projects
+ cards.forEach(card => {
+ const isParticipant = card.dataset.isParticipant === "true";
+ card.parentElement.hidden = !isParticipant;
+ if (!card.parentElement.hidden) {
+ visibleCount++;
+ }
+ });
+ this.textContent = "Show all projects";
+ this.dataset.showing = "participant";
+ } else {
+ // Switch to showing all projects
+ cards.forEach(card => {
+ card.parentElement.hidden = false;
+ visibleCount++;
+ });
+ this.textContent = "Show my projects";
+ this.dataset.showing = "all";
+ }
+ // Reset text filter when toggling participant view
+ document.getElementById("project-filter").value = "";
+ // Update count
+ document.getElementById("project-count").textContent = visibleCount;
+});
diff --git a/atr/static/js/report-results.js b/atr/static/js/report-results.js
new file mode 100644
index 0000000..5b39f2f
--- /dev/null
+++ b/atr/static/js/report-results.js
@@ -0,0 +1,83 @@
+function toggleAllDetails() {
+ const details = document.querySelectorAll("details");
+ // Check if any are closed
+ const anyClosed = Array.from(details).some(detail => !detail.open);
+ // If any are closed, open all
+ // Otherwise, close all
+ details.forEach(detail => detail.open = anyClosed);
+}
+
+function toggleStatusVisibility(type, status) {
+ const btn = document.getElementById(`btn-toggle-${type}-${status}`);
+ const targets =
document.querySelectorAll(`.atr-result-${type}.atr-result-status-${status}`);
+ if (!targets.length) return;
+ let elementsCurrentlyHidden = targets[0].classList.contains("atr-hide");
+ targets.forEach(el => {
+ if (elementsCurrentlyHidden) {
+ el.classList.remove("atr-hide");
+ } else {
+ el.classList.add("atr-hide");
+ }
+ });
+ const bsSt = (status === "failure" || status === "exception") ? "danger" :
status;
+ const cntMatch = btn.textContent.match(/\((\d+)\)/);
+ if (!cntMatch) {
+ console.error("Button text regex mismatch for:", btn.textContent);
+ return;
+ }
+ const cnt = cntMatch[0];
+ const newButtonAction = elementsCurrentlyHidden ? "Hide" : "Show";
+ btn.querySelector("span").textContent = newButtonAction;
+ if (newButtonAction === "Hide") {
+ btn.classList.remove(`btn-outline-${bsSt}`);
+ btn.classList.add(`btn-${bsSt}`);
+ } else {
+ btn.classList.remove(`btn-${bsSt}`);
+ btn.classList.add(`btn-outline-${bsSt}`);
+ }
+ if (type === "member") {
+ updateMemberStriping();
+ } else if (type === "primary") {
+ updatePrimaryStriping();
+ }
+}
+
+function restripeVisibleRows(rowSelector, stripeClass) {
+ let visibleIdx = 0;
+ document.querySelectorAll(rowSelector).forEach(row => {
+ row.classList.remove(stripeClass);
+ const hidden = row.classList.contains("atr-hide") ||
row.classList.contains("page-member-path-hide");
+ if (!hidden) {
+ if (visibleIdx % 2 === 0) row.classList.add(stripeClass);
+ visibleIdx++;
+ }
+ });
+}
+
+function updatePrimaryStriping() {
+ restripeVisibleRows(".atr-result-primary", "page-member-visible-odd");
+}
+
+function updateMemberStriping() {
+ restripeVisibleRows(".atr-result-member", "page-member-visible-odd");
+}
+
+const mpfInput = document.getElementById("member-path-filter");
+if (mpfInput) {
+ mpfInput.addEventListener("input", function() {
+ const filterText = this.value.toLowerCase();
+ document.querySelectorAll(".atr-result-member").forEach(row => {
+ const pathCell = row.cells[0];
+ let hide = false;
+ if (filterText) {
+ if (!pathCell.textContent.toLowerCase().includes(filterText)) {
+ hide = true;
+ }
+ }
+ row.classList.toggle("page-member-path-hide", hide);
+ });
+ updateMemberStriping();
+ });
+}
+updatePrimaryStriping();
+updateMemberStriping();
diff --git a/atr/templates/projects.html b/atr/templates/projects.html
index f27b3cd..9878905 100644
--- a/atr/templates/projects.html
+++ b/atr/templates/projects.html
@@ -84,78 +84,5 @@
{% block javascripts %}
{{ super() }}
- <script>
- function filter() {
- const projectFilter = document.getElementById("project-filter").value;
- const cards = document.querySelectorAll(".page-project-card");
- let visibleCount = 0;
- for (let card of cards) {
- const nameElement = card.querySelector(".card-title");
- const name = nameElement.innerHTML;
- if (!projectFilter) {
- card.parentElement.hidden = false;
- visibleCount++;
- } else {
- card.parentElement.hidden = !name.match(new RegExp(projectFilter,
'i'));
- if (!card.parentElement.hidden) {
- visibleCount++;
- }
- }
- }
- document.getElementById("project-count").textContent = visibleCount;
- }
-
- // Add event listeners
- document.getElementById("filter-button").addEventListener("click", filter);
- document.getElementById("project-filter").addEventListener("keydown",
function(event) {
- if (event.key === "Enter") {
- filter();
- event.preventDefault();
- }
- });
-
- // Add click handlers for project cards
- document.querySelectorAll(".page-project-card").forEach(function(card) {
- card.addEventListener("click", function(event) {
- // Prevent card navigation if click is inside a form
- if (event.target.closest("form")) {
- return;
- }
- window.location.href = this.getAttribute("data-project-url");
- });
- });
-
- // Participant filter logic
- const participantButton =
document.getElementById("filter-participant-button");
- participantButton.addEventListener("click", function() {
- const showing = this.dataset.showing;
- const cards = document.querySelectorAll(".page-project-card");
- let visibleCount = 0;
-
- if (showing === "all") {
- // Switch to showing only participant projects
- cards.forEach(card => {
- const isParticipant = card.dataset.isParticipant === 'true';
- card.parentElement.hidden = !isParticipant;
- if (!card.parentElement.hidden) {
- visibleCount++;
- }
- });
- this.textContent = "Show all projects";
- this.dataset.showing = "participant";
- } else {
- // Switch to showing all projects
- cards.forEach(card => {
- card.parentElement.hidden = false;
- visibleCount++;
- });
- this.textContent = "Show my projects";
- this.dataset.showing = "all";
- }
- // Reset text filter when toggling participant view
- document.getElementById("project-filter").value = "";
- // Update count
- document.getElementById("project-count").textContent = visibleCount;
- });
- </script>
+ <script src="{{ static_url('js/projects-directory.js') }}"></script>
{% endblock javascripts %}
diff --git a/atr/templates/report-selected-path.html
b/atr/templates/report-selected-path.html
index 89e44ed..2fc36e9 100644
--- a/atr/templates/report-selected-path.html
+++ b/atr/templates/report-selected-path.html
@@ -337,91 +337,7 @@
{% block javascripts %}
{{ super() }}
- <script>
- function toggleAllDetails() {
- const details = document.querySelectorAll("details");
- // Check if any are closed
- const anyClosed = Array.from(details).some(detail => !detail.open);
- // If any are closed, open all
- // Otherwise, close all
- details.forEach(detail => detail.open = anyClosed);
- }
-
- function toggleStatusVisibility(type, status) {
- const btn = document.getElementById(`btn-toggle-${type}-${status}`);
- const targets =
document.querySelectorAll(`.atr-result-${type}.atr-result-status-${status}`);
- if (!targets.length) return;
- let elementsCurrentlyHidden = targets[0].classList.contains("atr-hide");
- targets.forEach(el => {
- if (elementsCurrentlyHidden) {
- el.classList.remove("atr-hide");
- } else {
- el.classList.add("atr-hide");
- }
- });
- const bsSt = (status === "failure" || status === "exception") ? "danger"
: status;
- const cntMatch = btn.textContent.match(/\((\d+)\)/);
- if (!cntMatch) {
- console.error("Button text regex mismatch for:", btn.textContent);
- return;
- }
- const cnt = cntMatch[0];
- const newButtonAction = elementsCurrentlyHidden ? "Hide" : "Show";
- btn.querySelector("span").textContent = newButtonAction;
- if (newButtonAction === "Hide") {
- btn.classList.remove(`btn-outline-${bsSt}`);
- btn.classList.add(`btn-${bsSt}`);
- } else {
- btn.classList.remove(`btn-${bsSt}`);
- btn.classList.add(`btn-outline-${bsSt}`);
- }
- if (type === "member") {
- updateMemberStriping();
- } else if (type === "primary") {
- updatePrimaryStriping();
- }
- }
-
- function restripeVisibleRows(rowSelector, stripeClass) {
- let visibleIdx = 0;
- document.querySelectorAll(rowSelector).forEach(row => {
- row.classList.remove(stripeClass);
- const hidden = row.classList.contains("atr-hide") ||
row.classList.contains("page-member-path-hide");
- if (!hidden) {
- if (visibleIdx % 2 === 0) row.classList.add(stripeClass);
- visibleIdx++;
- }
- });
- }
-
- function updatePrimaryStriping() {
- restripeVisibleRows(".atr-result-primary", "page-member-visible-odd");
- }
-
- function updateMemberStriping() {
- restripeVisibleRows(".atr-result-member", "page-member-visible-odd");
- }
-
- const mpfInput = document.getElementById("member-path-filter");
- if (mpfInput) {
- mpfInput.addEventListener("input", function() {
- const filterText = this.value.toLowerCase();
- document.querySelectorAll(".atr-result-member").forEach(row => {
- const pathCell = row.cells[0];
- let hide = false;
- if (filterText) {
- if (!pathCell.textContent.toLowerCase().includes(filterText)) {
- hide = true;
- }
- }
- row.classList.toggle("page-member-path-hide", hide);
- });
- updateMemberStriping();
- });
- }
- updatePrimaryStriping();
- updateMemberStriping();
- </script>
+ <script src="{{ static_url('js/report-results.js') }}"></script>
{% endblock javascripts %}
{% macro function_name_from_key(key) -%}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]