Skip to content

Commit

Permalink
MQTT rework v0.1 + Settings UI improvements ⚙
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 14, 2023
1 parent a3702fe commit 8ad63ba
Show file tree
Hide file tree
Showing 34 changed files with 706 additions and 116 deletions.
10 changes: 10 additions & 0 deletions front/css/pialert.css
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,16 @@ height: 50px;
display: none;
}

.settings-group
{
font-size: 20px;
}

.settings-group i{
font-size: 16px;
}


.table_row {
padding: 3px;
width:100%;
Expand Down
67 changes: 34 additions & 33 deletions front/devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,41 +397,41 @@ function initializeDatatable (status) {

// Convert JSON data into the desired format
var dataArray = {
data: filteredData.map(function(item) {
var originalRow = [
item.dev_Name || "",
item.dev_Owner || "",
item.dev_DeviceType || "",
item.dev_Icon || "",
item.dev_Favorite || "",
item.dev_Group || "",
// ---
item.dev_FirstConnection || "",
item.dev_LastConnection || "",
item.dev_LastIP || "",
item.dev_MAC || "", // TODO handle internet node mac
getDeviceStatus(item) || "",
item.dev_MAC || "", // hidden
item.dev_LastIP || "", // IP orderable
item.rowid || "",
item.dev_Network_Node_MAC_ADDR || "",
item.connected_devices || 0,
item.dev_Location || "",
item.dev_Vendor || "",
item.dev_Network_Node_port || 0
]

var newRow = []

// reorder data based on user-definer columns order
for(index = 0; index < tableColumnOrder.length; index++)
{
newRow.push(originalRow[tableColumnOrder[index]]);
}
data: filteredData.map(function(item) {
var originalRow = [
item.dev_Name || "",
item.dev_Owner || "",
item.dev_DeviceType || "",
item.dev_Icon || "",
item.dev_Favorite || "",
item.dev_Group || "",
// ---
item.dev_FirstConnection || "",
item.dev_LastConnection || "",
item.dev_LastIP || "",
(["2", "6", "A", "E", "a", "e"].includes(item.dev_MAC[1]) ? 1 : 0) || "", // Check if randomized MAC
getDeviceStatus(item) || "",
item.dev_MAC || "", // hidden
formatIPlong(item.dev_LastIP) || "", // IP orderable
item.rowid || "",
item.dev_Network_Node_MAC_ADDR || "",
item.connected_devices || 0,
item.dev_Location || "",
item.dev_Vendor || "",
item.dev_Network_Node_port || 0
];

var newRow = [];

// reorder data based on user-defined columns order
for (index = 0; index < tableColumnOrder.length; index++) {
newRow.push(originalRow[tableColumnOrder[index]]);
}

return newRow;
})
return newRow;
})
};


// TODO displayed columns

Expand Down Expand Up @@ -529,6 +529,7 @@ function initializeDatatable (status) {
// Random MAC
{targets: [mapIndx(9)],
'createdCell': function (td, cellData, rowData, row, col) {
console.log(cellData)
if (cellData == 1){
$(td).html ('<i data-toggle="tooltip" data-placement="right" title="Random MAC" style="font-size: 16px;" class="text-yellow glyphicon glyphicon-random"></i>');
} else {
Expand Down
16 changes: 15 additions & 1 deletion front/js/pialert_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,21 @@ function getNameByMacAddress(macAddress) {
}

// -----------------------------------------------------------------------------
//
// A function used to make the IP address orderable
function formatIPlong(ipAddress) {
const parts = ipAddress.split('.');
if (parts.length !== 4) {
throw new Error('Invalid IP address format');
}
return (parseInt(parts[0]) << 24) |
(parseInt(parts[1]) << 16) |
(parseInt(parts[2]) << 8) |
parseInt(parts[3]);
}

// -----------------------------------------------------------------------------
// A function to get a device property using the mac address as key and DB column nakme as parameter
// for the value to be returned
function getDeviceDataByMacAddress(macAddress, dbColumn) {

const sessionDataKey = 'devicesListAll_JSON';
Expand Down
27 changes: 11 additions & 16 deletions front/php/templates/language/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"Device_TableHead_FirstSession" : "First Session",
"Device_TableHead_LastSession" : "Last Session",
"Device_TableHead_LastIP" : "Last IP",
"Device_TableHead_MAC" : "MAC",
"Device_TableHead_MAC" : "Random MAC",
"Device_TableHead_MAC_full" : "Full MAC",
"Device_TableHead_LastIPOrder" : "Last IP Order",
"Device_TableHead_Status" : "Status",
Expand Down Expand Up @@ -460,6 +460,14 @@
"Plugins_Filters_Mac" : "Mac Filter",
"Plugins_Out_of" : "out of",
"Plugins_no_control" : "No form control was found to render this value.",
"Plugins_type_core" : "Core",
"Plugins_type_core_icon" : "fa-solid fa-gem",
"Plugins_type_scanner" : "Scanners",
"Plugins_type_scanner_icon" : "fa-solid fa-magnifying-glass-plus",
"Plugins_type_system" : "System",
"Plugins_type_system_icon" : "fa-solid fa-gear",
"Plugins_type_publisher" : "Publishers",
"Plugins_type_publisher_icon" : "fa-solid fa-comment-dots",
"Settings_Metadata_Toggle" : "Show/hide metadata for the given setting.",
"settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database or app startup sequence.",
"settings_missing_block" : "You can not save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.",
Expand Down Expand Up @@ -546,21 +554,8 @@
"MQTT_display_name" : "MQTT",
"MQTT_icon" : "<i class=\"fa fa-square-rss\"></i>",
"REPORT_TITLE" : "Report",
"REPORT_ERROR" : "The page you are looking for is temporarily unavailable, please try again after a few seconds",
"REPORT_MQTT_name" : "Enable MQTT",
"REPORT_MQTT_description" : "Enable sending notifications via <a target=\"_blank\" href=\"https://www.home-assistant.io/integrations/mqtt/\">MQTT</a> to your Home Assistance instance.",
"MQTT_BROKER_name" : "MQTT broker URL",
"MQTT_BROKER_description" : "MQTT host URL (do not include <code>http://</code> or <code>https://</code>).",
"MQTT_PORT_name" : "MQTT broker port",
"MQTT_PORT_description" : "Port number where the broker is listening. Usually <code>1883</code>.",
"MQTT_USER_name" : "MQTT user",
"MQTT_USER_description" : "User name used to login into your MQTT broker instance.",
"MQTT_PASSWORD_name" : "MQTT password",
"MQTT_PASSWORD_description" : "Password used to login into your MQTT broker instance.",
"MQTT_QOS_name" : "MQTT Quality of Service",
"MQTT_QOS_description" : "Quality of service setting for MQTT message sending. <code>0</code> - Low quality to <code>2</code> - High quality. The higher the quality the longer the delay.",
"MQTT_DELAY_SEC_name" : "MQTT delay per device",
"MQTT_DELAY_SEC_description" : "A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~<code>2</code>s to update a sensor config on the broker). Tested with <code>2</code>-<code>3</code> seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn not affect subsequent scans or notifications.",
"REPORT_ERROR" : "The page you are looking for is temporarily unavailable, please try again after a few seconds",

"API_display_name" : "API",
"API_icon" : "<i class=\"fa fa-arrow-down-up-across-line\"></i>",
"API_CUSTOM_SQL_name" : "Custom endpoint",
Expand Down
1 change: 1 addition & 0 deletions front/plugins/_publisher_apprise/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"code_name": "_publisher_apprise",
"unique_prefix": "APPRISE",
"plugin_type": "publisher",
"enabled": true,
"data_source": "script",
"show_ui": true,
Expand Down
1 change: 1 addition & 0 deletions front/plugins/_publisher_email/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"code_name": "_publisher_email",
"unique_prefix": "SMTP",
"plugin_type": "publisher",
"enabled": true,
"data_source": "script",
"show_ui": true,
Expand Down
8 changes: 8 additions & 0 deletions front/plugins/_publisher_mqtt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Overview

- TBC

### Usage

- Go to settings and fill in relevant details.

Loading

0 comments on commit 8ad63ba

Please sign in to comment.