| """ |
| CyberForge Dashboard - Hugging Face Spaces Version |
| """ |
| import os |
| import sys |
| import streamlit as st |
| from streamlit_extras.add_vertical_space import add_vertical_space |
| from streamlit_extras.colored_header import colored_header |
|
|
| |
| is_huggingface = os.environ.get('SPACE_ID') is not None |
|
|
| |
| st.set_page_config( |
| page_title="CyberForge Dashboard", |
| page_icon="π΅οΈββοΈ", |
| layout="wide", |
| initial_sidebar_state="expanded" |
| ) |
|
|
| |
| st.markdown(""" |
| <style> |
| .stApp { |
| background-color: #0e1117; |
| } |
| .sidebar .sidebar-content { |
| background-color: #262730; |
| } |
| h1, h2, h3 { |
| color: #f8f9fa; |
| } |
| .cybertext { |
| color: #00ff8d; |
| font-family: monospace; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
|
|
| |
| if is_huggingface: |
| |
| import hf_database |
| st.session_state.is_demo = True |
| |
| |
| st.warning("β οΈ Running in Hugging Face Spaces DEMO MODE. Data is stored in-memory and will be reset when the space restarts.") |
| else: |
| |
| import src.database_init |
| |
| |
| from components.dashboard import render_dashboard |
| from components.threats import render_threats |
| from components.monitoring import render_monitoring |
| from components.alerts import render_alerts |
| from components.reports import render_reports |
| from components.live_feed import render_live_feed, render_content_analysis |
| from components.web_scraper import render_web_scraper_ui |
|
|
| |
| def add_notification(title, message, severity="info", icon="π"): |
| """Add a notification to the session state""" |
| if "notifications" not in st.session_state: |
| st.session_state.notifications = [] |
| |
| |
| import time |
| notification = { |
| "id": int(time.time() * 1000), |
| "title": title, |
| "message": message, |
| "severity": severity, |
| "icon": icon, |
| "read": False, |
| "timestamp": time.time() |
| } |
| st.session_state.notifications.insert(0, notification) |
|
|
| |
| if "notifications" not in st.session_state: |
| st.session_state.notifications = [] |
|
|
| |
| with st.sidebar: |
| st.image("assets/cyberforge_logo.svg", width=200) |
| st.title("CyberForge") |
| |
| |
| if st.session_state.get("is_demo", False): |
| st.markdown("#### π Demo Mode") |
| |
| st.markdown("---") |
| |
| |
| nav_selection = st.radio( |
| "Navigation", |
| ["Dashboard", "Threats", "Monitoring", "Alerts", "Reports", "Live Feed", "Content Analysis", "Web Scraper"] |
| ) |
| |
| |
| st.markdown("---") |
| st.markdown("### User Info") |
| if st.session_state.get("is_demo", False): |
| st.markdown("π€ **Admin User** (Demo)") |
| st.markdown("π Role: Administrator") |
| else: |
| st.markdown("π€ **Analyst**") |
| st.markdown("π Role: Security Analyst") |
| |
| |
| unread_count = sum(1 for n in st.session_state.notifications if not n["read"]) |
| if unread_count > 0: |
| st.markdown(f"π **{unread_count}** unread notifications") |
| |
| |
| st.markdown("---") |
| st.markdown("### CyberForge v1.0") |
| st.markdown("Β© 2025 Chemically Motivated Solutions") |
| |
| |
| if is_huggingface: |
| st.markdown("---") |
| st.markdown(""" |
| <a href="https://huggingface.co/spaces" target="_blank"> |
| <img src="https://img.shields.io/badge/Hosted%20on-HF%20Spaces-blue" alt="HuggingFace Spaces"/> |
| </a> |
| """, unsafe_allow_html=True) |
|
|
| |
| if nav_selection == "Dashboard": |
| render_dashboard() |
| elif nav_selection == "Threats": |
| render_threats() |
| elif nav_selection == "Monitoring": |
| render_monitoring() |
| elif nav_selection == "Alerts": |
| render_alerts() |
| elif nav_selection == "Reports": |
| render_reports() |
| elif nav_selection == "Live Feed": |
| render_live_feed() |
| elif nav_selection == "Content Analysis": |
| render_content_analysis() |
| elif nav_selection == "Web Scraper": |
| render_web_scraper_ui() |