Liittymien VLAN/Laite/IP-kentät hakevat nyt tiedot IPAM:sta ja laiterekisteristä
- NetAdmin liittymälomakkeen VLAN, Laite ja IP muutettu tekstikentistä dropdown-valikoiksi - Asiakasformin liittymäkentät samoin muutettu dropdown-valikoiksi - Dropdownit populoidaan IPAM:n VLANeista, IP-osoitteista ja Tekniikan laiterekisteristä - IP-dropdown ryhmittelee vapaat ja varatut IP:t optgroupeilla - Laite-dropdown näyttää ping-statuksen, hallintaosoitteen ja mallin - VLAN-dropdown näyttää VLAN ID:n, nimen ja sijainnin - Jos nykyinen arvo ei ole IPAM/laiterekisterissä, näytetään se (manuaalinen)-lisätekstillä - IPAM-tilan automaattipäivitys: kun liittymälle asetetaan IP, IPAM merkitsee sen varatuksi - Kun IP poistetaan tai vaihdetaan, vanha IP vapautetaan IPAM:ssa automaattisesti - API palauttaa nyt vlans ja ips -listat netadmin_connections-endpointissa Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
api.php
43
api.php
@@ -4412,6 +4412,11 @@ switch ($action) {
|
||||
$deviceMap = [];
|
||||
foreach ($devices as $d) { $deviceMap[$d['nimi']] = $d; }
|
||||
|
||||
// Hae IPAM VLANit ja IP:t dropdown-valikkoja varten
|
||||
$ipamAll = dbLoadIpam($companyId);
|
||||
$vlans = array_values(array_filter($ipamAll, fn($e) => $e['tyyppi'] === 'vlan'));
|
||||
$ips = array_values(array_filter($ipamAll, fn($e) => $e['tyyppi'] === 'ip'));
|
||||
|
||||
// Rikasta liittymädata laitetiedoilla
|
||||
foreach ($connections as &$conn) {
|
||||
$deviceName = $conn['laite'] ?? '';
|
||||
@@ -4423,7 +4428,9 @@ switch ($action) {
|
||||
echo json_encode([
|
||||
'connections' => $connections,
|
||||
'total' => count($connections),
|
||||
'devices' => $devices
|
||||
'devices' => $devices,
|
||||
'vlans' => $vlans,
|
||||
'ips' => $ips
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
@@ -4472,6 +4479,40 @@ switch ($action) {
|
||||
echo json_encode(['error' => 'Liittymää ei löytynyt']);
|
||||
break;
|
||||
}
|
||||
// Automaattinen IPAM-tilan päivitys kun IP muuttuu
|
||||
$oldIp = trim($conn['ip'] ?? '');
|
||||
$newIp = trim($input['ip'] ?? '');
|
||||
if ($oldIp !== $newIp) {
|
||||
$ipamAll = dbLoadIpam($companyId);
|
||||
// Vapauta vanha IP
|
||||
if ($oldIp) {
|
||||
foreach ($ipamAll as $entry) {
|
||||
if ($entry['tyyppi'] === 'ip' && $entry['verkko'] === $oldIp && $entry['tila'] === 'varattu') {
|
||||
$entry['tila'] = 'vapaa';
|
||||
$entry['asiakas'] = '';
|
||||
$entry['muokattu'] = date('Y-m-d H:i:s');
|
||||
$entry['muokkaaja'] = currentUser();
|
||||
dbSaveIpam($companyId, $entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Varaa uusi IP
|
||||
if ($newIp) {
|
||||
$customerName = $conn['customer_name'] ?? '';
|
||||
foreach ($ipamAll as $entry) {
|
||||
if ($entry['tyyppi'] === 'ip' && $entry['verkko'] === $newIp) {
|
||||
$entry['tila'] = 'varattu';
|
||||
$entry['asiakas'] = $customerName;
|
||||
$entry['muokattu'] = date('Y-m-d H:i:s');
|
||||
$entry['muokkaaja'] = currentUser();
|
||||
dbSaveIpam($companyId, $entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbUpdateConnection($connId, $input);
|
||||
$updated = dbLoadConnection($connId);
|
||||
echo json_encode($updated);
|
||||
|
||||
Reference in New Issue
Block a user