IPAM: duplikaatti-IP-tarkistus, vapaat lohkot, asiakas-kentän poisto + varattu oletus

- Duplikaatti-IP/verkko -tarkistus: estää saman verkko-osoitteen lisäämisen kahdesti
- Vapaan tilan näyttö: kun subnet avataan, näytetään vapaat osoitelohkot lasten välissä (vihreä "Vapaa"-rivi)
- Asiakas-kenttä poistettu IPAM-näkymästä (taulukot, lomake, haku)
- Varattu oletustilaksi verkkoa/VLANia lisättäessä

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 09:50:18 +02:00
parent 8a73423bf1
commit 44053d27f2
4 changed files with 128 additions and 31 deletions

11
api.php
View File

@@ -1836,6 +1836,17 @@ switch ($action) {
'muokattu' => date('Y-m-d H:i:s'),
'muokkaaja' => currentUser(),
];
// Duplikaatti-tarkistus: sama verkko/IP ei saa olla jo olemassa
if ($entry['verkko'] !== '' && $entry['tyyppi'] !== 'vlan') {
$existingAll = dbLoadIpam($companyId);
foreach ($existingAll as $ex) {
if ($ex['verkko'] === $entry['verkko'] && $ex['id'] !== $entry['id'] && $ex['tyyppi'] !== 'vlan') {
http_response_code(400);
echo json_encode(['error' => 'IP-osoite tai verkko "' . $entry['verkko'] . '" on jo olemassa (' . ($ex['nimi'] ?: 'nimetön') . ')']);
exit;
}
}
}
dbSaveIpam($companyId, $entry);
// Auto-VLAN: jos subnet/ip:llä on vlan_id, luo VLAN automaattisesti jos ei vielä ole
if ($entry['tyyppi'] !== 'vlan' && !empty($entry['vlan_id'])) {