From ba711f5423784f1ebce936f1a21b8d1ee15ad957 Mon Sep 17 00:00:00 2001 From: David Itehua Xalamihua Date: Mon, 28 Apr 2025 12:07:53 -0600 Subject: [PATCH] fir btn download excel file --- main.py | 7 ++- static/h_tmp_user/a_home/a_home.css | 64 ++++++++++++--------- static/h_tmp_user/a_home/datatable.js | 80 ++++++++++++++++++++++----- templates/h_tmp_usr/a_home.html | 17 ++---- templates/h_tmp_usr/z_tmp.html | 37 ++++++++----- templates/z_comps/download_xlsx.html | 48 ++++++++++------ 6 files changed, 165 insertions(+), 88 deletions(-) diff --git a/main.py b/main.py index b362a45..f3a496c 100644 --- a/main.py +++ b/main.py @@ -469,7 +469,7 @@ def user_home(): data_contact = dbUsers.get_all_data(q_contact) # return render_template(v['tmp_user']['home'], token_data=token_data, f_mnsj=f_mnsj, nombre=nombre, exp=exp, data_contact=data_contact) - return render_template(v['tmp_user']['home'], f_mnsj=f_mnsj, nombre=nombre, exp=exp, data_contact=data_contact) + return render_template(v['tmp_user']['home'], f_mnsj=f_mnsj, nombre=nombre, exp=exp, data_contact=data_contact, active_page='user_home') @app.route('/user/manage-record', methods=['POST']) @jwt_required() @@ -520,7 +520,7 @@ def download_db(): @validate_user_exists def user_txteditor(): template_name = v['tmp_user'].get('txt_editor') - return render_template(template_name) + return render_template(template_name, active_page='user_txteditor') @app.route('/user/save-post', methods=['POST']) @@ -599,7 +599,8 @@ def my_posts(): v['tmp_user']['my_posts'], data=data, current_page=page, - total_pages=total_pages + total_pages=total_pages, + active_page='my_posts' ) diff --git a/static/h_tmp_user/a_home/a_home.css b/static/h_tmp_user/a_home/a_home.css index 7a34326..cae3e10 100644 --- a/static/h_tmp_user/a_home/a_home.css +++ b/static/h_tmp_user/a_home/a_home.css @@ -59,6 +59,20 @@ margin-right: 0.5rem; } +#dbContact thead { + text-align: center; + vertical-align: middle; + background-color: black; + color: white; +} + +#dbContact th { + text-align: center; + vertical-align: middle; + background-color: black; + color: white; +} + /* Smartphones (hasta 767px) */ @@ -176,37 +190,20 @@ } - - - -#dbContact thead { - text-align: center; - vertical-align: middle; - background-color: black; - color: white; -} - -#dbContact th { - text-align: center; - vertical-align: middle; - background-color: black; - color: white; -} - - - - - - /* Tablets (768px - 1023px) */ @media (min-width: 768px) and (max-width: 1023px) { /* main{ background-color: pink; } */ main { min-height: 80vh; + place-items: center; /* background-color: blueviolet; */ } - + #dbContact thead { + position: sticky; + top: 0; + z-index: 10; + } } @@ -214,17 +211,34 @@ @media (min-width: 1024px) and (max-width: 1439px) { /* main{ background-color: purple; } */ main { - min-height: 50vh; + min-height: 80vh; + place-items: center; /* background-color: aqua; */ } + + #dbContact thead { + position: sticky; + top: 0; + z-index: 10; + } + + } /* PCs de escritorio (1440px - 1919px) macbook */ @media (min-width: 1440px) and (max-width: 1919px) { /* main{ background-color: greenyellow; } */ main { - min-height: 50vh; + min-height: 80vh; } + + + #dbContact thead { + position: sticky; + top: 0; + z-index: 10; + } + } /* Pantallas Ultrawide (1920px en adelante) */ diff --git a/static/h_tmp_user/a_home/datatable.js b/static/h_tmp_user/a_home/datatable.js index 09f498f..ff1bb51 100644 --- a/static/h_tmp_user/a_home/datatable.js +++ b/static/h_tmp_user/a_home/datatable.js @@ -1,28 +1,78 @@ -new DataTable('#dbContact', { - autoWidth: true, // 👈 agregar esto +// new DataTable('#dbContact', { +// autoWidth: true, +// responsive: true, + +// columnDefs: [ +// { +// targets: 3, // Recuerda, empieza en 0: Fecha(0), Nombre(1), Estado(2), Empleados(3) +// visible: window.innerWidth >= 1024 && window.innerWidth <= 1439 ? false : true +// } +// ], + +// initComplete: function () { +// this.api().columns().every(function () { +// let column = this; +// let header = $(column.header()); +// let title = header.text().trim(); + +// if (title !== 'Estatus') { +// header.append('
'); +// $('input', header).on('keyup change', function () { +// if (column.search() !== this.value) { +// column.search(this.value).draw(); +// } +// }); +// } +// }); +// } +// }); + +let table = new DataTable('#dbContact', { + autoWidth: true, responsive: true, - initComplete: function () { - // Agrega campos de filtro para cada columna this.api().columns().every(function () { let column = this; let header = $(column.header()); let title = header.text().trim(); - - // Excluir la columna "Estatus" del filtro + if (title !== 'Estatus') { - // Crea input de filtro header.append('
'); - - // Aplica el filtro al escribir - $('input', header) - .on('keyup change', function () { - if (column.search() !== this.value) { - column.search(this.value).draw(); - } - }); + $('input', header).on('keyup change', function () { + if (column.search() !== this.value) { + column.search(this.value).draw(); + } + }); } }); } }); + +function ajustarColumnasSegunPantalla() { + const width = window.innerWidth; + + if (width >= 1024 && width <= 1439) { + // Entre 1024px y 1439px: ocultar solo columna 3 + table.column(3).visible(false); + // table.column(4).visible(true); + } else if (width >= 768 && width <= 1023) { + // Entre 768px y 1023px: ocultar columna 3 y columna 4 + table.column(3).visible(false); + table.column(4).visible(false); + table.column(5).visible(false); + } + // Otros tamaños: mostrar ambas columnas + // else { + // table.column(3).visible(true); + // table.column(4).visible(true); + // } +} + +// Ejecutar una vez al cargar +ajustarColumnasSegunPantalla(); + +// Y además ajustar si cambia el tamaño de la ventana +window.addEventListener('resize', function() { + ajustarColumnasSegunPantalla(); +}); diff --git a/templates/h_tmp_usr/a_home.html b/templates/h_tmp_usr/a_home.html index e40162a..51a8cda 100644 --- a/templates/h_tmp_usr/a_home.html +++ b/templates/h_tmp_usr/a_home.html @@ -15,21 +15,11 @@ {% endblock css %} - - {% block body %} - - - - -
- - {% if is_admin %} - {% include 'z_comps/download_xlsx.html' %} - {% endif %} + {% if is_admin %} {% include 'z_comps/download_xlsx.html' %} {% endif %}
@@ -106,13 +96,14 @@ {% block js %} + + {% include 'z_comps/if_flash.html' %} {% include 'z_comps/aos_script.html' %} - @@ -142,4 +133,6 @@ + + {% endblock js %} \ No newline at end of file diff --git a/templates/h_tmp_usr/z_tmp.html b/templates/h_tmp_usr/z_tmp.html index 954cb1e..9d24c22 100644 --- a/templates/h_tmp_usr/z_tmp.html +++ b/templates/h_tmp_usr/z_tmp.html @@ -93,26 +93,33 @@
diff --git a/templates/z_comps/download_xlsx.html b/templates/z_comps/download_xlsx.html index d1de0c5..c48ac01 100644 --- a/templates/z_comps/download_xlsx.html +++ b/templates/z_comps/download_xlsx.html @@ -4,30 +4,42 @@ +