### Apprise Configuration in Environment Example Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md This example file demonstrates how to configure Apprise using environment variables for Docker deployments. It includes placeholders for notification URLs and other settings. ```env # Example .env file for Apprise configuration # Comma or newline separated list of notification service URLs APPRISE_URLS="mailto:user@example.com, tgram://botid/chatid, https://webhook.site/your-webhook-id" # Days before warranty expiration to send notifications (e.g., 7, 30) APPRISE_NOTIFY_DAYS=30 # Time of day to send notifications (HH:MM format) APPRISE_NOTIFY_TIME="10:00" # Optional prefix for all notification titles APPRISE_TITLE_PREFIX="[Warracker]" # Example for specific services: # APPRISE_URLS="discord://webhook/your_id/your_token" # APPRISE_URLS="slack://webhook/your_id/your_token" # APPRISE_URLS="email://user:password@smtp.example.com:587" ``` -------------------------------- ### CSV Format Example Source: https://context7.com/sassanix/warracker/llms.txt An example of the expected CSV format for importing warranty data. Note the handling of lifetime warranties and tags. ```text # ProductName,PurchaseDate,WarrantyDurationYears,WarrantyDurationMonths,WarrantyDurationDays,PurchasePrice,SerialNumber,Vendor,Tags # "Dell Laptop","2024-01-15",3,0,0,1499.99,"SN123","Dell","Electronics,Work" # "Kitchen Mixer","2024-02-20",2,0,0,299.99,"MX456","KitchenAid","Kitchen,Appliances" # "Lifetime Tools","2024-03-01",0,0,0,149.99,"","Craftsman","Tools" # IsLifetime=TRUE ``` -------------------------------- ### Docker Compose Configuration for Warracker Source: https://github.com/sassanix/warracker/blob/main/README.md This Docker Compose configuration sets up the Warracker service and its PostgreSQL database. Ensure you have a .env file for environment variables and Docker/Docker Compose installed. ```yaml services: warracker: image: ghcr.io/sassanix/warracker/main:latest ports: - "8005:80" volumes: - warracker_uploads:/data/uploads env_file: - .env depends_on: warrackerdb: condition: service_healthy restart: unless-stopped warrackerdb: image: postgres:15-alpine volumes: - postgres_data:/var/lib/postgresql/data env_file: - .env restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 5s timeout: 5s retries: 5 volumes: postgres_data: warracker_uploads: ``` -------------------------------- ### Get All Claims for a Warranty Source: https://context7.com/sassanix/warracker/llms.txt Retrieves all warranty claims associated with a specific warranty ID. Requires a valid JWT token. ```bash curl -X GET http://localhost:8005/api/warranties/1/claims \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Get Archived Warranties Source: https://context7.com/sassanix/warracker/llms.txt Retrieve a list of all warranties that have been archived. Requires a valid JWT token. ```bash curl -X GET http://localhost:8005/api/warranties/archived \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Get Tags for a Warranty Source: https://context7.com/sassanix/warracker/llms.txt Retrieves all tags associated with a specific warranty. Requires the warranty ID and a valid JWT token. ```bash curl -X GET http://localhost:8005/api/warranties/1/tags \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Get All User Tags Source: https://context7.com/sassanix/warracker/llms.txt Retrieves all tags associated with the current user. Requires a valid JWT token. ```bash curl -X GET http://localhost:8005/api/tags \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/sassanix/warracker/llms.txt Define application settings including database credentials, security keys, email, OIDC, and notification services in the .env file. ```bash # .env file example # Database Configuration DB_PASSWORD=your_secure_database_password DB_ADMIN_PASSWORD=your_secure_admin_password # Application Security SECRET_KEY=your_very_secure_flask_secret_key_change_this_in_production # Email Configuration (for password resets and notifications) SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USERNAME=your-email@gmail.com SMTP_PASSWORD=your-app-password SMTP_FROM_ADDRESS=notifications@yourdomain.com SMTP_USE_TLS=true # Application URLs FRONTEND_URL=http://localhost:8005 APP_BASE_URL=http://localhost:8005 # OIDC SSO Configuration (Optional) OIDC_PROVIDER_NAME=google OIDC_CLIENT_ID=your_oidc_client_id OIDC_CLIENT_SECRET=your_oidc_client_secret OIDC_ISSUER_URL=https://accounts.google.com OIDC_SCOPE=openid email profile # Apprise Push Notifications APPRISE_ENABLED=true APPRISE_URLS=discord://webhook_id/webhook_token,telegram://BotToken/ChatID APPRISE_EXPIRATION_DAYS=7,30 APPRISE_NOTIFICATION_TIME=09:00 APPRISE_TITLE_PREFIX=[Warracker] # Memory Optimization WARRACKER_MEMORY_MODE=optimized MAX_UPLOAD_MB=16 ``` -------------------------------- ### GET /api/warranties Source: https://context7.com/sassanix/warracker/llms.txt Retrieves all warranty records for the authenticated user. ```APIDOC ## GET /api/warranties ### Description Fetches a list of all warranties associated with the currently authenticated user. ### Method GET ### Endpoint /api/warranties ### Response #### Success Response (200) - **Array** (list) - List of warranty objects containing product details, dates, and status. ``` -------------------------------- ### Initialize Theme Preferences Source: https://github.com/sassanix/warracker/blob/main/frontend/reset-password.html Sets the document theme based on localStorage or system preference and initializes it on DOMContentLoaded. ```javascript function setTheme(isDark) { document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light'); } function initializeTheme() { // Check for saved theme preference const savedTheme = localStorage.getItem('darkMode'); if (savedTheme !== null) { // Use saved preference setTheme(savedTheme === 'true'); } else { // Use system preference as fallback const prefersDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; setTheme(prefersDarkMode); } } // Initialize theme when page loads document.addEventListener('DOMContentLoaded', initializeTheme); ``` -------------------------------- ### GET /api/statistics Source: https://context7.com/sassanix/warracker/llms.txt Retrieves warranty statistics for the authenticated user, including counts by status and expiration timelines. ```APIDOC ## GET /api/statistics ### Description Get warranty statistics including counts by status, expiration timeline, and recent expiring warranties. ### Method GET ### Endpoint http://localhost:8005/api/statistics ### Response #### Success Response (200) - **total** (integer) - Total number of warranties - **active** (integer) - Number of active warranties - **expired** (integer) - Number of expired warranties - **expiring_soon** (integer) - Number of warranties expiring soon - **timeline** (array) - List of expiration counts by year and month - **recent_warranties** (array) - List of recent warranties - **all_warranties** (array) - List of all warranties ``` -------------------------------- ### Retrieve Reference Data Source: https://context7.com/sassanix/warracker/llms.txt Fetch supported currencies, timezones, and locales for application configuration and form population. ```bash # Get supported currencies curl -X GET http://localhost:8005/api/currencies \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Get available timezones curl -X GET http://localhost:8005/api/timezones \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Get supported locales/languages curl -X GET http://localhost:8005/api/locales ``` -------------------------------- ### Implement Backup Logout Handler Source: https://github.com/sassanix/warracker/blob/main/frontend/about.html Sets up a logout event listener on the user menu with manual fallback redirection if the auth manager is unavailable. ```javascript ld(newLogoutMenuItem, logoutMenuItem); newLogoutMenuItem.addEventListener('click', async (e) => { e.preventDefault(); e.stopPropagation(); console.log('About page: Logout clicked (backup handler)'); // Close the user menu userMenuDropdown.classList.remove('active'); try { // Clear auth data manually since showLoading might fail localStorage.removeItem('auth_token'); localStorage.removeItem('user_info'); // Try to call the auth manager logout if available if (window.auth && typeof window.auth.logout === 'function') { console.log('About page: Calling auth.logout()'); await window.auth.logout(); } else { console.log('About page: Auth manager not available, redirecting manually'); // Redirect manually if auth manager fails window.location.href = 'login.html'; } } catch (error) { console.error('About page: Logout error, falling back to manual redirect:', error); // Clear auth data and redirect as fallback localStorage.removeItem('auth_token'); localStorage.removeItem('user_info'); window.location.href = 'login.html'; } }); console.log('About page: Backup logout handler set up'); } } else { console.error('About page: User menu elements not found!', { userMenuBtn: !!userMenuBtn, userMenuDropdown: !!userMenuDropdown }); } }, 200); // Delay to allow auth.js to complete setup // Move authentication check here, after auth.js has had time to set up setTimeout(() => { // Check if user is authenticated (with a small delay to allow auth.js to process) const authToken = localStorage.getItem('auth_token'); const userInfo = localStorage.getItem('user_info'); if (!authToken || !userInfo) { // User is not authenticated, redirect to login page console.log('About page: User not authenticated, redirecting to login'); window.location.href = 'login.html'; return; } }, 100); // Small delay to allow auth.js to complete setup }); ``` -------------------------------- ### Initialize Apprise Handler in Python Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md This Python code initializes the Apprise handler, loads configuration from environment variables or the database, and validates notification URLs. It supports multiple notification services. ```python from backend.apprise_handler import AppriseHandler # Initialize Apprise handler apprise_handler = AppriseHandler() # Load configuration (from environment or DB) apprise_handler.load_config() # Validate notification URLs if not apprise_handler.validate_urls(): print("Error: Invalid Apprise URLs configured.") # Handle error appropriately, e.g., notify admin # Example: Send a notification # apprise_handler.notify("Test notification message") ``` -------------------------------- ### Docker Compose for Apprise Integration Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md This docker-compose configuration snippet shows how to integrate Apprise, potentially including environment variables for its configuration. Ensure your .env file is correctly set up. ```yaml version: '3.8' services: warracker_app: build: . ports: - "5000:5000" env_file: - .env # Load environment variables, including Apprise settings depends_on: - db db: image: postgres:13 environment: POSTGRES_DB: warrackerdb POSTGRES_USER: warrackeruser POSTGRES_PASSWORD: warrackerpassword volumes: - postgres_data:/var/lib/postgresql/data volumes: postgres_data: ``` -------------------------------- ### Admin User and System Management Source: https://context7.com/sassanix/warracker/llms.txt Administrative endpoints for managing user roles, statuses, and system-wide warranty access. ```bash # Get all users (admin only) curl -X GET http://localhost:8005/api/admin/users \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" # Update user status/role curl -X PUT http://localhost:8005/api/admin/users/2 \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "is_admin": true, "is_active": true }' # Delete a user (admin only) curl -X DELETE http://localhost:8005/api/admin/users/2 \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" # Get all warranties across all users (admin only) curl -X GET http://localhost:8005/api/admin/warranties \ -H "Authorization: Bearer ADMIN_JWT_TOKEN" ``` -------------------------------- ### Deploy Warracker with Docker Compose Source: https://context7.com/sassanix/warracker/llms.txt Deploy the application and a PostgreSQL database using this docker-compose.yml configuration. ```yaml # docker-compose.yml version: '3' services: warracker: image: ghcr.io/sassanix/warracker/main:latest ports: - "8005:80" volumes: - warracker_uploads:/data/uploads env_file: - .env depends_on: warrackerdb: condition: service_healthy restart: unless-stopped warrackerdb: image: postgres:15-alpine volumes: - postgres_data:/var/lib/postgresql/data environment: - POSTGRES_DB=warranty_test - POSTGRES_USER=warranty_user - POSTGRES_PASSWORD=${DB_PASSWORD:-warranty_password} restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 5s timeout: 5s retries: 5 volumes: postgres_data: warracker_uploads: ``` -------------------------------- ### POST /api/register Source: https://context7.com/sassanix/warracker/llms.txt Registers a new user in the system. ```APIDOC ## POST /api/register ### Description Registers a new user account. The first user registered becomes the admin. ### Method POST ### Endpoint /api/register ### Request Body - **username** (string) - Required - Unique username - **email** (string) - Required - User email address - **password** (string) - Required - User password - **first_name** (string) - Optional - User first name - **last_name** (string) - Optional - User last name ### Response #### Success Response (200) - **message** (string) - Success message - **token** (string) - JWT authentication token - **user** (object) - User details object ``` -------------------------------- ### Add Apprise Settings to Database Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md This SQL script adds the necessary columns to the site_settings table to store Apprise configuration. Ensure this migration is applied before configuring Apprise. ```sql ALTER TABLE site_settings ADD COLUMN apprise_urls TEXT DEFAULT NULL, ADD COLUMN apprise_notify_days INTEGER DEFAULT 7, ADD COLUMN apprise_notify_time TEXT DEFAULT '09:00', ADD COLUMN apprise_title_prefix TEXT DEFAULT '[Warracker]'; ``` -------------------------------- ### Manage User Preferences Source: https://context7.com/sassanix/warracker/llms.txt Retrieve or update user-specific settings such as notification channels, themes, and localization preferences. ```bash # Get current preferences curl -X GET http://localhost:8005/api/preferences \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Update preferences curl -X PUT http://localhost:8005/api/preferences \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "theme": "dark", "default_view": "table", "expiring_soon_days": 45, "currency_symbol": "€", "date_format": "DMY", "notification_channel": "both", "preferred_language": "de" }' # Update language preference only curl -X PUT http://localhost:8005/api/user/language-preference \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"preferred_language": "fr"}' ``` -------------------------------- ### Initialize UI Popovers and Menus Source: https://github.com/sassanix/warracker/blob/main/frontend/index.html Handles event listeners for filter, sort, view, and data management popovers. Requires DOM elements to be present in the document. ```javascript // Lightweight UI logic for Filter/Sort popovers (no change to core logic) document.addEventListener('DOMContentLoaded', function () { var filterBtn = document.getElementById('filterBtn'); var sortBtn = document.getElementById('sortBtn'); var viewMenuBtn = document.getElementById('viewMenuBtn'); var viewMenu = document.getElementById('viewMenu'); var viewGridOption = document.getElementById('viewGridOption'); var viewListOption = document.getElementById('viewListOption'); var viewTableOption = document.getElementById('viewTableOption'); var currentViewLabel = document.getElementById('currentViewLabel'); var scopeDropdown = document.getElementById('scopeDropdown'); var scopeMenuBtn = document.getElementById('scopeMenuBtn'); var scopeMenu = document.getElementById('scopeMenu'); var scopePersonalOption = document.getElementById('scopePersonalOption'); var scopeGlobalOption = document.getElementById('scopeGlobalOption'); var currentScopeLabel = document.getElementById('currentScopeLabel'); var filterPopover = document.getElementById('filterPopover'); var sortPopover = document.getElementById('sortPopover'); var sortOptionsList = document.getElementById('sortOptionsList'); var sortBy = document.getElementById('sortBy'); var statusFilter = document.getElementById('statusFilter'); var tagFilter = document.getElementById('tagFilter'); var vendorFilter = document.getElementById('vendorFilter'); var warrantyTypeFilter = document.getElementById('warrantyTypeFilter'); var clearFiltersBtn = document.getElementById('clearFiltersBtn'); var applyFiltersBtn = document.getElementById('applyFiltersBtn'); var filterIndicator = document.getElementById('filterIndicator'); // Data dropdown var dataMenuBtn = document.getElementById('dataMenuBtn'); var dataMenu = document.getElementById('dataMenu'); var dataImportOption = document.getElementById('dataImportOption'); var dataExportOption = document.getElementById('dataExportOption'); var legacyImportBtn = document.getElementById('importBtn'); var legacyExportBtn = document.getElementById('exportBtn'); if (dataMenuBtn && dataMenu) { dataMenuBtn.addEventListener('click', function (e) { e.stopPropagation(); dataMenu.classList.toggle('active'); if (dataMenu.classList.contains('active')) closeAllPopovers(dataMenu); }); } if (dataImportOption && legacyImportBtn) { dataImportOption.addEventListener('click', function () { legacyImportBtn.click(); if (dataMenu) dataMenu.classList.remove('active'); }); } if (dataExportOption && legacyExportBtn) { dataExportOption.addEventListener('click', function () { legacyExportBtn.click(); if (dataMenu) dataMenu.classList.remove('active'); }); } // Expose globally so core script can trigger it after async loads window.updateFilterIndicator = function () { try { var hasActive = false; if (statusFilter && statusFilter.value && statusFilter.value !== 'all') hasActive = true; if (tagFilter && tagFilter.value && tagFilter.value !== 'all') hasActive = true; if (vendorFilter && vendorFilter.value && vendorFilter.value !== 'all') hasActive = true; if (warrantyTypeFilter && warrantyTypeFilter.value && warrantyTypeFilter.value !== 'all') hasActive = true; if (filterIndicator) filterIndicator.style.display = hasActive ? 'inline-block' : 'none'; } catch (e) { /* no-op */ } }; function closeAllPopovers(except) { [filterPopover, sortPopover, viewMenu, scopeMenu, dataMenu].forEach(function (p) { if (p && p !== except) p.classList.remove('active'); }); } if (filterBtn && filterPopover) { filterBtn.addEventListener('click', function (e) { e.stopPropagation(); filterPopover.classList.toggle('active'); if (filterPopover.classList.contains('active')) closeAllPopovers(filterPopover); }); } if (sortBtn && sortPopover) { sortBtn.addEventListener('click', function (e) { e.stopPropagation(); sortPopover.classList.toggle('active'); if (sortPopover.classList.contains('active')) closeAllPopovers(sortPopover); }); } if (viewMenuBtn && viewMenu) { viewMenuBtn.addEventListener('click', function (e) { e.stopPropagation(); viewMenu.classList.toggle('active'); if (viewMenu.classList.contains('active')) { closeAllPopovers(viewMenu); // Sync highlight with the currently selected view when opening try { var currentType = 'grid'; var wl = document.getElementById('warrantiesList'); if (wl) { if (wl.classList.contains('list-view')) currentType = 'list'; else if (wl.classList.contains('table-view')) currentType = 'table'; } else { var prefixV = (window.getPreferenceKeyPrefix ? window.getPreferenceKeyPrefix() : 'user_'); var savedV = localStorage.getItem(prefixV + 'defaultView') || localStorage.getItem(prefixV + 'warrantyView') || 'grid'; currentType = savedV; } if (typeof setViewIconFrom === 'function') setViewIconFrom(currentType); } catch (e) { /* no-op */ } } }); function setViewIconFrom(viewType) { var icon = docum ``` -------------------------------- ### Manage User Authentication Source: https://context7.com/sassanix/warracker/llms.txt Endpoints for user registration, login, token validation, and session invalidation. ```bash # Register a new user curl -X POST http://localhost:8005/api/register \ -H "Content-Type: application/json" \ -d '{ "username": "john_doe", "email": "john@example.com", "password": "SecurePass123", "first_name": "John", "last_name": "Doe" }' # Response: # { # "message": "User registered successfully!", # "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", # "user": { # "id": 1, # "username": "john_doe", # "email": "john@example.com", # "is_admin": true # } # } # Login curl -X POST http://localhost:8005/api/login \ -H "Content-Type: application/json" \ -d '{ "username": "john_doe", "password": "SecurePass123" }' # Validate token and get user info curl -X GET http://localhost:8005/api/validate-token \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Logout (invalidates all sessions) curl -X POST http://localhost:8005/api/logout \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Create Warranty with Exact Expiration Date Source: https://context7.com/sassanix/warracker/llms.txt Create a new warranty with a specific expiration date instead of a duration. Ensure all required fields are provided. ```bash curl -X POST http://localhost:8005/api/warranties \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -F "product_name=Kitchen Appliance" \ -F "purchase_date=2024-01-01" \ -F "exact_expiration_date=2026-06-30" \ -F "warranty_duration_years=0" \ -F "warranty_duration_months=0" \ -F "warranty_duration_days=0" ``` -------------------------------- ### Initialize About Page DOM and Functionality Source: https://github.com/sassanix/warracker/blob/main/frontend/about.html This script initializes the About page by setting up event listeners for DOMContentLoaded, dynamically updating version information, and managing loading spinners. It also includes specific handlers for user menu interactions and theme initialization. ```javascript document.addEventListener('DOMContentLoaded', () => { console.log('About page: DOMContentLoaded triggered'); // Update version display dynamically const versionDisplay = document.getElementById('versionDisplay'); if (versionDisplay && window.i18next) { const currentVersion = '1.0.3'; // This should match version-checker.js versionDisplay.textContent = window.i18next.t('about.version') + ' v' + currentVersion; } // Add safe loading functions for about page window.showLoading = function() { const loadingContainer = document.getElementById('loadingContainer'); if (loadingContainer && loadingContainer.classList) { loadingContainer.classList.add('active'); console.log('About page: Loading spinner shown'); } else { console.log('About page: Loading container not found or unavailable'); } }; window.hideLoading = function() { const loadingContainer = document.getElementById('loadingContainer'); if (loadingContainer && loadingContainer.classList) { loadingContainer.classList.remove('active'); console.log('About page: Loading spinner hidden'); } else { console.log('About page: Loading container not found or unavailable'); } }; // Keep theme initialization here if needed for specific timing if (typeof initializeTheme === 'function') { console.log('About page: Calling initializeTheme'); initializeTheme(); // Call theme initialization if it exists } // Add specific debugging for user menu elements setTimeout(() => { const userMenuBtn = document.getElementById('userMenuBtn'); const userMenuDropdown = document.getElementById('userMenuDropdown'); console.log('About page: User menu debug info:', { userMenuBtn: !!userMenuBtn, userMenuDropdown: !!userMenuDropdown, userMenuBtnId: userMenuBtn ? userMenuBtn.id : 'not found', dropdownId: userMenuDropdown ? userMenuDropdown.id : 'not found', authModuleAvailable: !!window.auth, isAuthenticated: window.auth ? window.auth.isAuthenticated() : 'auth not available' }); if (userMenuBtn) { console.log('About page: userMenuBtn element:', userMenuBtn); console.log('About page: userMenuBtn element found, proceeding with backup handler setup'); } // Add a backup user menu handler specifically for about page if (userMenuBtn && userMenuDropdown) { console.log('About page: Setting up backup user menu handler'); console.log('About page: Current dropdown classes:', userMenuDropdown.className); console.log('About page: Current dropdown active state:', userMenuDropdown.classList.contains('active')); // Test CSS rules by temporarily adding/removing active class console.log('About page: Testing CSS rules...'); userMenuDropdown.classList.add('active'); const testDisplayActive = window.getComputedStyle(userMenuDropdown).display; userMenuDropdown.classList.remove('active'); const testDisplayInactive = window.getComputedStyle(userMenuDropdown).display; console.log('About page: CSS test results:', { displayWhenActive: testDisplayActive, displayWhenInactive: testDisplayInactive }); // Remove any existing click listeners and add our own const newUserMenuBtn = userMenuBtn.cloneNode(true); userMenuBtn.parentNode.replaceChild(newUserMenuBtn, userMenuBtn); newUserMenuBtn.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); console.log('About page: Backup user menu clicked'); console.log('About page: Dropdown before toggle:', { classes: userMenuDropdown.className, hasActive: userMenuDropdown.classList.contains('active'), style: userMenuDropdown.style.display }); const isCurrentlyActive = userMenuDropdown.classList.contains('active'); if (isCurrentlyActive) { userMenuDropdown.classList.remove('active'); console.log('About page: User menu closed'); } else { userMenuDropdown.classList.add('active'); console.log('About page: User menu opened'); } // Double-check the state after toggle console.log('About page: Dropdown after toggle:', { classes: userMenuDropdown.className, hasActive: userMenuDropdown.classList.contains('active'), computedStyle: window.getComputedStyle(userMenuDropdown).display }); }); // Add global click listener to close menu when clicking outside const outsideClickHandler = (e) => { if (userMenuDropdown.classList.contains('active') && !userMenuDropdown.contains(e.target) && !newUserMenuBtn.contains(e.target)) { userMenuDropdown.classList.remove('active'); console.log('About page: User menu closed by outside click'); } }; // Use setTimeout to ensure this listener is added after any others setTimeout(() => { document.addEventListener('click', outsideClickHandler); console.log('About page: Outside click handler added'); }, 10); console.log('About page: Backup user menu handler set up successfully'); // Add specific logout handler for the about page const logoutMenuItem = document.getElementById('logoutMenuItem'); if (logoutMenuItem) { // Clone the logout menu item to remove any existing listeners const newLogoutMenuItem = logoutMenuItem.cloneNode(true); logoutMenuItem.parentNode.replaceChild(newLogoutMenuItem, logoutMenuItem); } } }, 0); }); ``` -------------------------------- ### Manage Warranty Filters and Sorting Source: https://github.com/sassanix/warracker/blob/main/frontend/index.html Handles filter application, clearing, and sorting logic with localStorage persistence for user preferences. ```javascript ters.search; if (clearSearchBtn) clearSearchBtn.style.display = 'flex'; if (searchInput.parentElement) searchInput.parentElement.classList.add('active-search'); } } } catch (e) { /* no-op */ } if (applyFiltersBtn) { applyFiltersBtn.addEventListener('click', function () { [statusFilter, tagFilter, vendorFilter, warrantyTypeFilter].forEach(function (el) { if (el) el.dispatchEvent(new Event('change', { bubbles: true })); }); // Persist filters including search try { var prefix = (window.getPreferenceKeyPrefix ? window.getPreferenceKeyPrefix() : 'user_'); var searchInput = document.getElementById('searchWarranties'); var filtersToSave = { status: statusFilter ? statusFilter.value : 'all', tag: tagFilter ? tagFilter.value : 'all', vendor: vendorFilter ? vendorFilter.value : 'all', warranty_type: warrantyTypeFilter ? warrantyTypeFilter.value : 'all', search: searchInput ? searchInput.value : '' }; localStorage.setItem(prefix + 'warrantyFilters', JSON.stringify(filtersToSave)); } catch (e) { /* no-op */ } window.updateFilterIndicator(); if (filterPopover) filterPopover.classList.remove('active'); }); } if (clearFiltersBtn) { clearFiltersBtn.addEventListener('click', function () { if (statusFilter) statusFilter.value = 'all'; if (tagFilter) tagFilter.value = 'all'; if (vendorFilter) vendorFilter.value = 'all'; if (warrantyTypeFilter) warrantyTypeFilter.value = 'all'; // Clear search field and its UI state var searchInput = document.getElementById('searchWarranties'); var clearSearchBtn = document.getElementById('clearSearch'); if (searchInput) { searchInput.value = ''; if (searchInput.parentElement) searchInput.parentElement.classList.remove('active-search'); } if (clearSearchBtn) clearSearchBtn.style.display = 'none'; [statusFilter, tagFilter, vendorFilter, warrantyTypeFilter].forEach(function (el) { if (el) el.dispatchEvent(new Event('change', { bubbles: true })); }); // Clear persisted filter preferences on reset (including search and sort) try { var prefix = (window.getPreferenceKeyPrefix ? window.getPreferenceKeyPrefix() : 'user_'); localStorage.removeItem(prefix + 'warrantyFilters'); localStorage.removeItem(prefix + 'warrantySortBy'); } catch (e) { /* no-op */ } updateFilterIndicator(); if (filterPopover) filterPopover.classList.remove('active'); }); } if (sortOptionsList) { sortOptionsList.addEventListener('click', function (e) { var li = e.target && e.target.closest('li[data-sort]'); if (!li) return; Array.prototype.forEach.call(sortOptionsList.querySelectorAll('li'), function (n) { n.classList.remove('active'); }); li.classList.add('active'); if (sortBy) { sortBy.value = li.getAttribute('data-sort'); sortBy.dispatchEvent(new Event('change', { bubbles: true })); // Persist sort try { var prefix = (window.getPreferenceKeyPrefix ? window.getPreferenceKeyPrefix() : 'user_'); localStorage.setItem(prefix + 'warrantySortBy', sortBy.value || 'expiration'); } catch (e) { /* no-op */ } } if (sortPopover) sortPopover.classList.remove('active'); }); } // Initialize states window.updateFilterIndicator(); if (sortBy && sortOptionsList) { // Try to load saved sort preference try { var prefix = (window.getPreferenceKeyPrefix ? window.getPreferenceKeyPrefix() : 'user_'); var savedSort = localStorage.getItem(prefix + 'warrantySortBy'); if (savedSort) sortBy.value = savedSort; } catch (e) { /* no-op */ } var current = sortBy.value || 'expiration'; var activeLi = sortOptionsList.querySelector('li[data-sort="' + current + '"]'); if (activeLi) activeLi.classList.add('active'); } }); ``` -------------------------------- ### Styling for Releases Link Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Applies a blue accent color to the releases link for visual consistency. ```css .releases-link { color: #007bff; /* Blue accent for releases */ transition: color 0.3s ease; } .releases-link:hover { color: #0056b3; /* Darker blue on hover */ } .releases-link i { margin-right: 8px; } ``` -------------------------------- ### Create Warranty (Lifetime or Exact Expiration) Source: https://context7.com/sassanix/warracker/llms.txt Creates a new warranty, supporting either lifetime warranties or exact expiration dates. ```APIDOC ## POST /api/warranties ### Description Creates a new warranty. Can be configured as a lifetime warranty or with an exact expiration date. ### Method POST ### Endpoint /api/warranties ### Parameters #### Request Body - **product_name** (string) - Required - The name of the product. - **purchase_date** (string) - Required - The date of purchase (YYYY-MM-DD). - **is_lifetime** (boolean) - Optional - Set to true for lifetime warranties. - **exact_expiration_date** (string) - Optional - The exact expiration date (YYYY-MM-DD). Use if not a lifetime warranty. - **warranty_duration_years** (integer) - Optional - Duration in years (use if not lifetime or exact expiration). - **warranty_duration_months** (integer) - Optional - Duration in months (use if not lifetime or exact expiration). - **warranty_duration_days** (integer) - Optional - Duration in days (use if not lifetime or exact expiration). - **purchase_price** (number) - Optional - The price paid for the product. - **vendor** (string) - Optional - The vendor from whom the product was purchased. ### Request Example (Lifetime Warranty) ```bash curl -X POST http://localhost:8005/api/warranties \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -F "product_name=Craftsman Hand Tools Set" \ -F "purchase_date=2024-02-20" \ -F "is_lifetime=true" \ -F "purchase_price=149.99" \ -F "vendor=Sears" ``` ### Request Example (Exact Expiration Date) ```bash curl -X POST http://localhost:8005/api/warranties \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -F "product_name=Kitchen Appliance" \ -F "purchase_date=2024-01-01" \ -F "exact_expiration_date=2026-06-30" \ -F "warranty_duration_years=0" \ -F "warranty_duration_months=0" \ -F "warranty_duration_days=0" ``` ### Response #### Success Response (200) - **warranty_id** (integer) - The ID of the newly created warranty. - **message** (string) - Confirmation message. #### Response Example ```json { "warranty_id": 1, "message": "Warranty created successfully." } ``` ``` -------------------------------- ### Manage User Profile and Account Source: https://context7.com/sassanix/warracker/llms.txt Endpoints for retrieving profile info, updating details, changing email addresses, and deleting accounts. ```bash # Get current user info curl -X GET http://localhost:8005/api/user \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Update profile curl -X PUT http://localhost:8005/api/profile \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "first_name": "John", "last_name": "Smith", "email": "john.smith@example.com" }' # Change email address curl -X POST http://localhost:8005/api/change-email \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "new_email": "newemail@example.com", "password": "CurrentPassword123" }' # Delete account (non-owner users only) curl -X DELETE http://localhost:8005/api/account \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Retrieve Warranty Statistics Source: https://context7.com/sassanix/warracker/llms.txt Endpoints for fetching user-specific or global warranty statistics and checking global view permissions. ```bash # Get user statistics curl -X GET http://localhost:8005/api/statistics \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Get global statistics (all users, requires permission) curl -X GET http://localhost:8005/api/statistics/global \ -H "Authorization: Bearer YOUR_JWT_TOKEN" # Check if global view is enabled for current user curl -X GET http://localhost:8005/api/settings/global-view-status \ -H "Authorization: Bearer YOUR_JWT_TOKEN" ``` -------------------------------- ### Configure Email From Address Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Supports the `SMTP_FROM_ADDRESS` environment variable for customizing the email From address independently of the SMTP username. This enhances email configuration flexibility. ```python smtp_from_address = os.environ.get('SMTP_FROM_ADDRESS', default_from_address) ``` -------------------------------- ### User Menu and Authentication Button Styles Source: https://github.com/sassanix/warracker/blob/main/frontend/status.html CSS for styling user-specific menus, login/register buttons, and responsive adjustments for smaller screens. Ensures a consistent look across different devices. ```css .user-menu { position: relative; margin-left: 15px; } .user-btn { background: none; border: none; color: var(--text-color); cursor: pointer; display: flex; align-items: center; font-size: 0.9rem; padding: 5px 10px; border-radius: 20px; transition: background-color 0.3s; } .user-btn:hover { background-color: rgba(0, 0, 0, 0.05); } .dark-mode .user-btn:hover { background-color: rgba(255, 255, 255, 0.1); } .user-btn i { margin-right: 5px; } .user-menu-dropdown { position: absolute; top: 100%; right: 0; background-color: var(--card-bg); border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); width: 200px; z-index: 1000; display: none; padding: 10px 0; margin-top: 5px; } .user-menu-dropdown.active { display: block; } .user-info { padding: 10px 15px; border-bottom: 1px solid var(--border-color); margin-bottom: 5px; } .user-name { font-weight: bold; margin-bottom: 5px; } .user-email { font-size: 0.8rem; color: var(--text-muted); word-break: break-all; } .user-menu-item { padding: 8px 15px; cursor: pointer; transition: background-color 0.3s; display: flex; align-items: center; } .user-menu-item:hover { background-color: var(--hover-bg); } .user-menu-item i { margin-right: 10px; width: 16px; text-align: center; } .auth-buttons { display: flex; gap: 10px; margin-left: 15px; } .auth-btn { padding: 5px 15px; border-radius: 20px; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; } .auth-btn i { margin-right: 5px; } .login-btn { background-color: transparent; border: 1px solid var(--primary-color); color: var(--primary-color); } .login-btn:hover { background-color: rgba(var(--primary-rgb), 0.1); } .register-btn { background-color: var(--primary-color); border: 1px solid var(--primary-color); color: white; } .register-btn:hover { background-color: var(--primary-dark); } @media (max-width: 768px) { .export-btn .export-text { display: none; } } ``` -------------------------------- ### Create New Tag Source: https://context7.com/sassanix/warracker/llms.txt Creates a new custom tag for organizing warranties. Requires a valid JWT token and a JSON payload with tag name and color. ```bash curl -X POST http://localhost:8005/api/tags \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Electronics", "color": "#3498db" }' ``` -------------------------------- ### About Page Redesign - Project Information Card Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Displays GitHub repository and releases links with GitHub branding on the About page. Uses Font Awesome icons. ```html
``` -------------------------------- ### POST /api/login Source: https://context7.com/sassanix/warracker/llms.txt Authenticates a user and returns a JWT token. ```APIDOC ## POST /api/login ### Description Authenticates a user with credentials and returns a JWT token for subsequent requests. ### Method POST ### Endpoint /api/login ### Request Body - **username** (string) - Required - User username - **password** (string) - Required - User password ``` -------------------------------- ### Styling for License Link Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Applies a green accent color to the license link for visual consistency. ```css .license-link { color: #28a745; /* Green accent for license */ transition: color 0.3s ease; } .license-link:hover { color: #218838; /* Darker green on hover */ } .license-link i { margin-right: 8px; } ``` -------------------------------- ### POST /api/warranties Source: https://context7.com/sassanix/warracker/llms.txt Creates a new warranty record with optional file attachments. ```APIDOC ## POST /api/warranties ### Description Creates a new warranty record. Supports multipart form data for uploading receipts, manuals, and product photos. ### Method POST ### Endpoint /api/warranties ### Request Body - **product_name** (string) - Required - **purchase_date** (string) - Required - **warranty_duration_years** (integer) - Required - **purchase_price** (float) - Required - **currency** (string) - Required - **vendor** (string) - Required - **serial_numbers[]** (array) - Optional - **tag_ids[]** (array) - Optional - **invoice** (file) - Optional - **manual** (file) - Optional - **product_photo** (file) - Optional ``` -------------------------------- ### Add Apprise Warranty Scope to Database Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Adds the warranty scope setting to the site_settings table with a default value of 'all'. ```sql apprise_warranty_scope ``` -------------------------------- ### Check Registration Status via API Source: https://context7.com/sassanix/warracker/llms.txt Use this cURL command to verify the registration status of the Warracker instance. ```bash curl -X GET http://localhost:8005/api/registration-status ``` -------------------------------- ### Responsive Card Layout and Hover Effects Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Implements a responsive grid layout for information cards that adapts to mobile devices and includes smooth hover animations. ```css .info-card { background-color: var(--card-background); border-radius: 8px; padding: 20px; margin: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; display: flex; flex-direction: column; align-items: flex-start; } .info-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.2); } .info-card h3 { margin-top: 0; margin-bottom: 15px; color: var(--text-primary); } .info-card a { text-decoration: none; color: var(--link-color); margin-bottom: 10px; display: flex; align-items: center; font-weight: 500; } .info-card a:hover { text-decoration: underline; } .info-card i { margin-right: 10px; font-size: 1.2em; } /* Responsive adjustments */ .about-page-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 20px; } @media (max-width: 992px) { .about-page-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 768px) { .about-page-grid { grid-template-columns: 1fr; } .info-card { margin: 10px; } } ``` -------------------------------- ### Configure Nginx for IPv6 Source: https://github.com/sassanix/warracker/blob/main/CHANGELOG.md Add this directive to the Nginx configuration to enable IPv6 listening. ```nginx listen [::]:80; ``` -------------------------------- ### Create New Warranty Claim Source: https://context7.com/sassanix/warracker/llms.txt Submits a new warranty claim. This endpoint requires the warranty ID, a valid JWT token, and a JSON payload with claim details. ```bash curl -X POST http://localhost:8005/api/warranties/1/claims \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "claim_date": "2024-06-15", "status": "Submitted", "claim_number": "CLM-2024-001", "description": "Screen flickering issue reported" }' ``` -------------------------------- ### Import Warranties from CSV Source: https://context7.com/sassanix/warracker/llms.txt Imports warranty data from a CSV file. This endpoint handles automatic tag creation and duplicate detection. Requires a valid JWT token and the CSV file uploaded as form data. ```bash curl -X POST http://localhost:8005/api/warranties/import \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -F "csv_file=@/path/to/warranties.csv" ```