mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 10:54:52 +00:00
Refactor interface linking system:
- Remove 'interface_connected_asset_interface' column usage - Introduce 'asset_interface_links' table for one-to-one connections - Update add/edit/delete queries and modals to handle new schema - Exclude already-connected interfaces in dropdowns - Improve data integrity and simplify linking logic
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<!-- Interface Name -->
|
||||
<div class="form-group">
|
||||
<label>Interface Name</label>
|
||||
<div class="input-group">
|
||||
@@ -24,6 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MAC Address -->
|
||||
<div class="form-group">
|
||||
<label>MAC Address</label>
|
||||
<div class="input-group">
|
||||
@@ -34,6 +36,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IP (with optional DHCP checkbox) -->
|
||||
<div class="form-group">
|
||||
<label>IP or DHCP</label>
|
||||
<div class="input-group">
|
||||
@@ -49,6 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IPv6 -->
|
||||
<div class="form-group">
|
||||
<label>IPv6</label>
|
||||
<div class="input-group">
|
||||
@@ -59,6 +63,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Port -->
|
||||
<div class="form-group">
|
||||
<label>Port</label>
|
||||
<div class="input-group">
|
||||
@@ -69,6 +74,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Network -->
|
||||
<div class="form-group">
|
||||
<label>Network</label>
|
||||
<div class="input-group">
|
||||
@@ -78,15 +84,15 @@
|
||||
<select class="form-control select2" name="network">
|
||||
<option value="">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_network_select = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_network_select)) {
|
||||
$network_id = $row['network_id'];
|
||||
$network_name = nullable_htmlentities($row['network_name']);
|
||||
$network = nullable_htmlentities($row['network']);
|
||||
|
||||
?>
|
||||
<option value="<?php echo $network_id; ?>"><?php echo $network_name; ?> - <?php echo $network; ?></option>
|
||||
<option value="<?php echo $network_id; ?>">
|
||||
<?php echo "$network_name - $network"; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -101,21 +107,32 @@
|
||||
<select class="form-control select2" name="connected_to">
|
||||
<option value="">- None -</option>
|
||||
<?php
|
||||
$sql_interfaces_select = mysqli_query($mysqli, "
|
||||
SELECT i.interface_id, i.interface_port, a.asset_name
|
||||
FROM asset_interfaces i
|
||||
LEFT JOIN assets a ON a.asset_id = i.interface_asset_id
|
||||
WHERE a.asset_archived_at IS NULL
|
||||
AND a.asset_client_id = $client_id
|
||||
AND a.asset_id != $asset_id
|
||||
AND i.interface_id NOT IN (SELECT interface_a_id FROM asset_interface_links)
|
||||
AND i.interface_id NOT IN (SELECT interface_b_id FROM asset_interface_links)
|
||||
ORDER BY a.asset_name ASC, i.interface_port ASC
|
||||
");
|
||||
|
||||
$sql_interfaces_select = mysqli_query($mysqli, "SELECT * FROM asset_interfaces LEFT JOIN assets ON interface_asset_id = asset_id WHERE asset_archived_at IS NULL AND asset_client_id = $client_id ORDER BY asset_name ASC, interface_port ASC");
|
||||
while ($row = mysqli_fetch_array($sql_interfaces_select)) {
|
||||
$interface_id_select = intval($row['interface_id']);
|
||||
$interface_port_select = nullable_htmlentities($row['interface_port']);
|
||||
$asset_type_select = nullable_htmlentities($row['asset_type']);
|
||||
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
||||
|
||||
?>
|
||||
<option value="<?php echo $interface_id_select; ?>"><?php echo "$asset_name_select - $interface_port_select"; ?></option>
|
||||
<option value="<?php echo $interface_id_select; ?>">
|
||||
<?php echo "$asset_name_select - $interface_port_select"; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" rows="5" placeholder="Enter some notes" name="notes"></textarea>
|
||||
</div>
|
||||
@@ -123,7 +140,9 @@
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_asset_interface" class="btn btn-primary"><i class="fa fa-check"></i> Create</button>
|
||||
<button type="submit" name="add_asset_interface" class="btn btn-primary">
|
||||
<i class="fa fa-check"></i> Create
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user