diff --git a/sld-dashboard/app/base/static/assets/js/pagination.js b/sld-dashboard/app/base/static/assets/js/pagination.js index 8cfc8ba8..3e2b19ff 100644 --- a/sld-dashboard/app/base/static/assets/js/pagination.js +++ b/sld-dashboard/app/base/static/assets/js/pagination.js @@ -1,69 +1,76 @@ - $(document).ready(function(){ - var rowsPerPage = 10; // Valor inicial - var rows = $('#myTable tr'); - var filteredRows = rows; // Inicialmente, todas las filas son el conjunto filtrado - var pagesCount; - var currentPage = 1; +$(document).ready(function(){ + var rowsPerPage = 10; // Valor inicial + var rows = $('#myTable tr'); + var filteredRows = rows; // Inicialmente, todas las filas son el conjunto filtrado + var pagesCount; + var currentPage = 1; - function displayPage(page) { + function displayPage(page) { var start = (page - 1) * rowsPerPage; var end = start + rowsPerPage; rows.hide(); filteredRows.slice(start, end).show(); - } + } - function setupPagination() { + function setupPagination() { pagesCount = Math.ceil(filteredRows.length / rowsPerPage); $('.pagination .number-page').remove(); // Remove old page numbers for (var i = 1; i <= pagesCount; i++) { - $('
  • ' + i + '
  • ') - .insertBefore("#next-page") - .on('click', function(e) { - e.preventDefault(); - currentPage = parseInt($(this).text()); - displayPage(currentPage); - $(".pagination .number-page").removeClass('active'); - $(this).addClass('active'); - }); + $('
  • ' + i + '
  • ') + .insertBefore("#next-page") + .on('click', function(e) { + e.preventDefault(); + currentPage = parseInt($(this).text()); + displayPage(currentPage); + $(".pagination .number-page").removeClass('active'); + $(this).addClass('active'); + }); } displayPage(1); - } + } - $("#myInput").on("keyup", function() { + // Event Delegation for edit buttons and other interactive elements + $(document).on('click', '.edit-button', function() { + // Aquí iría el código para manejar la edición + }); + + // Existing search functionality + $("#myInput").on("keyup", function() { var value = $(this).val().toLowerCase(); filteredRows = rows.filter(function() { - return $(this).text().toLowerCase().indexOf(value) > -1; + return $(this).text().toLowerCase().indexOf(value) > -1; }); - currentPage = 1; // Reset to first page + currentPage = 1; setupPagination(); - }); + }); - // Handle row per page selection - $(".dropdown-menu a").on("click", function(e) { + // Existing dropdown functionality + $(".dropdown-menu a").on("click", function(e) { e.preventDefault(); var selectedValue = $(this).text().trim(); rowsPerPage = selectedValue.toLowerCase() === 'all' ? rows.length : parseInt(selectedValue); currentPage = 1; // Reset to first page setupPagination(); - }); + }); - // Setup initial pagination - setupPagination(); + // Initial setup + setupPagination(); - // Previous and Next button logic - $("#previous-page").on('click', function(e) { + // Previous and Next button logic + $("#previous-page").on('click', function(e) { e.preventDefault(); if (currentPage > 1) { - currentPage--; - displayPage(currentPage); + currentPage--; + displayPage(currentPage); } - }); + }); - $("#next-page").on('click', function(e) { + $("#next-page").on('click', function(e) { e.preventDefault(); if (currentPage < pagesCount) { - currentPage++; - displayPage(currentPage); + currentPage++; + displayPage(currentPage); } - }); - }); \ No newline at end of file + }); +}); +d \ No newline at end of file diff --git a/sld-dashboard/app/base/static/assets/js/pagination_edit.js b/sld-dashboard/app/base/static/assets/js/pagination_edit.js new file mode 100644 index 00000000..8627070b --- /dev/null +++ b/sld-dashboard/app/base/static/assets/js/pagination_edit.js @@ -0,0 +1,85 @@ + document.addEventListener("DOMContentLoaded", function() { + var rowsPerPage = 10; + var table = document.getElementById("table"); + var tbody = table.getElementsByTagName("tbody")[0]; + var rows = Array.from(tbody.getElementsByTagName("tr")); + var pagination = document.querySelector(".pagination"); + var currentPage = 1; + + function displayPage(page, rowsToShow) { + var start = (page - 1) * rowsPerPage; + var end = start + rowsPerPage; + rows.forEach(row => row.style.display = "none"); + rowsToShow.slice(start, end).forEach(row => row.style.display = ""); + } + + function setupPagination(rowsToShow) { + pagination.innerHTML = ''; + var pagesCount = Math.ceil(rowsToShow.length / rowsPerPage); + + // Previous page button + var prevPageItem = document.createElement("li"); + prevPageItem.className = "page-item"; + var prevPageLink = document.createElement("a"); + prevPageLink.className = "page-link"; + prevPageLink.href = "#"; + prevPageLink.innerText = "Previous"; + prevPageItem.appendChild(prevPageLink); + pagination.appendChild(prevPageItem); + + // Page number buttons + for (var i = 1; i <= pagesCount; i++) { + var pageItem = document.createElement("li"); + pageItem.className = "page-item"; + var pageLink = document.createElement("a"); + pageLink.className = "page-link"; + pageLink.href = "#"; + pageLink.innerText = i; + pageItem.appendChild(pageLink); + pagination.appendChild(pageItem); + + pageLink.addEventListener("click", function(e) { + e.preventDefault(); + currentPage = parseInt(this.innerText); + displayPage(currentPage, rowsToShow); + }); + } + + // Next page button + var nextPageItem = document.createElement("li"); + nextPageItem.className = "page-item"; + var nextPageLink = document.createElement("a"); + nextPageLink.className = "page-link"; + nextPageLink.href = "#"; + nextPageLink.innerText = "Next"; + nextPageItem.appendChild(nextPageLink); + pagination.appendChild(nextPageItem); + + prevPageLink.addEventListener("click", function(e) { + e.preventDefault(); + if (currentPage > 1) { + displayPage(--currentPage, rowsToShow); + } + }); + + nextPageLink.addEventListener("click", function(e) { + e.preventDefault(); + if (currentPage < pagesCount) { + displayPage(++currentPage, rowsToShow); + } + }); + + displayPage(1, rowsToShow); // Display the first page + } + + function updateSearchAndPagination() { + var filter = document.getElementById("search").value.toUpperCase(); + var filteredRows = rows.filter(row => row.textContent.toUpperCase().indexOf(filter) > -1); + currentPage = 1; + setupPagination(filteredRows); + } + + document.getElementById("search").addEventListener("keyup", updateSearchAndPagination); + + setupPagination(rows); // Initial setup with all rows + }); \ No newline at end of file diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index 86e8acb1..921249d8 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -52,7 +52,7 @@

    All Deploys

    - +
    @@ -62,6 +62,7 @@

    All Deploys

    +
    @@ -110,7 +107,7 @@

    All Deploys

    - + {% for deploy in deploys| sort(attribute='id') %} @@ -336,35 +333,18 @@

    All users

    - +
    @@ -73,7 +73,7 @@

    All users

    - + {% for user in users | sort(attribute='id') %}