Bloquage du bouton de téléchargement si trop de lignes #38

This commit is contained in:
Colin Maudry
2025-09-23 12:27:57 +02:00
parent 46dfc23d42
commit 159d409237
2 changed files with 34 additions and 5 deletions
+6 -2
View File
@@ -31,7 +31,11 @@ python run.py
## Notes de version
### 2.0.1 (23 septembre 2025)
#### 2.0.1 (23 septembre 2025)
- Bloquage du bouton de téléchargement si trop de lignes (+ 65000) [#38](https//github.com/ColinMaudry/decp.info/issues/38)
- Meilleures instructions d'installation et lancement
- Coquilles 🐚
### 2.0.0 (23 septembre 2025)
@@ -39,7 +43,7 @@ python run.py
- section "À propos" plus développée
- correction de bugs dans les filtres de la data table
### 2.0.0-alpha
#### 2.0.0-alpha
- Data table fonctionnelle
+28 -3
View File
@@ -141,7 +141,11 @@ layout = [
html.Div(
[
html.P("lignes", id="nb_rows"),
html.Button("Télécharger au format Excel", id="btn-download-data"),
html.Button(
"Téléchargement désactivé au-delà de 65 000 lignes",
id="btn-download-data",
disabled=True,
),
dcc.Download(id="download-data"),
html.P("Données mises à jour le " + str(update_date)),
],
@@ -157,6 +161,9 @@ layout = [
Output("table", "data"),
Output("table", "data_timestamp"),
Output("nb_rows", "children"),
Output("btn-download-data", "disabled"),
Output("btn-download-data", "children"),
Output("btn-download-data", "title"),
Input("table", "page_current"),
Input("table", "page_size"),
Input("table", "filter_query"),
@@ -215,7 +222,9 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
df_filtered = dff.clone()
nb_rows = f"{format_number(dff.height)} lignes"
height = dff.height
nb_rows = f"{format_number(height)} lignes"
# Pagination des données
start_row = page_current * page_size
@@ -223,7 +232,23 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
dff = dff.slice(start_row, page_size)
dicts = dff.to_dicts()
return dicts, data_timestamp + 1, nb_rows
if height > 65000:
download_disabled = True
download_text = "Téléchargement désactivé au-delà de 65 000 lignes"
download_title = "Excel ne supporte pas d'avoir plus de 65 000 URLs dans une même feuille de calcul. Contactez-moi pour me présenter votre besoin en téléchargement afin je puisse adapter la solution."
else:
download_disabled = False
download_text = "Télécharger au format Excel"
download_title = ""
return (
dicts,
data_timestamp + 1,
nb_rows,
download_disabled,
download_text,
download_title,
)
@callback(