Spaces:
Sleeping
Sleeping
""" | |
مكون الشريط الجانبي المحسن | |
""" | |
import streamlit as st | |
from datetime import datetime | |
import config | |
from streamlit_option_menu import option_menu | |
def render_sidebar(): | |
""" | |
عرض وإدارة الشريط الجانبي المحسن | |
الإرجاع: | |
اسم الوحدة المحددة | |
""" | |
with st.sidebar: | |
# عرض الشعار بحجم أكبر | |
st.image("static/images/logo.png", width=200) | |
# إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu | |
selected_module = option_menu( | |
"نظام العقود والمناقصات", | |
[ | |
"الرئيسية", | |
"إدارة المشاريع", | |
"التسعير المتكاملة", | |
"الموارد والتكاليف", | |
"تحليل المستندات", | |
"تحليل المخاطر", | |
"التقارير والتحليلات", | |
"المساعد الذكي" | |
], | |
icons=[ | |
'house-fill', | |
'folder-fill', | |
'calculator-fill', | |
'tools', | |
'file-earmark-text-fill', | |
'exclamation-triangle-fill', | |
'bar-chart-fill', | |
'robot' | |
], | |
menu_icon="cast", | |
default_index=0, | |
styles={ | |
"container": {"padding": "5px", "background-color": "#f0f2f6", "direction": "rtl", "border-radius": "8px"}, | |
"icon": {"color": "#2C5282", "font-size": "18px"}, | |
"nav-link": {"font-size": "14px", "text-align": "right", "margin": "0px", "padding": "10px", "border-radius": "4px"}, | |
"nav-link-selected": {"background-color": "#2C5282", "font-weight": "bold"}, | |
}, | |
key="main_menu" # إضافة معرف فريد لتجنب مشكلة تكرار المعرفات | |
) | |
# إضافة فاصل | |
st.markdown("---") | |
# إضافة معلومات المشروع الحالي | |
if 'current_project' in st.session_state and st.session_state.current_project: | |
# التحقق من نوع البيانات للمشروع الحالي | |
project_id = st.session_state.current_project | |
# البحث عن معلومات المشروع باستخدام المعرف | |
project = None | |
if 'projects' in st.session_state: | |
for p in st.session_state.projects: | |
if isinstance(p, dict) and 'id' in p and p['id'] == project_id: | |
project = p | |
break | |
# عرض معلومات المشروع إذا تم العثور عليه | |
if project and isinstance(project, dict): | |
st.markdown(""" | |
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-right: 4px solid #2C5282; margin-bottom: 15px;"> | |
<h3 style="color: #2C5282; margin-top: 0; font-size: 18px;">المشروع الحالي</h3> | |
<p style="font-weight: bold; margin-bottom: 5px;">{name}</p> | |
<p style="margin: 0; font-size: 14px;">العميل: {client}</p> | |
</div> | |
""".format( | |
name=project.get('name', 'غير معروف'), | |
client=project.get('client', 'غير معروف') | |
), unsafe_allow_html=True) | |
# إضافة زر للتبديل بين المشاريع | |
if st.button("تبديل المشروع", key="switch_project_btn"): | |
# لتنفيذ في مرحلة لاحقة | |
pass | |
# إضافة معلومات المستخدم | |
if 'user_info' in st.session_state and st.session_state.user_info: | |
user = st.session_state.user_info | |
st.markdown("---") | |
st.markdown(""" | |
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 15px;"> | |
<h3 style="color: #2C5282; margin-top: 0; font-size: 18px;">معلومات المستخدم</h3> | |
<p style="font-weight: bold; margin-bottom: 5px;">{name}</p> | |
<p style="margin: 0; font-size: 14px;">الدور: {role}</p> | |
</div> | |
""".format( | |
name=user['full_name'], | |
role=user['role'] | |
), unsafe_allow_html=True) | |
# إضافة زر لتسجيل الخروج | |
if st.button("تسجيل الخروج", key="logout_btn"): | |
st.session_state.is_authenticated = False | |
st.session_state.user_info = None | |
st.rerun() | |
# إضافة معلومات النسخة | |
st.markdown("---") | |
st.markdown(""" | |
<div style="text-align: center; color: #6c757d; font-size: 13px;"> | |
<p style="margin: 0;">الإصدار: 2.0.0</p> | |
<p style="margin: 0;">تاريخ الإصدار: 2025-04-01</p> | |
<p style="margin: 0;">© 2025 شركة شبه الجزيرة للمقاولات</p> | |
</div> | |
""", unsafe_allow_html=True) | |
return selected_module | |