v1.4.0: Monatsfilter, Pagination, Rollenverwaltung, DB-Bereinigung
- Liste: Monatsfilter mit ←/→ Navigation, Standard = aktueller Monat - Liste: Pagination (10 Einträge/Seite) - BEO-Auswahl filtert nur role='guide' - logbuch_objekte: ObjektName entfernt, JOIN auf objekte - utf8mb4 Migration und DB-Charset-Umstellung - SSH-Tunnel-Support: MySQL auf 127.0.0.1:3336 - phpMyAdmin unter /myadmin Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -157,7 +157,7 @@ export default function MainClient({ kuerzel, beoId, beoName }: Props) {
|
||||
kuppel={activeKuppel}
|
||||
refreshKey={refreshKey}
|
||||
onEdit={handleEdit}
|
||||
limit={20}
|
||||
limit={15}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -25,11 +25,30 @@ const LIST_SQL =
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const kuppel = searchParams.get('kuppel') || 'West';
|
||||
const limit = Math.min(parseInt(searchParams.get('limit') || '20'), 100);
|
||||
const limit = Math.min(parseInt(searchParams.get('limit') || '10'), 100);
|
||||
const offset = Math.max(0, parseInt(searchParams.get('offset') || '0'));
|
||||
const month = searchParams.get('month') || '';
|
||||
|
||||
let listWhere = 'WHERE l.Kuppel = ?';
|
||||
let countWhere = 'WHERE Kuppel = ?';
|
||||
let params: (string | number | null)[] = [kuppel];
|
||||
if (month && /^\d{4}-\d{2}$/.test(month)) {
|
||||
const [y, m] = month.split('-').map(Number);
|
||||
const start = `${y}-${String(m).padStart(2, '0')}-01`;
|
||||
const nextM = m === 12 ? 1 : m + 1;
|
||||
const nextY = m === 12 ? y + 1 : y;
|
||||
const end = `${nextY}-${String(nextM).padStart(2, '0')}-01`;
|
||||
listWhere += ' AND l.Beginn >= ? AND l.Beginn < ?';
|
||||
countWhere += ' AND Beginn >= ? AND Beginn < ?';
|
||||
params = [kuppel, start, end];
|
||||
}
|
||||
|
||||
try {
|
||||
const rows = await query(LIST_SQL + ` LIMIT ${limit}`, [kuppel]);
|
||||
return NextResponse.json(rows);
|
||||
const [countRows, entries] = await Promise.all([
|
||||
query('SELECT COUNT(*) AS total FROM logbuch ' + countWhere, params) as Promise<{ total: number }[]>,
|
||||
query(LIST_SQL.replace('WHERE l.Kuppel = ?', listWhere) + ` LIMIT ${limit} OFFSET ${offset}`, params),
|
||||
]);
|
||||
return NextResponse.json({ entries, total: (countRows as unknown as { total: number }[])[0]?.total ?? 0 });
|
||||
} catch (error) {
|
||||
console.error('GET /api/logbuch:', error);
|
||||
return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 });
|
||||
|
||||
Reference in New Issue
Block a user