Update app.py
Browse files
app.py
CHANGED
@@ -1,144 +1,98 @@
|
|
1 |
-
import
|
|
|
2 |
import os
|
3 |
-
import json
|
4 |
-
import datetime
|
5 |
-
from pathlib import Path
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
from pages.tasks import create_tasks_page
|
10 |
-
from pages.notes import create_notes_page
|
11 |
-
from pages.goals import create_goals_page
|
12 |
-
from pages.ai_assistant import create_ai_assistant_page
|
13 |
-
from pages.search import create_search_page
|
14 |
-
from pages.analytics import create_analytics_page
|
15 |
-
from pages.focus import create_focus_page
|
16 |
-
from pages.integrations_new import create_integrations_page # Using the new integrations page
|
17 |
-
from pages.settings import create_settings_page
|
18 |
-
from pages.multimedia import create_multimedia_page
|
19 |
|
20 |
-
# Import utilities
|
21 |
-
|
22 |
-
from utils.
|
23 |
-
from utils.
|
24 |
-
from utils.
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
logger = get_logger(__name__)
|
29 |
-
|
30 |
-
# Define sidebar items
|
31 |
-
sidebar_items = [
|
32 |
-
"π Dashboard",
|
33 |
-
"π Tasks & Projects",
|
34 |
-
"π Notes & Docs",
|
35 |
-
"π― Goals & Planning",
|
36 |
-
"π€ AI Assistant Hub",
|
37 |
-
"π Smart Search",
|
38 |
-
"π Analytics",
|
39 |
-
"π§ Focus & Wellness",
|
40 |
-
"πΌοΈ Multimedia",
|
41 |
-
"π Integrations",
|
42 |
-
"βοΈ Settings"
|
43 |
-
]
|
44 |
-
|
45 |
-
# Map sidebar items to page creation functions
|
46 |
-
page_creators = {
|
47 |
-
"π Dashboard": create_dashboard_page,
|
48 |
-
"π Tasks & Projects": create_tasks_page,
|
49 |
-
"π Notes & Docs": create_notes_page,
|
50 |
-
"π― Goals & Planning": create_goals_page,
|
51 |
-
"π€ AI Assistant Hub": create_ai_assistant_page,
|
52 |
-
"π Smart Search": create_search_page,
|
53 |
-
"π Analytics": create_analytics_page,
|
54 |
-
"π§ Focus & Wellness": create_focus_page,
|
55 |
-
"πΌοΈ Multimedia": create_multimedia_page,
|
56 |
-
"π Integrations": create_integrations_page,
|
57 |
-
"βοΈ Settings": create_settings_page
|
58 |
-
}
|
59 |
-
|
60 |
-
@handle_exceptions
|
61 |
-
def create_app():
|
62 |
-
"""Create and configure the Gradio application"""
|
63 |
-
logger.info("Initializing Mona application")
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
gr.Markdown("# Mona - AI Productivity Platform")
|
73 |
-
|
74 |
-
# Create main layout with sidebar and content area
|
75 |
-
with gr.Row():
|
76 |
-
# Sidebar navigation
|
77 |
-
with gr.Column(scale=1, elem_id="sidebar"):
|
78 |
-
# User profile section
|
79 |
-
with gr.Group(elem_id="user-profile"):
|
80 |
-
gr.Markdown("### Welcome!")
|
81 |
-
|
82 |
-
# Navigation menu
|
83 |
-
selected_page = gr.Radio(
|
84 |
-
choices=sidebar_items,
|
85 |
-
value=sidebar_items[0],
|
86 |
-
label="Navigation",
|
87 |
-
elem_id="nav-menu"
|
88 |
-
)
|
89 |
-
|
90 |
-
# App info
|
91 |
-
with gr.Group(elem_id="app-info"):
|
92 |
-
gr.Markdown("v0.1.0 | Using Free AI Models")
|
93 |
-
|
94 |
-
# Main content area
|
95 |
-
with gr.Column(scale=4, elem_id="content-area"):
|
96 |
-
# Create a container for each page
|
97 |
-
for page_name, create_page in page_creators.items():
|
98 |
-
with gr.Group(visible=(page_name == sidebar_items[0])) as page_container:
|
99 |
-
create_page(state)
|
100 |
-
# Store the container in state for navigation
|
101 |
-
state[f"{page_name}_container"] = page_container
|
102 |
|
103 |
-
#
|
104 |
-
|
105 |
-
def change_page(page_name):
|
106 |
-
"""Show the selected page and hide others"""
|
107 |
-
logger.debug(f"Navigating to page: {page_name}")
|
108 |
-
return [gr.update(visible=(name == page_name)) for name in sidebar_items]
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
133 |
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
136 |
|
137 |
if __name__ == "__main__":
|
138 |
-
|
139 |
-
logger.info("Starting Mona application")
|
140 |
-
app = create_app()
|
141 |
-
app.launch()
|
142 |
-
except Exception as e:
|
143 |
-
logger.error(f"Failed to start application: {str(e)}")
|
144 |
-
raise
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import sys
|
3 |
import os
|
|
|
|
|
|
|
4 |
|
5 |
+
# Add the current directory to the path
|
6 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Import utilities first to test they work
|
9 |
+
try:
|
10 |
+
from utils.logging import get_logger
|
11 |
+
from utils.error_handling import DataError, ValidationError
|
12 |
+
from utils.storage import load_data, save_data
|
13 |
+
|
14 |
+
logger = get_logger(__name__)
|
15 |
+
logger.info("All utilities imported successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
except ImportError as e:
|
18 |
+
st.error(f"Import error: {e}")
|
19 |
+
st.stop()
|
20 |
+
|
21 |
+
# Now import pages
|
22 |
+
try:
|
23 |
+
from pages.dashboard import create_dashboard_page
|
24 |
+
from pages.tasks import create_tasks_page
|
25 |
+
except ImportError as e:
|
26 |
+
st.error(f"Pages import error: {e}")
|
27 |
+
# Create fallback functions
|
28 |
+
def create_dashboard_page():
|
29 |
+
st.title("π€ MONA Dashboard")
|
30 |
+
st.success("β
All utilities loaded successfully!")
|
31 |
+
st.info("Dashboard is ready to be implemented")
|
32 |
|
33 |
+
def create_tasks_page():
|
34 |
+
st.title("π MONA Tasks")
|
35 |
+
st.success("β
All utilities loaded successfully!")
|
36 |
+
st.info("Tasks page is ready to be implemented")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
# Test data operations
|
39 |
+
st.subheader("Testing Data Operations")
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
if st.button("Test Save Data"):
|
42 |
+
test_data = {"message": "Hello MONA!", "status": "working"}
|
43 |
+
try:
|
44 |
+
success = save_data(test_data, "test.json", "json")
|
45 |
+
if success:
|
46 |
+
st.success("Data saved successfully!")
|
47 |
+
else:
|
48 |
+
st.error("Failed to save data")
|
49 |
+
except Exception as e:
|
50 |
+
st.error(f"Save error: {e}")
|
51 |
|
52 |
+
if st.button("Test Load Data"):
|
53 |
+
try:
|
54 |
+
data = load_data("test.json", "json")
|
55 |
+
if data:
|
56 |
+
st.success("Data loaded successfully!")
|
57 |
+
st.json(data)
|
58 |
+
else:
|
59 |
+
st.warning("No data found")
|
60 |
+
except Exception as e:
|
61 |
+
st.error(f"Load error: {e}")
|
62 |
+
|
63 |
+
def main():
|
64 |
+
"""Main application entry point"""
|
65 |
+
st.set_page_config(
|
66 |
+
page_title="MONA",
|
67 |
+
page_icon="π€",
|
68 |
+
layout="wide",
|
69 |
+
initial_sidebar_state="expanded"
|
70 |
+
)
|
71 |
+
|
72 |
+
# Initialize data directory
|
73 |
+
from utils.storage import ensure_data_directory
|
74 |
+
ensure_data_directory()
|
75 |
+
|
76 |
+
# Initialize state
|
77 |
+
from utils.state import init_session_state
|
78 |
+
init_session_state()
|
79 |
+
|
80 |
+
# Sidebar navigation
|
81 |
+
with st.sidebar:
|
82 |
+
st.title("π€ MONA")
|
83 |
+
st.markdown("---")
|
84 |
|
85 |
+
page = st.radio(
|
86 |
+
"Navigation",
|
87 |
+
["Dashboard", "Tasks"],
|
88 |
+
index=0
|
89 |
+
)
|
90 |
|
91 |
+
# Route to appropriate page
|
92 |
+
if page == "Dashboard":
|
93 |
+
create_dashboard_page()
|
94 |
+
elif page == "Tasks":
|
95 |
+
create_tasks_page()
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|