File size: 4,284 Bytes
2929135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
111
112
113
114
115
116
117
118
119
120
121
import streamlit as st
from typing import Dict, Any, Callable
from datetime import datetime, timedelta

class SidebarComponent:
    def __init__(self, on_filter_change: Optional[Callable] = None):
        """
        Initialize the sidebar component
        
        Args:
            on_filter_change: Optional callback for filter changes
        """
        self.on_filter_change = on_filter_change
        
        # Initialize session state for filters if not exists
        if 'filters' not in st.session_state:
            st.session_state.filters = {
                'department': 'All Departments',
                'priority': 'Medium',
                'time_range': 8,
                'view_mode': 'Standard'
            }

    def render(self):
        """Render the sidebar"""
        with st.sidebar:
            st.markdown("# βš™οΈ Operations Control")
            
            # Department Selection
            st.markdown("### πŸ₯ Department")
            department = st.selectbox(
                "Select Department",
                [
                    "All Departments",
                    "Emergency Room",
                    "ICU",
                    "General Ward",
                    "Surgery",
                    "Pediatrics",
                    "Cardiology"
                ],
                index=0,
                help="Filter data by department"
            )

            # Priority Filter
            st.markdown("### 🎯 Priority Level")
            priority = st.select_slider(
                "Set Priority",
                options=["Low", "Medium", "High", "Urgent", "Critical"],
                value=st.session_state.filters['priority'],
                help="Filter by priority level"
            )

            # Time Range
            st.markdown("### πŸ•’ Time Range")
            time_range = st.slider(
                "Select Time Range",
                min_value=1,
                max_value=24,
                value=st.session_state.filters['time_range'],
                help="Time range for data analysis (hours)"
            )

            # View Mode
            st.markdown("### πŸ‘οΈ View Mode")
            view_mode = st.radio(
                "Select View Mode",
                ["Standard", "Detailed", "Compact"],
                help="Change the display density"
            )

            # Quick Actions
            st.markdown("### ⚑ Quick Actions")
            col1, col2 = st.columns(2)
            with col1:
                if st.button("πŸ“Š Report", use_container_width=True):
                    st.info("Generating report...")
            with col2:
                if st.button("πŸ”„ Refresh", use_container_width=True):
                    st.success("Data refreshed!")

            # Emergency Mode Toggle
            st.markdown("### 🚨 Emergency Mode")
            emergency_mode = st.toggle(
                "Activate Emergency Protocol",
                help="Enable emergency mode for critical situations"
            )
            if emergency_mode:
                st.warning("Emergency Mode Active!")

            # Help & Documentation
            with st.expander("❓ Help & Tips"):
                st.markdown("""
                    ### Quick Guide
                    - πŸ” Use filters to focus on specific areas
                    - πŸ“ˆ Monitor real-time metrics
                    - 🚨 Toggle emergency mode for critical situations
                    - πŸ“Š Generate reports for analysis
                    - πŸ’‘ Access quick actions for common tasks
                """)

            # Update filters in session state
            st.session_state.filters.update({
                'department': department,
                'priority': priority,
                'time_range': time_range,
                'view_mode': view_mode,
                'emergency_mode': emergency_mode
            })

            # Call filter change callback if provided
            if self.on_filter_change:
                self.on_filter_change(st.session_state.filters)

            # Footer
            st.markdown("---")
            st.markdown(
                f"*Last updated: {datetime.now().strftime('%H:%M:%S')}*",
                help="Last data refresh timestamp"
            )