File size: 4,162 Bytes
88d205f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Results Dashboard Component

This module provides the UI component for displaying the code review results.
"""

import gradio as gr
import logging

logger = logging.getLogger(__name__)


def create_results_dashboard():
    """
    Create the results dashboard component.
    
    Returns:
        gr.Tabs: The results dashboard component tabs.
    """
    # Create a Tabs component directly instead of wrapping in a Group
    results_tabs = gr.Tabs(visible=False)
    
    # Executive Summary Tab
    with results_tabs:
        with gr.TabItem("Executive Summary"):
            gr.Markdown("### πŸ“Š Analysis Results")
            with gr.Row():
                with gr.Column(scale=2):
                    gr.Markdown("#### πŸ“ Overview")
                    summary_text = gr.Markdown("")
                
                with gr.Column(scale=1):
                    gr.Markdown("#### πŸ“ˆ Key Metrics")
                    with gr.Row():
                        gr.Label("Code Quality Score", value="N/A")
                    with gr.Row():
                        gr.Label("Security Score", value="N/A")
                    with gr.Row():
                        gr.Label("Performance Score", value="N/A")
        
        # Technical Details Tab
        with gr.TabItem("Technical Details"):
            with gr.Accordion("Repository Structure", open=True):
                repo_structure = gr.Markdown("")
            
            with gr.Accordion("Language Breakdown", open=True):
                language_breakdown = gr.BarPlot(
                    x="Language",
                    y="Lines of Code",
                    title="Language Distribution",
                    tooltip=["Language", "Lines of Code"],
                    height=300,
                )
            
            with gr.Accordion("Code Quality Issues", open=True):
                quality_issues = gr.Dataframe(
                    headers=["File", "Line", "Issue", "Severity", "Description"],
                    datatype=["str", "number", "str", "str", "str"],
                    row_count=10,
                )
        
        # Security Analysis Tab
        with gr.TabItem("Security Analysis"):
            with gr.Accordion("Vulnerabilities", open=True):
                vulnerabilities = gr.Dataframe(
                    headers=["File", "Line", "Vulnerability", "Severity", "Description", "Recommendation"],
                    datatype=["str", "number", "str", "str", "str", "str"],
                    row_count=10,
                )
            
            with gr.Accordion("Dependency Issues", open=True):
                dependency_issues = gr.Dataframe(
                    headers=["Package", "Current Version", "Recommended Version", "Vulnerability", "Severity"],
                    datatype=["str", "str", "str", "str", "str"],
                    row_count=10,
                )
        
        # Performance Analysis Tab
        with gr.TabItem("Performance Analysis"):
            with gr.Accordion("Performance Hotspots", open=True):
                performance_hotspots = gr.Dataframe(
                    headers=["File", "Function", "Issue", "Impact", "Recommendation"],
                    datatype=["str", "str", "str", "str", "str"],
                    row_count=10,
                )
            
            with gr.Accordion("Resource Usage", open=True):
                resource_usage = gr.BarPlot(
                    x="Component",
                    y="Usage",
                    title="Resource Usage",
                    tooltip=["Component", "Usage"],
                    height=300,
                )
        
        # Recommendations Tab
        with gr.TabItem("Recommendations"):
            with gr.Accordion("High Priority", open=True):
                high_priority_recs = gr.Markdown("")
            
            with gr.Accordion("Medium Priority", open=True):
                medium_priority_recs = gr.Markdown("")
            
            with gr.Accordion("Low Priority", open=True):
                low_priority_recs = gr.Markdown("")
    
    return results_tabs