Add print badges, pagination, route splitting, JWT auth fixes, and list page alignment
- Fix equipment badge barcode not rendering (loading race condition) - Fix printer QR code not rendering on initial load (same race condition) - Add model image to equipment badge via imageurl from Model table - Fix white-on-white machine number text on badge, tighten barcode spacing - Add PaginationBar component used across all list pages - Split monolithic router into per-plugin route modules - Fix 25 GET API endpoints returning 401 (jwt_required -> optional=True) - Align list page columns across Equipment, PCs, and Network pages - Add print views: EquipmentBadge, PrinterQRSingle, PrinterQRBatch, USBLabelBatch - Add PC Relationships report, migration docs, and CLAUDE.md project guide - Various plugin model, API, and frontend refinements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -161,10 +161,10 @@ def get_usb_device(device_id: int):
|
||||
# Get recent checkout history
|
||||
checkouts = USBCheckout.query.filter_by(
|
||||
usbdeviceid=device_id
|
||||
).order_by(USBCheckout.checkout_time.desc()).limit(20).all()
|
||||
).order_by(USBCheckout.checkouttime.desc()).limit(20).all()
|
||||
|
||||
result = device.to_dict()
|
||||
result['checkout_history'] = [c.to_dict() for c in checkouts]
|
||||
result['checkouthistory'] = [c.to_dict() for c in checkouts]
|
||||
|
||||
return success_response(result)
|
||||
|
||||
@@ -258,16 +258,16 @@ def checkout_device(device_id: int):
|
||||
usbdeviceid=device_id,
|
||||
machineid=0, # Legacy field, set to 0 for new checkouts
|
||||
sso=data['sso'],
|
||||
checkout_name=data.get('checkout_name'),
|
||||
checkout_time=datetime.utcnow(),
|
||||
checkout_reason=data.get('checkout_reason'),
|
||||
was_wiped=False
|
||||
checkoutname=data.get('checkoutname'),
|
||||
checkouttime=datetime.utcnow(),
|
||||
checkoutreason=data.get('checkoutreason'),
|
||||
waswiped=False
|
||||
)
|
||||
|
||||
# Update device status
|
||||
device.ischeckedout = True
|
||||
device.currentuserid = data['sso']
|
||||
device.currentusername = data.get('checkout_name')
|
||||
device.currentusername = data.get('checkoutname')
|
||||
device.currentcheckoutdate = datetime.utcnow()
|
||||
device.modifieddate = datetime.utcnow()
|
||||
|
||||
@@ -300,15 +300,15 @@ def checkin_device(device_id: int):
|
||||
# Find active checkout
|
||||
active_checkout = USBCheckout.query.filter_by(
|
||||
usbdeviceid=device_id,
|
||||
checkin_time=None
|
||||
checkintime=None
|
||||
).first()
|
||||
|
||||
data = request.get_json() or {}
|
||||
|
||||
if active_checkout:
|
||||
active_checkout.checkin_time = datetime.utcnow()
|
||||
active_checkout.checkin_notes = data.get('checkin_notes', active_checkout.checkin_notes)
|
||||
active_checkout.was_wiped = data.get('was_wiped', False)
|
||||
active_checkout.checkintime = datetime.utcnow()
|
||||
active_checkout.checkinnotes = data.get('checkinnotes', active_checkout.checkinnotes)
|
||||
active_checkout.waswiped = data.get('waswiped', False)
|
||||
|
||||
# Update device status
|
||||
device.ischeckedout = False
|
||||
@@ -337,7 +337,7 @@ def get_device_history(device_id: int):
|
||||
|
||||
query = USBCheckout.query.filter_by(
|
||||
usbdeviceid=device_id
|
||||
).order_by(USBCheckout.checkout_time.desc())
|
||||
).order_by(USBCheckout.checkouttime.desc())
|
||||
|
||||
items, total = paginate_query(query, page, per_page)
|
||||
data = [c.to_dict() for c in items]
|
||||
@@ -361,13 +361,13 @@ def list_all_checkouts():
|
||||
|
||||
# Filter by active only
|
||||
if request.args.get('active', '').lower() == 'true':
|
||||
query = query.filter(USBCheckout.checkin_time == None)
|
||||
query = query.filter(USBCheckout.checkintime == None)
|
||||
|
||||
# Filter by user
|
||||
if sso := request.args.get('sso'):
|
||||
query = query.filter(USBCheckout.sso == sso)
|
||||
|
||||
query = query.order_by(USBCheckout.checkout_time.desc())
|
||||
query = query.order_by(USBCheckout.checkouttime.desc())
|
||||
|
||||
items, total = paginate_query(query, page, per_page)
|
||||
data = [c.to_dict() for c in items]
|
||||
@@ -380,7 +380,7 @@ def list_all_checkouts():
|
||||
def list_active_checkouts():
|
||||
"""List all currently active checkouts."""
|
||||
checkouts = USBCheckout.query.filter(
|
||||
USBCheckout.checkin_time == None
|
||||
).order_by(USBCheckout.checkout_time.desc()).all()
|
||||
USBCheckout.checkintime == None
|
||||
).order_by(USBCheckout.checkouttime.desc()).all()
|
||||
|
||||
return success_response([c.to_dict() for c in checkouts])
|
||||
|
||||
@@ -123,16 +123,16 @@ class USBCheckout(BaseModel):
|
||||
|
||||
# User info
|
||||
sso = db.Column(db.String(20), nullable=False, comment='SSO of user')
|
||||
checkout_name = db.Column(db.String(100), nullable=True, comment='Name of user')
|
||||
checkoutname = db.Column(db.String(100), nullable=True, comment='Name of user')
|
||||
|
||||
# Checkout details
|
||||
checkout_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
checkin_time = db.Column(db.DateTime, nullable=True)
|
||||
checkouttime = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
||||
checkintime = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
# Metadata
|
||||
checkout_reason = db.Column(db.Text, nullable=True, comment='Reason for checkout')
|
||||
checkin_notes = db.Column(db.Text, nullable=True)
|
||||
was_wiped = db.Column(db.Boolean, nullable=True, comment='Was device wiped after return')
|
||||
checkoutreason = db.Column(db.Text, nullable=True, comment='Reason for checkout')
|
||||
checkinnotes = db.Column(db.Text, nullable=True)
|
||||
waswiped = db.Column(db.Boolean, nullable=True, comment='Was device wiped after return')
|
||||
|
||||
# Relationships
|
||||
device = db.relationship('USBDevice', backref=db.backref('checkouts', lazy='dynamic'))
|
||||
@@ -143,13 +143,13 @@ class USBCheckout(BaseModel):
|
||||
@property
|
||||
def is_active(self):
|
||||
"""Check if this checkout is currently active (not returned)."""
|
||||
return self.checkin_time is None
|
||||
return self.checkintime is None
|
||||
|
||||
@property
|
||||
def duration_days(self):
|
||||
"""Get duration of checkout in days."""
|
||||
end = self.checkin_time or datetime.utcnow()
|
||||
delta = end - self.checkout_time
|
||||
end = self.checkintime or datetime.utcnow()
|
||||
delta = end - self.checkouttime
|
||||
return delta.days
|
||||
|
||||
def to_dict(self):
|
||||
|
||||
Reference in New Issue
Block a user