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 */
|
/* 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;
|
background-color: #feeeee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+63
-6
@@ -1,5 +1,7 @@
|
|||||||
import dash
|
import polars as pl
|
||||||
from dash import Input, Output, callback, dcc, html, register_page
|
from dash import Input, Output, callback, dash_table, dcc, html, register_page
|
||||||
|
|
||||||
|
from src.utils import lf
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
__name__,
|
__name__,
|
||||||
@@ -11,14 +13,15 @@ register_page(
|
|||||||
|
|
||||||
# 21690123100011
|
# 21690123100011
|
||||||
|
|
||||||
print(dash.page_registry["pages.acheteur"])
|
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
|
dcc.Store(id="acheteur_data", storage_type="memory"),
|
||||||
dcc.Location(id="url", refresh="callback-nav"),
|
dcc.Location(id="url", refresh="callback-nav"),
|
||||||
html.Div(
|
html.Div(
|
||||||
className="container",
|
className="container",
|
||||||
children=[
|
children=[
|
||||||
html.H2(id="acheteur_title", 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):
|
def update_acheteur(url):
|
||||||
acheteur_siret = url.split("/")[-1]
|
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"
|
title = "Tableau"
|
||||||
register_page(__name__, path="/", title="decp.info", name=title, order=1)
|
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,
|
cell_selectable=False,
|
||||||
id="table",
|
id="table",
|
||||||
page_size=20,
|
page_size=20,
|
||||||
@@ -90,6 +92,7 @@ datatable = dash_table.DataTable(
|
|||||||
],
|
],
|
||||||
data_timestamp=0,
|
data_timestamp=0,
|
||||||
markdown_options={"html": True},
|
markdown_options={"html": True},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
|
|||||||
Reference in New Issue
Block a user