rimasalshehri commited on
Commit
8a9d3bb
·
verified ·
1 Parent(s): a6b356c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +101 -184
app.py CHANGED
@@ -1,9 +1,102 @@
1
  import streamlit as st
2
  import pandas as pd
3
- #from streamlit_lottie import st_lottie
4
  import time
5
  import requests
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Sample user data for login
8
  users = {
9
  "manager123": {"password": "managerpass", "role": "Manager"},
@@ -18,17 +111,11 @@ def load_lottie_url(url: str):
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")
@@ -61,6 +148,8 @@ def add_return_to_login():
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()
@@ -98,179 +187,7 @@ def main():
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")
127
- st.text_input("Last Name")
128
- st.text_input("National ID / Residency Number")
129
- st.text_input("Email")
130
- st.text_input("Phone Number")
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:
146
- st.success(f"Displaying tickets for Customer ID: {customer_id}")
147
- ticket_data = {
148
- "Ticket Number": ["141", "565", "999"],
149
- "Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
150
- "Type": ["General", "Billing", "Technical"],
151
- "Status": ["Resolved", "Pending", "In Progress"],
152
- }
153
- df = pd.DataFrame(ticket_data)
154
- st.dataframe(df)
155
- else:
156
- st.warning("Please enter your 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...")
194
- st.button("Submit Response")
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()
 
1
  import streamlit as st
2
  import pandas as pd
 
3
  import time
4
  import requests
5
 
6
+ # Apply custom CSS for design
7
+ st.markdown(
8
+ """
9
+ <style>
10
+ /* General background color for the entire app */
11
+ .stApp {
12
+ background-color: #084C3C;
13
+ }
14
+
15
+ /* Sidebar (Navigation Menu) styling */
16
+ section[data-testid="stSidebar"] {
17
+ background-color: #E4ECE3; /* Light green background */
18
+ color: #084C3C; /* Dark green text */
19
+ }
20
+
21
+ /* Sidebar text and titles styling */
22
+ section[data-testid="stSidebar"] p, section[data-testid="stSidebar"] h1,
23
+ section[data-testid="stSidebar"] h2, section[data-testid="stSidebar"] h3 {
24
+ color: #084C3C; /* Dark green for text */
25
+ }
26
+
27
+ /* Input fields styling */
28
+ input, textarea, select, .stFileUploader {
29
+ background-color: white !important; /* White background for fields */
30
+ border: 2px solid #E4ECE3 !important; /* Light green border */
31
+ color: #084C3C !important; /* Dark green text color */
32
+ border-radius: 5px !important; /* Rounded corners */
33
+ }
34
+
35
+ /* Input fields focus effect */
36
+ input:focus, textarea:focus, select:focus, .stFileUploader:focus {
37
+ border: 2px solid #7FDB8B !important; /* Lighter green on focus */
38
+ outline: none !important; /* Remove default focus outline */
39
+ }
40
+
41
+ /* Button styling */
42
+ div[data-testid="stFormSubmitButton"] button, div.stButton > button {
43
+ background-color: #E4ECE3 !important; /* Light green button background */
44
+ color: #084C3C !important; /* Dark green text */
45
+ border-radius: 10px !important; /* Rounded corners */
46
+ padding: 10px 20px !important;
47
+ border: none !important;
48
+ }
49
+
50
+ /* Button hover effect */
51
+ div[data-testid="stFormSubmitButton"] button:hover, div.stButton > button:hover {
52
+ background-color: #7FDB8B !important; /* Lighter green on hover */
53
+ color: white !important; /* White text on hover */
54
+ }
55
+
56
+ /* Table styling */
57
+ table {
58
+ border-collapse: collapse;
59
+ width: 100%;
60
+ background-color: #E4ECE3; /* Light green background */
61
+ }
62
+
63
+ th, td {
64
+ border: 1px solid #084C3C; /* Dark green border */
65
+ text-align: left;
66
+ padding: 10px;
67
+ color: #084C3C; /* Dark green text */
68
+ }
69
+
70
+ th {
71
+ background-color: #7FDB8B; /* Light green for table header */
72
+ }
73
+
74
+ tr:nth-child(even) {
75
+ background-color: #f9f9f9; /* Light gray for alternating rows */
76
+ }
77
+
78
+ /* Placeholder text styling */
79
+ input::placeholder, textarea::placeholder {
80
+ color: #084C3C !important;
81
+ opacity: 0.7;
82
+ }
83
+
84
+ /* Title and header styling */
85
+ h1, h2, h3 {
86
+ color: #E4ECE3; /* Light green text for titles */
87
+ }
88
+
89
+ /* Spinner styling */
90
+ .css-1fgu7a7 {
91
+ background-color: #E4ECE3 !important;
92
+ border: 2px solid #084C3C !important;
93
+ color: #084C3C !important;
94
+ }
95
+ </style>
96
+ """,
97
+ unsafe_allow_html=True
98
+ )
99
+
100
  # Sample user data for login
101
  users = {
102
  "manager123": {"password": "managerpass", "role": "Manager"},
 
111
  return None
112
  return r.json()
113
 
114
+ # URL for the animation (optional)
115
  lottie_url = "https://assets6.lottiefiles.com/packages/lf20_5hhtik.json"
 
 
116
  lottie_json = load_lottie_url(lottie_url)
117
 
118
+ # Function to display the Lottie animation
 
 
 
 
119
  def show_loading_animation():
120
  if lottie_json:
121
  st_lottie(lottie_json, height=300, key="loading")
 
148
  st.session_state.clear() # Clear the session state to log out
149
  st.rerun() # Rerun the app to show the login page again
150
 
151
+ # Add your existing main() and other pages here...
152
+ # Main app logic continues...
153
  def main():
154
  if "logged_in" not in st.session_state or not st.session_state["logged_in"]:
155
  login_page()
 
187
  show_loading_animation()
188
  time.sleep(0.5) # Simulate a short loading delay
189
 
190
+ # Add page-specific logic here...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
+ if __name__ == "__main__":
193
+ main()