TpsNandhini commited on
Commit
6a095d6
1 Parent(s): d2c2cac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -66
app.py CHANGED
@@ -4,9 +4,10 @@ import bcrypt
4
  import datetime
5
  import re
6
  import pytz
7
- import numpy as np
8
- import pandas as pd
9
- import plotly.express as px
 
10
 
11
  # MySQL Connection
12
  connection = mysql.connector.connect(
@@ -84,8 +85,6 @@ 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
- if 'employee_submitted' not in st.session_state:
88
- st.session_state.employee_submitted = False
89
 
90
  # Page styling
91
  st.markdown("""
@@ -139,7 +138,9 @@ st.markdown("""
139
 
140
  # Login page
141
  def login():
142
- st.markdown('<p class="big-font">Performance Prediction Login</p>', unsafe_allow_html=True)
 
 
143
 
144
  col1, col2, col3 = st.columns([1, 2, 1])
145
 
@@ -223,78 +224,96 @@ def reset_password_page():
223
  elif not username_exists(username):
224
  st.error("Username not found. Enter a valid username.")
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.")
 
234
  st.session_state.current_page = 'login'
235
  st.experimental_rerun()
236
 
237
- st.markdown("<br>", unsafe_allow_html=True)
238
- st.markdown("<div class='link-text'>Remember your password?</div>", unsafe_allow_html=True)
239
- if st.button('Login'):
240
- st.session_state.current_page = 'login'
241
- st.experimental_rerun()
 
 
 
242
 
243
- # Home page
244
  def home_page():
245
- st.sidebar.title(f"Welcome, {st.session_state.username}!")
246
-
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,6 +321,9 @@ def home_page():
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':
 
4
  import datetime
5
  import re
6
  import pytz
7
+ import numpy as np
8
+ import pandas as pd
9
+ import plotly.express as px
10
+ import plotly.graph_objs as go # Import Plotly's graph objects
11
 
12
  # MySQL Connection
13
  connection = mysql.connector.connect(
 
85
  st.session_state.username = ''
86
  if 'current_page' not in st.session_state:
87
  st.session_state.current_page = 'login'
 
 
88
 
89
  # Page styling
90
  st.markdown("""
 
138
 
139
  # Login page
140
  def login():
141
+ st.image("performance prediction.jpeg", use_column_width=True)
142
+ st.markdown('<p class="big-font">Performance Nexus Login</p>', unsafe_allow_html=True)
143
+
144
 
145
  col1, col2, col3 = st.columns([1, 2, 1])
146
 
 
224
  elif not username_exists(username):
225
  st.error("Username not found. Enter a valid username.")
226
  elif not new_password or not re_password:
227
+ st.error("Enter new password and confirm password.")
 
 
228
  elif new_password != re_password:
229
+ st.error("Passwords do not match. Please re-enter.")
230
+ elif len(new_password) <= 3:
231
+ st.error("Password too short")
232
  else:
233
  reset_password(username, new_password)
234
+ st.success("Password reset successful. You can now login with your new password.")
235
+ st.session_state.reset_password = False
236
  st.session_state.current_page = 'login'
237
  st.experimental_rerun()
238
 
239
+ if not st.session_state.get('reset_password', False):
240
+ st.markdown("<br>", unsafe_allow_html=True)
241
+ st.markdown("<div class='link-text'>Back to Login?</div>", unsafe_allow_html=True)
242
+ if st.button('Login'):
243
+ st.session_state.current_page = 'login'
244
+ st.experimental_rerun()
245
+
246
+ rotating_images = ["path_to_image1.png", "path_to_image2.png", "path_to_image3.png"]
247
 
 
248
  def home_page():
249
+ st.title(f"Welcome to the Performance Nexus Dashboard, {st.session_state.username}!")
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
+ # Display rotating images
252
+ for image_path in rotating_images:
253
+ st.image(image_path, use_column_width=True)
254
+ st.markdown("<br>", unsafe_allow_html=True)
255
+ st.markdown("<hr>", unsafe_allow_html=True)
256
+
257
+ # Sidebar for user input
258
+ st.sidebar.header("Input Parameters")
259
+ employee_id = st.sidebar.number_input("Employee ID", min_value=1, max_value=1000, value=1)
260
+ department = st.sidebar.selectbox("Department", ["Sales", "Marketing", "Engineering", "HR"])
261
+ experience = st.sidebar.slider("Years of Experience", 0, 20, 5)
262
+
263
  # Main dashboard area
264
+ col1, col2 = st.columns(2)
265
 
266
+ with col1:
267
+ st.subheader("Employee Performance Score")
268
+ # Placeholder for performance prediction
269
+ performance_score = np.random.randint(60, 100)
270
+ st.metric("Predicted Performance", f"{performance_score}%", "4%")
271
 
272
+ st.subheader("Key Factors Influencing Performance")
273
+ factors = pd.DataFrame({
274
+ 'Factor': ['Experience', 'Training', 'Projects', 'Teamwork'],
275
+ 'Impact': [0.3, 0.25, 0.28, 0.17]
276
+ })
277
+ fig = px.bar(factors, x='Impact', y='Factor', orientation='h')
278
+ st.plotly_chart(fig)
279
+
280
+ with col2:
281
+ st.subheader("Performance Trend")
282
+ # Placeholder for performance trend
283
+ dates = pd.date_range(start="2023-01-01", end="2023-12-31", freq="M")
284
+ performance = np.random.randint(70, 100, size=len(dates))
285
+ trend_data = pd.DataFrame({"Date": dates, "Performance": performance})
286
+ fig = px.line(trend_data, x="Date", y="Performance")
287
+ st.plotly_chart(fig)
288
+
289
+ # Gauge chart for employee rating
290
+ st.subheader("Employee Rating")
291
+ fig = go.Figure(go.Indicator(
292
+ mode = "gauge+number",
293
+ value = performance_score,
294
+ domain = {'x': [0, 1], 'y': [0, 1]},
295
+ title = {'text': "Employee Rating"},
296
+ gauge = {
297
+ 'axis': {'range': [None, 100]},
298
+ 'steps' : [
299
+ {'range': [0, 60], 'color': "lightgray"},
300
+ {'range': [60, 80], 'color': "gray"},
301
+ {'range': [80, 100], 'color': "green"}],
302
+ 'threshold' : {
303
+ 'line': {'color': "red", 'width': 4},
304
+ 'thickness': 0.75,
305
+ 'value': performance_score}}))
306
+ st.plotly_chart(fig)
307
+
308
+
309
+ # Additional insights
310
+ st.subheader("Performance Insights")
311
+ st.write(f"Based on the analysis for Employee ID {employee_id} in the {department} department:")
312
+ st.write(f"- Current performance is {'above' if performance_score > 80 else 'below'} average")
313
+ st.write(f"- Key area for improvement: {'Training' if performance_score < 80 else 'Project Management'}")
314
+ st.write(f"- Recommended action: {'Enroll in advanced skills program' if performance_score < 80 else 'Take on leadership role in upcoming project'}")
315
+
316
+ # Logout button
317
  if st.button("Logout"):
318
  st.session_state.login_successful = False
319
  st.session_state.username = ''
 
321
  st.experimental_rerun()
322
 
323
  # Main app logic
324
+ if 'current_page' not in st.session_state:
325
+ st.session_state.current_page = 'login'
326
+
327
  if st.session_state.current_page == 'login':
328
  login()
329
  elif st.session_state.current_page == 'sign_up':