Added row limiting
All checks were successful
Build Docker image / build (push) Successful in 3m22s
Build Docker image / deploy (push) Successful in 3s
Build Docker image / verify (push) Successful in 48s

This commit is contained in:
Roman Krček
2025-08-08 09:25:25 +02:00
parent 667c18a746
commit f5c2063586
3 changed files with 16 additions and 10 deletions

View File

@@ -18,6 +18,8 @@
let sortColumn = $state<keyof RowData | null>(null);
let sortDirection = $state<'asc' | 'desc'>('asc');
const ROW_LIMIT = 200;
// Fetch and process data from the Google Sheet
async function fetchAndProcessData() {
isLoading = true;
@@ -70,9 +72,9 @@
birthday: mapping.birthday !== -1 ? row[mapping.birthday] || '' : '',
pictureUrl,
alreadyPrinted,
_rowIndex: index + 2, // Sheet rows are 1-based, plus header
_rowIndex: index + 2,
_valid: isValid,
_checked: isValid && !alreadyPrinted
_checked: false
};
})
.filter((row): row is RowData => row !== null);
@@ -97,7 +99,6 @@
if (row && row._valid) {
row._checked = !row._checked;
}
console.log("toggleRow", id, row?._checked);
}
// Function to toggle all valid rows
@@ -107,7 +108,11 @@
rows.forEach((row) => {
if (row._valid && !row.alreadyPrinted) {
row._checked = shouldCheck;
if (shouldCheck && selectedCount < ROW_LIMIT) {
row._checked = true;
} else {
row._checked = false;
}
}
});
}
@@ -162,8 +167,10 @@
<div>
<h2 class="mb-2 text-xl font-semibold text-gray-900">Filter and Select Rows</h2>
<p class="text-sm text-gray-700">
Review your data and select which rows to include. Invalid or already printed rows are
disabled.
Review your data and select which rows to include. Select a batch of max 200 items by using the top checkbox.
</p>
<p class="text-sm text-gray-700">
Already printed or invalid data is marked in the status column.
</p>
{#if $selectedSheet?.id}
<p class="mt-1 text-sm text-gray-500">
@@ -174,7 +181,7 @@
rel="noopener noreferrer"
class="text-blue-600 underline hover:text-blue-800"
>
Open Google Sheet
Open the spreadsheet
</a>
</p>
{/if}
@@ -307,7 +314,7 @@
type="checkbox"
class="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-200"
checked={row._checked}
disabled={!row._valid}
disabled={!row._valid || (selectedCount >= ROW_LIMIT && !row._checked)}
onchange={() => toggleRow(row.id)}
/>
</td>

View File

@@ -12,7 +12,7 @@
let hasSearched = $state(false);
let recentSheets = $state<any[]>([]);
const RECENT_SHEETS_KEY = 'recent-sheets';
const RECENT_SHEETS_KEY = 'recentSheets';
onMount(() => {
ensureToken();

View File

@@ -7,7 +7,6 @@
onMount(() => {
initGoogleClients(() => {
// You can add any logic here to run after the client is initialized
console.log('Google API client initialized');
});
});