From d5e35a885d3daa7e536634026428040cd82c6f08 Mon Sep 17 00:00:00 2001 From: Pranjal Joshi Date: Sun, 31 May 2026 14:53:38 +0530 Subject: [PATCH] ci: fix lint/type errors - missing electrical icons, unused vars, mypy issues --- backend/app/api/routes/canvas.py | 2 +- backend/app/db/database.py | 8 +-- frontend/src/App.tsx | 2 +- frontend/src/components/panels/Sidebar.tsx | 2 +- frontend/src/utils/nodeIcons.ts | 60 ++++++++++++++-------- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/backend/app/api/routes/canvas.py b/backend/app/api/routes/canvas.py index 303a804..d4aafbd 100644 --- a/backend/app/api/routes/canvas.py +++ b/backend/app/api/routes/canvas.py @@ -42,7 +42,7 @@ async def load_canvas( @router.post("/save") async def save_canvas( body: CanvasSaveRequest, db: AsyncSession = Depends(get_db), _: str = Depends(get_current_user) -) -> dict[str, bool]: +) -> dict[str, bool | str]: design_id = body.design_id if design_id is None: first = (await db.execute(select(Design).order_by(Design.created_at).limit(1))).scalar() diff --git a/backend/app/db/database.py b/backend/app/db/database.py index 4a96874..290f717 100644 --- a/backend/app/db/database.py +++ b/backend/app/db/database.py @@ -186,7 +186,7 @@ async def init_db() -> None: # Seed default Network Topology design if designs table is empty _default_design_id = str(_uuid_mod.uuid4()) row = await conn.exec_driver_sql("SELECT COUNT(*) FROM designs") - count = (await row.fetchone())[0] + count = (row.fetchone())[0] if count == 0: await conn.exec_driver_sql( "INSERT INTO designs (id, name, design_type, created_at, updated_at) " @@ -195,7 +195,7 @@ async def init_db() -> None: ) else: row2 = await conn.exec_driver_sql("SELECT id FROM designs WHERE design_type = 'network' LIMIT 1") - default = await row2.fetchone() + default = row2.fetchone() _default_design_id = default[0] if default else _default_design_id # Add design_id to nodes @@ -261,8 +261,8 @@ async def init_db() -> None: "SELECT id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware " "FROM nodes WHERE properties IS NULL" ) - for row in rows.fetchall(): - node_id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware = row + for r in rows.fetchall(): + node_id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware = r props = [] visible = bool(show_hardware) if cpu_model: diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ab5295b..d56bf46 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -45,7 +45,7 @@ export default function App() { const canvasRef = useRef(null) const { isAuthenticated } = useAuthStore() const { activeTheme, setTheme, customStyle, setCustomStyle } = useThemeStore() - const { designs, activeDesignId, activeDesignType, setDesigns, setActiveDesign } = useDesignStore() + const { activeDesignId, setDesigns, setActiveDesign } = useDesignStore() useStatusPolling() diff --git a/frontend/src/components/panels/Sidebar.tsx b/frontend/src/components/panels/Sidebar.tsx index b86eca0..c0f1e0b 100644 --- a/frontend/src/components/panels/Sidebar.tsx +++ b/frontend/src/components/panels/Sidebar.tsx @@ -5,7 +5,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip import { useCanvasStore } from '@/stores/canvasStore' import { useDesignStore } from '@/stores/designStore' import { useAuthStore } from '@/stores/authStore' -import { canvasApi, designsApi, scanApi, settingsApi } from '@/api/client' +import { designsApi, scanApi, settingsApi } from '@/api/client' import { toast } from 'sonner' import { useLatestRelease } from '@/hooks/useLatestRelease' import { diff --git a/frontend/src/utils/nodeIcons.ts b/frontend/src/utils/nodeIcons.ts index 6a5d2a3..e7ea3a5 100644 --- a/frontend/src/utils/nodeIcons.ts +++ b/frontend/src/utils/nodeIcons.ts @@ -25,6 +25,8 @@ import { Mail, MessageSquare, Phone, // Misc devices Printer, Smartphone, Laptop, Search, Filter, BookOpen, PlugZap, Type, + // Electrical + ToggleLeft, } from 'lucide-react' import type { LucideIcon } from 'lucide-react' @@ -154,32 +156,46 @@ export const ICON_MAP: Record = Object.fromEntries( ) export const NODE_TYPE_DEFAULT_ICONS: Record = { - isp: Globe, - router: Router, - firewall: Flame, - switch: Network, - server: Server, - proxmox: Layers, - vm: Box, - lxc: Container, - nas: HardDrive, - iot: Cpu, - ap: Wifi, - camera: Cctv, - printer: Printer, - computer: Monitor, - laptop: Laptop, - mobile: Smartphone, - cpl: PlugZap, - docker_host: Anchor, - docker_container: Package, + isp: Globe, + router: Router, + firewall: Flame, + switch: Network, + server: Server, + proxmox: Layers, + vm: Box, + lxc: Container, + nas: HardDrive, + iot: Cpu, + ap: Wifi, + camera: Cctv, + printer: Printer, + computer: Monitor, + laptop: Laptop, + mobile: Smartphone, + cpl: PlugZap, + docker_host: Anchor, + docker_container: Package, zigbee_coordinator: Radio, zigbee_router: Zap, zigbee_enddevice: Lightbulb, generic: Circle, - group: Circle, - groupRect: Circle, - text: Type, + group: Circle, + groupRect: Circle, + text: Type, + grid: Zap, + ups: Power, + battery: BatteryCharging, + generator: Fan, + solar_panel: Sun, + inverter: Workflow, + circuit_breaker: PlugZap, + contactor: ToggleLeft, + electrical_switch: ToggleLeft, + socket: Plug, + light: Lightbulb, + meter: Gauge, + transformer: CircleDot, + load: Circle, } /** Resolve the display icon for a node — custom_icon takes priority over type default.