mirror of
https://gitea.baerentsen.space/FrederikBaerentsen/BrickTracker.git
synced 2026-05-24 18:28:52 -05:00
Added page size option
This commit is contained in:
+14
@@ -170,6 +170,20 @@
|
||||
# Default: parts
|
||||
# BK_PARTS_FOLDER=parts
|
||||
|
||||
# Optional: Enable server-side pagination for parts page (recommended for large collections)
|
||||
# When enabled, parts page uses server-side pagination with configurable page sizes
|
||||
# When disabled, parts page loads all data at once with instant client-side search
|
||||
# Default: false
|
||||
# BK_SERVER_SIDE_PAGINATION=true
|
||||
|
||||
# Optional: Number of parts to show per page on desktop devices (when server-side pagination is enabled)
|
||||
# Default: 50
|
||||
# BK_PARTS_PAGINATION_SIZE_DESKTOP=50
|
||||
|
||||
# Optional: Number of parts to show per page on mobile devices (when server-side pagination is enabled)
|
||||
# Default: 25
|
||||
# BK_PARTS_PAGINATION_SIZE_MOBILE=25
|
||||
|
||||
# Optional: Port the server will listen on.
|
||||
# Default: 3333
|
||||
# BK_PORT=3333
|
||||
|
||||
+3
-1
@@ -5,8 +5,10 @@
|
||||
### 1.2.5
|
||||
|
||||
- Add configurable pagination system with `SERVER_SIDE_PAGINATION` environment variable
|
||||
- `BK_SERVER_SIDE_PAGINATION=true`: Server-side pagination with mobile-responsive page sizes (25/50 items)
|
||||
- `BK_SERVER_SIDE_PAGINATION=true`: Server-side pagination with configurable page sizes
|
||||
- `BK_SERVER_SIDE_PAGINATION=false`: Original single-page mode with live instant search
|
||||
- `BK_PARTS_PAGINATION_SIZE_DESKTOP`: Items per page on desktop (default: 50)
|
||||
- `BK_PARTS_PAGINATION_SIZE_MOBILE`: Items per page on mobile (default: 25)
|
||||
- Supports search, filtering, and sorting in both modes
|
||||
- Optimized for large datasets (100k+ parts)
|
||||
- Enhance parts page functionality
|
||||
|
||||
@@ -41,6 +41,8 @@ CONFIG: Final[list[dict[str, Any]]] = [
|
||||
{'n': 'SERVER_SIDE_PAGINATION', 'c': bool},
|
||||
{'n': 'PARTS_DEFAULT_ORDER', 'd': '"rebrickable_parts"."name" ASC, "rebrickable_parts"."color_name" ASC, "bricktracker_parts"."spare" ASC'}, # noqa: E501
|
||||
{'n': 'PARTS_FOLDER', 'd': 'parts', 's': True},
|
||||
{'n': 'PARTS_PAGINATION_SIZE_DESKTOP', 'd': 50, 'c': int},
|
||||
{'n': 'PARTS_PAGINATION_SIZE_MOBILE', 'd': 25, 'c': int},
|
||||
{'n': 'PORT', 'd': 3333, 'c': int},
|
||||
{'n': 'PURCHASE_DATE_FORMAT', 'd': '%d/%m/%Y'},
|
||||
{'n': 'PURCHASE_CURRENCY', 'd': '€'},
|
||||
|
||||
@@ -31,10 +31,10 @@ def list() -> str:
|
||||
# Get pagination parameters
|
||||
page = int(request.args.get('page', 1))
|
||||
|
||||
# Determine page size based on device type
|
||||
# Determine page size based on device type and configuration
|
||||
user_agent = request.headers.get('User-Agent', '').lower()
|
||||
is_mobile = any(device in user_agent for device in ['mobile', 'android', 'iphone', 'ipad'])
|
||||
per_page = 25 if is_mobile else 50
|
||||
per_page = current_app.config['PARTS_PAGINATION_SIZE_MOBILE'] if is_mobile else current_app.config['PARTS_PAGINATION_SIZE_DESKTOP']
|
||||
|
||||
# Get parts with pagination
|
||||
parts, total_count = BrickPartList().all_filtered_paginated(
|
||||
|
||||
Reference in New Issue
Block a user