Add USB, Notifications, Network plugins and reusable EmployeeSearch component
New Plugins: - USB plugin: Device checkout/checkin with employee lookup, checkout history - Notifications plugin: Announcements with types, scheduling, shopfloor display - Network plugin: Network device management with subnets and VLANs - Equipment and Computers plugins: Asset type separation Frontend: - EmployeeSearch component: Reusable employee lookup with autocomplete - USB views: List, detail, checkout/checkin modals - Notifications views: List, form with recognition mode - Network views: Device list, detail, form - Calendar view with FullCalendar integration - Shopfloor and TV dashboard views - Reports index page - Map editor for asset positioning - Light/dark mode fixes for map tooltips Backend: - Employee search API with external lookup service - Collector API for PowerShell data collection - Reports API endpoints - Slides API for TV dashboard - Fixed AppVersion model (removed BaseModel inheritance) - Added checkout_name column to usbcheckouts table Styling: - Unified detail page styles - Improved pagination (page numbers instead of prev/next) - Dark/light mode theme improvements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
121
plugins/network/models/network_device.py
Normal file
121
plugins/network/models/network_device.py
Normal file
@@ -0,0 +1,121 @@
|
||||
"""Network device plugin models."""
|
||||
|
||||
from shopdb.extensions import db
|
||||
from shopdb.core.models.base import BaseModel
|
||||
|
||||
|
||||
class NetworkDeviceType(BaseModel):
|
||||
"""
|
||||
Network device type classification.
|
||||
|
||||
Examples: Switch, Router, Access Point, Camera, IDF, Firewall, etc.
|
||||
"""
|
||||
__tablename__ = 'networkdevicetypes'
|
||||
|
||||
networkdevicetypeid = db.Column(db.Integer, primary_key=True)
|
||||
networkdevicetype = db.Column(db.String(100), unique=True, nullable=False)
|
||||
description = db.Column(db.Text)
|
||||
icon = db.Column(db.String(50), comment='Icon name for UI')
|
||||
|
||||
def __repr__(self):
|
||||
return f"<NetworkDeviceType {self.networkdevicetype}>"
|
||||
|
||||
|
||||
class NetworkDevice(BaseModel):
|
||||
"""
|
||||
Network device-specific extension data.
|
||||
|
||||
Links to core Asset table via assetid.
|
||||
Stores network device-specific fields like hostname, firmware, ports, etc.
|
||||
"""
|
||||
__tablename__ = 'networkdevices'
|
||||
|
||||
networkdeviceid = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Link to core asset
|
||||
assetid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('assets.assetid', ondelete='CASCADE'),
|
||||
unique=True,
|
||||
nullable=False,
|
||||
index=True
|
||||
)
|
||||
|
||||
# Network device classification
|
||||
networkdevicetypeid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('networkdevicetypes.networkdevicetypeid'),
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Vendor
|
||||
vendorid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('vendors.vendorid'),
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Network identity
|
||||
hostname = db.Column(
|
||||
db.String(100),
|
||||
index=True,
|
||||
comment='Network hostname'
|
||||
)
|
||||
|
||||
# Firmware/software version
|
||||
firmwareversion = db.Column(db.String(100), nullable=True)
|
||||
|
||||
# Physical characteristics
|
||||
portcount = db.Column(
|
||||
db.Integer,
|
||||
nullable=True,
|
||||
comment='Number of ports (for switches)'
|
||||
)
|
||||
|
||||
# Features
|
||||
ispoe = db.Column(
|
||||
db.Boolean,
|
||||
default=False,
|
||||
comment='Power over Ethernet capable'
|
||||
)
|
||||
ismanaged = db.Column(
|
||||
db.Boolean,
|
||||
default=False,
|
||||
comment='Managed device (SNMP, web interface, etc.)'
|
||||
)
|
||||
|
||||
# For IDF/closet locations
|
||||
rackunit = db.Column(
|
||||
db.String(20),
|
||||
nullable=True,
|
||||
comment='Rack unit position (e.g., U1, U5)'
|
||||
)
|
||||
|
||||
# Relationships
|
||||
asset = db.relationship(
|
||||
'Asset',
|
||||
backref=db.backref('network_device', uselist=False, lazy='joined')
|
||||
)
|
||||
networkdevicetype = db.relationship('NetworkDeviceType', backref='networkdevices')
|
||||
vendor = db.relationship('Vendor', backref='network_devices')
|
||||
|
||||
__table_args__ = (
|
||||
db.Index('idx_netdev_type', 'networkdevicetypeid'),
|
||||
db.Index('idx_netdev_hostname', 'hostname'),
|
||||
db.Index('idx_netdev_vendor', 'vendorid'),
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<NetworkDevice {self.hostname or self.assetid}>"
|
||||
|
||||
def to_dict(self):
|
||||
"""Convert to dictionary with related names."""
|
||||
result = super().to_dict()
|
||||
|
||||
# Add related object names
|
||||
if self.networkdevicetype:
|
||||
result['networkdevicetype_name'] = self.networkdevicetype.networkdevicetype
|
||||
if self.vendor:
|
||||
result['vendor_name'] = self.vendor.vendor
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user