- Fixed DataTable row selection and event handling - Added explicit column keys to prevent auto-generated keys - Implemented row-to-flow mapping for reliable selection tracking - Converted left metrics panel to horizontal top bar - Fixed all missing FlowStats/EnhancedAnalysisData attributes - Created comprehensive Textual API documentation in Documentation/textual/ - Added validation checklist to prevent future API mismatches - Preserved cursor position during data refreshes - Fixed RowKey type handling and event names The TUI now properly handles flow selection, displays metrics in a compact top bar, and correctly correlates selected rows with the details pane.
69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
"""
|
|
Statistical Analysis Widget - Metrics dashboard with real-time updates
|
|
"""
|
|
|
|
from textual.widgets import Static, TabbedContent, TabPane, DataTable
|
|
from textual.containers import Vertical, Horizontal
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from ....analysis.core import EthernetAnalyzer
|
|
|
|
|
|
class StatisticalAnalysisWidget(Vertical):
|
|
"""
|
|
Statistical Analysis Dashboard
|
|
|
|
Features:
|
|
- Real-time metrics display
|
|
- Performance analysis charts
|
|
- Outlier detection
|
|
- Export capabilities
|
|
"""
|
|
|
|
def __init__(self, analyzer: 'EthernetAnalyzer', **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.analyzer = analyzer
|
|
|
|
def compose(self):
|
|
"""Create the statistics dashboard"""
|
|
|
|
yield Static("STATISTICAL ANALYSIS", id="stats-title")
|
|
|
|
# Metrics summary
|
|
with Horizontal(id="metrics-summary"):
|
|
yield Static("Total Flows: 0", id="total-flows-metric")
|
|
yield Static("Total Packets: 0", id="total-packets-metric")
|
|
yield Static("Outliers: 0", id="outliers-metric")
|
|
yield Static("Quality: 0%", id="quality-metric")
|
|
|
|
# Analysis modes
|
|
with TabbedContent():
|
|
with TabPane("Performance", id="performance-tab"):
|
|
perf_table = DataTable(id="performance-table")
|
|
perf_table.add_columns("Metric", "Value", "Threshold", "Status")
|
|
yield perf_table
|
|
|
|
with TabPane("Protocol Distribution", id="protocol-tab"):
|
|
proto_table = DataTable(id="protocol-table")
|
|
proto_table.add_columns("Protocol", "Flows", "Packets", "Percentage")
|
|
yield proto_table
|
|
|
|
with TabPane("Timing Analysis", id="timing-tab"):
|
|
timing_table = DataTable(id="timing-table")
|
|
timing_table.add_columns("Flow", "Min", "Max", "Avg", "Jitter")
|
|
yield timing_table
|
|
|
|
with TabPane("Quality Metrics", id="quality-tab"):
|
|
quality_table = DataTable(id="quality-table")
|
|
quality_table.add_columns("Flow", "Enhanced", "Quality", "Outliers")
|
|
yield quality_table
|
|
|
|
def on_mount(self) -> None:
|
|
"""Initialize the widget"""
|
|
self.refresh_data()
|
|
|
|
def refresh_data(self) -> None:
|
|
"""Refresh statistical analysis data"""
|
|
# TODO: Implement statistics data refresh
|
|
pass |