////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: /Data/WebUI/src/Navigation_Sidebar.jsx import React, { useState } from "react"; import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, ListItemButton, ListItemText } from "@mui/material"; import { ExpandMore as ExpandMoreIcon, Devices as DevicesIcon, FilterAlt as FilterIcon, Groups as GroupsIcon, Work as JobsIcon, Polyline as WorkflowsIcon, Code as ScriptIcon, PeopleOutline as CommunityIcon, Apps as AssembliesIcon } from "@mui/icons-material"; import { LocationCity as SitesIcon } from "@mui/icons-material"; import { ManageAccounts as AdminUsersIcon, Dns as ServerInfoIcon } from "@mui/icons-material"; function NavigationSidebar({ currentPage, onNavigate, isAdmin = false }) { const [expandedNav, setExpandedNav] = useState({ sites: true, devices: true, automation: true, filters: true, admin: true }); const NavItem = ({ icon, label, pageKey, indent = 0 }) => { const active = currentPage === pageKey; return ( onNavigate(pageKey)} sx={{ pl: indent ? 4 : 2, py: 1, color: active ? "#e6f2ff" : "#ccc", position: "relative", background: active ? "linear-gradient(90deg, rgba(88,166,255,0.10) 0%, rgba(88,166,255,0.03) 60%, rgba(88,166,255,0.00) 100%)" : "transparent", borderTopRightRadius: 0, borderBottomRightRadius: 0, boxShadow: active ? "inset 0 0 0 1px rgba(88,166,255,0.25)" : "none", transition: "background 160ms ease, box-shadow 160ms ease, color 160ms ease", "&:hover": { background: active ? "linear-gradient(90deg, rgba(88,166,255,0.14) 0%, rgba(88,166,255,0.06) 60%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c" } }} selected={active} > {icon && ( {icon} )} ); }; return ( {/* Sites */} {(() => { const groupActive = currentPage === "sites"; return ( setExpandedNav((s) => ({ ...s, sites: e }))} square disableGutters sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }} > } sx={{ position: "relative", background: groupActive ? "linear-gradient(90deg, rgba(88,166,255,0.08) 0%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c", minHeight: "36px", "& .MuiAccordionSummary-content": { margin: 0 }, "&::before": { content: '""', position: "absolute", left: 0, top: 0, bottom: 0, width: groupActive ? 3 : 0, bgcolor: "#58a6ff", borderTopRightRadius: 2, borderBottomRightRadius: 2, transition: "width 160ms ease" } }} > Sites } label="All Sites" pageKey="sites" /> ); })()} {/* Devices */} {(() => { const groupActive = currentPage === "devices"; return ( setExpandedNav((s) => ({ ...s, devices: e }))} square disableGutters sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }} > } sx={{ position: "relative", background: groupActive ? "linear-gradient(90deg, rgba(88,166,255,0.08) 0%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c", minHeight: "36px", "& .MuiAccordionSummary-content": { margin: 0 }, "&::before": { content: '""', position: "absolute", left: 0, top: 0, bottom: 0, width: groupActive ? 3 : 0, bgcolor: "#58a6ff", borderTopRightRadius: 2, borderBottomRightRadius: 2, transition: "width 160ms ease" } }} > Devices } label="Devices" pageKey="devices" /> ); })()} {/* Automation */} {(() => { const groupActive = ["jobs", "assemblies", "community"].includes(currentPage); return ( setExpandedNav((s) => ({ ...s, automation: e }))} square disableGutters sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }} > } sx={{ position: "relative", background: groupActive ? "linear-gradient(90deg, rgba(88,166,255,0.08) 0%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c", minHeight: "36px", "& .MuiAccordionSummary-content": { margin: 0 }, "&::before": { content: '""', position: "absolute", left: 0, top: 0, bottom: 0, width: groupActive ? 3 : 0, bgcolor: "#58a6ff", borderTopRightRadius: 2, borderBottomRightRadius: 2, transition: "width 160ms ease" } }} > Automation } label="Assemblies" pageKey="assemblies" /> } label="Community Content" pageKey="community" /> } label="Scheduled Jobs" pageKey="jobs" /> ); })()} {/* Filters & Groups */} {(() => { const groupActive = currentPage === "filters" || currentPage === "groups"; return ( setExpandedNav((s) => ({ ...s, filters: e }))} square disableGutters sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }} > } sx={{ position: "relative", background: groupActive ? "linear-gradient(90deg, rgba(88,166,255,0.08) 0%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c", minHeight: "36px", "& .MuiAccordionSummary-content": { margin: 0 }, "&::before": { content: '""', position: "absolute", left: 0, top: 0, bottom: 0, width: groupActive ? 3 : 0, bgcolor: "#58a6ff", borderTopRightRadius: 2, borderBottomRightRadius: 2, transition: "width 160ms ease" } }} > Filters & Groups } label="Filters" pageKey="filters" /> } label="Groups" pageKey="groups" /> ); })()} {/* Admin */} {(() => { if (!isAdmin) return null; const groupActive = currentPage === "admin_users" || currentPage === "server_info"; return ( setExpandedNav((s) => ({ ...s, admin: e }))} square disableGutters sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }} > } sx={{ position: "relative", background: groupActive ? "linear-gradient(90deg, rgba(88,166,255,0.08) 0%, rgba(88,166,255,0.00) 100%)" : "#2c2c2c", minHeight: "36px", "& .MuiAccordionSummary-content": { margin: 0 }, "&::before": { content: '""', position: "absolute", left: 0, top: 0, bottom: 0, width: groupActive ? 3 : 0, bgcolor: "#58a6ff", borderTopRightRadius: 2, borderBottomRightRadius: 2, transition: "width 160ms ease" } }} > Admin Settings } label="User Management" pageKey="admin_users" /> } label="Server Info" pageKey="server_info" /> ); })()} ); } export default React.memo(NavigationSidebar);