This commit is contained in:
65
src/ui/display.py
Normal file
65
src/ui/display.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""Display utilities for DevTrace UI."""
|
||||
|
||||
from typing import Dict, Any
|
||||
from datetime import datetime
|
||||
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich.panel import Panel
|
||||
|
||||
|
||||
class DisplayManager:
|
||||
"""Manages rich display utilities for DevTrace."""
|
||||
|
||||
def __init__(self):
|
||||
self.console = Console()
|
||||
|
||||
def show_status(self, stats: Dict[str, Any]) -> None:
|
||||
"""Display DevTrace status and statistics."""
|
||||
table = Table(title="DevTrace Statistics")
|
||||
table.add_column("Metric", style="cyan")
|
||||
table.add_column("Value", style="green", justify="right")
|
||||
|
||||
table.add_row("Total Sessions", str(stats.get("total_sessions", 0)))
|
||||
table.add_row("Active Sessions", str(stats.get("active_sessions", 0)))
|
||||
table.add_row("File Events", str(stats.get("file_events", 0)))
|
||||
table.add_row("Command Events", str(stats.get("command_events", 0)))
|
||||
table.add_row("Git Events", str(stats.get("git_events", 0)))
|
||||
table.add_row("Total Events", str(stats.get("total_events", 0)))
|
||||
|
||||
self.console.print(Panel(table, title="DevTrace Status"))
|
||||
|
||||
def show_success(self, message: str) -> None:
|
||||
"""Show a success message."""
|
||||
self.console.print(Panel(
|
||||
f"[bold green]✓ {message}[/]",
|
||||
style="green"
|
||||
))
|
||||
|
||||
def show_error(self, message: str) -> None:
|
||||
"""Show an error message."""
|
||||
self.console.print(Panel(
|
||||
f"[bold red]✗ {message}[/]",
|
||||
style="red"
|
||||
))
|
||||
|
||||
def show_warning(self, message: str) -> None:
|
||||
"""Show a warning message."""
|
||||
self.console.print(Panel(
|
||||
f"[bold yellow]⚠ {message}[/]",
|
||||
style="yellow"
|
||||
))
|
||||
|
||||
def format_duration(self, seconds: float) -> str:
|
||||
"""Format duration in human-readable format."""
|
||||
if seconds < 60:
|
||||
return f"{seconds:.1f}s"
|
||||
elif seconds < 3600:
|
||||
mins = seconds / 60
|
||||
return f"{mins:.1f}m"
|
||||
elif seconds < 86400:
|
||||
hours = seconds / 3600
|
||||
return f"{hours:.1f}h"
|
||||
else:
|
||||
days = seconds / 86400
|
||||
return f"{days:.1f}d"
|
||||
Reference in New Issue
Block a user