Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import pandas as pd
|
|
| 3 |
import time
|
| 4 |
import requests
|
| 5 |
import os
|
|
|
|
| 6 |
|
| 7 |
# Set page configuration (must be the first Streamlit command)
|
| 8 |
st.set_page_config(page_title="Ticket System", layout="centered", initial_sidebar_state="expanded")
|
|
@@ -141,26 +142,35 @@ def login_page():
|
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
-
|
| 145 |
-
if username in users and users[username]["password"] == password:
|
| 146 |
-
st.session_state["user_type"] = users[username]["role"]
|
| 147 |
-
st.session_state["logged_in"] = True
|
| 148 |
-
st.session_state["login_success"] = True
|
| 149 |
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
-
if st.button("Forget Password"):
|
| 163 |
-
st.session_state["page"] = "Forget Password"
|
| 164 |
|
| 165 |
|
| 166 |
def navigate_to_page(page_name):
|
|
@@ -272,8 +282,10 @@ def main():
|
|
| 272 |
if "page" not in st.session_state:
|
| 273 |
st.session_state["page"] = "Login" # Default to the Login page
|
| 274 |
add_return_to_login()
|
|
|
|
|
|
|
| 275 |
# Show the navigation menu only if not on Login or Forget Password pages
|
| 276 |
-
if st.session_state["page"] not in ["Login", "Forget Password"]:
|
| 277 |
st.sidebar.title("Navigation")
|
| 278 |
user_type = st.session_state.get("user_type", "Customer")
|
| 279 |
|
|
@@ -293,6 +305,8 @@ def main():
|
|
| 293 |
login_page()
|
| 294 |
elif st.session_state["page"] == "Forget Password":
|
| 295 |
forget_password_page()
|
|
|
|
|
|
|
| 296 |
elif st.session_state["page"] == "Submit Ticket":
|
| 297 |
submit_ticket_page()
|
| 298 |
elif st.session_state["page"] == "Check Ticket Status":
|
|
@@ -318,11 +332,124 @@ def center_logo():
|
|
| 318 |
st.empty() # Empty content in the first column
|
| 319 |
|
| 320 |
with col2:
|
| 321 |
-
st.image("logo.png", width=300, use_container_width=True)
|
| 322 |
|
| 323 |
with col3:
|
| 324 |
st.empty()
|
| 325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
def submit_ticket_page():
|
| 327 |
center_logo()
|
| 328 |
vspace()
|
|
@@ -626,8 +753,8 @@ def customer_dashboard_page():
|
|
| 626 |
st.dataframe(df)
|
| 627 |
st.components.v1.iframe(
|
| 628 |
"https://app.powerbi.com/view?r=eyJrIjoiY2Q0ODE1NGItOThjMy00MzM4LWE2OGUtMjRkNmUzYmZlMDk3IiwidCI6ImI0NTNkOTFiLTZhYzEtNGI2MS1iOGI4LTVlNjVlNDIyMjMzZiIsImMiOjl9",
|
| 629 |
-
height=
|
| 630 |
-
width=
|
| 631 |
scrolling=True
|
| 632 |
)
|
| 633 |
|
|
@@ -640,26 +767,7 @@ def management_dashboard_page():
|
|
| 640 |
#center_logo("logo.png") # Center the logo
|
| 641 |
st.markdown('<h1 style="color: #084C3C;">Management Dashboard</h1>', unsafe_allow_html=True)
|
| 642 |
|
| 643 |
-
#
|
| 644 |
-
# employee_data = {
|
| 645 |
-
# "Employee ID": ["E001", "E002", "E003"],
|
| 646 |
-
# "Name": ["John Doe", "Jane Smith", "Ali Ahmad"],
|
| 647 |
-
# "Performance Score": [85, 90, 88],
|
| 648 |
-
# }
|
| 649 |
-
# df_employee = pd.DataFrame(employee_data)
|
| 650 |
-
|
| 651 |
-
# # Display the employee data table
|
| 652 |
-
# st.dataframe(df_employee)
|
| 653 |
-
|
| 654 |
-
# Add the Power BI dashboard iframe
|
| 655 |
-
st.components.v1.iframe(
|
| 656 |
-
"https://app.powerbi.com/view?r=eyJrIjoiMzQ5N2RlMDQtY2I5ZC00NWE5LWE0ZjItMjExMzgyNmNmZWFjIiwidCI6ImI0NTNkOTFiLTZhYzEtNGI2MS1iOGI4LTVlNjVlNDIyMjMzZiIsImMiOjl9",
|
| 657 |
-
height=700,
|
| 658 |
-
width=1000,
|
| 659 |
-
scrolling=True
|
| 660 |
-
)
|
| 661 |
-
|
| 662 |
-
# Define employee data
|
| 663 |
employee_data = {
|
| 664 |
"Employee ID": ["E001", "E002", "E003"],
|
| 665 |
"Name": ["John Doe", "Jane Smith", "Ali Ahmad"],
|
|
@@ -670,6 +778,14 @@ def management_dashboard_page():
|
|
| 670 |
# Display the employee data table
|
| 671 |
st.dataframe(df_employee)
|
| 672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
|
| 674 |
|
| 675 |
def customize_navigation_menu_dark_green():
|
|
|
|
| 3 |
import time
|
| 4 |
import requests
|
| 5 |
import os
|
| 6 |
+
from datetime import datetime
|
| 7 |
|
| 8 |
# Set page configuration (must be the first Streamlit command)
|
| 9 |
st.set_page_config(page_title="Ticket System", layout="centered", initial_sidebar_state="expanded")
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
+
col1, col2, col3 = st.columns(3) # Create three columns
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
with col1: # First column for the Login button
|
| 148 |
+
if st.button("Login"):
|
| 149 |
+
if username in users and users[username]["password"] == password:
|
| 150 |
+
st.session_state["user_type"] = users[username]["role"]
|
| 151 |
+
st.session_state["logged_in"] = True
|
| 152 |
+
st.session_state["login_success"] = True
|
| 153 |
|
| 154 |
+
st.success(f"Logged in successfully as {users[username]['role']}")
|
| 155 |
+
|
| 156 |
+
# Navigate to the appropriate page based on the user's role
|
| 157 |
+
if users[username]["role"] == "Customer":
|
| 158 |
+
st.session_state["page"] = "Submit Ticket"
|
| 159 |
+
elif users[username]["role"] == "Manager":
|
| 160 |
+
st.session_state["page"] = "Management Dashboard"
|
| 161 |
+
elif users[username]["role"] == "Employee":
|
| 162 |
+
st.session_state["page"] = "Respond to a Ticket"
|
| 163 |
+
else:
|
| 164 |
+
st.error("Invalid username or password.")
|
| 165 |
+
|
| 166 |
+
with col2: # Second column for the Forget Password button
|
| 167 |
+
if st.button("Forget Password"):
|
| 168 |
+
st.session_state["page"] = "Forget Password"
|
| 169 |
+
|
| 170 |
+
with col3: # Third column for the Create Account button
|
| 171 |
+
if st.button("Create an Account"):
|
| 172 |
+
st.session_state["page"] = "Create Account"
|
| 173 |
|
|
|
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
def navigate_to_page(page_name):
|
|
|
|
| 282 |
if "page" not in st.session_state:
|
| 283 |
st.session_state["page"] = "Login" # Default to the Login page
|
| 284 |
add_return_to_login()
|
| 285 |
+
if st.session_state["page"] == "Submit Ticket":
|
| 286 |
+
submit_ticket_page()
|
| 287 |
# Show the navigation menu only if not on Login or Forget Password pages
|
| 288 |
+
if st.session_state["page"] not in ["Login", "Forget Password","Create Account"]:
|
| 289 |
st.sidebar.title("Navigation")
|
| 290 |
user_type = st.session_state.get("user_type", "Customer")
|
| 291 |
|
|
|
|
| 305 |
login_page()
|
| 306 |
elif st.session_state["page"] == "Forget Password":
|
| 307 |
forget_password_page()
|
| 308 |
+
elif st.session_state["page"] == "Create Account":
|
| 309 |
+
create_account_page()
|
| 310 |
elif st.session_state["page"] == "Submit Ticket":
|
| 311 |
submit_ticket_page()
|
| 312 |
elif st.session_state["page"] == "Check Ticket Status":
|
|
|
|
| 332 |
st.empty() # Empty content in the first column
|
| 333 |
|
| 334 |
with col2:
|
| 335 |
+
st.image("/Users/klnimri/Desktop/Newtest/Test/bin/logo.png", width=300, use_container_width=True)
|
| 336 |
|
| 337 |
with col3:
|
| 338 |
st.empty()
|
| 339 |
|
| 340 |
+
def create_account_page():
|
| 341 |
+
center_logo()
|
| 342 |
+
vspace()
|
| 343 |
+
vspace()
|
| 344 |
+
vspace()
|
| 345 |
+
hide_sidebar()
|
| 346 |
+
st.markdown("<h1 style='text-align: center; color: #084C3C;'>Create Account</h1>", unsafe_allow_html=True)
|
| 347 |
+
st.markdown(
|
| 348 |
+
"""
|
| 349 |
+
<style>
|
| 350 |
+
div.stButton > button {
|
| 351 |
+
background-color: #4CAF50 !important;
|
| 352 |
+
color: white !important;
|
| 353 |
+
border: none;
|
| 354 |
+
padding: 10px 20px !important;
|
| 355 |
+
text-align: center !important;
|
| 356 |
+
text-decoration: none;
|
| 357 |
+
font-size: 16px !important;
|
| 358 |
+
font-weight: bold !important;
|
| 359 |
+
cursor: pointer;
|
| 360 |
+
border-radius: 4px !important;
|
| 361 |
+
transition: background-color 0.3s ease;
|
| 362 |
+
display: inline-block;
|
| 363 |
+
margin-top: 20px; /* Space above the button */
|
| 364 |
+
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); /* Optional shadow */
|
| 365 |
+
}
|
| 366 |
+
div.stButton > button:hover {
|
| 367 |
+
background-color: #45a049 !important;
|
| 368 |
+
color: white !important;
|
| 369 |
+
}
|
| 370 |
+
</style>
|
| 371 |
+
""",
|
| 372 |
+
unsafe_allow_html=True,
|
| 373 |
+
)
|
| 374 |
+
st.markdown(
|
| 375 |
+
"""
|
| 376 |
+
<style>
|
| 377 |
+
div[data-testid="stFormSubmitButton"] > button {
|
| 378 |
+
background-color: #4CAF50 !important; /* Green background */
|
| 379 |
+
color: white !important; /* White text */
|
| 380 |
+
border: none !important; /* No border */
|
| 381 |
+
padding: 10px 20px !important; /* Button padding */
|
| 382 |
+
text-align: center !important; /* Center the text */
|
| 383 |
+
text-decoration: none !important; /* No underline */
|
| 384 |
+
font-size: 16px !important; /* Font size */
|
| 385 |
+
font-weight: bold !important; /* Bold text */
|
| 386 |
+
cursor: pointer !important; /* Pointer cursor */
|
| 387 |
+
border-radius: 4px !important; /* Rounded corners */
|
| 388 |
+
transition: background-color 0.3s ease !important; /* Smooth hover effect */
|
| 389 |
+
display: inline-block !important; /* Inline block display */
|
| 390 |
+
margin-top: 20px !important; /* Space above the button */
|
| 391 |
+
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1) !important; /* Optional shadow */
|
| 392 |
+
}
|
| 393 |
+
div[data-testid="stFormSubmitButton"] > button:hover {
|
| 394 |
+
background-color: #45a049 !important; /* Slightly lighter green on hover */
|
| 395 |
+
color: white !important; /* White text on hover */
|
| 396 |
+
}
|
| 397 |
+
</style>
|
| 398 |
+
""",
|
| 399 |
+
unsafe_allow_html=True,
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
with st.form(key="create_account_form"):
|
| 403 |
+
id_number = st.text_input("ID Number / Iqama Number")
|
| 404 |
+
first_name = st.text_input("First Name")
|
| 405 |
+
second_name = st.text_input("Second Name")
|
| 406 |
+
last_name = st.text_input("Last Name")
|
| 407 |
+
countries = [
|
| 408 |
+
"Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia",
|
| 409 |
+
"Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
|
| 410 |
+
"Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
|
| 411 |
+
"Cabo Verde", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia",
|
| 412 |
+
"Comoros", "Congo (Congo-Brazzaville)", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czechia (Czech Republic)",
|
| 413 |
+
"Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea",
|
| 414 |
+
"Eritrea", "Estonia", "Eswatini", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia",
|
| 415 |
+
"Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti",
|
| 416 |
+
"Holy See", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy",
|
| 417 |
+
"Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea (North)", "Korea (South)", "Kosovo",
|
| 418 |
+
"Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania",
|
| 419 |
+
"Luxembourg", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania",
|
| 420 |
+
"Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar",
|
| 421 |
+
"Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "North Macedonia",
|
| 422 |
+
"Norway", "Oman", "Pakistan", "Palau", "Palestine State", "Panama", "Papua New Guinea", "Paraguay", "Peru",
|
| 423 |
+
"Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia",
|
| 424 |
+
"Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal",
|
| 425 |
+
"Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia",
|
| 426 |
+
"South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Sweden", "Switzerland", "Syria",
|
| 427 |
+
"Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
|
| 428 |
+
"Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay",
|
| 429 |
+
"Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"
|
| 430 |
+
]
|
| 431 |
+
nationality = st.selectbox("Nationality", countries)
|
| 432 |
+
email = st.text_input("E-mail")
|
| 433 |
+
phone_number = st.text_input("Phone Number")
|
| 434 |
+
dob = st.date_input("Date of Birth", min_value=datetime(1900, 1, 1), max_value=datetime.now())
|
| 435 |
+
Short_Address = st.text_input(
|
| 436 |
+
"Short Address Code (4 letters + 4 digits)",
|
| 437 |
+
max_chars=8,
|
| 438 |
+
help="Enter exactly 4 letters followed by 4 digits (e.g., ABCD1234)",
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
submitted = st.form_submit_button("Create Account")
|
| 442 |
+
|
| 443 |
+
if submitted:
|
| 444 |
+
if len(Short_Address) == 8 and Short_Address[:4].isalpha() and Short_Address[4:].isdigit():
|
| 445 |
+
st.success("Account created successfully!")
|
| 446 |
+
else:
|
| 447 |
+
st.error("Invalid Short Address Code. It must be 4 letters followed by 4 digits (e.g., ABCD1234).")
|
| 448 |
+
|
| 449 |
+
if st.button("Back to Login"):
|
| 450 |
+
st.session_state["page"] = "Login"
|
| 451 |
+
|
| 452 |
+
|
| 453 |
def submit_ticket_page():
|
| 454 |
center_logo()
|
| 455 |
vspace()
|
|
|
|
| 753 |
st.dataframe(df)
|
| 754 |
st.components.v1.iframe(
|
| 755 |
"https://app.powerbi.com/view?r=eyJrIjoiY2Q0ODE1NGItOThjMy00MzM4LWE2OGUtMjRkNmUzYmZlMDk3IiwidCI6ImI0NTNkOTFiLTZhYzEtNGI2MS1iOGI4LTVlNjVlNDIyMjMzZiIsImMiOjl9",
|
| 756 |
+
height=600,
|
| 757 |
+
width=800,
|
| 758 |
scrolling=True
|
| 759 |
)
|
| 760 |
|
|
|
|
| 767 |
#center_logo("logo.png") # Center the logo
|
| 768 |
st.markdown('<h1 style="color: #084C3C;">Management Dashboard</h1>', unsafe_allow_html=True)
|
| 769 |
|
| 770 |
+
# Define employee data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 771 |
employee_data = {
|
| 772 |
"Employee ID": ["E001", "E002", "E003"],
|
| 773 |
"Name": ["John Doe", "Jane Smith", "Ali Ahmad"],
|
|
|
|
| 778 |
# Display the employee data table
|
| 779 |
st.dataframe(df_employee)
|
| 780 |
|
| 781 |
+
# Add the Power BI dashboard iframe
|
| 782 |
+
st.components.v1.iframe(
|
| 783 |
+
"https://app.powerbi.com/view?r=eyJrIjoiMzQ5N2RlMDQtY2I5ZC00NWE5LWE0ZjItMjExMzgyNmNmZWFjIiwidCI6ImI0NTNkOTFiLTZhYzEtNGI2MS1iOGI4LTVlNjVlNDIyMjMzZiIsImMiOjl9",
|
| 784 |
+
height=800,
|
| 785 |
+
width=1000,
|
| 786 |
+
scrolling=True
|
| 787 |
+
)
|
| 788 |
+
|
| 789 |
|
| 790 |
|
| 791 |
def customize_navigation_menu_dark_green():
|