Skip to content

Commit fe762ef

Browse files
committed
Asset Interfaces: Renamed Port to Description, added Interface Type
1 parent 8d8b0f4 commit fe762ef

11 files changed

+148
-85
lines changed

api/v1/assets/create.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
$insert_id = mysqli_insert_id($mysqli);
2121

2222
// Add Primary Interface
23-
mysqli_query($mysqli,"INSERT INTO asset_interfaces SET interface_name = 'Primary', interface_mac = '$mac', interface_ip = '$ip', interface_port = 'eth0', interface_primary = 1, interface_network_id = $network, interface_asset_id = $insert_id");
23+
mysqli_query($mysqli,"INSERT INTO asset_interfaces SET interface_name = '1', interface_mac = '$mac', interface_ip = '$ip', interface_primary = 1, interface_network_id = $network, interface_asset_id = $insert_id");
2424

2525
// Logging
2626
logAction("Asset", "Create", "$name via API ($api_key_name)", $client_id, $insert_id);

client_asset_details.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@
9999
SELECT
100100
ai.interface_id,
101101
ai.interface_name,
102+
ai.interface_description,
103+
ai.interface_type,
102104
ai.interface_mac,
103105
ai.interface_ip,
104106
ai.interface_ipv6,
105-
ai.interface_port,
106107
ai.interface_primary,
107108
ai.interface_notes,
108109
n.network_name,
109110
n.network_id,
110111
connected_interfaces.interface_id AS connected_interface_id,
111112
connected_interfaces.interface_name AS connected_interface_name,
112-
connected_interfaces.interface_port AS connected_interface_port,
113113
connected_assets.asset_name AS connected_asset_name
114114
FROM asset_interfaces AS ai
115115
LEFT JOIN networks AS n
@@ -391,10 +391,10 @@
391391
<table class="table table-striped table-borderless table-hover table-sm">
392392
<thead class="<?php if ($interface_count == 0) { echo "d-none"; } ?>">
393393
<tr>
394-
<th>Name</th>
394+
<th>Name / Port</th>
395+
<th>Type</th>
395396
<th>MAC</th>
396397
<th>IP</th>
397-
<th>Port</th>
398398
<th>Network</th>
399399
<th>Connected To</th>
400400
<th class="text-center">Action</th>
@@ -405,10 +405,11 @@
405405
<?php
406406
$interface_id = intval($row['interface_id']);
407407
$interface_name = nullable_htmlentities($row['interface_name']);
408+
$interface_description = nullable_htmlentities($row['interface_description']);
409+
$interface_type = nullable_htmlentities($row['interface_type']);
408410
$interface_mac = nullable_htmlentities($row['interface_mac']);
409411
$interface_ip = nullable_htmlentities($row['interface_ip']);
410412
$interface_ipv6 = nullable_htmlentities($row['interface_ipv6']);
411-
$interface_port = nullable_htmlentities($row['interface_port']);
412413
$interface_primary = intval($row['interface_primary']);
413414
$network_id = intval($row['network_id']);
414415
$network_name = nullable_htmlentities($row['network_name']);
@@ -417,18 +418,18 @@
417418
// Prepare display text
418419
$interface_mac_display = $interface_mac ?: '-';
419420
$interface_ip_display = $interface_ip ?: '-';
420-
$interface_port_display = $interface_port ?: '-';
421+
$interface_type_display = $interface_type ?: '-';
421422
$network_name_display = $network_name
422423
? "<i class='fas fa-fw fa-network-wired mr-1'></i>$network_name $network_id"
423424
: '-';
424425

425426
// Connected interface details
426427
$connected_asset_name = nullable_htmlentities($row['connected_asset_name']);
427-
$connected_interface_port = nullable_htmlentities($row['connected_interface_port']);
428+
$connected_interface_name = nullable_htmlentities($row['connected_interface_name']);
428429

429430
// Show either "-" or "AssetName - Port"
430431
if ($connected_asset_name) {
431-
$connected_to_display = "<strong>$connected_asset_name</strong> - $connected_interface_port";
432+
$connected_to_display = "<strong>$connected_asset_name</strong> - $connected_interface_name";
432433
} else {
433434
$connected_to_display = "-";
434435
}
@@ -440,9 +441,9 @@
440441
<?php echo $interface_name; ?>
441442
</a>
442443
</td>
444+
<td><?php echo $interface_type_display; ?></td>
443445
<td><?php echo $interface_mac_display; ?></td>
444446
<td><?php echo $interface_ip_display; ?></td>
445-
<td><?php echo $interface_port_display; ?></td>
446447
<td><?php echo $network_name_display; ?></td>
447448
<td><?php echo $connected_to_display; ?></td>
448449
<td>

database_updates.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,6 @@ function processFile($file_path, $file_name, $mysqli) {
24712471

24722472
if (CURRENT_DATABASE_VERSION == '1.8.0') {
24732473

2474-
24752474
mysqli_query($mysqli, "ALTER TABLE `ticket_statuses` ADD `ticket_status_order` int(11) NOT NULL DEFAULT 0");
24762475

24772476
mysqli_query($mysqli, "ALTER TABLE `tickets` ADD `ticket_order` int(11) NOT NULL DEFAULT 0");
@@ -2482,11 +2481,19 @@ function processFile($file_path, $file_name, $mysqli) {
24822481

24832482
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.8.1'");
24842483
}
2484+
2485+
if (CURRENT_DATABASE_VERSION == '1.8.1') {
2486+
mysqli_query($mysqli, "ALTER TABLE `asset_interfaces` CHANGE `interface_port` `interface_description` VARCHAR(200) DEFAULT NULL AFTER `interface_name`");
2487+
2488+
mysqli_query($mysqli, "ALTER TABLE `asset_interfaces` ADD `interface_type` VARCHAR(50) DEFAULT NULL AFTER `interface_description`");
2489+
2490+
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.8.2'");
2491+
}
24852492

2486-
// if (CURRENT_DATABASE_VERSION == '1.8.1') {
2487-
// // Insert queries here required to update to DB version 1.8.2
2493+
// if (CURRENT_DATABASE_VERSION == '1.8.2') {
2494+
// // Insert queries here required to update to DB version 1.8.3
24882495
// // Then, update the database to the next sequential version
2489-
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.8.2'");
2496+
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.8.3'");
24902497
// }
24912498

24922499
} else {

db.sql

+6-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ DROP TABLE IF EXISTS `asset_interfaces`;
167167
CREATE TABLE `asset_interfaces` (
168168
`interface_id` int(11) NOT NULL AUTO_INCREMENT,
169169
`interface_name` varchar(200) NOT NULL,
170+
`interface_description` varchar(200) DEFAULT NULL,
171+
`interface_type` varchar(50) DEFAULT NULL,
170172
`interface_mac` varchar(200) DEFAULT NULL,
171173
`interface_ip` varchar(200) DEFAULT NULL,
172174
`interface_nat_ip` varchar(200) DEFAULT NULL,
173175
`interface_ipv6` varchar(200) DEFAULT NULL,
174-
`interface_port` varchar(200) DEFAULT NULL,
175176
`interface_notes` text DEFAULT NULL,
176177
`interface_primary` tinyint(1) DEFAULT 0,
177178
`interface_created_at` datetime NOT NULL DEFAULT current_timestamp(),
@@ -1704,9 +1705,6 @@ CREATE TABLE `settings` (
17041705
`config_ticket_autoclose_hours` int(5) NOT NULL DEFAULT 72,
17051706
`config_ticket_new_ticket_notification_email` varchar(200) DEFAULT NULL,
17061707
`config_ticket_default_billable` tinyint(1) NOT NULL DEFAULT 0,
1707-
`config_ticket_default_view` tinyint(1) NOT NULL DEFAULT 0,
1708-
`config_ticket_moving_columns` tinyint(1) NOT NULL DEFAULT 1,
1709-
`config_ticket_ordering` tinyint(1) NOT NULL DEFAULT 0,
17101708
`config_enable_cron` tinyint(1) NOT NULL DEFAULT 0,
17111709
`config_recurring_auto_send_invoice` tinyint(1) NOT NULL DEFAULT 1,
17121710
`config_enable_alert_domain_expire` tinyint(1) NOT NULL DEFAULT 1,
@@ -1743,6 +1741,9 @@ CREATE TABLE `settings` (
17431741
`config_phone_mask` tinyint(1) NOT NULL DEFAULT 1,
17441742
`config_whitelabel_enabled` int(11) NOT NULL DEFAULT 0,
17451743
`config_whitelabel_key` text DEFAULT NULL,
1744+
`config_ticket_default_view` tinyint(1) NOT NULL DEFAULT 0,
1745+
`config_ticket_ordering` tinyint(1) NOT NULL DEFAULT 0,
1746+
`config_ticket_moving_columns` tinyint(1) NOT NULL DEFAULT 1,
17461747
PRIMARY KEY (`company_id`)
17471748
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
17481749
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -2347,4 +2348,4 @@ CREATE TABLE `vendors` (
23472348
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
23482349
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
23492350

2350-
-- Dump completed on 2025-01-25 21:47:06
2351+
-- Dump completed on 2025-02-12 17:12:46

get_settings.php

+6
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,9 @@
309309
'In Person'=>'fa-people-arrows',
310310
'Note'=>'fa-sticky-note'
311311
);
312+
313+
$interface_types_array = array (
314+
'Ethernet',
315+
'SFP',
316+
'WiFi'
317+
);

includes/database_version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* It is used in conjunction with database_updates.php
66
*/
77

8-
DEFINE("LATEST_DATABASE_VERSION", "1.8.1");
8+
DEFINE("LATEST_DATABASE_VERSION", "1.8.2");

modals/client_asset_interface_add_modal.php

+39-17
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,45 @@
1616

1717
<!-- Interface Name -->
1818
<div class="form-group">
19-
<label>Interface Name</label>
19+
<label>Interface Name / Port</label>
2020
<div class="input-group">
2121
<div class="input-group-prepend">
2222
<span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
2323
</div>
24-
<input type="text" class="form-control" name="name" placeholder="Interface Name" maxlength="200" required>
24+
<input type="text" class="form-control" name="name" placeholder="Interface name or port number" maxlength="200" required>
25+
</div>
26+
</div>
27+
28+
<!-- Type -->
29+
<div class="form-group">
30+
<label for="network">Type</label>
31+
<div class="input-group">
32+
<div class="input-group-prepend">
33+
<span class="input-group-text"><i class="fa fa-fw fa-plug"></i></span>
34+
</div>
35+
<select class="form-control select2" name="type">
36+
<option value="">- Select Type -</option>
37+
<?php foreach($interface_types_array as $interface_type) { ?>
38+
<option><?php echo $interface_type; ?></option>
39+
<?php } ?>
40+
</select>
41+
</div>
42+
</div>
43+
44+
<!-- Interface Description -->
45+
<div class="form-group">
46+
<label>Description</label>
47+
<div class="input-group">
48+
<div class="input-group-prepend">
49+
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
50+
</div>
51+
<input
52+
type="text"
53+
class="form-control"
54+
name="description"
55+
placeholder="Short Description"
56+
maxlength="200"
57+
>
2558
</div>
2659
</div>
2760

@@ -63,17 +96,6 @@
6396
</div>
6497
</div>
6598

66-
<!-- Port -->
67-
<div class="form-group">
68-
<label>Port</label>
69-
<div class="input-group">
70-
<div class="input-group-prepend">
71-
<span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
72-
</div>
73-
<input type="text" class="form-control" name="port" placeholder="Interface Port ex. eth0" maxlength="200">
74-
</div>
75-
</div>
76-
7799
<!-- Network -->
78100
<div class="form-group">
79101
<label>Network</label>
@@ -108,24 +130,24 @@
108130
<option value="">- None -</option>
109131
<?php
110132
$sql_interfaces_select = mysqli_query($mysqli, "
111-
SELECT i.interface_id, i.interface_port, a.asset_name
133+
SELECT i.interface_id, i.interface_name, a.asset_name
112134
FROM asset_interfaces i
113135
LEFT JOIN assets a ON a.asset_id = i.interface_asset_id
114136
WHERE a.asset_archived_at IS NULL
115137
AND a.asset_client_id = $client_id
116138
AND a.asset_id != $asset_id
117139
AND i.interface_id NOT IN (SELECT interface_a_id FROM asset_interface_links)
118140
AND i.interface_id NOT IN (SELECT interface_b_id FROM asset_interface_links)
119-
ORDER BY a.asset_name ASC, i.interface_port ASC
141+
ORDER BY a.asset_name ASC, i.interface_name ASC
120142
");
121143

122144
while ($row = mysqli_fetch_array($sql_interfaces_select)) {
123145
$interface_id_select = intval($row['interface_id']);
124-
$interface_port_select = nullable_htmlentities($row['interface_port']);
146+
$interface_name_select = nullable_htmlentities($row['interface_name']);
125147
$asset_name_select = nullable_htmlentities($row['asset_name']);
126148
?>
127149
<option value="<?php echo $interface_id_select; ?>">
128-
<?php echo "$asset_name_select - $interface_port_select"; ?>
150+
<?php echo "$asset_name_select - $interface_name_select"; ?>
129151
</option>
130152
<?php } ?>
131153
</select>

0 commit comments

Comments
 (0)