diff --git a/dashboard/api.py b/dashboard/api.py index 1e87daf..c9ea8f0 100644 --- a/dashboard/api.py +++ b/dashboard/api.py @@ -65,6 +65,13 @@ def get_stats(): """Get dashboard stats summary""" db = get_database() stats = db.get_dashboard_stats() + + # If no check in database, fall back to scraper state's last_check + if not stats.get('last_check'): + state = scraper_state.get_state() + if state.get('last_check'): + stats['last_check'] = {'checked_at': state['last_check']} + return jsonify(stats) diff --git a/dashboard/app.py b/dashboard/app.py index 7bfef02..7e7e97b 100644 --- a/dashboard/app.py +++ b/dashboard/app.py @@ -15,7 +15,12 @@ from flask_cors import CORS from src.database import get_database from src.favorites import get_favorites_manager -from .api import api_bp + +# Handle both direct execution and package import +try: + from .api import api_bp +except ImportError: + from api import api_bp # Create Flask app app = Flask(__name__) diff --git a/dashboard/static/app.js b/dashboard/static/app.js index 7671ad5..37d2a5d 100644 --- a/dashboard/static/app.js +++ b/dashboard/static/app.js @@ -86,6 +86,9 @@ function initEventListeners() { } }); + // Clear filters button + document.getElementById('clearFiltersBtn')?.addEventListener('click', clearAllFilters); + // Add favorite button document.getElementById('addFavoriteBtn')?.addEventListener('click', addFavorite); @@ -96,6 +99,16 @@ function initEventListeners() { }); } +// Clear all product filters +function clearAllFilters() { + document.getElementById('filterSite').value = ''; + document.getElementById('filterCategory').value = ''; + document.getElementById('filterStock').value = ''; + document.getElementById('filterFavorites').checked = false; + currentEventFilter = null; + loadProducts(); +} + // API Helpers async function api(endpoint, options = {}) { try { @@ -328,23 +341,23 @@ async function loadProducts() { const cleanName = cleanProductName(product.name); const hasImage = product.image_url && !product.image_url.includes('data:') && product.image_url.length > 10; - // Build store logo fallback HTML - const storeLogoHtml = ` -
- `; - return `