Affichage du nombre de lignes close #19
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
/* Change le texte du bout d'export */
|
/* Change la marge bout d'export */
|
||||||
button.export {
|
.table-menu {
|
||||||
font-size: 0;
|
font-size: 16px;
|
||||||
|
margin: 12px;
|
||||||
}
|
}
|
||||||
button.export:before {
|
|
||||||
content: "Télécharger au format Excel";
|
.table-menu > * {
|
||||||
font-size: 14px;
|
margin: 8px;
|
||||||
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Masquer le bouton de configuration de la casse dans les filtres */
|
/* Masquer le bouton de configuration de la casse dans les filtres */
|
||||||
|
|||||||
+16
-10
@@ -11,6 +11,7 @@ from polars.exceptions import ComputeError
|
|||||||
from src.utils import (
|
from src.utils import (
|
||||||
add_annuaire_link,
|
add_annuaire_link,
|
||||||
booleans_to_strings,
|
booleans_to_strings,
|
||||||
|
format_number,
|
||||||
numbers_to_strings,
|
numbers_to_strings,
|
||||||
split_filter_part,
|
split_filter_part,
|
||||||
)
|
)
|
||||||
@@ -140,8 +141,14 @@ layout = [
|
|||||||
id="loading-1",
|
id="loading-1",
|
||||||
type="default",
|
type="default",
|
||||||
children=[
|
children=[
|
||||||
html.Button("Téléchargement", id="btn-download-data"),
|
html.Div(
|
||||||
dcc.Download(id="download-data"),
|
[
|
||||||
|
html.P("lignes", id="nb_rows"),
|
||||||
|
html.Button("Télécharger au format Excel", id="btn-download-data"),
|
||||||
|
dcc.Download(id="download-data"),
|
||||||
|
],
|
||||||
|
className="table-menu",
|
||||||
|
),
|
||||||
datatable,
|
datatable,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -151,6 +158,7 @@ layout = [
|
|||||||
@callback(
|
@callback(
|
||||||
Output("table", "data"),
|
Output("table", "data"),
|
||||||
Output("table", "data_timestamp"),
|
Output("table", "data_timestamp"),
|
||||||
|
Output("nb_rows", "children"),
|
||||||
Input("table", "page_current"),
|
Input("table", "page_current"),
|
||||||
Input("table", "page_size"),
|
Input("table", "page_size"),
|
||||||
Input("table", "filter_query"),
|
Input("table", "filter_query"),
|
||||||
@@ -160,7 +168,7 @@ def update_table(page_current, page_size, filter_query, data_timestamp):
|
|||||||
print(" + + + + + + + + + + + + + + + + + + ")
|
print(" + + + + + + + + + + + + + + + + + + ")
|
||||||
global df_filtered
|
global df_filtered
|
||||||
|
|
||||||
# 1. Apply Filters
|
# Application des filtres
|
||||||
lff: pl.LazyFrame = lf # start from the original data
|
lff: pl.LazyFrame = lf # start from the original data
|
||||||
if filter_query:
|
if filter_query:
|
||||||
filtering_expressions = filter_query.split(" && ")
|
filtering_expressions = filter_query.split(" && ")
|
||||||
@@ -195,25 +203,23 @@ def update_table(page_current, page_size, filter_query, data_timestamp):
|
|||||||
# elif operator == 'datestartswith':
|
# elif operator == 'datestartswith':
|
||||||
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
||||||
|
|
||||||
# 2. Paginate Data
|
# Pagination des données
|
||||||
start_row = page_current * page_size
|
start_row = page_current * page_size
|
||||||
# end_row = (page_current + 1) * page_size
|
# end_row = (page_current + 1) * page_size
|
||||||
|
|
||||||
# Remplacement des valeurs numériques par des chaînes de caractères
|
# Remplacement des valeurs numériques par des chaînes de caractères
|
||||||
lff = numbers_to_strings(lff)
|
lff = numbers_to_strings(lff)
|
||||||
|
|
||||||
dff = lff.collect()
|
dff: pl.DataFrame = lff.collect()
|
||||||
|
|
||||||
df_filtered = dff.clone()
|
df_filtered = dff.clone()
|
||||||
|
|
||||||
|
nb_rows = f"{format_number(dff.height)} lignes"
|
||||||
dff = dff.slice(start_row, page_size)
|
dff = dff.slice(start_row, page_size)
|
||||||
# print("dff_sliced:", lff.select("titulaire.typeId"))
|
# print("dff_sliced:", lff.select("titulaire.typeId"))
|
||||||
dff = dff.to_dicts()
|
dicts = dff.to_dicts()
|
||||||
|
|
||||||
return (
|
return dicts, data_timestamp + 1, nb_rows # update data, update timestamp
|
||||||
dff,
|
|
||||||
data_timestamp + 1,
|
|
||||||
) # update data, update timestamp
|
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
|
|||||||
@@ -64,3 +64,8 @@ def numbers_to_strings(lf: pl.LazyFrame) -> pl.LazyFrame:
|
|||||||
"""
|
"""
|
||||||
lf = lf.with_columns(pl.col(pl.Float64, pl.Int16).cast(pl.String).fill_null(""))
|
lf = lf.with_columns(pl.col(pl.Float64, pl.Int16).cast(pl.String).fill_null(""))
|
||||||
return lf
|
return lf
|
||||||
|
|
||||||
|
|
||||||
|
def format_number(number) -> str:
|
||||||
|
number = "{:,}".format(number).replace(",", " ")
|
||||||
|
return number
|
||||||
|
|||||||
Reference in New Issue
Block a user