EGYADMIN commited on
Commit
46dd33b
·
verified ·
1 Parent(s): 369f454

Create improved_sidebar.py

Browse files
Files changed (1) hide show
  1. utils/components/improved_sidebar.py +211 -0
utils/components/improved_sidebar.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ مكون الشريط الجانبي المحسن
3
+ """
4
+
5
+ import streamlit as st
6
+ from datetime import datetime
7
+ # استيراد ملف التكوين الحالي
8
+ from config import APP_TITLE, UI_THEME, DEFAULT_MODULE, STATIC_DIR
9
+ from streamlit_option_menu import option_menu
10
+
11
+ def render_sidebar():
12
+ """
13
+ عرض وإدارة الشريط الجانبي بتصميم احترافي
14
+
15
+ الإرجاع:
16
+ اسم الوحدة المحددة
17
+ """
18
+ # تحديد الألوان بناءً على سمة واجهة المستخدم
19
+ if UI_THEME == "dark":
20
+ primary_color = "#3498db"
21
+ secondary_color = "#ff9a3c"
22
+ bg_color = "#1e1e1e"
23
+ text_color = "#ffffff"
24
+ sidebar_bg = "#2d2d2d"
25
+ else:
26
+ primary_color = "#2c3e50"
27
+ secondary_color = "#ff9a3c"
28
+ bg_color = "#f8f9fa"
29
+ text_color = "#333333"
30
+ sidebar_bg = "#f0f2f6"
31
+
32
+ # تطبيق CSS مخصص لتحسين مظهر الشريط الجانبي
33
+ st.markdown(f"""
34
+ <style>
35
+ /* تنسيق الشريط الجانبي بالكامل */
36
+ section[data-testid="stSidebar"] {{
37
+ background-color: {bg_color};
38
+ direction: rtl;
39
+ }}
40
+
41
+ /* تنسيق حاوية اللوجو */
42
+ .logo-container {{
43
+ display: flex;
44
+ justify-content: center;
45
+ margin-bottom: 10px;
46
+ padding: 15px 0;
47
+ }}
48
+
49
+ /* تنسيق عنوان التطبيق */
50
+ .app-title {{
51
+ text-align: center;
52
+ color: {primary_color};
53
+ font-weight: bold;
54
+ font-size: 1.2rem;
55
+ margin-bottom: 15px;
56
+ padding-bottom: 10px;
57
+ border-bottom: 1px solid #e0e0e0;
58
+ }}
59
+
60
+ /* تنسيق القوائم */
61
+ .css-1544g2n {{
62
+ padding-right: 0 !important;
63
+ }}
64
+
65
+ /* تنسيق عناصر القائمة */
66
+ .nav-link {{
67
+ text-align: right !important;
68
+ padding: 10px 15px !important;
69
+ margin: 5px 0 !important;
70
+ border-radius: 5px !important;
71
+ transition: all 0.3s ease !important;
72
+ }}
73
+
74
+ /* تنسيق الأيقونات */
75
+ .nav-link i {{
76
+ margin-left: 10px !important;
77
+ margin-right: 0 !important;
78
+ }}
79
+
80
+ /* تنسيق القائمة المحددة */
81
+ .nav-link-selected {{
82
+ background-color: {secondary_color} !important;
83
+ color: white !important;
84
+ font-weight: bold !important;
85
+ }}
86
+
87
+ /* تنسيق معلومات المشروع */
88
+ .project-info {{
89
+ background-color: {sidebar_bg};
90
+ padding: 10px;
91
+ border-radius: 5px;
92
+ margin-top: 10px;
93
+ margin-bottom: 10px;
94
+ }}
95
+
96
+ /* تنسيق معلومات المستخدم */
97
+ .user-info {{
98
+ background-color: {sidebar_bg};
99
+ padding: 10px;
100
+ border-radius: 5px;
101
+ margin-top: 10px;
102
+ }}
103
+
104
+ /* تنسيق الفواصل */
105
+ hr {{
106
+ margin: 15px 0;
107
+ border-color: #e0e0e0;
108
+ }}
109
+
110
+ /* تنسيق الأزرار */
111
+ .stButton button {{
112
+ width: 100%;
113
+ background-color: {primary_color};
114
+ color: white;
115
+ border: none;
116
+ padding: 8px 0;
117
+ border-radius: 5px;
118
+ transition: all 0.3s ease;
119
+ }}
120
+
121
+ .stButton button:hover {{
122
+ background-color: {primary_color}dd;
123
+ }}
124
+ </style>
125
+ """, unsafe_allow_html=True)
126
+
127
+ with st.sidebar:
128
+ # إضافة اللوجو بتنسيق مخصص
129
+ st.markdown('<div class="logo-container">', unsafe_allow_html=True)
130
+ st.image("static/images/logo.png", width=180)
131
+ st.markdown('</div>', unsafe_allow_html=True)
132
+
133
+ # إضافة عنوان التطبيق
134
+ st.markdown(f'<div class="app-title">{APP_TITLE.split("-")[0].strip()}</div>', unsafe_allow_html=True)
135
+
136
+ # إنشاء قائمة الخيارات باستخدام مكتبة streamlit_option_menu
137
+ selected_module = option_menu(
138
+ "", # إزالة العنوان لأننا أضفناه بشكل منفصل أعلاه
139
+ [
140
+ "الرئيسية",
141
+ "إدارة المشاريع",
142
+ "التسعير المتكاملة",
143
+ "الموارد والتكاليف",
144
+ "تحليل المستندات",
145
+ "تحليل المخاطر",
146
+ "التقارير والتحليلات",
147
+ "المساعد الذكي"
148
+ ],
149
+ icons=[
150
+ 'house-fill',
151
+ 'folder-fill',
152
+ 'calculator-fill',
153
+ 'tools',
154
+ 'file-earmark-text-fill',
155
+ 'exclamation-triangle-fill',
156
+ 'bar-chart-fill',
157
+ 'robot'
158
+ ],
159
+ menu_icon=None, # إزالة أيقونة القائمة
160
+ default_index=0,
161
+ styles={
162
+ "container": {"padding": "0px", "background-color": "transparent"},
163
+ "icon": {"color": primary_color, "font-size": "18px"},
164
+ "nav-link": {"font-size": "14px", "text-align": "right", "margin": "5px 0px", "padding": "10px 15px"},
165
+ "nav-link-selected": {"background-color": secondary_color, "color": "white", "font-weight": "bold"},
166
+ }
167
+ )
168
+
169
+ # إضافة فاصل
170
+ st.markdown("<hr>", unsafe_allow_html=True)
171
+
172
+ # إضافة معلومات المشروع الحالي
173
+ if 'current_project' in st.session_state and st.session_state.current_project:
174
+ project = st.session_state.current_project
175
+
176
+ st.markdown('<div class="project-info">', unsafe_allow_html=True)
177
+ st.markdown("### المشروع الحالي")
178
+ st.markdown(f"**{project['name']}**")
179
+ st.markdown(f"رقم المناقصة: {project['number']}")
180
+ st.markdown(f"الجهة المالكة: {project['client']}")
181
+ st.markdown('</div>', unsafe_allow_html=True)
182
+
183
+ # إضافة زر للتبديل بين المشاريع
184
+ if st.button("تبديل المشروع"):
185
+ # لتنفيذ في مرحلة لاحقة
186
+ pass
187
+
188
+ # إضافة معلومات المستخدم
189
+ if 'user_info' in st.session_state and st.session_state.user_info:
190
+ user = st.session_state.user_info
191
+
192
+ st.markdown("<hr>", unsafe_allow_html=True)
193
+ st.markdown('<div class="user-info">', unsafe_allow_html=True)
194
+ st.markdown("### معلومات المستخدم")
195
+ st.markdown(f"**{user['full_name']}**")
196
+ st.markdown(f"الدور: {user['role']}")
197
+ st.markdown('</div>', unsafe_allow_html=True)
198
+
199
+ # إضافة زر لتسجيل الخروج
200
+ if st.button("تسجيل الخروج"):
201
+ st.session_state.is_authenticated = False
202
+ st.session_state.user_info = None
203
+ st.rerun()
204
+
205
+ # إضافة معلومات النسخة
206
+ st.markdown("<hr>", unsafe_allow_html=True)
207
+ st.markdown(f"الإصدار: 1.0.0")
208
+ st.markdown(f"تاريخ الإصدار: 2025-03-15")
209
+ st.markdown(f"© 2025 شركة شبه الجزيرة للمقاولات")
210
+
211
+ return selected_module