Optimierung: Thread-sichere Datenbankverbindungen und verbesserte Indizes

This commit is contained in:
2025-03-21 12:55:50 +01:00
parent 4d5a7b4f5e
commit 16bd7ec544
2 changed files with 279 additions and 272 deletions

View File

@@ -2,6 +2,15 @@ let searchTimeout;
let lastResults = [];
let fachrichtungTimeout;
let ortTimeout;
let currentPage = 1;
let totalPages = 1;
let currentResults = [];
let currentSearchQuery = '';
let currentFilters = {
fachrichtung: '',
plz: '',
ort: ''
};
function createPhoneLink(phone) {
if (!phone) return '';
@@ -220,14 +229,13 @@ function exportToVCF(customer) {
const vcfData = [
'BEGIN:VCARD',
'VERSION:3.0',
`FN:${customer.vorname || ''} ${customer.nachname || ''}`,
`N:${customer.nachname || ''};${customer.vorname || ''};;`,
`FN:${customer.name || ''}`,
`N:${customer.name || ''};;;`,
`TEL;TYPE=CELL:${customer.telefon || ''}`,
`TEL;TYPE=HOME:${customer.telefon_2 || ''}`,
`TEL;TYPE=HOME:${customer.mobil || ''}`,
`EMAIL:${customer.email || ''}`,
`ADR;TYPE=HOME:;;${customer.strasse || ''};${customer.plz || ''};${customer.ort || ''};${customer.land || ''}`,
`ORG:${customer.firma || ''}`,
`NOTE:${customer.notizen || ''}`,
`ADR;TYPE=HOME:;;${customer.strasse || ''};${customer.plz || ''};${customer.ort || ''};`,
`ORG:${customer.fachrichtung || ''}`,
'END:VCARD'
].join('\n');
@@ -235,7 +243,7 @@ function exportToVCF(customer) {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `kontakt_${customer.vorname || ''}_${customer.nachname || ''}_${new Date().toISOString().split('T')[0]}.vcf`;
a.download = `kontakt_${customer.name || ''}_${new Date().toISOString().split('T')[0]}.vcf`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
@@ -332,6 +340,7 @@ function clearInput(inputId) {
}
async function searchCustomers() {
let searchTimeout;
const loading = document.getElementById('loading');
const results = document.getElementById('results');
const generalSearch = document.getElementById('q').value;
@@ -341,6 +350,8 @@ async function searchCustomers() {
const plzSearch = document.getElementById('plzInput').value;
const fachrichtungSearch = document.getElementById('fachrichtungInput').value;
const tagFilter = document.getElementById('tagFilter').value;
currentSearchQuery = generalSearch;
currentPage = 1;
// Zeige Ladeanimation
loading.style.display = 'block';