diff --git a/src/popup/popup.css b/src/popup/popup.css index bc715be..438d4d2 100644 --- a/src/popup/popup.css +++ b/src/popup/popup.css @@ -234,6 +234,7 @@ body { .password-toggle svg { display: block; + pointer-events: none; } /* Buttons */ @@ -464,6 +465,21 @@ body { color: var(--binect-blue-deep); } +/* Local tag */ +.tag-local { + display: inline-block; + margin-left: 6px; + padding: 1px 5px; + font-size: 9px; + font-weight: 500; + text-transform: uppercase; + background: var(--light-bg); + color: var(--text-light); + border: 1px solid var(--border-color); + border-radius: 3px; + vertical-align: middle; +} + /* Recipient address */ .pdf-item-recipient { font-size: 11px; diff --git a/src/popup/popup.ts b/src/popup/popup.ts index dec39b1..18425a5 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -40,6 +40,11 @@ let pdfQueue: DocumentProxy[] = []; let currentCredentials: { username: string; password: string } | null = null; let showingArchive = false; // false = live view, true = archive view +// Auto-refresh state +const REFRESH_INTERVALS = [10, 20, 30, 50, 80, 130, 210]; // seconds +let refreshTimeouts: ReturnType[] = []; +let refreshIndex = 0; + /** * Initialize popup */ @@ -110,6 +115,54 @@ async function handleToggleArchiveView() { await loadPDFQueue(); } +/** + * Start auto-refresh sequence after user interaction + */ +function startAutoRefresh() { + // Clear any existing refresh timeouts + cancelAutoRefresh(); + refreshIndex = 0; + scheduleNextRefresh(); +} + +/** + * Schedule the next refresh in the sequence + */ +function scheduleNextRefresh() { + if (refreshIndex >= REFRESH_INTERVALS.length) { + return; // Sequence complete + } + + const delay = REFRESH_INTERVALS[refreshIndex] * 1000; + const timeout = setTimeout(async () => { + console.log(`[Popup] Auto-refresh #${refreshIndex + 1} after ${REFRESH_INTERVALS[refreshIndex]}s`); + await handleRefreshAll(); + refreshIndex++; + scheduleNextRefresh(); + }, delay); + + refreshTimeouts.push(timeout); +} + +/** + * Cancel all pending auto-refresh timeouts + */ +function cancelAutoRefresh() { + for (const timeout of refreshTimeouts) { + clearTimeout(timeout); + } + refreshTimeouts = []; +} + +/** + * Extract just the filename from a full path + */ +function extractFilename(fullPath: string): string { + // Handle both forward and back slashes + const parts = fullPath.split(/[/\\]/); + return parts[parts.length - 1] || fullPath; +} + /** * Handle password visibility toggle */ @@ -364,6 +417,8 @@ function renderPDFItem(pdf: DocumentProxy, section: 'pending' | 'basket' | 'prod const statusClass = getStatusClass(pdf.binectStatus); const statusText = getStatusText(pdf); const priceText = pdf.price ? `${(pdf.price / 100).toFixed(2)} €` : ''; + const displayFilename = extractFilename(pdf.filename); + const isLocalOnly = !pdf.binectDocumentId; let actionsHtml = ''; @@ -407,7 +462,10 @@ function renderPDFItem(pdf: DocumentProxy, section: 'pending' | 'basket' | 'prod
${getStatusIcon(pdf.binectStatus)}
-
${escapeHtml(pdf.filename)}
+
+ ${escapeHtml(displayFilename)} + ${isLocalOnly ? 'local' : ''} +
${formatFileSize(pdf.size)} · ${escapeHtml(pdf.sourceDomain)} ${priceText ? ` · ${priceText}` : ''} @@ -626,6 +684,9 @@ async function handleSendPDF(id: string) { showStatus(`Uploaded! Ready to order (${(pdf.price || 0) / 100} €)`, 'success'); + // Start auto-refresh sequence + startAutoRefresh(); + // Hide status after 3 seconds setTimeout(() => { hideStatus(); @@ -729,6 +790,9 @@ async function handleOrderPDF(id: string) { showStatus('Order placed! Document is in production.', 'success'); + // Start auto-refresh sequence + startAutoRefresh(); + // Hide status after 3 seconds setTimeout(() => { hideStatus();