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
|
||||||
|
|||||||
+46
-43
@@ -47,49 +47,52 @@ 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(
|
||||||
cell_selectable=False,
|
className="marches_table",
|
||||||
id="table",
|
children=dash_table.DataTable(
|
||||||
page_size=20,
|
cell_selectable=False,
|
||||||
page_current=0,
|
id="table",
|
||||||
page_action="custom",
|
page_size=20,
|
||||||
filter_action="custom",
|
page_current=0,
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
page_action="custom",
|
||||||
columns=[
|
filter_action="custom",
|
||||||
{
|
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
||||||
"name": i,
|
columns=[
|
||||||
"id": i,
|
{
|
||||||
"presentation": "markdown",
|
"name": i,
|
||||||
"type": "text",
|
"id": i,
|
||||||
"format": {"nully": "N/A"},
|
"presentation": "markdown",
|
||||||
"hideable": True,
|
"type": "text",
|
||||||
}
|
"format": {"nully": "N/A"},
|
||||||
for i in lf.collect_schema().names()
|
"hideable": True,
|
||||||
],
|
}
|
||||||
sort_action="custom",
|
for i in lf.collect_schema().names()
|
||||||
sort_mode="multi",
|
],
|
||||||
sort_by=[],
|
sort_action="custom",
|
||||||
row_deletable=False,
|
sort_mode="multi",
|
||||||
style_cell_conditional=[
|
sort_by=[],
|
||||||
{
|
row_deletable=False,
|
||||||
"if": {"column_id": "objet"},
|
style_cell_conditional=[
|
||||||
"minWidth": "350px",
|
{
|
||||||
"textAlign": "left",
|
"if": {"column_id": "objet"},
|
||||||
"overflow": "hidden",
|
"minWidth": "350px",
|
||||||
"lineHeight": "14px",
|
"textAlign": "left",
|
||||||
"whiteSpace": "normal",
|
"overflow": "hidden",
|
||||||
},
|
"lineHeight": "14px",
|
||||||
{
|
"whiteSpace": "normal",
|
||||||
"if": {"column_id": "acheteur_nom"},
|
},
|
||||||
"minWidth": "250px",
|
{
|
||||||
"textAlign": "left",
|
"if": {"column_id": "acheteur_nom"},
|
||||||
"overflow": "hidden",
|
"minWidth": "250px",
|
||||||
"lineHeight": "14px",
|
"textAlign": "left",
|
||||||
"whiteSpace": "normal",
|
"overflow": "hidden",
|
||||||
},
|
"lineHeight": "14px",
|
||||||
],
|
"whiteSpace": "normal",
|
||||||
data_timestamp=0,
|
},
|
||||||
markdown_options={"html": True},
|
],
|
||||||
|
data_timestamp=0,
|
||||||
|
markdown_options={"html": True},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
|
|||||||
Reference in New Issue
Block a user