diff --git a/.gitignore b/.gitignore index c8eded4f..edf44c23 100755 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ config/pialert.conf db/* db/pialert.db front/log/* +front/api/* **/plugins/**/*.log **/%40eaDir/ **/@eaDir/ diff --git a/docker-compose.yml b/docker-compose.yml index cf3a4c5c..1d2594b1 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ services: - ${DEV_LOCATION}/front/css:/home/pi/pialert/front/css - ${DEV_LOCATION}/front/lib/AdminLTE:/home/pi/pialert/front/lib/AdminLTE - ${DEV_LOCATION}/front/js:/home/pi/pialert/front/js + - ${DEV_LOCATION}/front/api:/home/pi/pialert/front/api - ${DEV_LOCATION}/front/php:/home/pi/pialert/front/php - ${DEV_LOCATION}/front/deviceDetails.php:/home/pi/pialert/front/deviceDetails.php - ${DEV_LOCATION}/front/devices.php:/home/pi/pialert/front/devices.php @@ -45,6 +46,7 @@ services: - ${DEV_LOCATION}/front/network.php:/home/pi/pialert/front/network.php - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php + - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes # --------------------------------------------------------------------------- diff --git a/front/css/pialert.css b/front/css/pialert.css index 22acde6b..24d017db 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -740,6 +740,15 @@ height: 50px; { cursor:pointer; } + +.drag +{ + cursor: move; /* fallback if grab cursor is unsupported */ + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; +} + .db_info_table_row .select2-container--default .select2-selection--multiple .select2-selection__choice { background-color:#258744; diff --git a/front/flows.php b/front/flows.php new file mode 100644 index 00000000..d038c774 --- /dev/null +++ b/front/flows.php @@ -0,0 +1,31 @@ + + + + + +
+ + +
+ +

+ + +

+
+ + + + + +
+ + \ No newline at end of file diff --git a/front/network.php b/front/network.php index c6e58d47..0eb7e451 100755 --- a/front/network.php +++ b/front/network.php @@ -24,8 +24,7 @@ - -
+
@@ -448,6 +447,7 @@ require 'php/templates/footer.php'; ?> + @@ -607,6 +607,19 @@ }); } + // --------------------------------------------------------------------------- + function handleNodeClick(event) + { + + console.log(event.target.offsetParent) + + const targetTabMAC = $(event.target.offsetParent).attr("data-mytreemacmain"); + + var targetTab = $(`a[data-mytabmac="${targetTabMAC}"]`); + + // Simulate a click event on the target tab + targetTab.click(); + } // --------------------------------------------------------------------------- var myTree; var treeAreaHeight = 800; @@ -642,7 +655,7 @@ highlightedCss = nodeData.data.mac == selectedNodeMac ? " highlightedNode" : ""; - return result = "
"> - +
  • + +
  • diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 3f57aaf1..7a14cbbd 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -42,6 +42,7 @@ "Navigation_Plugins" : "Plugins", "Navigation_Maintenance" : "Maintenance", "Navigation_Settings" : "Settings", + "Navigation_Flows" : "Flows", "Navigation_HelpFAQ" : "Help / FAQ", "Device_Title" : "Devices", "Device_Shortcut_AllDevices" : "All Devices", @@ -298,7 +299,7 @@ "Maintenance_Tool_del_ActHistory_noti" : "Delete network activity", "Maintenance_Tool_del_ActHistory_noti_text" : "Are you sure you want to reset the network activity?", "Maintenance_Tool_ExportCSV" : "CSV Export", - "Maintenance_Tool_ExportCSV_text" : "Generate a CSV (comma separated value) file containing the list of Devices including the Network relationships between Network Nodes and connected devices.", + "Maintenance_Tool_ExportCSV_text" : "Generate a CSV (comma separated value) file containing the list of Devices including the Network relationships between Network Nodes and connected devices. You can also trigger this by acessing this URL your pialert url/php/server/devices.php?action=ExportCSV", "Maintenance_Tool_ExportCSV_noti" : "CSV Export", "Maintenance_Tool_ExportCSV_noti_text" : "Are you sure you want to generate a CSV file?", "Maintenance_Tool_ImportCSV" : "CSV Import", diff --git a/front/plugins/known_template/README.md b/front/plugins/known_template/README.md new file mode 100755 index 00000000..ba16b097 --- /dev/null +++ b/front/plugins/known_template/README.md @@ -0,0 +1,11 @@ +## Overview + +A simple template-based plugin for known devices. You can change to overwrite values for known devices. + +### Usage + +- Head to **Settings** > **Known Devices** to adjust the default values. + +### Notes + +- This plugin generates editable settings that are then used in the `device.py` script to initialize new values. TO FIX \ No newline at end of file diff --git a/front/plugins/known_template/config.json b/front/plugins/known_template/config.json new file mode 100755 index 00000000..ce750874 --- /dev/null +++ b/front/plugins/known_template/config.json @@ -0,0 +1,567 @@ +{ + "code_name": "Devices.known", + "template_type": "database-entry", + "unique_prefix": "KNWN", + "enabled": true, + "data_source": "template", + "localized": ["display_name", "description", "icon"], + "display_name": [{ + "language_code": "en_us", + "string": "Known Devices" + }], + "description": [{ + "language_code": "en_us", + "string": "The template used for known devices." + }], + "icon": [ + { + "language_code": "en_us", + "string": "" + } + ], + "params" : [ + { + "name" : "target_macs", + "type" : "setting", + "value" : "KNWN_target_macs" + }, + { + "name" : "dev_AlertDeviceDown", + "type" : "setting", + "value" : "KNWN_dev_AlertDeviceDown" + }, + { + "name" : "dev_AlertEvents", + "type" : "setting", + "value" : "KNWN_dev_AlertEvents" + } + ], + "settings":[ + { + "function": "target_macs", + "type": "readonly", + "maxLength": 50, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Target devices" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The MAC address of the devices to update. Uneditable. This parameter is dynamically updated via a Flow." + } + ] + }, + { + "function": "CMD", + "type": "text", + "default_value":"UPDATE Devices SET dev_AlertDeviceDown = {KNWN_dev_AlertDeviceDown}, dev_AlertEvents = {KNWN_dev_AlertEvents} WHERE dev_MAC in ({target_macs})", + "options": [], + "localized": ["name", "description"], + "name" : [{ + "language_code":"en_us", + "string" : "UPDATE SQL" + }], + "description": [{ + "language_code":"en_us", + "string" : "This SQL query is used to update target devices." + }] + }, + { + "function": "dev_Name", + "type": "readonly", + "maxLength": 50, + "default_value": "(unknown)", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Name" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The name of the device. Uneditable as internal functionality is dependent on specific new device names." + } + ] + }, + { + "function": "dev_Owner", + "type": "string", + "maxLength": 30, + "default_value": "House", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Owner" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The owner of the device." + } + ] + }, + { + "function": "dev_DeviceType", + "type": "string", + "maxLength": 30, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Type" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The type of the device." + } + ] + }, + { + "function": "dev_Vendor", + "type": "readonly", + "maxLength": 250, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Vendor" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The vendor of the device. Uneditable - Autodetected." + } + ] + }, + { + "function": "dev_Favorite", + "type": "integer.checkbox", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Favorite Device" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether the device is marked as a favorite." + } + ] + }, + { + "function": "dev_Group", + "type": "string", + "maxLength": 10, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Group" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The group to which the device belongs." + } + ] + }, + { + "function": "dev_Comments", + "type": "string", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Comments" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Additional comments or notes about the device." + } + ] + }, + { + "function": "dev_FirstConnection", + "type": "readonly", + "format": "date-time", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "First Connection" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The date and time of the first connection with the device. Uneditable - Autodetected." + } + ] + }, + { + "function": "dev_LastConnection", + "type": "readonly", + "format": "date-time", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Last Connection" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The date and time of the last connection with the device. Uneditable - Autodetected." + } + ] + }, + { + "function": "dev_LastIP", + "type": "readonly", + "maxLength": 50, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Last IP" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The last known IP address of the device. Uneditable - Autodetected." + } + ] + }, + { + "function": "dev_StaticIP", + "type": "integer.checkbox", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Static IP" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether the device has a static IP address." + } + ] + }, + { + "function": "dev_ScanCycle", + "type": "integer.checkbox", + "default_value": 1, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Scan Cycle" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The default value of the Scan device dropdown. Enable if newly discovered devices should be scanned." + } + ] + }, + { + "function": "dev_LogEvents", + "type": "integer.checkbox", + "default_value": 1, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Log Events" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether events related to the device shouldbe logged." + }] + }, + { + "function": "dev_AlertEvents", + "type": "integer.checkbox", + "default_value": 1, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Alert Events" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether events related to the device should trigger alerts. The default value of the Alert All Events checkbox." + } + ] + }, + { + "function": "dev_AlertDeviceDown", + "type": "integer.checkbox", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Alert Device Down" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether an alert should be triggered when the device goes down. The default value of the Alert Down checkbox." + } + ] + }, + { + "function": "dev_SkipRepeated", + "type": "integer", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Skip Repeated" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The default value of the Skip repeated notifications for dropdown. Enter number of hours for which repeated notifications should be ignored for. If you enter 0 then you get notified on all events." + } + ] + }, + { + "function": "dev_LastNotification", + "type": "readonly", + "format": "date-time", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Last Notification" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The date and time of the last notification sent for the device. Uneditable - Autodetected." + } + ] + }, + { + "function": "dev_PresentLastScan", + "type": "integer.checkbox", + "default_value": 1, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Present Last Scan" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether the device should be marked as present after detected in a scan." + } + ] + }, + { + "function": "dev_NewDevice", + "type": "integer.checkbox", + "default_value": true, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "New Device" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether the device is considered a new device. The default value of the New Device checkbox." + } + ] + }, + { + "function": "dev_Location", + "type": "string", + "maxLength": 250, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Location" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The location of the device." + } + ] + }, + { + "function": "dev_Archived", + "type": "integer.checkbox", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Archived" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Indicates whether the device is archived. The default value of the Archived checkbox." + } + ] + }, + { + "function": "dev_Network_Node_MAC_ADDR", + "type": "string", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Network Node MAC Address" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The MAC address of the network node." + } + ] + }, + { + "function": "dev_Network_Node_port", + "type": "readonly", + "default_value": 0, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Network Node Port" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The port number of the network node. Uneditable." + } + ] + }, + { + "function": "dev_Icon", + "type": "string", + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Device Icon" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "The icon associated with the device. Check the documentation on icons for more details." + } + ] + } + ], + "required": [ + "dev_MAC", + "dev_Name", + "dev_Owner", + "dev_FirstConnection", + "dev_LastConnection", + "dev_LastIP", + "dev_StaticIP", + "dev_ScanCycle", + "dev_LogEvents", + "dev_AlertEvents", + "dev_AlertDeviceDown", + "dev_SkipRepeated", + "dev_LastNotification", + "dev_PresentLastScan", + "dev_NewDevice", + "dev_Location", + "dev_Archived", + "dev_Network_Node_MAC_ADDR", + "dev_Network_Node_port", + "dev_Icon" + ], + "additionalProperties": false + } + + + \ No newline at end of file diff --git a/front/pluginsCore.php b/front/pluginsCore.php index 4c155260..b5cc9757 100755 --- a/front/pluginsCore.php +++ b/front/pluginsCore.php @@ -335,7 +335,7 @@ function generateTabs()
  • - (${histCountDisplayed} out of ${histCount} ) + (${histCountDisplayed} out of ${histCount})
  • diff --git a/pialert/flows/unmark_new.json b/pialert/flows/apply_template.json similarity index 89% rename from pialert/flows/unmark_new.json rename to pialert/flows/apply_template.json index 10321cfb..0df0952d 100755 --- a/pialert/flows/unmark_new.json +++ b/pialert/flows/apply_template.json @@ -1,5 +1,5 @@ { - "name":"unmark_new", + "name":"apply_template", "triggers": [ { "type": "new", @@ -50,8 +50,10 @@ "type": "plugin", "params": { - "name": "UNMRK_NEW", - "CMD": "db.row" + "unique_prefix": "KNWN", + "override":{ + + } } } diff --git a/pialert/initialise.py b/pialert/initialise.py index 1b28a2d4..1125538d 100755 --- a/pialert/initialise.py +++ b/pialert/initialise.py @@ -40,12 +40,12 @@ def ccd(key, default, config_dir, name, inputtype, options, group, events=[], de conf.mySettingsSQLsafe.append((key, name, desc, inputtype, options, regex, str(result), group, str(events))) # save metadata in dummy setting if '__metadata' not in key: - conf.mySettingsSQLsafe.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, [])) + conf.mySettingsSQLsafe.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, '')) conf.mySettings.append((key, name, desc, inputtype, options, regex, result, group, str(events))) # save metadata in dummy setting if '__metadata' not in key: - conf.mySettings.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, [])) + conf.mySettings.append((f'{key}__metadata', "metadata name", "metadata desc", 'json', "", "", json.dumps(setJsonMetadata), group, '')) return result #-------------------------------------------------------------------------------