tooling and docs
This commit is contained in:
90
src/main.py
90
src/main.py
@@ -8,6 +8,9 @@ from pages import DashboardPage, OllamaManagerPage
|
||||
from utils import GPUMonitor, SystemMonitor, OllamaMonitor
|
||||
import logging
|
||||
|
||||
from tools import TOOLS
|
||||
from tools.base_tool import ToolContext, set_tool_context
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
@@ -28,6 +31,14 @@ app.timer(2.0, system_monitor.update)
|
||||
app.timer(2.0, gpu_monitor.update)
|
||||
app.timer(2.0, ollama_monitor.update)
|
||||
|
||||
# Initialize tool context
|
||||
tool_context = ToolContext(
|
||||
system_monitor=system_monitor,
|
||||
gpu_monitor=gpu_monitor,
|
||||
ollama_monitor=ollama_monitor
|
||||
)
|
||||
set_tool_context(tool_context)
|
||||
|
||||
|
||||
def create_layout(current_route='/'):
|
||||
# Force dark mode
|
||||
@@ -41,22 +52,31 @@ def create_layout(current_route='/'):
|
||||
Sidebar(current_route)
|
||||
|
||||
|
||||
# Create tool routes with sub-pages support
|
||||
for tool_baseroute, tool in TOOLS.items():
|
||||
# Register all routes defined by the tool
|
||||
for sub_path, handler in tool.routes.items():
|
||||
# Construct full route path
|
||||
full_route = tool.baseroute + sub_path if sub_path else tool.baseroute
|
||||
|
||||
# Create a closure to capture the current handler and route
|
||||
def create_route_handler(route, handler_func):
|
||||
@ui.page(route)
|
||||
async def tool_page():
|
||||
create_layout(route)
|
||||
await handler_func()
|
||||
return tool_page
|
||||
|
||||
# Register the route
|
||||
create_route_handler(full_route, handler)
|
||||
|
||||
|
||||
@ui.page('/')
|
||||
async def index_page():
|
||||
create_layout('/')
|
||||
DashboardPage(system_monitor, gpu_monitor, ollama_monitor)
|
||||
|
||||
|
||||
@ui.page('/system')
|
||||
async def system_page():
|
||||
create_layout('/system')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('System Overview').classes('text-2xl font-bold text-white mb-4')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Detailed system information will be displayed here...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/ollama')
|
||||
async def ollama_page():
|
||||
create_layout('/ollama')
|
||||
@@ -65,56 +85,6 @@ async def ollama_page():
|
||||
# await page._load_models()
|
||||
|
||||
|
||||
@ui.page('/processes')
|
||||
async def processes_page():
|
||||
create_layout('/processes')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('Process Manager').classes('text-2xl font-bold text-white')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Process management coming soon...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/network')
|
||||
async def network_page():
|
||||
create_layout('/network')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('Network Monitor').classes('text-2xl font-bold text-white')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Network monitoring coming soon...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/packages')
|
||||
async def packages_page():
|
||||
create_layout('/packages')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('Package Manager').classes('text-2xl font-bold text-white')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Package management coming soon...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/logs')
|
||||
async def logs_page():
|
||||
create_layout('/logs')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('Log Viewer').classes('text-2xl font-bold text-white')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Log viewing coming soon...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/info')
|
||||
async def info_page():
|
||||
create_layout('/info')
|
||||
with ui.element('div').classes('main-content w-full'):
|
||||
with ui.column().classes('w-full max-w-4xl mx-auto p-6 gap-6'):
|
||||
ui.label('System Information').classes('text-2xl font-bold text-white')
|
||||
with ui.card().classes('metric-card p-6'):
|
||||
ui.label('Detailed system information coming soon...').classes('text-grey-5')
|
||||
|
||||
|
||||
@ui.page('/settings')
|
||||
async def settings_page():
|
||||
create_layout('/settings')
|
||||
|
||||
Reference in New Issue
Block a user