|
12 | 12 |
|
13 | 13 | # --- INITIALIZE STATE --- |
14 | 14 | if "role_db" not in st.session_state: |
15 | | - # This DB resets on restart. In a real app, you'd connect this to a Google Sheet or Database. |
16 | 15 | st.session_state.role_db = { |
17 | 16 | "armasupplyguy@gmail.com": "SUPER_ADMIN" |
18 | 17 | } |
|
78 | 77 | password_input = st.text_input("System Password", type="password") |
79 | 78 |
|
80 | 79 | if st.button("Login", type="primary"): |
81 | | - # Check 1: Is the email in our authorized list? |
82 | 80 | if email_input in st.session_state.role_db: |
83 | | - # Check 2: Is the password correct? |
84 | 81 | if password_input == SYSTEM_PASSWORD: |
85 | 82 | st.session_state.logged_in = True |
86 | 83 | st.session_state.current_user = email_input |
|
90 | 87 | st.error("Incorrect Password.") |
91 | 88 | else: |
92 | 89 | st.error("Access Denied. Email not authorized.") |
93 | | - |
94 | | - # Stop the script here if not logged in |
95 | 90 | st.stop() |
96 | 91 |
|
97 | 92 | # ========================================================= |
98 | 93 | # MAIN APP (Only runs if logged_in is True) |
99 | 94 | # ========================================================= |
100 | 95 |
|
101 | | -# Current Authenticated User |
102 | 96 | USER_EMAIL = st.session_state.current_user |
103 | 97 | user_role = st.session_state.role_db.get(USER_EMAIL, "CLP") |
104 | 98 |
|
@@ -236,9 +230,135 @@ def get_mod_status(): |
236 | 230 | if current_mod: |
237 | 231 | st.title(f"Issue: {current_mod['name']}") |
238 | 232 | col_report, col_chat = st.columns([2, 1]) |
| 233 | + |
239 | 234 | with col_report: |
240 | 235 | with st.container(border=True): |
241 | 236 | st.caption(f"Severity: {current_mod['severity']} | Assigned: {current_mod['assignment']}") |
| 237 | + |
| 238 | + # Check JSON data existence |
242 | 239 | if current_mod.get('json_data'): |
243 | 240 | st.code(current_mod['json_data'], language='json') |
244 | | - st.markdown(current_mod['description'], |
| 241 | + |
| 242 | + # Render Description |
| 243 | + st.markdown(current_mod['description'], unsafe_allow_html=True) |
| 244 | + |
| 245 | + st.divider() |
| 246 | + |
| 247 | + if not current_mod['complete']: |
| 248 | + if st.button("✅ Mark as Resolved", type="primary"): |
| 249 | + current_mod['complete'] = True |
| 250 | + st.success("Issue resolved! Moved to Fixed dump.") |
| 251 | + st.session_state.page = "view_fixed_mods" |
| 252 | + st.rerun() |
| 253 | + else: |
| 254 | + st.success("This issue is marked as RESOLVED.") |
| 255 | + if st.button("Re-open Issue"): |
| 256 | + current_mod['complete'] = False |
| 257 | + st.rerun() |
| 258 | + |
| 259 | + with col_chat: |
| 260 | + st.subheader("💬 Discussion") |
| 261 | + chat_container = st.container(height=400, border=True) |
| 262 | + for msg in current_mod['discussion']: |
| 263 | + chat_container.markdown(f"**{msg['user']}**: {msg['text']}") |
| 264 | + chat_container.caption(f"{msg['time']}") |
| 265 | + chat_container.divider() |
| 266 | + with st.form(key="chat_form", clear_on_submit=True): |
| 267 | + user_msg = st.text_input("Type a message...") |
| 268 | + submit_chat = st.form_submit_button("Send") |
| 269 | + if submit_chat and user_msg: |
| 270 | + timestamp = datetime.now().strftime("%H:%M") |
| 271 | + current_mod['discussion'].append({ |
| 272 | + "user": USER_EMAIL, |
| 273 | + "text": user_msg, |
| 274 | + "time": timestamp |
| 275 | + }) |
| 276 | + st.rerun() |
| 277 | + else: |
| 278 | + st.error("Mod report not found.") |
| 279 | + |
| 280 | +# --- PAGE: CREATE EVENT --- |
| 281 | +elif st.session_state.page == "create_event": |
| 282 | + st.title("Create New Event") |
| 283 | + if user_role in ["CLPLEAD", "SUPER_ADMIN"]: |
| 284 | + with st.container(border=True): |
| 285 | + e_name = st.text_input("Event Name") |
| 286 | + e_date = st.date_input("Date") |
| 287 | + e_time = st.time_input("Time") |
| 288 | + e_tz = st.selectbox("Timezone", ["UTC", "EST", "PST", "GMT"]) |
| 289 | + e_loc = st.text_input("Location (Server/Discord)") |
| 290 | + st.write("Event Details (Rich Text):") |
| 291 | + e_desc = st_quill(key="event_quill_create") |
| 292 | + if st.button("Publish Event"): |
| 293 | + st.session_state.events.append({ |
| 294 | + "name": e_name, "date": str(e_date), "time": str(e_time), |
| 295 | + "tz": e_tz, "loc": e_loc, "desc": e_desc |
| 296 | + }) |
| 297 | + st.success("Event Published!") |
| 298 | + st.session_state.page = "view_events" |
| 299 | + st.rerun() |
| 300 | + else: |
| 301 | + st.error("You do not have permission to create events.") |
| 302 | + |
| 303 | +# --- PAGE: VIEW EVENTS --- |
| 304 | +elif st.session_state.page == "view_events": |
| 305 | + st.title("Training & Events Calendar") |
| 306 | + if not st.session_state.events: |
| 307 | + st.info("No events scheduled.") |
| 308 | + for event in st.session_state.events: |
| 309 | + with st.chat_message("event"): |
| 310 | + st.write(f"### {event['name']}") |
| 311 | + st.write(f"🕒 {event['date']} at {event['time']} ({event['tz']}) | 📍 {event['loc']}") |
| 312 | + st.markdown(event['desc'], unsafe_allow_html=True) |
| 313 | + |
| 314 | +# --- PAGE: CREATE TUTORIAL --- |
| 315 | +elif st.session_state.page == "create_tutorial": |
| 316 | + st.title("Create New Tutorial") |
| 317 | + if user_role in ["CLPLEAD", "SUPER_ADMIN"]: |
| 318 | + with st.container(border=True): |
| 319 | + t_title = st.text_input("Tutorial Title") |
| 320 | + t_content = st_quill(key="tut_quill_create") |
| 321 | + if st.button("Save Tutorial"): |
| 322 | + st.session_state.tutorials.append({"title": t_title, "content": t_content}) |
| 323 | + st.success("Tutorial Saved!") |
| 324 | + st.session_state.page = "view_tutorials" |
| 325 | + st.rerun() |
| 326 | + else: |
| 327 | + st.error("You do not have permission to create tutorials.") |
| 328 | + |
| 329 | +# --- PAGE: VIEW TUTORIALS --- |
| 330 | +elif st.session_state.page == "view_tutorials": |
| 331 | + st.title("Tutorials Library") |
| 332 | + if not st.session_state.tutorials: |
| 333 | + st.info("No tutorials available.") |
| 334 | + for tut in st.session_state.tutorials: |
| 335 | + with st.container(border=True): |
| 336 | + st.subheader(tut['title']) |
| 337 | + st.markdown(tut['content'], unsafe_allow_html=True) |
| 338 | + |
| 339 | +# --- PAGE: VIEW USERS --- |
| 340 | +elif st.session_state.page == "view_users": |
| 341 | + st.title("Staff Roster & Online Status") |
| 342 | + for email, role in st.session_state.role_db.items(): |
| 343 | + with st.container(border=True): |
| 344 | + col_avatar, col_info, col_status = st.columns([1, 4, 2]) |
| 345 | + with col_avatar: |
| 346 | + st.write("👤") |
| 347 | + with col_info: |
| 348 | + st.subheader(email) |
| 349 | + st.caption(f"Role: {role}") |
| 350 | + with col_status: |
| 351 | + if email == USER_EMAIL: |
| 352 | + st.success("🟢 Online") |
| 353 | + else: |
| 354 | + st.write("⚪ Offline") |
| 355 | + |
| 356 | +# --- PAGE: ROLE MANAGEMENT --- |
| 357 | +elif st.session_state.page == "roles": |
| 358 | + st.title("Super Admin: Role Management") |
| 359 | + new_email = st.text_input("User Email") |
| 360 | + new_role = st.selectbox("Assign Role", ["admin", "CLPLEAD", "CLP"]) |
| 361 | + if st.button("Update Role"): |
| 362 | + st.session_state.role_db[new_email] = new_role |
| 363 | + st.success(f"Updated {new_email} to {new_role}") |
| 364 | + st.table(pd.DataFrame(st.session_state.role_db.items(), columns=["Email", "Role"])) |
0 commit comments