fix
This commit is contained in:
parent
398e2d2d00
commit
584de757bb
4 changed files with 23 additions and 24 deletions
|
|
@ -2,7 +2,7 @@ import streamlit as st
|
||||||
import requests
|
import requests
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
API_BASE = "http://localhost:8000/api/v1"
|
API_BASE = "https://api.cosmoguard.it/api/v1"
|
||||||
|
|
||||||
EXPOSURE_ROUTES = ["Dermal", "Oral", "Inhalation", "Ocular"]
|
EXPOSURE_ROUTES = ["Dermal", "Oral", "Inhalation", "Ocular"]
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ with tab_lista:
|
||||||
"ritenzione", "esposizione_calcolata", "esposizione_relativa",
|
"ritenzione", "esposizione_calcolata", "esposizione_relativa",
|
||||||
]
|
]
|
||||||
existing = [c for c in display_cols if c in df.columns]
|
existing = [c for c in display_cols if c in df.columns]
|
||||||
st.dataframe(df[existing], use_container_width=True, hide_index=True)
|
st.dataframe(df[existing], width="stretch", hide_index=True)
|
||||||
|
|
||||||
st.divider()
|
st.divider()
|
||||||
st.subheader("Elimina Preset")
|
st.subheader("Elimina Preset")
|
||||||
|
|
@ -124,7 +124,7 @@ with tab_lista:
|
||||||
with col_btn:
|
with col_btn:
|
||||||
sub1, sub2 = st.columns(2)
|
sub1, sub2 = st.columns(2)
|
||||||
with sub1:
|
with sub1:
|
||||||
if st.button("Si", key=f"confirm_{name}", type="primary", use_container_width=True):
|
if st.button("Si", key=f"confirm_{name}", type="primary", width="stretch"):
|
||||||
try:
|
try:
|
||||||
del_resp = requests.delete(f"{API_BASE}/esposition/delete/{name}", timeout=10)
|
del_resp = requests.delete(f"{API_BASE}/esposition/delete/{name}", timeout=10)
|
||||||
del_data = del_resp.json()
|
del_data = del_resp.json()
|
||||||
|
|
@ -137,12 +137,12 @@ with tab_lista:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.error(f"Errore: {e}")
|
st.error(f"Errore: {e}")
|
||||||
with sub2:
|
with sub2:
|
||||||
if st.button("No", key=f"cancel_{name}", use_container_width=True):
|
if st.button("No", key=f"cancel_{name}", width="stretch"):
|
||||||
st.session_state.confirm_delete_preset = None
|
st.session_state.confirm_delete_preset = None
|
||||||
st.rerun()
|
st.rerun()
|
||||||
else:
|
else:
|
||||||
with col_btn:
|
with col_btn:
|
||||||
if st.button("Elimina", key=f"del_{name}", use_container_width=True):
|
if st.button("Elimina", key=f"del_{name}", width="stretch"):
|
||||||
st.session_state.confirm_delete_preset = name
|
st.session_state.confirm_delete_preset = name
|
||||||
st.rerun()
|
st.rerun()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import pandas as pd
|
||||||
from functions import cosing_download
|
from functions import cosing_download
|
||||||
from functions_ui import download_pdf
|
from functions_ui import download_pdf
|
||||||
|
|
||||||
#API_BASE = "https://api.cosmoguard.it/api/v1"
|
API_BASE = "https://api.cosmoguard.it/api/v1"
|
||||||
API_BASE = "http://localhost:8000/api/v1"
|
|
||||||
|
|
||||||
st.set_page_config(page_title="Ricerca Ingredienti", layout="wide")
|
st.set_page_config(page_title="Ricerca Ingredienti", layout="wide")
|
||||||
st.title("Ricerca Ingredienti per CAS")
|
st.title("Ricerca Ingredienti per CAS")
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import requests
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
|
||||||
API_BASE = "http://localhost:8000/api/v1"
|
API_BASE = "https://api.cosmoguard.it/api/v1"
|
||||||
|
|
||||||
STATUS_MAP = {
|
STATUS_MAP = {
|
||||||
1: ("Ricevuto", "🔵"),
|
1: ("Ricevuto", "🔵"),
|
||||||
|
|
@ -222,7 +222,7 @@ def show_order_detail(id_ordine):
|
||||||
if col_name in df_display.columns:
|
if col_name in df_display.columns:
|
||||||
df_display[col_name] = df_display[col_name].map({True: "Sì", False: "-"})
|
df_display[col_name] = df_display[col_name].map({True: "Sì", False: "-"})
|
||||||
|
|
||||||
st.dataframe(df_display, use_container_width=True, hide_index=True)
|
st.dataframe(df_display, width="stretch", hide_index=True)
|
||||||
else:
|
else:
|
||||||
st.info("Nessun ingrediente disponibile")
|
st.info("Nessun ingrediente disponibile")
|
||||||
|
|
||||||
|
|
@ -234,13 +234,13 @@ def show_order_detail(id_ordine):
|
||||||
|
|
||||||
# 1. Aggiorna stato
|
# 1. Aggiorna stato
|
||||||
with btn_cols[0]:
|
with btn_cols[0]:
|
||||||
if st.button("🔄 Aggiorna", key="refresh_btn", use_container_width=True):
|
if st.button("🔄 Aggiorna", key="refresh_btn", width="stretch"):
|
||||||
st.rerun()
|
st.rerun()
|
||||||
|
|
||||||
# 2. Retry (solo se ERRORE)
|
# 2. Retry (solo se ERRORE)
|
||||||
with btn_cols[1]:
|
with btn_cols[1]:
|
||||||
if stato == 9:
|
if stato == 9:
|
||||||
if st.button("🔁 Retry", key="retry_btn", type="primary", use_container_width=True):
|
if st.button("🔁 Retry", key="retry_btn", type="primary", width="stretch"):
|
||||||
with st.spinner("Retry in corso..."):
|
with st.spinner("Retry in corso..."):
|
||||||
result = api_retry_order(id_ordine)
|
result = api_retry_order(id_ordine)
|
||||||
if result.get("success"):
|
if result.get("success"):
|
||||||
|
|
@ -249,13 +249,13 @@ def show_order_detail(id_ordine):
|
||||||
else:
|
else:
|
||||||
st.error(result.get("error") or result.get("detail", "Errore retry"))
|
st.error(result.get("error") or result.get("detail", "Errore retry"))
|
||||||
else:
|
else:
|
||||||
st.button("🔁 Retry", key="retry_btn_disabled", disabled=True, use_container_width=True)
|
st.button("🔁 Retry", key="retry_btn_disabled", disabled=True, width="stretch")
|
||||||
|
|
||||||
# 3. Scarica Excel
|
# 3. Scarica Excel
|
||||||
with btn_cols[2]:
|
with btn_cols[2]:
|
||||||
if has_project:
|
if has_project:
|
||||||
excel_data = None
|
excel_data = None
|
||||||
if st.button("📊 Scarica Excel", key="excel_prep_btn", use_container_width=True):
|
if st.button("📊 Scarica Excel", key="excel_prep_btn", width="stretch"):
|
||||||
with st.spinner("Generazione Excel..."):
|
with st.spinner("Generazione Excel..."):
|
||||||
excel_data = download_excel(id_ordine)
|
excel_data = download_excel(id_ordine)
|
||||||
if excel_data:
|
if excel_data:
|
||||||
|
|
@ -268,12 +268,12 @@ def show_order_detail(id_ordine):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
st.button("📊 Scarica Excel", key="excel_disabled", disabled=True,
|
st.button("📊 Scarica Excel", key="excel_disabled", disabled=True,
|
||||||
use_container_width=True, help="Progetto non ancora disponibile")
|
width="stretch", help="Progetto non ancora disponibile")
|
||||||
|
|
||||||
# 4. Scarica Fonti PDF
|
# 4. Scarica Fonti PDF
|
||||||
with btn_cols[3]:
|
with btn_cols[3]:
|
||||||
if has_project:
|
if has_project:
|
||||||
if st.button("📄 Scarica Fonti PDF", key="pdf_prep_btn", use_container_width=True):
|
if st.button("📄 Scarica Fonti PDF", key="pdf_prep_btn", width="stretch"):
|
||||||
with st.spinner("Generazione PDF fonti (può richiedere tempo)..."):
|
with st.spinner("Generazione PDF fonti (può richiedere tempo)..."):
|
||||||
zip_data = download_sources(id_ordine)
|
zip_data = download_sources(id_ordine)
|
||||||
if zip_data:
|
if zip_data:
|
||||||
|
|
@ -286,19 +286,19 @@ def show_order_detail(id_ordine):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
st.button("📄 Scarica Fonti PDF", key="pdf_disabled", disabled=True,
|
st.button("📄 Scarica Fonti PDF", key="pdf_disabled", disabled=True,
|
||||||
use_container_width=True, help="Progetto non ancora disponibile")
|
width="stretch", help="Progetto non ancora disponibile")
|
||||||
|
|
||||||
# 5. Elimina ordine
|
# 5. Elimina ordine
|
||||||
with btn_cols[4]:
|
with btn_cols[4]:
|
||||||
if not st.session_state.confirm_delete:
|
if not st.session_state.confirm_delete:
|
||||||
if st.button("🗑️ Elimina", key="delete_btn", use_container_width=True):
|
if st.button("🗑️ Elimina", key="delete_btn", width="stretch"):
|
||||||
st.session_state.confirm_delete = True
|
st.session_state.confirm_delete = True
|
||||||
st.rerun()
|
st.rerun()
|
||||||
else:
|
else:
|
||||||
st.warning("Confermi l'eliminazione?")
|
st.warning("Confermi l'eliminazione?")
|
||||||
sub_cols = st.columns(2)
|
sub_cols = st.columns(2)
|
||||||
with sub_cols[0]:
|
with sub_cols[0]:
|
||||||
if st.button("✅ Conferma", key="confirm_yes", type="primary", use_container_width=True):
|
if st.button("✅ Conferma", key="confirm_yes", type="primary", width="stretch"):
|
||||||
with st.spinner("Eliminazione in corso..."):
|
with st.spinner("Eliminazione in corso..."):
|
||||||
result = api_delete_order(id_ordine)
|
result = api_delete_order(id_ordine)
|
||||||
if result.get("success"):
|
if result.get("success"):
|
||||||
|
|
@ -310,7 +310,7 @@ def show_order_detail(id_ordine):
|
||||||
else:
|
else:
|
||||||
st.error(result.get("detail") or result.get("error", "Errore eliminazione"))
|
st.error(result.get("detail") or result.get("error", "Errore eliminazione"))
|
||||||
with sub_cols[1]:
|
with sub_cols[1]:
|
||||||
if st.button("❌ Annulla", key="confirm_no", use_container_width=True):
|
if st.button("❌ Annulla", key="confirm_no", width="stretch"):
|
||||||
st.session_state.confirm_delete = False
|
st.session_state.confirm_delete = False
|
||||||
st.rerun()
|
st.rerun()
|
||||||
|
|
||||||
|
|
@ -346,7 +346,7 @@ def show_orders_list():
|
||||||
with filter_cols[3]:
|
with filter_cols[3]:
|
||||||
st.write("") # spacer
|
st.write("") # spacer
|
||||||
st.write("")
|
st.write("")
|
||||||
if st.button("🔄 Aggiorna", key="refresh_list", use_container_width=True):
|
if st.button("🔄 Aggiorna", key="refresh_list", width="stretch"):
|
||||||
st.session_state.orders_cache = None
|
st.session_state.orders_cache = None
|
||||||
st.rerun()
|
st.rerun()
|
||||||
|
|
||||||
|
|
@ -414,7 +414,7 @@ def show_orders_list():
|
||||||
col_btn, col_info = st.columns([1, 5])
|
col_btn, col_info = st.columns([1, 5])
|
||||||
|
|
||||||
with col_btn:
|
with col_btn:
|
||||||
if st.button(f"#{id_ord}", key=f"order_{id_ord}", use_container_width=True):
|
if st.button(f"#{id_ord}", key=f"order_{id_ord}", width="stretch"):
|
||||||
st.session_state.selected_order_id = id_ord
|
st.session_state.selected_order_id = id_ord
|
||||||
st.session_state.confirm_delete = False
|
st.session_state.confirm_delete = False
|
||||||
st.rerun()
|
st.rerun()
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import requests
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import re
|
import re
|
||||||
|
|
||||||
API_BASE = "http://localhost:8000/api/v1"
|
API_BASE = "https://api.cosmoguard.it/api/v1"
|
||||||
|
|
||||||
# CAS validation: 2-7 digits, dash, 2 digits, dash, 1 check digit
|
# CAS validation: 2-7 digits, dash, 2 digits, dash, 1 check digit
|
||||||
CAS_PATTERN = re.compile(r"^\d{2,7}-\d{2}-\d$")
|
CAS_PATTERN = re.compile(r"^\d{2,7}-\d{2}-\d$")
|
||||||
|
|
@ -223,7 +223,7 @@ def display_orderData(order_data: dict):
|
||||||
"Colorante": "Si" if i["is_colorante"] else "-",
|
"Colorante": "Si" if i["is_colorante"] else "-",
|
||||||
"Salta Tox": "Si" if i["skip_tox"] else "-",
|
"Salta Tox": "Si" if i["skip_tox"] else "-",
|
||||||
})
|
})
|
||||||
st.dataframe(pd.DataFrame(display_rows), use_container_width=True, hide_index=True)
|
st.dataframe(pd.DataFrame(display_rows), width='stretch', hide_index=True)
|
||||||
|
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
@ -420,7 +420,7 @@ edited_df = st.data_editor(
|
||||||
st.session_state.ingredient_df,
|
st.session_state.ingredient_df,
|
||||||
column_config=column_config,
|
column_config=column_config,
|
||||||
num_rows="dynamic",
|
num_rows="dynamic",
|
||||||
use_container_width=True,
|
width="stretch",
|
||||||
hide_index=True,
|
hide_index=True,
|
||||||
key="ingredients_editor",
|
key="ingredients_editor",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue