From 6ebaea2d45ce46baef602912fa99a08b6b464bd4 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Thu, 2 Mar 2023 18:58:04 +0100 Subject: [PATCH] GUI improvements and new assetclass description --- assetclassedit.php | 1 + assetclassview.php | 1 + assetview.php | 13 +++++++------ cable.php | 6 ++++-- install/mysql.sql | 2 +- lang/de.php | 7 ++++++- lang/en.php | 9 +++++++-- search.php | 15 +++++++++------ submit.php | 25 ++++++++++++++----------- subnet.php | 4 ++-- tpl/assetclassadd.tpl | 8 ++++++++ tpl/assetclassedit.tpl | 12 +++++++++++- tpl/assetclassgroupdel.tpl | 4 +--- tpl/assetclassgroupedit.tpl | 3 ++- tpl/assetclassview.tpl | 8 ++++++++ tpl/assetedit.tpl | 3 ++- tpl/cableadd.tpl | 12 ++++++++++++ tpl/cabledel.tpl | 14 +++++--------- tpl/cableedit.tpl | 6 +++++- tpl/cableview.tpl | 2 +- tpl/locationedit.tpl | 2 +- tpl/nodeedit.tpl | 2 +- tpl/search.tpl | 11 ++++++++--- tpl/subnetedit.tpl | 3 ++- tpl/vlanadd.tpl | 5 ++++- tpl/vlanedit.tpl | 3 ++- tpl/zoneedit.tpl | 3 ++- 27 files changed, 127 insertions(+), 57 deletions(-) diff --git a/assetclassedit.php b/assetclassedit.php index c0fe463..4d16503 100644 --- a/assetclassedit.php +++ b/assetclassedit.php @@ -13,6 +13,7 @@ $assetclass_id = sanitize($_GET['assetclass_id']); include("header.php"); $sql = "SELECT assetclass_id AS id, assetclass_name AS name, + assetclass_description AS description, assetclassgroup_id AS group_id FROM assetclass WHERE assetclass_id=?"; diff --git a/assetclassview.php b/assetclassview.php index 9f359d2..b5c17dd 100644 --- a/assetclassview.php +++ b/assetclassview.php @@ -14,6 +14,7 @@ $assetclass_id = sanitize($_GET['assetclass_id']); include("header.php"); $sql = "SELECT a.assetclass_id, a.assetclass_name, g.assetclassgroup_id, + a.assetclass_description, g.assetclassgroup_name, g.assetclassgroup_color FROM assetclass AS a LEFT OUTER JOIN assetclassgroup AS g USING (assetclassgroup_id) WHERE a.assetclass_id=?"; diff --git a/assetview.php b/assetview.php index c30afcc..55ed18d 100644 --- a/assetview.php +++ b/assetview.php @@ -19,17 +19,18 @@ include("header.php"); $sql = "SELECT a.asset_id, a.asset_name, a.asset_hostname, a.asset_info, a.asset_intf, a.asset_type, c.assetclass_id, c.assetclass_name - FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id) - WHERE a.asset_id=?"; + FROM asset AS a LEFT OUTER JOIN assetclass AS c USING (assetclass_id) + WHERE a.asset_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$asset_id]); $asset = $sth->fetch(PDO::FETCH_OBJ); $smarty->assign("asset", $asset); -$sql = "SELECT node_id, node_ip, LEFT(node_info, 40) as node_info - FROM node - WHERE asset_id=? - ORDER BY INET_ATON(node_ip)"; +$sql = "SELECT node_id, node_ip, + CONCAT(LEFT(node_info, 40), IF(CHAR_LENGTH(node_info)>40,'...','')) AS node_info + FROM node + WHERE asset_id=? + ORDER BY INET_ATON(node_ip)"; $sth = $dbh->prepare($sql); $sth->execute([$asset_id]); $smarty->assign("nodes", $sth->fetchAll(PDO::FETCH_ASSOC)); diff --git a/cable.php b/cable.php index 7ed2ef6..a7d8d53 100644 --- a/cable.php +++ b/cable.php @@ -35,15 +35,17 @@ switch ($submit = form_get_action()) { $description = sanitize($_POST['description']); $color = sanitize($_POST['color']); $type = sanitize($_POST['cable_type']); + $links = sanitize($_POST['links']); $info = sanitize($_POST['info']); $sql = "INSERT INTO cable - (cable_description, cable_color, cable_type, cable_info) + (cable_description, cable_color, cable_type, cable_links, cable_info) VALUES - (:description, :color, :type, :info)"; + (:description, :color, :type, :links, :info)"; $sth = $dbh->prepare($sql); $sth->bindValue(':description', $description, PDO::PARAM_STR); $sth->bindValue(':color', $color, PDO::PARAM_STR); $sth->bindValue(':type', $type, PDO::PARAM_STR); + $sth->bindValue(':links', $info, PDO::PARAM_INT); $sth->bindValue(':info', $info, PDO::PARAM_STR); $sth->execute(); $id = $dbh->lastInsertId(); diff --git a/install/mysql.sql b/install/mysql.sql index 1a01027..e4f9966 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -15,6 +15,7 @@ CREATE TABLE assetclass ( assetclass_id int(10) NOT NULL AUTO_INCREMENT, assetclassgroup_id int(10) NOT NULL, assetclass_name varchar(100) NOT NULL, + assetclass_description varchar(100) DEFAULT NULL, PRIMARY KEY (assetclass_id), INDEX ix_assetclass_name (assetclass_name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -28,7 +29,6 @@ CREATE TABLE assetclassgroup ( INDEX ix_assetclassgroup_name (assetclassgroup_name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- WIP CREATE TABLE cable ( cable_id int(10) NOT NULL AUTO_INCREMENT, cable_description varchar(100) NOT NULL, diff --git a/lang/de.php b/lang/de.php index 48bc230..4c372f3 100644 --- a/lang/de.php +++ b/lang/de.php @@ -32,6 +32,7 @@ $lang = array( 'lang_all' => 'Alle', 'lang_cancel' => 'Abbruch', 'lang_color' => 'Farbe', + 'lang_del' => 'Löschen', 'lang_error' => 'Fehler', 'lang_item' => 'Gegenstand', 'lang_language' => 'Sprache', @@ -66,6 +67,7 @@ $lang = array( 'lang_assetclass_del' => 'Objektklasse löschen', 'lang_assetclass_edit' => 'Objektklasse ändern', 'lang_assetclass_name' => 'Objektklassenname', + 'lang_assetclass_desc' => 'Beschreibung', 'lang_assetclass_count' => '# Objekte', 'lang_assetclass_none' => 'Es sind keine Objektklassen vorhanden', @@ -104,6 +106,9 @@ $lang = array( 'lang_locationsubnet' => 'Standort/Subnetz', 'lang_locationsubnet_edit' => 'Standort/Subnetz bearbeiten', + 'lang_cable_add' => 'Kabel hinzufügen', + 'lang_cable_del' => 'Kabel löschen', + 'lang_cable_edit' => 'Kabel ändern', 'lang_cable_info' => 'Kabelinfo', 'lang_cable_type' => 'Kabeltyp', 'lang_cable_none' => 'Es sind keine Kabel vorhanden', @@ -169,7 +174,7 @@ $lang = array( 'lang_zone_add' => 'Zone hinzufügen', 'lang_zone_del' => 'Zone löschen', - 'lang_zone_edit' => 'Zone bearbeiten', + 'lang_zone_edit' => 'Zone ändern', 'lang_zone_none' => 'Es sind keine Zonen vorhanden', 'lang_vlan_add' => 'VLAN hinzufügen', diff --git a/lang/en.php b/lang/en.php index 0b17f0a..02bc48d 100644 --- a/lang/en.php +++ b/lang/en.php @@ -32,6 +32,7 @@ $lang = array( 'lang_all' => 'All', 'lang_cancel' => 'Cancel', 'lang_color' => 'Color', + 'lang_del' => 'Delete', 'lang_error' => 'Error', 'lang_item' => 'Item', 'lang_language' => 'Language', @@ -73,6 +74,7 @@ $lang = array( 'lang_assetclassgroup_del' => 'Delete assetclassgroup', 'lang_assetclassgroup_edit' => 'Modify assetclassgroup', 'lang_assetclassgroup_name' => 'Assetclassgroup Name', + 'lang_assetclass_desc' => 'Description', 'lang_assetclassgroup_count' => '# Classes', 'lang_assetclassgroup_none' => 'There are no assetclassegroups defined', @@ -94,7 +96,7 @@ $lang = array( 'lang_location_add' => 'Add location', 'lang_location_del' => 'Delete location', - 'lang_location_edit' => 'Mofidy location', + 'lang_location_edit' => 'Modify location', 'lang_location_info' => 'Location info', 'lang_location_name' => 'Location name', 'lang_location_parent' => 'Parent', @@ -104,6 +106,9 @@ $lang = array( 'lang_locationsubnet' => 'Location/Subnet', 'lang_locationsubnet_edit' => 'Edit Location/Subnet', + 'lang_cable_add' => 'Add cable', + 'lang_cable_del' => 'Delete cable', + 'lang_cable_edit' => 'Modify cable', 'lang_cable_info' => 'Cable info', 'lang_cable_type' => 'Cable type', 'lang_cable_none' => 'There are no cables defined', @@ -169,7 +174,7 @@ $lang = array( 'lang_zone_add' => 'Add zone', 'lang_zone_del' => 'Delete zone', - 'lang_zone_edit' => 'Mofidy zone', + 'lang_zone_edit' => 'Modify zone', 'lang_zone_none' => 'There are no zones defined', 'lang_vlan_add' => 'Add VLAN', diff --git a/search.php b/search.php index 6419334..bcf3479 100644 --- a/search.php +++ b/search.php @@ -28,11 +28,13 @@ $needle = '%' . $search . '%'; $resultcounter = 0; // asset -$sql = "SELECT asset_id AS id, asset_name AS name, asset_info AS description - FROM asset - WHERE asset_name LIKE :needle OR asset_hostname LIKE :needle - OR asset_info LIKE :needle - ORDER BY asset_name"; +$sql = "SELECT a.asset_id AS id, a.asset_name AS name, + CONCAT(LEFT(asset_info, 50), IF(CHAR_LENGTH(asset_info)>50,'...','')) AS description, + c.assetclass_name AS assetclass + FROM asset AS a LEFT JOIN assetclass AS c USING (assetclass_id) + WHERE a.asset_name LIKE :needle OR a.asset_hostname LIKE :needle + OR a.asset_info LIKE :needle + ORDER BY a.asset_name"; $sth = $dbh->prepare($sql); $sth->execute(['needle' => $needle]); @@ -53,7 +55,8 @@ $resultcounter += count($locations); $smarty->assign("locations", $locations); // node -$sql = "SELECT node_id AS id, node_ip AS ip +$sql = "SELECT node_id AS id, node_ip AS ip, + CONCAT(LEFT(node_info, 30), IF(CHAR_LENGTH(node_info)>30,'...','')) AS info FROM node WHERE node_ip LIKE :needle OR node_mac LIKE :needle OR node_dns1 LIKE :needle OR node_dns2 LIKE :needle diff --git a/submit.php b/submit.php index bf43511..902a870 100644 --- a/submit.php +++ b/submit.php @@ -121,15 +121,16 @@ if (isset($_POST['add'])) { break; case ("assetclass") : - $assetclass_name = sanitize($_POST['assetclass_name']); - $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']); + $name = sanitize($_POST['assetclass_name']); + $description = sanitize($_POST['assetclass_description']); + $group_id = sanitize($_POST['assetclassgroup_id']); $sql = "INSERT INTO assetclass - (assetclass_name, assetclassgroup_id) + (assetclass_name, assetclass_description, assetclassgroup_id) VALUE - (?, ?)"; + (?, ?, ?)"; $sth = $dbh->prepare($sql); - $sth->execute([$assetclass_name, $assetclassgroup_id]); + $sth->execute([$name, $description, $group_id]); header_location("assetclassview.php?assetclass_id=" . $dbh->lastInsertId()); break; @@ -549,17 +550,19 @@ if (isset($_POST['edit'])) { header_location("assetview.php?asset_id=" . $asset_id); case ("assetclass") : - $assetclass_id = sanitize($_POST['assetclass_id']); - $assetclass_name = sanitize($_POST['assetclass_name']); - $assetclassgroup_id = sanitize($_POST['assetclassgroup_id']); + $id = sanitize($_POST['assetclass_id']); + $name = sanitize($_POST['assetclass_name']); + $description = sanitize($_POST['assetclass_description']); + $group_id = sanitize($_POST['assetclassgroup_id']); $sql = "UPDATE assetclass SET - assetclass_name=?, assetclassgroup_id=? + assetclass_name=?, assetclass_description=?, + assetclassgroup_id=? WHERE assetclass_id=?"; $sth = $dbh->prepare($sql); - $sth->execute([$assetclass_name, $assetclassgroup_id, $assetclass_id]); + $sth->execute([$name, $description, $group_id, $id]); - header_location("assetclassview.php?assetclass_id=" . $assetclass_id); + header_location("assetclassview.php?assetclass_id=" . $id); break; case ("assetclassgroup") : diff --git a/subnet.php b/subnet.php index 969eb59..50b418e 100644 --- a/subnet.php +++ b/subnet.php @@ -11,8 +11,8 @@ include("includes.php"); include("header.php"); $sql = "SELECT s.subnet_id, s.subnet_address, s.subnet_mask, - s.ntp_server, LEFT(s.subnet_info, 40) AS subnet_info, - CHAR_LENGTH(s.subnet_info) AS subnet_length, + s.ntp_server, + CONCAT(LEFT(s.subnet_info, 50), IF(CHAR_LENGTH(s.subnet_info)>50,'...','')) AS subnet_info, COUNT(node.subnet_id) AS node_counter FROM subnet AS s LEFT JOIN node USING (subnet_id) GROUP BY s.subnet_id diff --git a/tpl/assetclassadd.tpl b/tpl/assetclassadd.tpl index 1168bcf..3f2b1c7 100644 --- a/tpl/assetclassadd.tpl +++ b/tpl/assetclassadd.tpl @@ -30,6 +30,14 @@ + + + {$lang_assetclass_desc} + + + + + diff --git a/tpl/assetclassedit.tpl b/tpl/assetclassedit.tpl index 07147ce..80096cf 100644 --- a/tpl/assetclassedit.tpl +++ b/tpl/assetclassedit.tpl @@ -5,7 +5,8 @@
+ + + + +
- {$assetclass->name} + + {$lang_assetclass_edit} : {$assetclass->name} {$lang_cancel} @@ -31,6 +32,15 @@
+ {$lang_assetclass_desc} + + +
diff --git a/tpl/assetclassgroupdel.tpl b/tpl/assetclassgroupdel.tpl index 781efab..aae8e2f 100644 --- a/tpl/assetclassgroupdel.tpl +++ b/tpl/assetclassgroupdel.tpl @@ -9,13 +9,11 @@
{$lang_cancel} - +
-

-
diff --git a/tpl/assetclassgroupedit.tpl b/tpl/assetclassgroupedit.tpl index 88f2705..29a8867 100644 --- a/tpl/assetclassgroupedit.tpl +++ b/tpl/assetclassgroupedit.tpl @@ -5,7 +5,8 @@ + + + +
- {$assetclassgroup->name} + + {$lang_assetclassgroup_edit} : {$assetclassgroup->name} {$lang_cancel} diff --git a/tpl/assetclassview.tpl b/tpl/assetclassview.tpl index fc9c945..f2154fe 100644 --- a/tpl/assetclassview.tpl +++ b/tpl/assetclassview.tpl @@ -37,6 +37,14 @@ {/if}
+ {$lang_assetclass_desc} + + {$assetclass->assetclass_description} +
diff --git a/tpl/assetedit.tpl b/tpl/assetedit.tpl index 5e2c54a..dcea3d6 100644 --- a/tpl/assetedit.tpl +++ b/tpl/assetedit.tpl @@ -6,7 +6,8 @@
- {$asset_name} + + {$lang_asset_edit} : {$asset->asset_name} {$lang_cancel} diff --git a/tpl/cableadd.tpl b/tpl/cableadd.tpl index 9ee0ab7..ce636d8 100644 --- a/tpl/cableadd.tpl +++ b/tpl/cableadd.tpl @@ -3,6 +3,7 @@ + + + + +
+ {$lang_cable_add} @@ -17,6 +18,9 @@ {$lang_cable} +   +
@@ -54,6 +58,14 @@ {html_options name=cable_type options=$type_options selected=$cable->cable_type}
+ # Links + + +
{$lang_color} diff --git a/tpl/cabledel.tpl b/tpl/cabledel.tpl index 401d644..cdf4696 100644 --- a/tpl/cabledel.tpl +++ b/tpl/cabledel.tpl @@ -1,5 +1,5 @@
- + @@ -7,12 +7,8 @@ {$lang_cable_del}
- {$lang_cancel} - - - Abbruch - - + {$lang_cancel} +
@@ -28,10 +24,10 @@
- {$lang_cable_name} + {$lang_description} - {$cable->description} + {$description}
diff --git a/tpl/cableedit.tpl b/tpl/cableedit.tpl index d0c6d80..afb9d14 100644 --- a/tpl/cableedit.tpl +++ b/tpl/cableedit.tpl @@ -4,7 +4,8 @@ + - diff --git a/tpl/locationedit.tpl b/tpl/locationedit.tpl index 1264ab3..06a90f1 100644 --- a/tpl/locationedit.tpl +++ b/tpl/locationedit.tpl @@ -6,7 +6,7 @@
- {$lang_cable_add} + + {$lang_cable_edit} : {$cable->description} {$lang_cancel} @@ -18,6 +19,9 @@ {$lang_cable} +   +
diff --git a/tpl/cableview.tpl b/tpl/cableview.tpl index c03715b..5a0c28b 100644 --- a/tpl/cableview.tpl +++ b/tpl/cableview.tpl @@ -16,7 +16,7 @@ {$lang_cable} +  
- {$location_name} + {$lang_location_edit} : {$location->name} {$lang_cancel} diff --git a/tpl/nodeedit.tpl b/tpl/nodeedit.tpl index 2c6218f..d7afbda 100644 --- a/tpl/nodeedit.tpl +++ b/tpl/nodeedit.tpl @@ -6,7 +6,7 @@
- {$node_ip} + {$lang_node_edit} : {$node->ip} {$lang_cancel} diff --git a/tpl/search.tpl b/tpl/search.tpl index 1d94686..1eff91a 100644 --- a/tpl/search.tpl +++ b/tpl/search.tpl @@ -28,10 +28,9 @@ {if $assets|@count > 0} - - {foreach item=asset from=$assets} @@ -41,6 +40,9 @@ + {/foreach}
+ {$lang_assets} ({$assets|@count})
{$asset.description} + {$asset.assetclass} +
@@ -66,7 +68,7 @@ {if $nodes|@count > 0} - @@ -75,6 +77,9 @@ + {/foreach}
+ {$lang_nodes} ({$nodes|@count})
{$node.ip} + {$node.info} +
diff --git a/tpl/subnetedit.tpl b/tpl/subnetedit.tpl index 03e81fe..6537b01 100644 --- a/tpl/subnetedit.tpl +++ b/tpl/subnetedit.tpl @@ -5,7 +5,8 @@ + diff --git a/tpl/vlanedit.tpl b/tpl/vlanedit.tpl index 7f5b510..8252072 100644 --- a/tpl/vlanedit.tpl +++ b/tpl/vlanedit.tpl @@ -5,7 +5,8 @@
- {$lang_subnet_edit} + + {$lang_subnet_edit} : {$subnet->address}/{$subnet->mask} {$lang_cancel} diff --git a/tpl/vlanadd.tpl b/tpl/vlanadd.tpl index 664b4f2..3fc12eb 100644 --- a/tpl/vlanadd.tpl +++ b/tpl/vlanadd.tpl @@ -18,6 +18,9 @@ {$lang_vlan} +   +
@@ -40,7 +43,7 @@ {$lang_color} - # + #
- {$vlan->name} + + {$lang_vlan_edit} : {$vlan->name} {$lang_cancel} diff --git a/tpl/zoneedit.tpl b/tpl/zoneedit.tpl index f0f3071..b705992 100644 --- a/tpl/zoneedit.tpl +++ b/tpl/zoneedit.tpl @@ -5,7 +5,8 @@
- {$zone_origin} + + {$lang_zone_edit} : {$zone->zone_origin} {$lang_cancel}