diff --git a/front/css/pialert.css b/front/css/pialert.css index 4e9cd440..d3e7747c 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -807,6 +807,7 @@ input[readonly] { border-top:1px; border-top-color:grey; padding:0px; + padding-top:6px; margin:0px; align-items:center; border-radius:20px; diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 995ade83..6efe84ee 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -480,12 +480,32 @@ function navigateToDeviceWithIp (ip) { window.open(window.location.origin +'/deviceDetails.php?mac=' + mac , "_blank"); } }); - - }); } +// ----------------------------------------------------------------------------- +function getNameByMacAddress(macAddress) { + + const sessionDataKey = 'devicesListAll'; + const sessionData = sessionStorage.getItem(sessionDataKey); + + if (!sessionData) { + console.log(`Session variable "${sessionDataKey}" not found.`); + return "Unknown"; + } + + const devices = JSON.parse(sessionData); + + for (const device of devices) { + if (device.mac === macAddress) { + return device.name; + } + } + + return "Unknown"; // Return a default value if MAC address is not found +} + // ----------------------------------------------------------------------------- function isEmpty(value) { diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 0e0aaef7..6be6c1e7 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -470,7 +470,7 @@ "PIALERT_WEB_PROTECTION_name" : "Enable login", "PIALERT_WEB_PROTECTION_description" : "When enabled a login dialog is displayed. Read below carefully if you get locked out of your instance.", "PIALERT_WEB_PASSWORD_name" : "Login password", - "PIALERT_WEB_PASSWORD_description" : "The default password is 123456. To change the password run /home/pi/pialert/back/pialert-cli in the container", + "PIALERT_WEB_PASSWORD_description" : "The default password is 123456. To change the password run /home/pi/pialert/back/pialert-cli in the container or use the SETPWD_RUN Set password plugin.", "INCLUDED_SECTIONS_name" : "Notify on", "INCLUDED_SECTIONS_description" : "Specifies which events trigger notifications. Remove the event type(s) you don not want to get notified on. This setting overrides device-specific settings in the UI. (CTRL + Click to select/deselect).", "DAYS_TO_KEEP_EVENTS_name" : "Delete events older than", diff --git a/front/plugins/README.md b/front/plugins/README.md index 9469959f..45a8e972 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -96,7 +96,7 @@ More on specifics below. | 8 | `ForeignKey` | no | A foreign key that can be used to link to the parent object (usually a MAC address) | > [!NOTE] -> De-duplication is run once an hour on the `Plugins_Objects` database table and duplicate entries with the same value in columns `Object_PrimaryID`, `Object_SecondaryID`, `Plugin` (auto-filled based on `unique_prefix` of the plugin), `UserData` (can be populated with the `"type": "textboxsave"` column type) are removed. +> De-duplication is run once an hour on the `Plugins_Objects` database table and duplicate entries with the same value in columns `Object_PrimaryID`, `Object_SecondaryID`, `Plugin` (auto-filled based on `unique_prefix` of the plugin), `UserData` (can be populated with the `"type": "textbox_save"` column type) are removed. # config.json structure @@ -349,7 +349,7 @@ This approach is used to implement the `DHCPLSS` plugin. The script parses all s "mapped_to_column": "DHCP_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -533,17 +533,17 @@ You can have any `"function": "my_custom_name"` custom name, however, the ones l The UI will adjust how columns are displayed in the UI based on the definition of the `database_column_definitions` object. These are the supported form controls and related functionality: - Only columns with `"show": true` and also with at least an English translation will be shown in the UI. -- Supported types: `label`, `text`, `threshold`, `replace`, `deviceip`, `devicemac`, `url`. Check for details below, how columns behave based on the type. +- Supported types: `label`, `text`, `threshold`, `replace`, `device_ip`, `device_mac`, `url`. Check for details below, how columns behave based on the type. - `label` makes a column display only - `text` makes a column editable and a save icon is displayed next to it. - See below for information on `threshold`, `replace` - The `options` property is used in conjunction with these types: - `threshold` - The `options` array contains objects from lowest `maximum` to highest with corresponding `hexColor` used for the value background color if it's less than the specified `maximum`, but more than the previous one in the `options` array - `replace` - The `options` array contains objects with an `equals` property, that is compared to the "value" and if the values are the same, the string in `replacement` is displayed in the UI instead of the actual "value" -- `devicemac` - The value is considered to be a Mac address and a link pointing to the device with the given Mac address is generated. -- `deviceip` - The value is considered to be an IP address and a link pointing to the device with the given IP is generated. The IP is checked against the last detected IP addresses and translated into a Mac address that is then used for the link itself. +- `device_mac` - The value is considered to be a Mac address and a link pointing to the device with the given Mac address is generated. +- `device_ip` - The value is considered to be an IP address and a link pointing to the device with the given IP is generated. The IP is checked against the last detected IP addresses and translated into a Mac address that is then used for the link itself. - `url` - The value is considered to be a URL so a link is generated. -- `textboxsave` - An editable and saveable text box is generated that saves values in the database. Primarily intended for the `UserData` database column in the `Plugins_Objects` table. +- `textbox_save` - An editable and saveable text box is generated that saves values in the database. Primarily intended for the `UserData` database column in the `Plugins_Objects` table. ```json diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index 1e3dd99f..c9e927ab 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -216,7 +216,7 @@ "mapped_to_column": "cur_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_name_mac", "default_value":"", "options": [], "localized": ["name"], @@ -234,7 +234,7 @@ "mapped_to_column": "cur_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index de8be687..c9bb219f 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -82,7 +82,7 @@ "mapped_to_column": "DHCP_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -100,7 +100,7 @@ "mapped_to_column": "DHCP_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], @@ -221,7 +221,7 @@ "column": "UserData", "css_classes": "col-sm-2", "show": false, - "type": "textboxsave", + "type": "textbox_save", "default_value":"", "options": [], "localized": ["name"], @@ -445,11 +445,11 @@ } ] , "description":[{ "language_code":"en_us", - "string" : "Envíe una notificación solo en estos estados. new significa que se descubrió un nuevo objeto único (una combinación única de PrimaryId y SecondaryId). watched-changed significa que las columnas Watched_ValueN seleccionadas cambiaron." + "string" : "Send a notification only on these statuses. new means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. watched-changed means that selected Watched_ValueN columns changed." }, { "language_code":"es_es", - "string" : "." + "string" : "Envíe una notificación solo en estos estados. new significa que se descubrió un nuevo objeto único (una combinación única de PrimaryId y SecondaryId). watched-changed significa que las columnas Watched_ValueN seleccionadas cambiaron." }] } ] diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 216c8b9f..69e72e94 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -70,7 +70,7 @@ "column": "Object_PrimaryID", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], @@ -206,7 +206,7 @@ "column": "UserData", "css_classes": "col-sm-2", "show": true, - "type": "textboxsave", + "type": "textbox_save", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/nmap_services/config.json b/front/plugins/nmap_services/config.json index cce1608d..a3891201 100755 --- a/front/plugins/nmap_services/config.json +++ b/front/plugins/nmap_services/config.json @@ -223,7 +223,7 @@ "column": "ForeignKey", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index 898684ec..0b83bce3 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -205,7 +205,7 @@ "mapped_to_column": "cur_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -223,7 +223,7 @@ "mapped_to_column": "cur_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index db9e842a..da234cdb 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -95,7 +95,7 @@ "mapped_to_column": "DHCP_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -113,7 +113,7 @@ "mapped_to_column": "DHCP_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], @@ -234,7 +234,7 @@ "column": "UserData", "css_classes": "col-sm-2", "show": false, - "type": "textboxsave", + "type": "textbox_save", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index 3cec79ed..070d0f1c 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -226,7 +226,7 @@ "mapped_to_column": "DHCP_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -244,7 +244,7 @@ "mapped_to_column": "DHCP_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index 66b237a6..19e5597b 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -117,7 +117,7 @@ "mapped_to_column": "DHCP_MAC", "css_classes": "col-sm-2", "show": true, - "type": "devicemac", + "type": "device_mac", "default_value":"", "options": [], "localized": ["name"], @@ -135,7 +135,7 @@ "mapped_to_column": "DHCP_IP", "css_classes": "col-sm-2", "show": true, - "type": "deviceip", + "type": "device_ip", "default_value":"", "options": [], "localized": ["name"], @@ -256,7 +256,7 @@ "column": "UserData", "css_classes": "col-sm-2", "show": false, - "type": "textboxsave", + "type": "textbox_save", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 8ea65cb1..9ec01241 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -241,7 +241,7 @@ "column": "UserData", "css_classes": "col-sm-2", "show": true, - "type": "textboxsave", + "type": "textbox_save", "default_value":"", "options": [], "localized": ["name"], diff --git a/front/pluginsCore.php b/front/pluginsCore.php index 765d15cc..764b41ed 100755 --- a/front/pluginsCore.php +++ b/front/pluginsCore.php @@ -65,7 +65,7 @@ function getFormControl(dbColumnDef, value, index) { case 'label': result = `${value}`; break; - case 'textboxsave': + case 'textbox_save': value = value == 'null' ? '' : value; // hide 'null' values @@ -81,10 +81,13 @@ function getFormControl(dbColumnDef, value, index) { case 'url': result = `${value}`; break; - case 'devicemac': + case 'device_name_mac': + result = `${getNameByMacAddress(value)}`; + break; + case 'device_mac': result = `${value}`; break; - case 'deviceip': + case 'device_ip': result = `${value}`; break; case 'threshold':