""" مكون الشريط الجانبي لنظام واهبي لتحليل العقود والمناقصات Sidebar component for WAHBI Tender Analysis System """ import streamlit as st import os from pathlib import Path import streamlit_option_menu as option_menu import json import datetime # ألوان النظام الموحدة COLORS = { "primary": "#0B6E4F", "secondary": "#08603a", "accent": "#FFB100", "tertiary": "#5754FF", "quaternary": "#f43f5e", "success": "#10b981", "warning": "#f59e0b", "danger": "#ef4444", "light_bg": "#f8fafc", "text": "#334155", "heading": "#1e293b", "muted": "#64748b", "border": "#e2e8f0", } # تهيئة الرموز مع ألوان مخصصة للأقسام المختلفة SECTION_ICONS = { "الرئيسية": {"icon": "house-fill", "color": COLORS["primary"]}, "تحليل العقود": {"icon": "file-earmark-text-fill", "color": COLORS["primary"]}, "حاسبة التكاليف": {"icon": "calculator-fill", "color": COLORS["tertiary"]}, "إدارة المشاريع": {"icon": "clipboard2-data-fill", "color": COLORS["primary"]}, "الخريطة التفاعلية": {"icon": "geo-alt-fill", "color": COLORS["quaternary"]}, "المساعد الذكي": {"icon": "robot", "color": COLORS["accent"]}, "التقارير": {"icon": "bar-chart-fill", "color": COLORS["tertiary"]}, "المحتوى المحلي": {"icon": "flag-fill", "color": COLORS["success"]}, "تحليل المخاطر": {"icon": "shield-fill-exclamation", "color": COLORS["warning"]}, "الإعدادات": {"icon": "gear-fill", "color": COLORS["muted"]}, } def get_user_info(): """ استرجاع معلومات المستخدم الحالي (يُستخدم كمثال بسيط) """ # في بيئة الإنتاج، هذه المعلومات يجب أن تأتي من نظام المصادقة return { "name": "محمد أحمد", "role": "محلل عقود", "organization": "شركة المشاريع المتطورة", "last_login": datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), "image": None } def render_wahbi_logo(): """ عرض شعار نظام واهبي بتصميم SVG متقدم """ logo_html = """
واهبي AI
""" return logo_html def render_sidebar(): """ عرض الشريط الجانبي الرئيسي للتطبيق """ with st.sidebar: # عرض شعار النظام st.markdown(render_wahbi_logo(), unsafe_allow_html=True) # عرض معلومات المستخدم user = get_user_info() # مربع معلومات المستخدم بتصميم متقدم st.markdown(f"""
{user["name"][0] if user["name"] else "م"}

{user["name"]}

{user["role"]}

{user["organization"]}

آخر دخول: {user["last_login"]}
""", unsafe_allow_html=True) # القائمة الرئيسية باستخدام كومبوننت الشريط الجانبي menu_options = [ "الرئيسية", "تحليل العقود", "حاسبة التكاليف", "إدارة المشاريع", "الخريطة التفاعلية", "المساعد الذكي", "التقارير", "المحتوى المحلي", "تحليل المخاطر", "الإعدادات" ] icons = [SECTION_ICONS[option]["icon"] for option in menu_options] # توليد قائمة الألوان المخصصة للأيقونات icon_colors = [SECTION_ICONS[option]["color"] for option in menu_options] # تطبيق نمط CSS المخصص للقائمة menu_style = """ """ st.markdown(menu_style, unsafe_allow_html=True) # إضافة عنوان CSS للأيقونات for i, option in enumerate(menu_options): st.markdown(f""" """, unsafe_allow_html=True) selected = option_menu.option_menu( menu_title="نظام WAHBi AI", options=menu_options, icons=icons, menu_icon="grid-fill", default_index=0, styles={ "container": { "padding": "0.5rem !important", "background-color": "transparent", "direction": "rtl", "border-radius": "var(--border-radius)", "margin-bottom": "var(--spacing-md)", "border": "1px solid rgba(11, 110, 79, 0.1)", "backdrop-filter": "blur(10px)", "background": "rgba(255, 255, 255, 0.6)", }, "icon": { "font-size": "1.2rem", "float": "right", "margin-left": "15px", "vertical-align": "middle", }, "nav-link": { "font-size": "0.95rem", "text-align": "right", "direction": "rtl", "padding": "0.8rem 1rem", "margin-bottom": "0.5rem", "border-radius": "8px", "font-weight": "500", "display": "flex", "align-items": "center", "justify-content": "flex-start", "position": "relative", "overflow": "hidden", "z-index": "1", "transition": "all 0.3s ease", "background": "rgba(255, 255, 255, 0.7)", "border": "1px solid rgba(226, 232, 240, 0.7)", }, "nav-link-selected": { "background": "var(--primary-gradient)", "color": "white", "text-align": "right", "font-weight": "600", "box-shadow": "0 4px 12px rgba(11, 110, 79, 0.2)", "border": "none", }, } ) # تخزين القيمة المحددة في session_state st.session_state["sidebar_selected"] = selected # إظهار حالة الاتصال بقاعدة البيانات وحالة النظام st.markdown(f"""

حالة النظام

قاعدة البيانات متصلة
واجهة برمجة التطبيقات
الذكاء الاصطناعي
""", unsafe_allow_html=True) # معلومات النظام وعنوان المشروع with st.expander("حول النظام", expanded=False): st.markdown(f"""
نظام واهبي للذكاء الاصطناعي - إصدار 2.0
تحليل العقود والمناقصات
بواسطة نماذج الذكاء الاصطناعي المتقدمة
© 2025 جميع الحقوق محفوظة
""", unsafe_allow_html=True) def get_sidebar_selection(): """ الحصول على العنصر المحدد في القائمة الجانبية """ return st.session_state.get("sidebar_selected", "الرئيسية") def render_module_sidebar(module_name, options=[]): """ عرض شريط جانبي مخصص للوحدة المعلمات: module_name (str): اسم الوحدة options (list): قائمة بالخيارات المتاحة في الوحدة """ with st.sidebar: # عنوان الوحدة st.markdown(f"""
{module_name}
""", unsafe_allow_html=True) # إذا تم توفير خيارات للوحدة if options: # تطبيق نمط CSS المخصص للقائمة الفرعية module_menu_style = """ """ st.markdown(module_menu_style, unsafe_allow_html=True) # كتلة تحتوي على القائمة مع فئة CSS مخصصة menu_container = st.container() with menu_container: st.markdown('
', unsafe_allow_html=True) selected = option_menu.option_menu( menu_title=None, options=options, menu_icon=None, default_index=0, styles={ "container": { "padding": "0!important", "background-color": "transparent", "direction": "rtl" }, "icon": { "color": "var(--primary-color)", "font-size": "1rem", "float": "right", "margin-left": "12px" }, "nav-link": { "font-size": "0.9rem", "text-align": "right", "direction": "rtl", "margin-bottom": "0.35rem", "padding": "0.7rem 1rem", "border-radius": "6px" }, "nav-link-selected": { "background-color": "var(--primary-color)", "color": "white", "text-align": "right", "font-weight": "600" }, } ) # إغلاق كتلة القائمة st.markdown('
', unsafe_allow_html=True) # تخزين الخيار المحدد st.session_state[f"{module_name}_selected"] = selected return selected # زر للعودة إلى القائمة الرئيسية مع تصميم محسن back_button_container = st.container() with back_button_container: st.markdown(f""" """, unsafe_allow_html=True) # إضافة كتلة على شكل بطاقة تحتوي على الزر st.markdown("""
""", unsafe_allow_html=True) if st.button("العودة للقائمة الرئيسية", key=f"back_btn_{module_name}"): st.session_state["sidebar_selected"] = "الرئيسية" st.rerun() def get_module_selection(module_name): """ الحصول على العنصر المحدد في قائمة الوحدة المعلمات: module_name (str): اسم الوحدة """ return st.session_state.get(f"{module_name}_selected", None)