|
""" |
|
مكون الشريط الجانبي لنظام واهبي لتحليل العقود والمناقصات |
|
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 |
|
|
|
def get_user_info(): |
|
""" |
|
استرجاع معلومات المستخدم الحالي (يُستخدم كمثال بسيط) |
|
""" |
|
|
|
return { |
|
"name": "محمد أحمد", |
|
"role": "محلل عقود", |
|
"image": None |
|
} |
|
|
|
def render_sidebar(): |
|
""" |
|
عرض الشريط الجانبي الرئيسي للتطبيق |
|
""" |
|
with st.sidebar: |
|
|
|
user = get_user_info() |
|
|
|
|
|
st.markdown(f""" |
|
<div style="padding: 1rem; background: linear-gradient(135deg, #f0f7ff, #e8f1fb); border-radius: 10px; margin-bottom: 1.5rem; text-align: center;"> |
|
<div style="width: 80px; height: 80px; background: linear-gradient(135deg, #1E88E5, #64B5F6); border-radius: 50%; margin: 0 auto 0.8rem auto; display: flex; justify-content: center; align-items: center; color: white; font-size: 2rem; font-weight: bold;"> |
|
{user["name"][0] if user["name"] else "م"} |
|
</div> |
|
<h3 style="margin: 0; font-size: 1.2rem; color: #333;">{user["name"]}</h3> |
|
<p style="margin: 0; color: #1E88E5; font-size: 0.9rem;">{user["role"]}</p> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
selected = option_menu.option_menu( |
|
menu_title="الوصول السريع", |
|
options=[ |
|
"الرئيسية", |
|
"تحليل العقود", |
|
"حاسبة التكاليف", |
|
"إدارة المشاريع", |
|
"الخريطة التفاعلية", |
|
"المساعد الذكي", |
|
"التقارير", |
|
"الإعدادات" |
|
], |
|
icons=[ |
|
"house-fill", |
|
"file-earmark-text-fill", |
|
"calculator-fill", |
|
"clipboard2-data-fill", |
|
"geo-alt-fill", |
|
"robot", |
|
"bar-chart-fill", |
|
"gear-fill" |
|
], |
|
menu_icon="list", |
|
default_index=0, |
|
styles={ |
|
"container": {"padding": "0!important", "background-color": "transparent", "direction": "rtl"}, |
|
"icon": {"color": "#1E88E5", "font-size": "1rem", "float": "right", "margin-left": "10px"}, |
|
"nav-link": { |
|
"font-size": "0.9rem", |
|
"text-align": "right", |
|
"direction": "rtl", |
|
"--hover-color": "#E3F2FD", |
|
"margin-bottom": "0.2rem", |
|
"padding-right": "15px", |
|
}, |
|
"nav-link-selected": {"background-color": "#1E88E5", "color": "white", "text-align": "right"}, |
|
} |
|
) |
|
|
|
|
|
st.session_state["sidebar_selected"] = selected |
|
|
|
|
|
st.markdown(""" |
|
<div style="padding: 1rem; background-color: #f0f2f5; border-radius: 10px; margin-top: 1.5rem;"> |
|
<h4 style="margin: 0 0 0.8rem 0; font-size: 1rem; color: #333;">حالة النظام</h4> |
|
<div style="display: flex; align-items: center; margin-bottom: 0.5rem;"> |
|
<div style="width: 8px; height: 8px; border-radius: 50%; background-color: #4CAF50; margin-left: 0.5rem;"></div> |
|
<span style="font-size: 0.9rem; color: #666;">قاعدة البيانات متصلة</span> |
|
</div> |
|
<div style="display: flex; align-items: center; margin-bottom: 0.5rem;"> |
|
<div style="width: 8px; height: 8px; border-radius: 50%; background-color: #4CAF50; margin-left: 0.5rem;"></div> |
|
<span style="font-size: 0.9rem; color: #666;">واجهة برمجة التطبيقات</span> |
|
</div> |
|
<div style="display: flex; align-items: center;"> |
|
<div style="width: 8px; height: 8px; border-radius: 50%; background-color: #4CAF50; margin-left: 0.5rem;"></div> |
|
<span style="font-size: 0.9rem; color: #666;">الذكاء الاصطناعي</span> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
with st.expander("حول النظام", expanded=False): |
|
st.markdown(""" |
|
<div style="font-size: 0.9rem; color: #666;"> |
|
<p style="margin-bottom: 0.5rem;">نظام واهبي للذكاء الاصطناعي - إصدار 2.0</p> |
|
<p style="margin-bottom: 0.5rem;">تحليل العقود والمناقصات</p> |
|
<p style="margin: 0;">© 2025 جميع الحقوق محفوظة</p> |
|
</div> |
|
""", 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""" |
|
<h3 style="margin-bottom: 1rem; color: #1E88E5; font-size: 1.2rem; padding-bottom: 0.5rem; border-bottom: 1px solid #eee;"> |
|
{module_name} |
|
</h3> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
if options: |
|
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": "#1E88E5", "font-size": "1rem", "float": "right", "margin-left": "10px"}, |
|
"nav-link": { |
|
"font-size": "0.9rem", |
|
"text-align": "right", |
|
"direction": "rtl", |
|
"--hover-color": "#E3F2FD", |
|
"margin-bottom": "0.2rem", |
|
"padding-right": "15px", |
|
"padding": "0.5rem" |
|
}, |
|
"nav-link-selected": {"background-color": "#1E88E5", "color": "white", "text-align": "right"}, |
|
} |
|
) |
|
|
|
|
|
st.session_state[f"{module_name}_selected"] = selected |
|
|
|
return selected |
|
|
|
|
|
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) |