TpsNandhini commited on
Commit
0ee7187
1 Parent(s): ee0def7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -36
app.py CHANGED
@@ -84,6 +84,8 @@ if 'username' not in st.session_state:
84
  st.session_state.username = ''
85
  if 'current_page' not in st.session_state:
86
  st.session_state.current_page = 'login'
 
 
87
 
88
  # Page styling
89
  st.markdown("""
@@ -223,9 +225,9 @@ def reset_password_page():
223
  elif not new_password or not re_password:
224
  st.error("Enter all the credentials.")
225
  elif len(new_password) <= 3:
226
- st.error("Password too short. Must be at least 4 characters.")
227
  elif new_password != re_password:
228
- st.error("Passwords do not match. Please re-enter.")
229
  else:
230
  reset_password(username, new_password)
231
  st.success("Password has been reset successfully! Please login with your new password.")
@@ -245,48 +247,54 @@ def home_page():
245
  # Sidebar for inputting employee details
246
  st.sidebar.header("Enter Employee Details")
247
  employee_name = st.sidebar.text_input("Employee Name")
248
- employee_id = st.sidebar.number_input("Employee ID", min_value=1, max_value=1000, value=1)
249
  employee_age = st.sidebar.number_input("Employee Age", min_value=18, max_value=65, value=30)
250
  employee_join_date = st.sidebar.date_input("Joining Date", value=datetime.date(2020, 1, 1))
251
  employee_appraisal_date = st.sidebar.date_input("Last Appraisal Date", value=datetime.date(2023, 1, 1))
252
 
253
  if st.sidebar.button("Submit"):
 
254
  st.sidebar.success(f"Employee {employee_name} (ID: {employee_id}, Age: {employee_age}) details submitted successfully!")
255
 
256
  # Main dashboard area
257
  st.title("Performance Prediction Dashboard")
258
 
259
- col1, col2 = st.columns(2)
260
-
261
- with col1:
262
- st.subheader("Employee Performance Score")
263
- performance_score = np.random.randint(60, 100)
264
- st.metric("Predicted Performance", f"{performance_score}%", "4%")
265
 
266
- st.subheader("Key Factors Influencing Performance")
267
- factors = pd.DataFrame({
268
- 'Factor': ['Experience', 'Training', 'Projects', 'Teamwork'],
269
- 'Impact': [0.3, 0.25, 0.28, 0.17]
270
- })
271
- fig = px.bar(factors, x='Impact', y='Factor', orientation='h', color='Factor',
272
- color_discrete_sequence=px.colors.qualitative.Bold)
273
- st.plotly_chart(fig)
274
-
275
- with col2:
276
- st.subheader("Performance Trend")
277
- dates = pd.date_range(start="2023-01-01", end="2023-12-31", freq="M")
278
- performance = np.random.randint(70, 100, size=len(dates))
279
- trend_data = pd.DataFrame({"Date": dates, "Performance": performance})
280
- fig = px.line(trend_data, x="Date", y="Performance", title='Performance Over Time',
281
- line_shape='spline', render_mode='svg', color_discrete_sequence=['#1E88E5'])
282
- st.plotly_chart(fig)
283
-
284
- st.subheader("Performance Insights")
285
- st.write(f"Based on the analysis for Employee ID {employee_id}:")
286
- st.write(f"- Current performance is {'above' if performance_score > 80 else 'below'} average")
287
- st.write(f"- Key area for improvement: {'Training' if performance_score < 80 else 'Project Management'}")
288
- st.write(f"- Recommended action: {'Enroll in advanced skills program' if performance_score < 80 else 'Take on leadership role in upcoming project'}")
289
-
 
 
 
 
 
 
 
 
 
290
  if st.button("Logout"):
291
  st.session_state.login_successful = False
292
  st.session_state.username = ''
@@ -294,9 +302,6 @@ def home_page():
294
  st.experimental_rerun()
295
 
296
  # Main app logic
297
- if 'current_page' not in st.session_state:
298
- st.session_state.current_page = 'login'
299
-
300
  if st.session_state.current_page == 'login':
301
  login()
302
  elif st.session_state.current_page == 'sign_up':
 
84
  st.session_state.username = ''
85
  if 'current_page' not in st.session_state:
86
  st.session_state.current_page = 'login'
87
+ if 'employee_submitted' not in st.session_state:
88
+ st.session_state.employee_submitted = False
89
 
90
  # Page styling
91
  st.markdown("""
 
225
  elif not new_password or not re_password:
226
  st.error("Enter all the credentials.")
227
  elif len(new_password) <= 3:
228
+ st.error("Password too short. Enter a longer password.")
229
  elif new_password != re_password:
230
+ st.error("Passwords do not match! Please re-enter.")
231
  else:
232
  reset_password(username, new_password)
233
  st.success("Password has been reset successfully! Please login with your new password.")
 
247
  # Sidebar for inputting employee details
248
  st.sidebar.header("Enter Employee Details")
249
  employee_name = st.sidebar.text_input("Employee Name")
250
+ employee_id = st.sidebar.text_input("Employee ID")
251
  employee_age = st.sidebar.number_input("Employee Age", min_value=18, max_value=65, value=30)
252
  employee_join_date = st.sidebar.date_input("Joining Date", value=datetime.date(2020, 1, 1))
253
  employee_appraisal_date = st.sidebar.date_input("Last Appraisal Date", value=datetime.date(2023, 1, 1))
254
 
255
  if st.sidebar.button("Submit"):
256
+ st.session_state.employee_submitted = True
257
  st.sidebar.success(f"Employee {employee_name} (ID: {employee_id}, Age: {employee_age}) details submitted successfully!")
258
 
259
  # Main dashboard area
260
  st.title("Performance Prediction Dashboard")
261
 
262
+ if st.session_state.employee_submitted:
263
+ tab1, tab2 = st.tabs(["Overview", "Performance Insights"])
 
 
 
 
264
 
265
+ with tab1:
266
+ col1, col2 = st.columns(2)
267
+
268
+ with col1:
269
+ st.subheader("Employee Performance Score")
270
+ performance_score = np.random.randint(60, 100)
271
+ st.metric("Predicted Performance", f"{performance_score}%", "4%")
272
+
273
+ st.subheader("Key Factors Influencing Performance")
274
+ factors = pd.DataFrame({
275
+ 'Factor': ['Experience', 'Training', 'Projects', 'Teamwork'],
276
+ 'Impact': [0.3, 0.25, 0.28, 0.17]
277
+ })
278
+ fig = px.bar(factors, x='Impact', y='Factor', orientation='h', color='Factor',
279
+ color_discrete_sequence=px.colors.qualitative.Bold)
280
+ st.plotly_chart(fig)
281
+
282
+ with col2:
283
+ st.subheader("Performance Trend")
284
+ dates = pd.date_range(start="2023-01-01", end="2023-12-31", freq="M")
285
+ performance = np.random.randint(70, 100, size=len(dates))
286
+ trend_data = pd.DataFrame({"Date": dates, "Performance": performance})
287
+ fig = px.line(trend_data, x="Date", y="Performance", title='Performance Over Time',
288
+ line_shape='spline', render_mode='svg', color_discrete_sequence=['#1E88E5'])
289
+ st.plotly_chart(fig)
290
+
291
+ with tab2:
292
+ st.subheader("Performance Insights")
293
+ st.write(f"Based on the analysis for Employee ID {employee_id}:")
294
+ st.write(f"- Current performance is {'above' if performance_score > 80 else 'below'} average")
295
+ st.write(f"- Key area for improvement: {'Training' if performance_score < 80 else 'Project Management'}")
296
+ st.write(f"- Recommended action: {'Enroll in advanced skills program' if performance_score < 80 else 'Take on leadership role in upcoming project'}")
297
+
298
  if st.button("Logout"):
299
  st.session_state.login_successful = False
300
  st.session_state.username = ''
 
302
  st.experimental_rerun()
303
 
304
  # Main app logic
 
 
 
305
  if st.session_state.current_page == 'login':
306
  login()
307
  elif st.session_state.current_page == 'sign_up':