FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
AppRail.tsx
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
3
4import PlayArrowIcon from '@mui/icons-material/PlayArrow';
5import SettingsIcon from '@mui/icons-material/Settings';
6import TerminalIcon from '@mui/icons-material/Terminal';
7import ViewInArIcon from '@mui/icons-material/ViewInAr';
8import WidgetsIcon from '@mui/icons-material/Widgets';
9import {
10 Badge,
11 Box,
12 List,
13 ListItemButton,
14 ListItemIcon,
15 Tooltip,
16} from '@mui/material';
17import { useFersLogStore } from '@/stores/fersLogStore';
18
19interface AppRailProps {
20 activeView: string;
21 onViewChange: (view: string) => void;
22 onSettingsClick: () => void;
23}
24
25const views = [
26 { id: 'scenario', label: 'Scenario Builder', icon: <ViewInArIcon /> },
27 { id: 'assets', label: 'Asset Library', icon: <WidgetsIcon /> },
28 { id: 'simulation', label: 'Simulation Run', icon: <PlayArrowIcon /> },
29];
30
31export default function AppRail({
32 activeView,
33 onViewChange,
34 onSettingsClick,
35}: AppRailProps) {
36 const logOpen = useFersLogStore((state) => state.isOpen);
37 const toggleLogOpen = useFersLogStore((state) => state.toggleOpen);
38 const logCount = useFersLogStore((state) => state.entries.length);
39
40 return (
41 <Box
42 sx={{
43 width: 60,
44 height: '100%', // Use percentage instead of vh
45 display: 'flex',
46 flexDirection: 'column',
47 alignItems: 'center',
48 borderRight: 1,
49 borderColor: 'divider',
50 bgcolor: 'background.paper',
51 flexShrink: 0,
52 overflow: 'hidden', // Prevent overflow
53 }}
54 >
55 <List sx={{ flexGrow: 1, overflow: 'auto', width: '100%' }}>
56 {views.map((view) => (
57 <Tooltip title={view.label} placement="right" key={view.id}>
58 <ListItemButton
59 selected={activeView === view.id}
60 onClick={() => onViewChange(view.id)}
61 sx={{
62 my: 1,
63 justifyContent: 'center',
64 borderRadius: 2,
65 '&.Mui-selected': {
66 backgroundColor: 'action.selected',
67 },
68 }}
69 >
70 <ListItemIcon sx={{ minWidth: 0 }}>
71 {view.icon}
72 </ListItemIcon>
73 </ListItemButton>
74 </Tooltip>
75 ))}
76 </List>
77 <Box sx={{ pb: 1 }}>
78 <Tooltip title="Raw logs" placement="right">
79 <ListItemButton
80 selected={logOpen}
81 onClick={toggleLogOpen}
82 sx={{
83 my: 1,
84 justifyContent: 'center',
85 '&.Mui-selected': {
86 backgroundColor: 'action.selected',
87 },
88 }}
89 >
90 <ListItemIcon sx={{ minWidth: 0 }}>
91 <Badge
92 badgeContent={logCount}
93 max={999}
94 color="secondary"
95 invisible={logCount === 0}
96 >
97 <TerminalIcon />
98 </Badge>
99 </ListItemIcon>
100 </ListItemButton>
101 </Tooltip>
102 <Tooltip title="Settings" placement="right">
103 <ListItemButton
104 onClick={onSettingsClick}
105 sx={{ my: 1, justifyContent: 'center' }}
106 >
107 <ListItemIcon sx={{ minWidth: 0 }}>
108 <SettingsIcon />
109 </ListItemIcon>
110 </ListItemButton>
111 </Tooltip>
112 </Box>
113 </Box>
114 );
115}