diff --git a/src/pages/4-inputs.py b/src/pages/4-inputs.py index 5b3369fd37768eef214e320b5c13ca247159fa2d..472cde4c26eb1bab5462aec87a568e9d260fd499 100644 --- a/src/pages/4-inputs.py +++ b/src/pages/4-inputs.py @@ -17,62 +17,45 @@ pages_folder = Path("pages/") if 'form_submitted' not in st.session_state: st.session_state['form_submitted'] = False - -# Page header with st.container(): - # Text input fields - with st.form(key='my_form'): - - - st.header("Complete and send the following form with the data context:",divider="blue") - st.warning('Make sure that the form is well completed, because the reliability of the results depends mainly on it !', icon="âš ï¸") - - - col1, col3,col2 = st.columns((2,0.5,2)) - - + st.header("Complete and save the following form with the data context:",divider="blue") + st.warning('Make sure that the form is well completed, because the reliability of the results depends mainly on it !', icon="âš ï¸") + with st.form(key = 'my_form'): + _,col1, col3,col2 = st.columns((0.1, 1.4,0.5,2)) with col1: - st.header("Groupe 2",divider="blue") - - meta_project = st.text_input('Project name :', 'Life of Brian') - meta_machine_ID = st.text_input('NIRS ID :', 'Life of Brian') + ############## Project information ########### + st.subheader("Project information", divider="blue") + meta_project = st.text_input('Project name :') + meta_machine_ID = st.text_input('NIRS ID :',) meta_scan_place_options = ["Pace", "Other"] - meta_scan_place = st.radio("If relevant, sample species :", meta_scan_place_options) - - - meta_sample_species = st.text_input('If relevant, sample species :', 'Life of Brian') + meta_scan_place = st.radio("Analysis Laboratory :", meta_scan_place_options) + meta_sample_species = st.text_input('Samples species (If relevant, provide the sample species; otherwise insert No):') with col2: - st.header("Groupe 3",divider="blue") - meta_sample_category_options = ["Soil", "Plant", "Animal", "Other"] - meta_sample_category = st.radio("Sample category description :", meta_sample_category_options) - - meta_sample_sub_category_options = ["Green leave", "Leaf litter", "Litter", "Humus", "Soil", "Animal part", "Animal Powder", "Fungal sample", "Other"] - meta_sample_sub_category = st.radio("Sample category description :", meta_sample_sub_category_options) - meta_sample_humidity_options = ["Dry", "Fresh", "Wet"] - meta_sample_humidity = st.radio("Humidity state of the sample:", meta_sample_humidity_options) - - meta_sample_pretreatment_options = ["Powder", "Pastile", "Liquid"] - meta_sample_pretreatment = st.radio("Type of sample pre-treatment :", meta_sample_pretreatment_options) - - - - submitted = st.form_submit_button(label='Send') - - - - - if submitted: - - # Save the form data here - st.session_state['form_submitted'] = True - st.success('Form sent successfully!', icon="✅") - + clo3,_, col4,_ = st.columns([1,0.2,1,0.3]) + with clo3: + ############## The Nature of the Samples ########### + if '' in [meta_project, meta_machine_ID,meta_sample_species]: disabled1 = True + else: disabled1 = False + st.subheader("The Nature of the Samples",divider="blue") + meta_sample_category_options = ["Soil", "Plant", "Animal", "Other"] + meta_sample_category = st.radio("Samples category :", [""] + meta_sample_category_options) + meta_sample_sub_category_options = ["Green leaves", "Leaf litter", "Litter", "Humus", "Soil", "Animal part", "Animal Powder", "Fungal sample", "Other"] + meta_sample_sub_category = st.radio("Sample category description :", [""] + meta_sample_sub_category_options) + + with col4: + st.subheader("The Physical State of the Samples",divider="blue") + meta_sample_humidity_options = ["Dry", "Fresh", "Wet"] + meta_sample_humidity = st.radio("Humidity state of the sample :", [""] + meta_sample_humidity_options) + + meta_sample_pretreatment_options = ["Powder", "Pastile", "Liquid"] + meta_sample_pretreatment = st.radio("Type of sample pre-treatment :", [""] + meta_sample_pretreatment_options) + # Création du dictionnaire avec les données du formulaire form_data = { "meta_project": meta_project, @@ -85,22 +68,31 @@ with st.container(): "meta_scan_place": meta_scan_place } - # Enregistrement des données dans un fichier JSON - with open('form_data.json', 'w') as json_file: - json.dump(form_data, json_file) - - with st.container(): - if st.session_state['interface'] == 'simple': - header3, header4 = st.columns(2) - if header3.button("Samples Selection"): - st.switch_page(pages_folder / '1-samples_selection.py') - if header4.button("Model Creation"): - st.switch_page(pages_folder / '2-model_creation.py') - elif st.session_state['interface'] == 'advanced': - header3, header4, header5 = st.columns(3) - if header3.button("Samples Selection"): - st.switch_page(pages_folder / '1-samples_selection.py') - if header4.button("Model Creation"): - st.switch_page(pages_folder / '2-model_creation.py') - if header5.button("Prediction"): - st.switch_page(pages_folder / '3-prediction.py') \ No newline at end of file + submitted = st.form_submit_button(label='Save') + if submitted: + if '' not in form_data.values(): + # Save the form data here + st.session_state['form_submitted'] = True + st.success('Form was saved successfully!', icon="✅") + # Enregistrement des données dans un fichier JSON + with open('form_data.json', 'w') as json_file: + json.dump(form_data, json_file) + + with st.container(): + if st.session_state['interface'] == 'simple': + header3, header4 = st.columns(2) + if header3.button("Samples Selection"): + st.switch_page(pages_folder / '1-samples_selection.py') + if header4.button("Model Creation"): + st.switch_page(pages_folder / '2-model_creation.py') + elif st.session_state['interface'] == 'advanced': + header3, header4, header5 = st.columns(3) + if header3.button("Samples Selection"): + st.switch_page(pages_folder / '1-samples_selection.py') + if header4.button("Model Creation"): + st.switch_page(pages_folder / '2-model_creation.py') + if header5.button("Prediction"): + st.switch_page(pages_folder / '3-prediction.py') + + else: + st.error('Error: The form was not saved, please ensure the required fields are filled!') \ No newline at end of file