Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import sys
|
3 |
import os
|
|
|
4 |
import pandas as pd
|
5 |
import numpy as np
|
6 |
import matplotlib.pyplot as plt
|
@@ -8,31 +10,175 @@ import seaborn as sns
|
|
8 |
import plotly.express as px
|
9 |
import plotly.graph_objects as go
|
10 |
|
11 |
-
#
|
|
|
12 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
13 |
|
14 |
-
# استيراد
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
from pricing_system.integrated_app import IntegratedApp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
def main():
|
18 |
-
"""
|
19 |
-
الدالة الرئيسية لتشغيل التطبيق
|
20 |
-
"""
|
21 |
-
# تعيين عنوان الصفحة وأيقونة التطبيق
|
22 |
-
st.set_page_config(
|
23 |
-
page_title="نظام تحليل المناقصات",
|
24 |
-
page_icon="📊",
|
25 |
-
layout="wide",
|
26 |
-
initial_sidebar_state="expanded"
|
27 |
-
)
|
28 |
-
|
29 |
-
# تطبيق الأنماط الموحدة
|
30 |
-
with open("pricing_system/static/css/unified_style.css") as f:
|
31 |
-
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
32 |
-
|
33 |
-
# إنشاء وتشغيل التطبيق المتكامل
|
34 |
-
app = IntegratedApp()
|
35 |
-
app.run()
|
36 |
-
|
37 |
-
if __name__ == "__main__":
|
38 |
-
main()
|
|
|
1 |
+
# app.py
|
2 |
import streamlit as st
|
3 |
import sys
|
4 |
import os
|
5 |
+
from pathlib import Path
|
6 |
import pandas as pd
|
7 |
import numpy as np
|
8 |
import matplotlib.pyplot as plt
|
|
|
10 |
import plotly.express as px
|
11 |
import plotly.graph_objects as go
|
12 |
|
13 |
+
# إعداد المسارات
|
14 |
+
sys.path.append(str(Path(__file__).parent.parent))
|
15 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
16 |
|
17 |
+
# استيراد مدير التكوين
|
18 |
+
from config_manager import ConfigManager
|
19 |
+
|
20 |
+
# استيراد الوحدات
|
21 |
+
from modules.document_analysis.document_app import DocumentAnalysisApp
|
22 |
+
from modules.pricing.pricing_app import PricingApp
|
23 |
+
from modules.resources.resources_app import ResourcesApp
|
24 |
+
from modules.risk_analysis.risk_analyzer import RiskAnalysisApp
|
25 |
+
from modules.project_management.project_management_app import ProjectsApp
|
26 |
+
from modules.maps.maps_app import MapsApp
|
27 |
+
from modules.notifications.notifications_app import NotificationsApp
|
28 |
+
from modules.document_comparison.document_comparison_app import DocumentComparisonApp
|
29 |
+
from modules.translation.translation_app import TranslationApp
|
30 |
+
from modules.ai_assistant.ai_app import AIAssistantApp
|
31 |
+
from modules.data_analysis.data_analysis_app import DataAnalysisApp
|
32 |
from pricing_system.integrated_app import IntegratedApp
|
33 |
+
from styling.enhanced_ui import UIEnhancer
|
34 |
+
|
35 |
+
# تهيئة مدير التكوين
|
36 |
+
config_manager = ConfigManager()
|
37 |
+
|
38 |
+
# تكوين الصفحة
|
39 |
+
config_manager.set_page_config_if_needed(
|
40 |
+
page_title="نظام تحليل المناقصات",
|
41 |
+
page_icon="📊",
|
42 |
+
layout="wide",
|
43 |
+
initial_sidebar_state="expanded",
|
44 |
+
menu_items={
|
45 |
+
'Get Help': 'https://www.example.com/help',
|
46 |
+
'Report a bug': "https://www.example.com/bug",
|
47 |
+
'About': "### نظام تحليل المناقصات\nالإصدار 2.0.0"
|
48 |
+
}
|
49 |
+
)
|
50 |
+
|
51 |
+
# تطبيق التنسيق العام
|
52 |
+
ui_enhancer = UIEnhancer(page_title="نظام تحليل المناقصات", page_icon="📊")
|
53 |
+
ui_enhancer.apply_global_styles()
|
54 |
+
|
55 |
+
# تطبيق الأنماط الموحدة المخصصة للنظام
|
56 |
+
with open("pricing_system/static/css/unified_style.css") as f:
|
57 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
58 |
+
|
59 |
+
# إنشاء قائمة العناصر
|
60 |
+
menu_items = [
|
61 |
+
{"name": "لوحة المعلومات", "icon": "house"},
|
62 |
+
{"name": "المناقصات والعقود", "icon": "file-text"},
|
63 |
+
{"name": "تحليل المستندات", "icon": "file-earmark-text"},
|
64 |
+
{"name": "نظام التسعير", "icon": "calculator"},
|
65 |
+
{"name": "حاسبة تكاليف البناء", "icon": "building"},
|
66 |
+
{"name": "الموارد والتكاليف", "icon": "people"},
|
67 |
+
{"name": "تحليل المخاطر", "icon": "exclamation-triangle"},
|
68 |
+
{"name": "إدارة المشاريع", "icon": "kanban"},
|
69 |
+
{"name": "الخرائط والمواقع", "icon": "geo-alt"},
|
70 |
+
{"name": "الجدول الزمني", "icon": "calendar3"},
|
71 |
+
{"name": "الإشعارات", "icon": "bell"},
|
72 |
+
{"name": "مقارنة المستندات", "icon": "files"},
|
73 |
+
{"name": "الترجمة", "icon": "translate"},
|
74 |
+
{"name": "المساعد الذكي", "icon": "robot"},
|
75 |
+
{"name": "تحليل البيانات", "icon": "bar-chart"},
|
76 |
+
{"name": "الإعدادات", "icon": "gear"}
|
77 |
+
]
|
78 |
+
|
79 |
+
# إنشاء الشريط الجانبي
|
80 |
+
selected = ui_enhancer.create_sidebar(menu_items)
|
81 |
+
|
82 |
+
# تحديد الوحدة المطلوبة بناءً على اختيار المستخدم
|
83 |
+
if selected == "لوحة المعلومات":
|
84 |
+
ui_enhancer.create_header("لوحة المعلومات", "نظرة عامة على المناقصات والمشاريع")
|
85 |
+
|
86 |
+
col1, col2, col3 = st.columns(3)
|
87 |
+
|
88 |
+
with col1:
|
89 |
+
ui_enhancer.create_metric_card("المناقصات النشطة", "12", "+3", ui_enhancer.COLORS['primary'])
|
90 |
+
|
91 |
+
with col2:
|
92 |
+
ui_enhancer.create_metric_card("المشاريع قيد التنفيذ", "8", "+1", ui_enhancer.COLORS['success'])
|
93 |
+
|
94 |
+
with col3:
|
95 |
+
ui_enhancer.create_metric_card("المناقصات المقدمة", "24", "+5", ui_enhancer.COLORS['info'])
|
96 |
+
|
97 |
+
st.markdown("### الإشعارات الأخيرة")
|
98 |
+
notifications = [
|
99 |
+
{"title": "موعد تقديم مناقصة", "project": "إنشاء مبنى مستشفى الولادة والأطفال", "date": "2025-04-05", "priority": "عالية"},
|
100 |
+
{"title": "تحديث مستندات", "project": "صيانة وتطوير طريق الملك عبدالله", "date": "2025-03-28", "priority": "متوسطة"},
|
101 |
+
{"title": "اجتماع مراجعة التسعير", "project": "إنشاء محطة معالجة مياه الصرف الصحي", "date": "2025-03-25", "priority": "عالية"}
|
102 |
+
]
|
103 |
+
|
104 |
+
for notification in notifications:
|
105 |
+
with st.container():
|
106 |
+
col1, col2 = st.columns([4, 1])
|
107 |
+
with col1:
|
108 |
+
st.markdown(f"**{notification['title']}** - {notification['project']}")
|
109 |
+
st.caption(f"التاريخ: {notification['date']} | الأولوية: {notification['priority']}")
|
110 |
+
with col2:
|
111 |
+
st.button("عرض", key=f"view_{notification['title']}")
|
112 |
+
st.divider()
|
113 |
+
|
114 |
+
elif selected == "تحليل المستندات":
|
115 |
+
document_app = DocumentAnalysisApp()
|
116 |
+
document_app.run()
|
117 |
+
|
118 |
+
elif selected == "نظام التسعير":
|
119 |
+
integrated_pricing = IntegratedApp()
|
120 |
+
integrated_pricing.run()
|
121 |
+
|
122 |
+
elif selected == "الموارد والتكاليف":
|
123 |
+
resources_app = ResourcesApp()
|
124 |
+
resources_app.run()
|
125 |
+
|
126 |
+
elif selected == "تحليل المخاطر":
|
127 |
+
risk_app = RiskAnalysisApp()
|
128 |
+
risk_app.run()
|
129 |
+
|
130 |
+
elif selected == "إدارة المشاريع":
|
131 |
+
projects_app = ProjectsApp()
|
132 |
+
projects_app.run()
|
133 |
+
|
134 |
+
elif selected == "الخرائط والمواقع":
|
135 |
+
maps_app = MapsApp()
|
136 |
+
maps_app.run()
|
137 |
+
|
138 |
+
elif selected == "الإشعارات":
|
139 |
+
notifications_app = NotificationsApp()
|
140 |
+
notifications_app.run()
|
141 |
+
|
142 |
+
elif selected == "مقارنة المستندات":
|
143 |
+
document_comparison_app = DocumentComparisonApp()
|
144 |
+
document_comparison_app.run()
|
145 |
+
|
146 |
+
elif selected == "الترجمة":
|
147 |
+
translation_app = TranslationApp()
|
148 |
+
translation_app.run()
|
149 |
+
|
150 |
+
elif selected == "المساعد الذكي":
|
151 |
+
ai_app = AIAssistantApp()
|
152 |
+
ai_app.run()
|
153 |
+
|
154 |
+
elif selected == "تحليل البيانات":
|
155 |
+
data_analysis_app = DataAnalysisApp()
|
156 |
+
data_analysis_app.run()
|
157 |
+
|
158 |
+
elif selected == "الإعدادات":
|
159 |
+
ui_enhancer.create_header("الإعدادات", "إعدادات النظام والحساب")
|
160 |
+
st.markdown("### إعدادات النظام")
|
161 |
+
tabs = st.tabs(["إعدادات عامة", "الواجهة", "الأمان", "مفاتيح API"])
|
162 |
+
|
163 |
+
with tabs[0]:
|
164 |
+
st.checkbox("تفعيل الإشعارات", value=True)
|
165 |
+
st.checkbox("حفظ تلقائي للبيانات", value=True)
|
166 |
+
st.selectbox("اللغة", ["العربية", "English"])
|
167 |
+
st.selectbox("المنطقة الزمنية", ["توقيت الرياض (GMT+3)", "توقيت جرينتش (GMT)"])
|
168 |
+
|
169 |
+
with tabs[1]:
|
170 |
+
st.radio("النمط", ["فاتح", "داكن", "تلقائي (حسب نظام التشغيل)"])
|
171 |
+
st.slider("حجم الخط", 12, 20, 16)
|
172 |
+
st.color_picker("لون التمييز", "#1E88E5")
|
173 |
+
|
174 |
+
with tabs[2]:
|
175 |
+
st.checkbox("تفعيل المصادقة الثنائية", value=False)
|
176 |
+
st.number_input("مدة الجلسة (دقائق)", min_value=5, max_value=120, value=30)
|
177 |
+
st.button("تغيير كلمة المرور")
|
178 |
+
|
179 |
+
with tabs[3]:
|
180 |
+
st.text_input("مفتاح OpenAI API", type="password")
|
181 |
+
st.text_input("مفتاح Google Maps API", type="password")
|
182 |
+
st.button("حفظ مفاتيح API")
|
183 |
+
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|