Fix project ID resolution and null name concatenation
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
This commit is contained in:
parent
b824c8ea73
commit
9c8032d511
14
app.js
14
app.js
|
|
@ -1417,8 +1417,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
console.log(result.message);
|
||||
|
||||
const fullName = `${vorname} ${nachname}`.trim();
|
||||
const fullName = `${vorname || ''} ${nachname || ''}`.trim();
|
||||
if (fullName) {
|
||||
state.ownerStatuses[fullName] = status;
|
||||
}
|
||||
|
||||
const ownerLayerName = Object.keys(overlays).find(k => k.toLowerCase().includes('eigentümer'));
|
||||
if (ownerLayerName) {
|
||||
|
|
@ -1503,8 +1505,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if (response.ok) {
|
||||
const statuses = await response.json();
|
||||
statuses.forEach(s => {
|
||||
const fullName = `${s.vorname} ${s.nachname}`.trim();
|
||||
const first = s.vorname || '';
|
||||
const last = s.nachname || '';
|
||||
const fullName = `${first} ${last}`.trim();
|
||||
if (fullName) {
|
||||
state.ownerStatuses[fullName] = s.status;
|
||||
}
|
||||
});
|
||||
console.log(`${statuses.length} Eigentümer-Status geladen.`);
|
||||
|
||||
|
|
@ -1513,9 +1519,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if (ownerLayerName && overlays[ownerLayerName]) {
|
||||
overlays[ownerLayerName].setStyle(overlays[ownerLayerName].options.style);
|
||||
}
|
||||
} else {
|
||||
console.warn("API Fehler beim Laden der Status:", response.status);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Fehler beim Laden der Status:", err);
|
||||
console.error("Netzwerkfehler beim Laden der Status:", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
11
server.js
11
server.js
|
|
@ -115,12 +115,19 @@ app.get('/api/wea/:projekt_id', async (req, res) => {
|
|||
|
||||
// Hilfsfunktion zur Auflösung von Projekt-ID oder Name
|
||||
async function resolveProjectId(client, input) {
|
||||
if (!input) return null;
|
||||
|
||||
// Prüfen, ob input eine valide UUID ist
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (uuidRegex.test(input)) return input;
|
||||
|
||||
// Sonst in der Projekte-Tabelle nach Name suchen
|
||||
const res = await client.query('SELECT id FROM geodaten.projekte WHERE name = $1 OR name = $2', [input, input.toLowerCase()]);
|
||||
// Normalisierte Suche (Kleinschreibung, Bindestriche zu Unterstrichen)
|
||||
const normalized = input.toLowerCase().replace(/-/g, '_');
|
||||
|
||||
const res = await client.query(
|
||||
'SELECT id FROM geodaten.projekte WHERE LOWER(name) = $1 OR LOWER(REPLACE(name, \'-\', \'_\')) = $1',
|
||||
[normalized]
|
||||
);
|
||||
return res.rows.length > 0 ? res.rows[0].id : null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue