ci: fix lint/type errors - missing electrical icons, unused vars, mypy issues
This commit is contained in:
@@ -42,7 +42,7 @@ async def load_canvas(
|
|||||||
@router.post("/save")
|
@router.post("/save")
|
||||||
async def save_canvas(
|
async def save_canvas(
|
||||||
body: CanvasSaveRequest, db: AsyncSession = Depends(get_db), _: str = Depends(get_current_user)
|
body: CanvasSaveRequest, db: AsyncSession = Depends(get_db), _: str = Depends(get_current_user)
|
||||||
) -> dict[str, bool]:
|
) -> dict[str, bool | str]:
|
||||||
design_id = body.design_id
|
design_id = body.design_id
|
||||||
if design_id is None:
|
if design_id is None:
|
||||||
first = (await db.execute(select(Design).order_by(Design.created_at).limit(1))).scalar()
|
first = (await db.execute(select(Design).order_by(Design.created_at).limit(1))).scalar()
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ async def init_db() -> None:
|
|||||||
# Seed default Network Topology design if designs table is empty
|
# Seed default Network Topology design if designs table is empty
|
||||||
_default_design_id = str(_uuid_mod.uuid4())
|
_default_design_id = str(_uuid_mod.uuid4())
|
||||||
row = await conn.exec_driver_sql("SELECT COUNT(*) FROM designs")
|
row = await conn.exec_driver_sql("SELECT COUNT(*) FROM designs")
|
||||||
count = (await row.fetchone())[0]
|
count = (row.fetchone())[0]
|
||||||
if count == 0:
|
if count == 0:
|
||||||
await conn.exec_driver_sql(
|
await conn.exec_driver_sql(
|
||||||
"INSERT INTO designs (id, name, design_type, created_at, updated_at) "
|
"INSERT INTO designs (id, name, design_type, created_at, updated_at) "
|
||||||
@@ -195,7 +195,7 @@ async def init_db() -> None:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row2 = await conn.exec_driver_sql("SELECT id FROM designs WHERE design_type = 'network' LIMIT 1")
|
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
|
_default_design_id = default[0] if default else _default_design_id
|
||||||
|
|
||||||
# Add design_id to nodes
|
# 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 "
|
"SELECT id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware "
|
||||||
"FROM nodes WHERE properties IS NULL"
|
"FROM nodes WHERE properties IS NULL"
|
||||||
)
|
)
|
||||||
for row in rows.fetchall():
|
for r in rows.fetchall():
|
||||||
node_id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware = row
|
node_id, cpu_model, cpu_count, ram_gb, disk_gb, show_hardware = r
|
||||||
props = []
|
props = []
|
||||||
visible = bool(show_hardware)
|
visible = bool(show_hardware)
|
||||||
if cpu_model:
|
if cpu_model:
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default function App() {
|
|||||||
const canvasRef = useRef<HTMLDivElement>(null)
|
const canvasRef = useRef<HTMLDivElement>(null)
|
||||||
const { isAuthenticated } = useAuthStore()
|
const { isAuthenticated } = useAuthStore()
|
||||||
const { activeTheme, setTheme, customStyle, setCustomStyle } = useThemeStore()
|
const { activeTheme, setTheme, customStyle, setCustomStyle } = useThemeStore()
|
||||||
const { designs, activeDesignId, activeDesignType, setDesigns, setActiveDesign } = useDesignStore()
|
const { activeDesignId, setDesigns, setActiveDesign } = useDesignStore()
|
||||||
|
|
||||||
useStatusPolling()
|
useStatusPolling()
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
|
|||||||
import { useCanvasStore } from '@/stores/canvasStore'
|
import { useCanvasStore } from '@/stores/canvasStore'
|
||||||
import { useDesignStore } from '@/stores/designStore'
|
import { useDesignStore } from '@/stores/designStore'
|
||||||
import { useAuthStore } from '@/stores/authStore'
|
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 { toast } from 'sonner'
|
||||||
import { useLatestRelease } from '@/hooks/useLatestRelease'
|
import { useLatestRelease } from '@/hooks/useLatestRelease'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import {
|
|||||||
Mail, MessageSquare, Phone,
|
Mail, MessageSquare, Phone,
|
||||||
// Misc devices
|
// Misc devices
|
||||||
Printer, Smartphone, Laptop, Search, Filter, BookOpen, PlugZap, Type,
|
Printer, Smartphone, Laptop, Search, Filter, BookOpen, PlugZap, Type,
|
||||||
|
// Electrical
|
||||||
|
ToggleLeft,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import type { LucideIcon } from 'lucide-react'
|
import type { LucideIcon } from 'lucide-react'
|
||||||
|
|
||||||
@@ -154,32 +156,46 @@ export const ICON_MAP: Record<string, LucideIcon> = Object.fromEntries(
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const NODE_TYPE_DEFAULT_ICONS: Record<NodeType, LucideIcon> = {
|
export const NODE_TYPE_DEFAULT_ICONS: Record<NodeType, LucideIcon> = {
|
||||||
isp: Globe,
|
isp: Globe,
|
||||||
router: Router,
|
router: Router,
|
||||||
firewall: Flame,
|
firewall: Flame,
|
||||||
switch: Network,
|
switch: Network,
|
||||||
server: Server,
|
server: Server,
|
||||||
proxmox: Layers,
|
proxmox: Layers,
|
||||||
vm: Box,
|
vm: Box,
|
||||||
lxc: Container,
|
lxc: Container,
|
||||||
nas: HardDrive,
|
nas: HardDrive,
|
||||||
iot: Cpu,
|
iot: Cpu,
|
||||||
ap: Wifi,
|
ap: Wifi,
|
||||||
camera: Cctv,
|
camera: Cctv,
|
||||||
printer: Printer,
|
printer: Printer,
|
||||||
computer: Monitor,
|
computer: Monitor,
|
||||||
laptop: Laptop,
|
laptop: Laptop,
|
||||||
mobile: Smartphone,
|
mobile: Smartphone,
|
||||||
cpl: PlugZap,
|
cpl: PlugZap,
|
||||||
docker_host: Anchor,
|
docker_host: Anchor,
|
||||||
docker_container: Package,
|
docker_container: Package,
|
||||||
zigbee_coordinator: Radio,
|
zigbee_coordinator: Radio,
|
||||||
zigbee_router: Zap,
|
zigbee_router: Zap,
|
||||||
zigbee_enddevice: Lightbulb,
|
zigbee_enddevice: Lightbulb,
|
||||||
generic: Circle,
|
generic: Circle,
|
||||||
group: Circle,
|
group: Circle,
|
||||||
groupRect: Circle,
|
groupRect: Circle,
|
||||||
text: Type,
|
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.
|
/** Resolve the display icon for a node — custom_icon takes priority over type default.
|
||||||
|
|||||||
Reference in New Issue
Block a user