Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
import time
|
| 4 |
import requests
|
| 5 |
|
|
@@ -17,11 +18,17 @@ def load_lottie_url(url: str):
|
|
| 17 |
return None
|
| 18 |
return r.json()
|
| 19 |
|
| 20 |
-
# URL for
|
| 21 |
lottie_url = "https://assets6.lottiefiles.com/packages/lf20_5hhtik.json"
|
|
|
|
|
|
|
| 22 |
lottie_json = load_lottie_url(lottie_url)
|
| 23 |
|
| 24 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def show_loading_animation():
|
| 26 |
if lottie_json:
|
| 27 |
st_lottie(lottie_json, height=300, key="loading")
|
|
@@ -43,61 +50,77 @@ def login_page():
|
|
| 43 |
st.session_state["logged_in"] = True
|
| 44 |
st.session_state["login_success"] = True
|
| 45 |
st.success(f"Logged in successfully as {users[username]['role']}")
|
| 46 |
-
time.sleep(1)
|
| 47 |
else:
|
| 48 |
st.error("Invalid username or password.")
|
| 49 |
|
| 50 |
def add_return_to_login():
|
| 51 |
if "logged_in" in st.session_state and st.session_state["logged_in"]:
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
st.
|
|
|
|
| 55 |
|
| 56 |
def main():
|
| 57 |
if "logged_in" not in st.session_state or not st.session_state["logged_in"]:
|
| 58 |
login_page()
|
| 59 |
return
|
| 60 |
|
|
|
|
| 61 |
st.set_page_config(page_title="Ticket System", layout="centered", initial_sidebar_state="expanded")
|
|
|
|
| 62 |
add_return_to_login()
|
| 63 |
|
| 64 |
user_type = st.session_state.get("user_type", "Customer")
|
| 65 |
-
st.sidebar.title("Navigation")
|
| 66 |
|
|
|
|
| 67 |
if user_type == "Customer":
|
| 68 |
-
page = st.sidebar.radio(
|
|
|
|
|
|
|
|
|
|
| 69 |
elif user_type == "Manager":
|
| 70 |
-
page = st.sidebar.radio(
|
|
|
|
|
|
|
|
|
|
| 71 |
elif user_type == "Employee":
|
| 72 |
-
page = st.sidebar.radio(
|
|
|
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
st.sidebar.write("No pages available for this user type.")
|
| 75 |
return
|
| 76 |
|
|
|
|
| 77 |
with st.spinner("Loading..."):
|
| 78 |
show_loading_animation()
|
| 79 |
-
time.sleep(0.5)
|
| 80 |
|
|
|
|
| 81 |
if page == "Submit Ticket":
|
| 82 |
submit_ticket_page()
|
| 83 |
elif page == "Check Ticket Status":
|
| 84 |
check_ticket_status_page()
|
| 85 |
elif page == "FAQ & Info":
|
| 86 |
faq_info_page()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
elif page == "Management Dashboard":
|
| 88 |
management_dashboard_page()
|
| 89 |
elif page == "Ticket Dashboard":
|
| 90 |
ticket_dashboard_page()
|
| 91 |
elif page == "Customer Dashboard":
|
| 92 |
customer_dashboard_page()
|
| 93 |
-
elif page == "Respond to a Ticket":
|
| 94 |
-
respond_to_ticket_page()
|
| 95 |
-
elif page == "Ticket Status":
|
| 96 |
-
employee_ticket_status_page()
|
| 97 |
|
| 98 |
def submit_ticket_page():
|
| 99 |
st.image("logo.png", width=200)
|
| 100 |
-
st.
|
|
|
|
|
|
|
| 101 |
with st.form(key="submit_ticket_form"):
|
| 102 |
customer_id = st.text_input("Customer ID")
|
| 103 |
st.text_input("First Name")
|
|
@@ -108,12 +131,15 @@ def submit_ticket_page():
|
|
| 108 |
st.selectbox("Ticket Type", ["General", "Billing", "Technical", "Feedback"])
|
| 109 |
st.text_area("Describe your issue/request")
|
| 110 |
st.file_uploader("Upload Attachments (if any)", accept_multiple_files=True)
|
| 111 |
-
|
|
|
|
| 112 |
st.success(f"Your ticket has been submitted successfully. Customer ID: {customer_id}")
|
| 113 |
|
| 114 |
def check_ticket_status_page():
|
| 115 |
st.image("logo.png", width=200)
|
| 116 |
-
st.
|
|
|
|
|
|
|
| 117 |
customer_id = st.text_input("Customer ID")
|
| 118 |
if st.button("Check Status"):
|
| 119 |
if customer_id:
|
|
@@ -131,27 +157,37 @@ def check_ticket_status_page():
|
|
| 131 |
|
| 132 |
def faq_info_page():
|
| 133 |
st.image("logo.png", width=200)
|
| 134 |
-
st.
|
|
|
|
|
|
|
| 135 |
faq_data = [
|
| 136 |
-
("How to open a new account?", "Visit your nearest branch or use our app."),
|
| 137 |
("Branch Operating Hours", "Sunday to Thursday, 9:00 AM to 4:00 PM."),
|
|
|
|
|
|
|
| 138 |
]
|
| 139 |
for question, answer in faq_data:
|
| 140 |
-
st.
|
| 141 |
-
st.
|
| 142 |
|
| 143 |
def respond_to_ticket_page():
|
| 144 |
st.image("logo.png", width=200)
|
| 145 |
-
st.
|
|
|
|
|
|
|
| 146 |
ticket_data = {
|
| 147 |
"Ticket Number": ["141", "565", "999"],
|
| 148 |
"Customer ID": ["C001", "C002", "C003"],
|
| 149 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
| 150 |
"Type": ["General", "Billing", "Technical"],
|
| 151 |
"Status": ["Pending", "Pending", "In Progress"],
|
|
|
|
| 152 |
}
|
| 153 |
df = pd.DataFrame(ticket_data)
|
|
|
|
|
|
|
| 154 |
st.dataframe(df)
|
|
|
|
| 155 |
ticket_to_respond = st.selectbox("Select a ticket to respond to:", df["Ticket Number"].tolist())
|
| 156 |
if st.button("Respond to Ticket"):
|
| 157 |
st.text_area("Response:", placeholder="Write your response here...")
|
|
@@ -159,30 +195,82 @@ def respond_to_ticket_page():
|
|
| 159 |
|
| 160 |
def employee_ticket_status_page():
|
| 161 |
st.image("logo.png", width=200)
|
| 162 |
-
st.
|
|
|
|
|
|
|
| 163 |
customer_id = st.text_input("Customer ID")
|
| 164 |
if st.button("Check Ticket Status"):
|
| 165 |
if customer_id:
|
| 166 |
st.success(f"Displaying tickets for Customer ID: {customer_id}")
|
| 167 |
ticket_data = {
|
| 168 |
"Ticket Number": ["141", "565", "999"],
|
|
|
|
| 169 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
|
|
|
| 170 |
"Status": ["Resolved", "Pending", "In Progress"],
|
| 171 |
}
|
| 172 |
df = pd.DataFrame(ticket_data)
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
| 178 |
|
| 179 |
def ticket_dashboard_page():
|
| 180 |
-
st.
|
| 181 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
def customer_dashboard_page():
|
| 184 |
-
st.
|
| 185 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
if
|
| 188 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
#from streamlit_lottie import st_lottie
|
| 4 |
import time
|
| 5 |
import requests
|
| 6 |
|
|
|
|
| 18 |
return None
|
| 19 |
return r.json()
|
| 20 |
|
| 21 |
+
# URL for your animation (replace with your Hugging Face-hosted animation URL)
|
| 22 |
lottie_url = "https://assets6.lottiefiles.com/packages/lf20_5hhtik.json"
|
| 23 |
+
|
| 24 |
+
# Load the animation
|
| 25 |
lottie_json = load_lottie_url(lottie_url)
|
| 26 |
|
| 27 |
+
# Display the Lottie animation in the Streamlit app
|
| 28 |
+
if lottie_json:
|
| 29 |
+
st_lottie(lottie_json, speed=1, width=600, height=400, key="animation")
|
| 30 |
+
|
| 31 |
+
# Function to display the Lottie animation interactively
|
| 32 |
def show_loading_animation():
|
| 33 |
if lottie_json:
|
| 34 |
st_lottie(lottie_json, height=300, key="loading")
|
|
|
|
| 50 |
st.session_state["logged_in"] = True
|
| 51 |
st.session_state["login_success"] = True
|
| 52 |
st.success(f"Logged in successfully as {users[username]['role']}")
|
| 53 |
+
time.sleep(1) # Ensure the message is displayed briefly before redirection
|
| 54 |
else:
|
| 55 |
st.error("Invalid username or password.")
|
| 56 |
|
| 57 |
def add_return_to_login():
|
| 58 |
if "logged_in" in st.session_state and st.session_state["logged_in"]:
|
| 59 |
+
# Display the "Back" button only when the user is logged in
|
| 60 |
+
if st.sidebar.button("Back"):
|
| 61 |
+
st.session_state.clear() # Clear the session state to log out
|
| 62 |
+
st.rerun() # Rerun the app to show the login page again
|
| 63 |
|
| 64 |
def main():
|
| 65 |
if "logged_in" not in st.session_state or not st.session_state["logged_in"]:
|
| 66 |
login_page()
|
| 67 |
return
|
| 68 |
|
| 69 |
+
# Set the page configuration
|
| 70 |
st.set_page_config(page_title="Ticket System", layout="centered", initial_sidebar_state="expanded")
|
| 71 |
+
|
| 72 |
add_return_to_login()
|
| 73 |
|
| 74 |
user_type = st.session_state.get("user_type", "Customer")
|
|
|
|
| 75 |
|
| 76 |
+
st.sidebar.title("Navigation")
|
| 77 |
if user_type == "Customer":
|
| 78 |
+
page = st.sidebar.radio(
|
| 79 |
+
"Go to",
|
| 80 |
+
["Submit Ticket", "Check Ticket Status", "FAQ & Info"]
|
| 81 |
+
)
|
| 82 |
elif user_type == "Manager":
|
| 83 |
+
page = st.sidebar.radio(
|
| 84 |
+
"Go to",
|
| 85 |
+
["Management Dashboard", "Ticket Dashboard", "Customer Dashboard"]
|
| 86 |
+
)
|
| 87 |
elif user_type == "Employee":
|
| 88 |
+
page = st.sidebar.radio(
|
| 89 |
+
"Go to",
|
| 90 |
+
["Respond to a Ticket", "Ticket Status"]
|
| 91 |
+
)
|
| 92 |
else:
|
| 93 |
st.sidebar.write("No pages available for this user type.")
|
| 94 |
return
|
| 95 |
|
| 96 |
+
# Display loading animation
|
| 97 |
with st.spinner("Loading..."):
|
| 98 |
show_loading_animation()
|
| 99 |
+
time.sleep(0.5) # Simulate a short loading delay
|
| 100 |
|
| 101 |
+
# Page navigation logic
|
| 102 |
if page == "Submit Ticket":
|
| 103 |
submit_ticket_page()
|
| 104 |
elif page == "Check Ticket Status":
|
| 105 |
check_ticket_status_page()
|
| 106 |
elif page == "FAQ & Info":
|
| 107 |
faq_info_page()
|
| 108 |
+
elif page == "Respond to a Ticket":
|
| 109 |
+
respond_to_ticket_page()
|
| 110 |
+
elif page == "Ticket Status":
|
| 111 |
+
employee_ticket_status_page()
|
| 112 |
elif page == "Management Dashboard":
|
| 113 |
management_dashboard_page()
|
| 114 |
elif page == "Ticket Dashboard":
|
| 115 |
ticket_dashboard_page()
|
| 116 |
elif page == "Customer Dashboard":
|
| 117 |
customer_dashboard_page()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
def submit_ticket_page():
|
| 120 |
st.image("logo.png", width=200)
|
| 121 |
+
st.markdown('<h1 style="color: #084C3C;">Submit a Ticket</h1>', unsafe_allow_html=True)
|
| 122 |
+
st.markdown('<p style="color: #084C3C;">Please fill out the form below to submit a ticket.</p>', unsafe_allow_html=True)
|
| 123 |
+
|
| 124 |
with st.form(key="submit_ticket_form"):
|
| 125 |
customer_id = st.text_input("Customer ID")
|
| 126 |
st.text_input("First Name")
|
|
|
|
| 131 |
st.selectbox("Ticket Type", ["General", "Billing", "Technical", "Feedback"])
|
| 132 |
st.text_area("Describe your issue/request")
|
| 133 |
st.file_uploader("Upload Attachments (if any)", accept_multiple_files=True)
|
| 134 |
+
submitted = st.form_submit_button("Submit")
|
| 135 |
+
if submitted:
|
| 136 |
st.success(f"Your ticket has been submitted successfully. Customer ID: {customer_id}")
|
| 137 |
|
| 138 |
def check_ticket_status_page():
|
| 139 |
st.image("logo.png", width=200)
|
| 140 |
+
st.markdown('<h1 style="color: #084C3C;">Check Ticket Status</h1>', unsafe_allow_html=True)
|
| 141 |
+
st.markdown('<p style="color: #084C3C;">Enter your Customer ID to view your tickets.</p>', unsafe_allow_html=True)
|
| 142 |
+
|
| 143 |
customer_id = st.text_input("Customer ID")
|
| 144 |
if st.button("Check Status"):
|
| 145 |
if customer_id:
|
|
|
|
| 157 |
|
| 158 |
def faq_info_page():
|
| 159 |
st.image("logo.png", width=200)
|
| 160 |
+
st.markdown('<h1 style="color: #084C3C;">FAQ & Information</h1>', unsafe_allow_html=True)
|
| 161 |
+
st.markdown('<p style="color: #084C3C;">Find answers to frequently asked questions and other information.</p>', unsafe_allow_html=True)
|
| 162 |
+
|
| 163 |
faq_data = [
|
| 164 |
+
("How to open a new account?", "Visit your nearest branch with your ID or use our app for easy online account opening."),
|
| 165 |
("Branch Operating Hours", "Sunday to Thursday, 9:00 AM to 4:00 PM."),
|
| 166 |
+
("Update Personal Information", "Update at a branch or through the app."),
|
| 167 |
+
("Technical Support", "Ensure your app is updated and connected to the internet.")
|
| 168 |
]
|
| 169 |
for question, answer in faq_data:
|
| 170 |
+
st.markdown(f'<h2 style="color: #084C3C;">{question}</h2>', unsafe_allow_html=True)
|
| 171 |
+
st.markdown(f'<p style="color: #084C3C;">{answer}</p>', unsafe_allow_html=True)
|
| 172 |
|
| 173 |
def respond_to_ticket_page():
|
| 174 |
st.image("logo.png", width=200)
|
| 175 |
+
st.markdown('<h1 style="color: #084C3C;">Respond to a Ticket</h1>', unsafe_allow_html=True)
|
| 176 |
+
st.markdown('<p style="color: #084C3C;">View and respond to tickets submitted by customers.</p>', unsafe_allow_html=True)
|
| 177 |
+
|
| 178 |
ticket_data = {
|
| 179 |
"Ticket Number": ["141", "565", "999"],
|
| 180 |
"Customer ID": ["C001", "C002", "C003"],
|
| 181 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
| 182 |
"Type": ["General", "Billing", "Technical"],
|
| 183 |
"Status": ["Pending", "Pending", "In Progress"],
|
| 184 |
+
"Customer Name": ["Alice", "Bob", "Charlie"],
|
| 185 |
}
|
| 186 |
df = pd.DataFrame(ticket_data)
|
| 187 |
+
|
| 188 |
+
st.markdown('<h2 style="color: #084C3C;">Tickets to Respond</h2>', unsafe_allow_html=True)
|
| 189 |
st.dataframe(df)
|
| 190 |
+
|
| 191 |
ticket_to_respond = st.selectbox("Select a ticket to respond to:", df["Ticket Number"].tolist())
|
| 192 |
if st.button("Respond to Ticket"):
|
| 193 |
st.text_area("Response:", placeholder="Write your response here...")
|
|
|
|
| 195 |
|
| 196 |
def employee_ticket_status_page():
|
| 197 |
st.image("logo.png", width=200)
|
| 198 |
+
st.markdown('<h1 style="color: #084C3C;">Ticket Status</h1>', unsafe_allow_html=True)
|
| 199 |
+
st.markdown('<p style="color: #084C3C;">View ticket statuses by Customer ID.</p>', unsafe_allow_html=True)
|
| 200 |
+
|
| 201 |
customer_id = st.text_input("Customer ID")
|
| 202 |
if st.button("Check Ticket Status"):
|
| 203 |
if customer_id:
|
| 204 |
st.success(f"Displaying tickets for Customer ID: {customer_id}")
|
| 205 |
ticket_data = {
|
| 206 |
"Ticket Number": ["141", "565", "999"],
|
| 207 |
+
"Customer ID": ["C001", "C002", "C003"],
|
| 208 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
| 209 |
+
"Type": ["General", "Billing", "Technical"],
|
| 210 |
"Status": ["Resolved", "Pending", "In Progress"],
|
| 211 |
}
|
| 212 |
df = pd.DataFrame(ticket_data)
|
| 213 |
+
filtered_df = df[df["Customer ID"] == customer_id]
|
| 214 |
+
if not filtered_df.empty:
|
| 215 |
+
st.dataframe(filtered_df)
|
| 216 |
+
else:
|
| 217 |
+
st.warning("No tickets found for this Customer ID.")
|
| 218 |
+
else:
|
| 219 |
+
st.warning("Please enter a Customer ID.")
|
| 220 |
|
| 221 |
def ticket_dashboard_page():
|
| 222 |
+
st.image("logo.png", width=200)
|
| 223 |
+
st.markdown('<h1 style="color: #084C3C;">Ticket Dashboard</h1>', unsafe_allow_html=True)
|
| 224 |
+
st.markdown('<p style="color: #084C3C;">Overview of ticket statuses and statistics.</p>', unsafe_allow_html=True)
|
| 225 |
+
|
| 226 |
+
st.components.v1.iframe(
|
| 227 |
+
"https://app.powerbi.com/view?r=eyJrIjoiMDEwNzA2YjUtNGY0MC00NTFjLTg1ZTctYTZlZjQzOTUwNWUxIiwidCI6ImI0NTNkOTFiLTZhYzEtNGI2MS1iOGI4LTVlNjVlNDIyMjMzZiIsImMiOjl9",
|
| 228 |
+
height=800,
|
| 229 |
+
width=1000,
|
| 230 |
+
scrolling=True
|
| 231 |
+
)
|
| 232 |
|
| 233 |
def customer_dashboard_page():
|
| 234 |
+
st.image("logo.png", width=200)
|
| 235 |
+
st.markdown('<h1 style="color: #084C3C;">Customer Dashboard</h1>', unsafe_allow_html=True)
|
| 236 |
+
st.markdown('<p style="color: #084C3C;">Insights and data on customer interactions.</p>', unsafe_allow_html=True)
|
| 237 |
+
|
| 238 |
+
customer_data = {
|
| 239 |
+
"Customer ID": ["C001", "C002", "C003"],
|
| 240 |
+
"Name": ["Alice", "Bob", "Charlie"],
|
| 241 |
+
"Tickets Submitted": [5, 3, 8],
|
| 242 |
+
"Resolved": [4, 2, 7],
|
| 243 |
+
}
|
| 244 |
+
df = pd.DataFrame(customer_data)
|
| 245 |
+
|
| 246 |
+
st.markdown('<h2 style="color: #084C3C;">Customer Statistics</h2>', unsafe_allow_html=True)
|
| 247 |
+
st.dataframe(df)
|
| 248 |
+
|
| 249 |
+
def management_dashboard_page():
|
| 250 |
+
st.image("logo.png", width=200)
|
| 251 |
+
st.markdown('<h1 style="color: #084C3C;">Management Dashboard</h1>', unsafe_allow_html=True)
|
| 252 |
+
st.markdown('<p style="color: #084C3C;">Employee and department overviews.</p>', unsafe_allow_html=True)
|
| 253 |
+
|
| 254 |
+
employee_data = {
|
| 255 |
+
"Employee ID": ["E001", "E002", "E003"],
|
| 256 |
+
"Name": ["John Doe", "Jane Smith", "Ali Ahmad"],
|
| 257 |
+
"Department": ["Support", "Billing", "Technical"],
|
| 258 |
+
"Performance Score": [85, 90, 88],
|
| 259 |
+
}
|
| 260 |
+
df_employee = pd.DataFrame(employee_data)
|
| 261 |
+
|
| 262 |
+
department_data = {
|
| 263 |
+
"Department": ["Support", "Billing", "Technical"],
|
| 264 |
+
"Total Employees": [10, 8, 12],
|
| 265 |
+
"Tickets Handled": [100, 80, 120],
|
| 266 |
+
}
|
| 267 |
+
df_department = pd.DataFrame(department_data)
|
| 268 |
+
|
| 269 |
+
st.markdown('<h2 style="color: #084C3C;">Employee Dashboard</h2>', unsafe_allow_html=True)
|
| 270 |
+
st.dataframe(df_employee)
|
| 271 |
+
|
| 272 |
+
st.markdown('<h2 style="color: #084C3C;">Department Dashboard</h2>', unsafe_allow_html=True)
|
| 273 |
+
st.dataframe(df_department)
|
| 274 |
|
| 275 |
+
if _name_ == "_main_":
|
| 276 |
+
main()
|