Esmaeilkianii commited on
Commit
2216fc6
·
verified ·
1 Parent(s): 0a33e26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -17
app.py CHANGED
@@ -36,7 +36,7 @@ st.set_page_config(
36
  initial_sidebar_state="expanded"
37
  )
38
 
39
- # Custom CSS with modern design
40
  st.markdown("""
41
  <style>
42
  @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;200;300;400;500;600;700;800;900&display=swap');
@@ -47,6 +47,7 @@ st.markdown("""
47
 
48
  .main {
49
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
 
50
  }
51
 
52
  .main-header {
@@ -76,7 +77,7 @@ st.markdown("""
76
  margin: 0;
77
  }
78
 
79
- .stButton>button {
80
  background: linear-gradient(90deg, #1a8754 0%, #115740 100%);
81
  color: white;
82
  border-radius: 50px;
@@ -84,11 +85,24 @@ st.markdown("""
84
  font-weight: 600;
85
  transition: all 0.3s ease;
86
  border: none;
 
87
  }
88
 
89
- .stButton>button:hover {
90
  transform: translateY(-2px);
91
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  .metric-card {
@@ -97,12 +111,24 @@ st.markdown("""
97
  padding: 1.5rem;
98
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
99
  text-align: center;
 
 
 
 
 
 
100
  }
101
 
102
  .metric-card .metric-value {
103
  font-size: 2.5rem;
104
  font-weight: 700;
105
  color: #1a8754;
 
 
 
 
 
 
106
  }
107
 
108
  .metric-card .metric-label {
@@ -114,6 +140,24 @@ st.markdown("""
114
  direction: rtl;
115
  text-align: right;
116
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  </style>
118
  """, unsafe_allow_html=True)
119
 
@@ -344,9 +388,7 @@ if 'heights_df' not in st.session_state:
344
  st.session_state.heights_df = pd.DataFrame(columns=[
345
  'ردیف', 'نماینده', 'کانال', 'اداره', 'تولید', 'مساحت داشت', 'مساحت زیرمجموعه', 'واریته', 'سن',
346
  'ایستگاه 1', 'ایستگاه 2', 'ایستگاه 3', 'ایستگاه 4', 'ایستگاه 5', 'ارتفاع هفته جاری مزرعه',
347
- 'ارتفاع هفته گذشته مزرعه', 'رشد هفته جاری', 'رشد هفته گذشته', 'نیتروژن فعلی', 'نیتروژن استاندارد فعلی',
348
- 'نیتروژن قبلی', 'نیتروژن استاندارد قبلی', 'رطوبت غلاف فعلی', 'رطوبت استاندارد فعلی', 'رطوبت غلاف قبلی',
349
- 'رطوبت استاندارد قبلی', 'چاهک 1', 'تاریخ قرائت', 'چاهک 2', 'تاریخ قرائت2'
350
  ])
351
 
352
  # Main header
@@ -474,7 +516,7 @@ elif selected == "ورود اطلاعات":
474
  'ایستگاه 3': st.column_config.NumberColumn("ایستگاه 3", min_value=0.0, step=0.1, required=True),
475
  'ایستگاه 4': st.column_config.NumberColumn("ایستگاه 4", min_value=0.0, step=0.1, required=True),
476
  'ایستگاه 5': st.column_config.NumberColumn("ایستگاه 5", min_value=0.0, step=0.1, required=True),
477
- 'ارتفاع هفته جاری مزرعه': st.column_config.NumberColumn("ارتفاع هفته جاری مزرعه", min_value=0.0, step=0.1, required=True),
478
  'چاهک 1': st.column_config.NumberColumn("چاهک 1", min_value=0.0, step=0.1, required=True),
479
  'چاهک 2': st.column_config.NumberColumn("چاهک 2", min_value=0.0, step=0.1, required=True),
480
  'تاریخ قرائت': st.column_config.DateColumn("تاریخ قرائت", format="YYYY-MM-DD", required=True),
@@ -508,8 +550,9 @@ elif selected == "ورود اطلاعات":
508
  try:
509
  df = pd.read_excel(uploaded_file)
510
 
511
- # Dynamic column mapping based on your file structure
512
  column_mapping = {
 
513
  'ردیف': 'ردیف',
514
  'نماینده': 'نماینده',
515
  'کانال': 'کانال',
@@ -539,7 +582,7 @@ elif selected == "ورود اطلاعات":
539
  'چاهک 1': 'چاهک 1',
540
  'تاریخ قرائت': 'تاریخ قرائت',
541
  'چاهک 2': 'چاهک 2',
542
- 'تاریخ قرائت2': 'تاریخ قرائت2'
543
  }
544
 
545
  # Map columns dynamically
@@ -549,11 +592,13 @@ elif selected == "ورود اطلاعات":
549
  if english_col in available_columns:
550
  mapped_df[persian_col] = df[english_col]
551
 
552
- # Ensure all required columns are present
553
- required_columns = ['ردیف', 'نماینده', 'کانال', 'اداره', 'تولید', 'مساحت داشت', 'مساحت زیرمجموعه', 'واریته', 'سن',
554
- 'ایستگاه 1', 'ایستگاه 2', 'ایستگاه 3', 'ایستگاه 4', 'ایستگاه 5', 'ارتفاع هفته جاری مزرعه',
555
- 'چاهک 1', 'چاهک 2', 'تاریخ قرائت', 'تاریخ قرائت2']
556
- missing_columns = [col for col in required_columns if col not in mapped_df.columns]
 
 
557
  if missing_columns:
558
  st.error(f"ستون‌های زیر در فایل یافت نشدند: {', '.join(missing_columns)}")
559
  else:
@@ -579,7 +624,7 @@ elif selected == "ورود اطلاعات":
579
  for col in numeric_cols:
580
  mapped_df[col] = pd.to_numeric(mapped_df[col], errors='coerce')
581
 
582
- # Calculate average height if stations are provided
583
  for index, row in mapped_df.iterrows():
584
  stations = [row[f'ایستگاه {i}'] for i in range(1, 6) if pd.notna(row[f'ایستگاه {i}'])]
585
  if stations:
@@ -637,7 +682,7 @@ elif selected == "تنظیمات":
637
 
638
  # Footer
639
  st.markdown("""
640
- <footer style="position: fixed; bottom: 0; width: 100%; background-color: #1a8754; color: white; text-align: center; padding: 10px;">
641
  <p>© 2025 سامانه هوشمند پایش مزارع نیشکر دهخدا</p>
642
  </footer>
643
  """, unsafe_allow_html=True)
 
36
  initial_sidebar_state="expanded"
37
  )
38
 
39
+ # Custom CSS with modern, animated design
40
  st.markdown("""
41
  <style>
42
  @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;200;300;400;500;600;700;800;900&display=swap');
 
47
 
48
  .main {
49
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
50
+ padding-bottom: 60px; /* Space for footer */
51
  }
52
 
53
  .main-header {
 
77
  margin: 0;
78
  }
79
 
80
+ .stButton>button, .stSelectbox, .stSlider {
81
  background: linear-gradient(90deg, #1a8754 0%, #115740 100%);
82
  color: white;
83
  border-radius: 50px;
 
85
  font-weight: 600;
86
  transition: all 0.3s ease;
87
  border: none;
88
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
89
  }
90
 
91
+ .stButton>button:hover, .stSelectbox:hover, .stSlider:hover {
92
  transform: translateY(-2px);
93
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
94
+ background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%);
95
+ }
96
+
97
+ .stButton>button:active {
98
+ transform: translateY(0);
99
+ box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
100
+ background: linear-gradient(90deg, #27ae60 0%, #1a8754 100%);
101
+ }
102
+
103
+ .stSelectbox:focus, .stSlider:focus {
104
+ outline: none;
105
+ box-shadow: 0 0 0 2px rgba(26, 135, 84, 0.3);
106
  }
107
 
108
  .metric-card {
 
111
  padding: 1.5rem;
112
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
113
  text-align: center;
114
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
115
+ }
116
+
117
+ .metric-card:hover {
118
+ transform: translateY(-5px);
119
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
120
  }
121
 
122
  .metric-card .metric-value {
123
  font-size: 2.5rem;
124
  font-weight: 700;
125
  color: #1a8754;
126
+ animation: fadeIn 0.5s ease-in;
127
+ }
128
+
129
+ @keyframes fadeIn {
130
+ 0% { opacity: 0; transform: translateY(10px); }
131
+ 100% { opacity: 1; transform: translateY(0); }
132
  }
133
 
134
  .metric-card .metric-label {
 
140
  direction: rtl;
141
  text-align: right;
142
  }
143
+
144
+ footer {
145
+ position: relative;
146
+ bottom: 0;
147
+ width: 100%;
148
+ background-color: #1a8754;
149
+ color: white;
150
+ text-align: center;
151
+ padding: 1rem;
152
+ margin-top: 2rem;
153
+ border-top: 2px solid rgba(255, 255, 255, 0.1);
154
+ animation: footerFade 1s ease-in-out;
155
+ }
156
+
157
+ @keyframes footerFade {
158
+ 0% { opacity: 0; transform: translateY(20px); }
159
+ 100% { opacity: 1; transform: translateY(0); }
160
+ }
161
  </style>
162
  """, unsafe_allow_html=True)
163
 
 
388
  st.session_state.heights_df = pd.DataFrame(columns=[
389
  'ردیف', 'نماینده', 'کانال', 'اداره', 'تولید', 'مساحت داشت', 'مساحت زیرمجموعه', 'واریته', 'سن',
390
  'ایستگاه 1', 'ایستگاه 2', 'ایستگاه 3', 'ایستگاه 4', 'ایستگاه 5', 'ارتفاع هفته جاری مزرعه',
391
+ 'چاهک 1', 'چاهک 2', 'تاریخ قرائت', 'تاریخ قرائت2'
 
 
392
  ])
393
 
394
  # Main header
 
516
  'ایستگاه 3': st.column_config.NumberColumn("ایستگاه 3", min_value=0.0, step=0.1, required=True),
517
  'ایستگاه 4': st.column_config.NumberColumn("ایستگاه 4", min_value=0.0, step=0.1, required=True),
518
  'ایستگاه 5': st.column_config.NumberColumn("ایستگاه 5", min_value=0.0, step=0.1, required=True),
519
+ 'ارتفاع هفته جاری مزرعه': st.column_config.NumberColumn("ارتفاع هفته جاری مزرعه", min_value=0.0, step=0.1, required=True, disabled=True),
520
  'چاهک 1': st.column_config.NumberColumn("چاهک 1", min_value=0.0, step=0.1, required=True),
521
  'چاهک 2': st.column_config.NumberColumn("چاهک 2", min_value=0.0, step=0.1, required=True),
522
  'تاریخ قرائت': st.column_config.DateColumn("تاریخ قرائت", format="YYYY-MM-DD", required=True),
 
550
  try:
551
  df = pd.read_excel(uploaded_file)
552
 
553
+ # Dynamic column mapping based on your file structure from the document
554
  column_mapping = {
555
+ 'Unnamed: 0': 'ردیف',
556
  'ردیف': 'ردیف',
557
  'نماینده': 'نماینده',
558
  'کانال': 'کانال',
 
582
  'چاهک 1': 'چاهک 1',
583
  'تاریخ قرائت': 'تاریخ قرائت',
584
  'چاهک 2': 'چاهک 2',
585
+ 'تاریخ قرائت.1': 'تاریخ قرائت2'
586
  }
587
 
588
  # Map columns dynamically
 
592
  if english_col in available_columns:
593
  mapped_df[persian_col] = df[english_col]
594
 
595
+ # Required columns for the upload file
596
+ required_upload_columns = ['ردیف', 'نماینده', 'کانال', 'اداره', 'تولید', 'مساحت داشت', 'مساحت زیرمجموعه', 'واریته', 'سن',
597
+ 'ایستگاه 1', 'ایستگاه 2', 'ایستگاه 3', 'ایستگاه 4', 'ایستگاه 5', 'ارتفاع هفته جاری مزرعه',
598
+ 'چاهک 1', 'چاهک 2', 'تاریخ قرائت', 'تاریخ قرائت2']
599
+
600
+ # Check for missing required columns
601
+ missing_columns = [col for col in required_upload_columns if col not in mapped_df.columns]
602
  if missing_columns:
603
  st.error(f"ستون‌های زیر در فایل یافت نشدند: {', '.join(missing_columns)}")
604
  else:
 
624
  for col in numeric_cols:
625
  mapped_df[col] = pd.to_numeric(mapped_df[col], errors='coerce')
626
 
627
+ # Calculate average height if stations are provided (optional for upload, but kept for consistency)
628
  for index, row in mapped_df.iterrows():
629
  stations = [row[f'ایستگاه {i}'] for i in range(1, 6) if pd.notna(row[f'ایستگاه {i}'])]
630
  if stations:
 
682
 
683
  # Footer
684
  st.markdown("""
685
+ <footer style="position: relative; bottom: 0; width: 100%; background-color: #1a8754; color: white; text-align: center; padding: 1rem; margin-top: 2rem; border-top: 2px solid rgba(255, 255, 255, 0.1);">
686
  <p>© 2025 سامانه هوشمند پایش مزارع نیشکر دهخدا</p>
687
  </footer>
688
  """, unsafe_allow_html=True)