FERS 0.1.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 InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
5import PlayArrowIcon from '@mui/icons-material/PlayArrow';
6import PodcastsIcon from '@mui/icons-material/Podcasts';
7import SettingsIcon from '@mui/icons-material/Settings';
8import TerminalIcon from '@mui/icons-material/Terminal';
9import ViewInArIcon from '@mui/icons-material/ViewInAr';
10import WidgetsIcon from '@mui/icons-material/Widgets';
11import {
12 Badge,
13 Box,
14 List,
15 ListItemButton,
16 ListItemIcon,
17 Tooltip,
18} from '@mui/material';
19import { useFersLogStore } from '@/stores/fersLogStore';
20
21interface AppRailProps {
22 activeView: string;
23 onViewChange: (view: string) => void;
24 onSettingsClick: () => void;
25 onAboutClick: () => void;
26}
27
28const views = [
29 { id: 'scenario', label: 'Scenario Builder', icon: <ViewInArIcon /> },
30 { id: 'assets', label: 'Asset Library', icon: <WidgetsIcon /> },
31 { id: 'simulation', label: 'Simulation Run', icon: <PlayArrowIcon /> },
32 { id: 'vita49', label: 'VITA49 Streams', icon: <PodcastsIcon /> },
33];
34
35export default function AppRail({
36 activeView,
37 onViewChange,
38 onSettingsClick,
39 onAboutClick,
40}: AppRailProps) {
41 const logOpen = useFersLogStore((state) => state.isOpen);
42 const toggleLogOpen = useFersLogStore((state) => state.toggleOpen);
43 const logCount = useFersLogStore((state) => state.entries.length);
44
45 return (
46 <Box
47 sx={{
48 width: 60,
49 height: '100%',
50 display: 'flex',
51 flexDirection: 'column',
52 alignItems: 'center',
53 borderRight: 1,
54 borderColor: 'divider',
55 bgcolor: 'background.paper',
56 flexShrink: 0,
57 overflow: 'hidden',
58 }}
59 >
60 <List sx={{ flexGrow: 1, overflow: 'auto', width: '100%' }}>
61 {views.map((view) => (
62 <Tooltip title={view.label} placement="right" key={view.id}>
63 <ListItemButton
64 selected={activeView === view.id}
65 onClick={() => onViewChange(view.id)}
66 sx={{
67 my: 1,
68 justifyContent: 'center',
69 borderRadius: 2,
70 '&.Mui-selected': {
71 backgroundColor: 'action.selected',
72 },
73 }}
74 >
75 <ListItemIcon sx={{ minWidth: 0 }}>
76 {view.icon}
77 </ListItemIcon>
78 </ListItemButton>
79 </Tooltip>
80 ))}
81 </List>
82 <Box sx={{ pb: 1 }}>
83 <Tooltip title="Raw logs" placement="right">
84 <ListItemButton
85 selected={logOpen}
86 onClick={toggleLogOpen}
87 sx={{
88 my: 1,
89 justifyContent: 'center',
90 '&.Mui-selected': {
91 backgroundColor: 'action.selected',
92 },
93 }}
94 >
95 <ListItemIcon sx={{ minWidth: 0 }}>
96 <Badge
97 badgeContent={logCount}
98 max={999}
99 color="secondary"
100 invisible={logCount === 0}
101 >
102 <TerminalIcon />
103 </Badge>
104 </ListItemIcon>
105 </ListItemButton>
106 </Tooltip>
107 <Tooltip title="Settings" placement="right">
108 <ListItemButton
109 onClick={onSettingsClick}
110 sx={{ my: 1, justifyContent: 'center' }}
111 >
112 <ListItemIcon sx={{ minWidth: 0 }}>
113 <SettingsIcon />
114 </ListItemIcon>
115 </ListItemButton>
116 </Tooltip>
117 <Tooltip title="About" placement="right">
118 <ListItemButton
119 onClick={onAboutClick}
120 sx={{ my: 1, justifyContent: 'center' }}
121 >
122 <ListItemIcon sx={{ minWidth: 0 }}>
123 <InfoOutlinedIcon />
124 </ListItemIcon>
125 </ListItemButton>
126 </Tooltip>
127 </Box>
128 </Box>
129 );
130}