Derniers marché notifiés #28
This commit is contained in:
@@ -71,7 +71,10 @@ td[data-dash-column="objet"] {
|
||||
}
|
||||
|
||||
/* Alternance des couleurs pour les lignes */
|
||||
#table tr:nth-child(even) td {
|
||||
.marches_table {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.marches_table .cell-table tr:nth-child(even) td {
|
||||
background-color: #feeeee;
|
||||
}
|
||||
|
||||
|
||||
+63
-6
@@ -1,5 +1,7 @@
|
||||
import dash
|
||||
from dash import Input, Output, callback, dcc, html, register_page
|
||||
import polars as pl
|
||||
from dash import Input, Output, callback, dash_table, dcc, html, register_page
|
||||
|
||||
from src.utils import lf
|
||||
|
||||
register_page(
|
||||
__name__,
|
||||
@@ -11,14 +13,15 @@ register_page(
|
||||
|
||||
# 21690123100011
|
||||
|
||||
print(dash.page_registry["pages.acheteur"])
|
||||
|
||||
layout = [
|
||||
dcc.Store(id="acheteur_data", storage_type="memory"),
|
||||
dcc.Location(id="url", refresh="callback-nav"),
|
||||
html.Div(
|
||||
className="container",
|
||||
children=[
|
||||
html.H2(id="acheteur_title", children=""),
|
||||
html.H3("Derniers marchés publics notifiés"),
|
||||
html.Div(id="acheteur_last_marches", children=""),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -30,6 +33,60 @@ layout = [
|
||||
)
|
||||
def update_acheteur(url):
|
||||
acheteur_siret = url.split("/")[-1]
|
||||
acheteur_title = acheteur_siret
|
||||
if len(acheteur_siret) != 14:
|
||||
return f"Le SIRET renseigné doit faire 14 caractères ({acheteur_siret})"
|
||||
|
||||
return acheteur_title
|
||||
return acheteur_siret
|
||||
|
||||
|
||||
@callback(
|
||||
Output(component_id="acheteur_data", component_property="data"),
|
||||
Input(component_id="url", component_property="pathname"),
|
||||
)
|
||||
def get_acheteur_marches_data(url) -> pl.LazyFrame:
|
||||
acheteur_siret = url.split("/")[-1]
|
||||
lff = lf.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||
lff = lff.select(
|
||||
"uid",
|
||||
"objet",
|
||||
"dateNotification",
|
||||
"titulaire_nom",
|
||||
"montant",
|
||||
"codeCPV",
|
||||
"dureeMois",
|
||||
)
|
||||
lff = lff.sort("dateNotification", descending=True, nulls_last=True)
|
||||
data = lff.collect(engine="streaming").to_dicts()
|
||||
return data
|
||||
|
||||
|
||||
@callback(
|
||||
Output(component_id="acheteur_last_marches", component_property="children"),
|
||||
Input(component_id="acheteur_data", component_property="data"),
|
||||
)
|
||||
def get_last_marches_table(data) -> html.Div:
|
||||
table = html.Div(
|
||||
className="marches_table",
|
||||
children=dash_table.DataTable(
|
||||
data=data[:20],
|
||||
style_cell_conditional=[
|
||||
{
|
||||
"if": {"column_id": "objet"},
|
||||
"minWidth": "300px",
|
||||
"textAlign": "left",
|
||||
"overflow": "hidden",
|
||||
"lineHeight": "14px",
|
||||
"whiteSpace": "normal",
|
||||
},
|
||||
{
|
||||
"if": {"column_id": "titulaire_nom"},
|
||||
"minWidth": "200px",
|
||||
"textAlign": "left",
|
||||
"overflow": "hidden",
|
||||
"lineHeight": "14px",
|
||||
"whiteSpace": "normal",
|
||||
},
|
||||
],
|
||||
),
|
||||
)
|
||||
return table
|
||||
|
||||
+4
-1
@@ -47,7 +47,9 @@ schema = lf.collect_schema()
|
||||
title = "Tableau"
|
||||
register_page(__name__, path="/", title="decp.info", name=title, order=1)
|
||||
|
||||
datatable = dash_table.DataTable(
|
||||
datatable = html.Div(
|
||||
className="marches_table",
|
||||
children=dash_table.DataTable(
|
||||
cell_selectable=False,
|
||||
id="table",
|
||||
page_size=20,
|
||||
@@ -90,6 +92,7 @@ datatable = dash_table.DataTable(
|
||||
],
|
||||
data_timestamp=0,
|
||||
markdown_options={"html": True},
|
||||
),
|
||||
)
|
||||
|
||||
layout = [
|
||||
|
||||
Reference in New Issue
Block a user