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:
74
shopdb/core/api/slides.py
Normal file
74
shopdb/core/api/slides.py
Normal file
@@ -0,0 +1,74 @@
|
||||
"""Slides API for TV dashboard slideshow."""
|
||||
|
||||
import os
|
||||
from flask import Blueprint, current_app
|
||||
from shopdb.utils.responses import success_response, error_response, ErrorCodes
|
||||
|
||||
slides_bp = Blueprint('slides', __name__)
|
||||
|
||||
# Valid image extensions
|
||||
VALID_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp'}
|
||||
|
||||
|
||||
@slides_bp.route('', methods=['GET'])
|
||||
def get_slides():
|
||||
"""
|
||||
Get list of slides for TV dashboard.
|
||||
|
||||
Returns image files from the static/slides directory.
|
||||
"""
|
||||
# Look for slides in static folder
|
||||
static_folder = current_app.static_folder
|
||||
if not static_folder:
|
||||
static_folder = os.path.join(current_app.root_path, 'static')
|
||||
|
||||
slides_folder = os.path.join(static_folder, 'slides')
|
||||
|
||||
# Also check frontend public folder
|
||||
frontend_slides = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(current_app.root_path))),
|
||||
'frontend', 'public', 'slides'
|
||||
)
|
||||
|
||||
# Try multiple possible locations
|
||||
possible_paths = [
|
||||
slides_folder,
|
||||
frontend_slides,
|
||||
'/home/camp/projects/shopdb-flask/shopdb/static/slides',
|
||||
'/home/camp/projects/shopdb-flask/frontend/public/slides',
|
||||
]
|
||||
|
||||
slides_path = None
|
||||
for path in possible_paths:
|
||||
if os.path.isdir(path):
|
||||
slides_path = path
|
||||
break
|
||||
|
||||
if not slides_path:
|
||||
return success_response({
|
||||
'slides': [],
|
||||
'basepath': '/static/slides/',
|
||||
'message': 'Slides folder not found'
|
||||
})
|
||||
|
||||
# Get list of image files
|
||||
slides = []
|
||||
try:
|
||||
for filename in sorted(os.listdir(slides_path)):
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
if ext in VALID_EXTENSIONS:
|
||||
slides.append({'filename': filename})
|
||||
except Exception as e:
|
||||
return error_response(
|
||||
ErrorCodes.SERVER_ERROR,
|
||||
f'Error reading slides: {str(e)}',
|
||||
http_code=500
|
||||
)
|
||||
|
||||
# Determine base path for serving files
|
||||
basepath = '/static/slides/'
|
||||
|
||||
return success_response({
|
||||
'slides': slides,
|
||||
'basepath': basepath
|
||||
})
|
||||
Reference in New Issue
Block a user