diff --git a/docs/DEBUG_PLUGINS.md b/docs/DEBUG_PLUGINS.md index 387726fd..bc809f26 100755 --- a/docs/DEBUG_PLUGINS.md +++ b/docs/DEBUG_PLUGINS.md @@ -58,7 +58,7 @@ Input data from the plugin might cause mapping issues in specific edge cases. Lo 17:31:06 [API] Updating table_plugins_history.json file in /front/api ``` -> The debug output between the 🔻red arrows🔺 is important for debugging (arrows added only to highlight the section on this page, they are not available in teh actual debug log) +> The debug output between the 🔻red arrows🔺 is important for debugging (arrows added only to highlight the section on this page, they are not available in the actual debug log) In the above output notice the section logging how many events are produced by the plugin: diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 0a295fc1..e52d05eb 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -164,7 +164,7 @@ @@ -182,7 +182,7 @@ @@ -239,7 +239,7 @@ @@ -257,7 +257,7 @@ @@ -335,7 +335,7 @@ @@ -828,15 +828,24 @@ function initializeiCheck () { function initializeCombos () { // Initialize combos with queries - initializeCombo ( '#dropdownDeviceType', 'getDeviceTypes', 'txtDeviceType', true); + initializeCombo ( '#dropdownIcon', 'getIcons', 'txtIcon', false); initializeCombo ( '#dropdownAction', 'getActions', 'txtAction', false); initializeCombo ( '#dropdownDevices', 'getDevices', 'txtFromDevice', false); - initSettingDropdown("NEWDEV_dev_Owner", [], "dropdownOwner_initSettingDropdown", generatedevDetailsList, 'txtOwner' ) - initSettingDropdown("NEWDEV_dev_Group", [], "dropdownGroup_initSettingDropdown", generatedevDetailsList, 'txtGroup' ) - initSettingDropdown("NEWDEV_dev_Location", [], "dropdownLocation_initSettingDropdown", generatedevDetailsList, 'txtLocation' ) - initSettingDropdown("NEWDEV_dev_Network_Node_MAC_ADDR", [], "dropdownNetworkNodeMac_initSettingDropdown", generatedevDetailsList, 'txtNetworkNodeMac' ) + // Initiate dropdown + // function initSettingDropdown(settingKey, // Identifier for the setting + // valuesArray, // Array of values to be pre-selected in the dropdown + // targetLocation, // ID of the HTML element where dropdown should be rendered (will be replaced) + // callbackToGenerateEntries, // Callback function to generate entries based on options + // targetField) // Target field or element where selected value should be applied or updated + + + initSettingDropdown("NEWDEV_dev_DeviceType", [], "dropdownDeviceType_tmp", genDevDetailsList, 'txtDeviceType' ) + initSettingDropdown("NEWDEV_dev_Owner", [], "dropdownOwner_tmp", genDevDetailsList, 'txtOwner' ) + initSettingDropdown("NEWDEV_dev_Group", [], "dropdownGroup_tmp", genDevDetailsList, 'txtGroup' ) + initSettingDropdown("NEWDEV_dev_Location", [], "dropdownLocation_tmp", genDevDetailsList, 'txtLocation' ) + initSettingDropdown("NEWDEV_dev_Network_Node_MAC_ADDR", [], "dropdownNetworkNodeMac_tmp", genDevDetailsList, 'txtNetworkNodeMac' ) // Initialize static combos initializeComboSkipRepeated (); diff --git a/front/js/ui_components.js b/front/js/ui_components.js index 74f3592c..ce48f409 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -113,7 +113,11 @@ $(function () { // ----------------------------------------------------------------------------- // Initiate dropdown -function initSettingDropdown(settingKey, valuesArray, targetLocation, callbackToGenerateEntries, targetField) +function initSettingDropdown(settingKey, // Identifier for the setting + valuesArray, // Array of values to be pre-selected in the dropdown + targetLocation, // ID of the HTML element where dropdown should be rendered (will be replaced) + callbackToGenerateEntries, // Callback function to generate entries based on options + targetField) // Target field or element where selected value should be applied or updated { var optionsHtml = "" @@ -179,7 +183,7 @@ function generateList(data, valuesArray) { // ----------------------------------------------------------------------------- // Processor to generate a list -function generatedevDetailsList(data, valuesArray, targetField) { +function genDevDetailsList(data, valuesArray, targetField) { var listHtml = ""; diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 38b3b558..6fc3eac2 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -46,8 +46,6 @@ case 'getDevicesList': getDevicesList(); break; case 'getDevicesListCalendar': getDevicesListCalendar(); break; - case 'getDeviceTypes': getDeviceTypes(); break; - case 'updateNetworkLeaf': updateNetworkLeaf(); break; case 'overwriteIconType': overwriteIconType(); break; case 'getIcons': getIcons(); break; @@ -813,77 +811,6 @@ function getDevices() { echo (json_encode ($tableData)); } - -//------------------------------------------------------------------------------ -// Query the List of types -//------------------------------------------------------------------------------ -function getDeviceTypes() { - global $db; - - // SQL - $sql = 'SELECT DISTINCT 9 as dev_Order, dev_DeviceType - FROM Devices - WHERE dev_DeviceType NOT IN ("", - "Smartphone", "Tablet", - "Laptop", "Mini PC", "PC", "Printer", "Server", "Singleboard Computer (SBC)", "NAS", - "Domotic", "IP Camera", "Game Console", "SmartTV", "TV Decoder", "Virtual Assistance", - "Clock", "House Appliance", "Phone", "Radio", - "AP", "Gateway", "Firewall", "Hypervisor", "Powerline", "Switch", "WLAN", "PLC", "Router","USB LAN Adapter", "USB WIFI Adapter" ) - - UNION SELECT 1 as dev_Order, "Smartphone" - UNION SELECT 1 as dev_Order, "Tablet" - - UNION SELECT 2 as dev_Order, "Laptop" - UNION SELECT 2 as dev_Order, "Mini PC" - UNION SELECT 2 as dev_Order, "PC" - UNION SELECT 2 as dev_Order, "Printer" - UNION SELECT 2 as dev_Order, "Server" - UNION SELECT 2 as dev_Order, "Singleboard Computer (SBC)" - UNION SELECT 2 as dev_Order, "NAS" - - UNION SELECT 3 as dev_Order, "Domotic" - UNION SELECT 3 as dev_Order, "IP Camera" - UNION SELECT 3 as dev_Order, "Game Console" - UNION SELECT 3 as dev_Order, "SmartTV" - UNION SELECT 3 as dev_Order, "TV Decoder" - UNION SELECT 3 as dev_Order, "Virtual Assistance" - - UNION SELECT 4 as dev_Order, "Clock" - UNION SELECT 4 as dev_Order, "House Appliance" - UNION SELECT 4 as dev_Order, "Phone" - UNION SELECT 4 as dev_Order, "Radio" - - -- network devices - UNION SELECT 5 as dev_Order, "AP" - UNION SELECT 5 as dev_Order, "Gateway" - UNION SELECT 5 as dev_Order, "Firewall" - UNION SELECT 5 as dev_Order, "Hypervisor" - UNION SELECT 5 as dev_Order, "Powerline" - UNION SELECT 5 as dev_Order, "Switch" - UNION SELECT 5 as dev_Order, "WLAN" - UNION SELECT 5 as dev_Order, "PLC" - UNION SELECT 5 as dev_Order, "Router" - UNION SELECT 5 as dev_Order, "USB LAN Adapter" - UNION SELECT 5 as dev_Order, "USB WIFI Adapter" - - UNION SELECT 10 as dev_Order, "Other" - - ORDER BY 1,2'; - - - $result = $db->query($sql); - - // arrays of rows - $tableData = array(); - while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { - $tableData[] = array ('order' => $row['dev_Order'], - 'name' => $row['dev_DeviceType']); - } - - // Return json - echo (json_encode ($tableData)); -} - // ---------------------------------------------------------------------------------------- function updateNetworkLeaf() { diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index ba81eb9f..58b5bbf1 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -139,7 +139,7 @@ { "name" : "value", "type" : "sql", - "value" : "SELECT Distinct id, name FROM (SELECT '' as id, '❌None' as name UNION SELECT dev_DeviceType as id, dev_DeviceType as name FROM (SELECT dev_DeviceType FROM Devices where dev_DeviceType <> '' UNION SELECT 'Smartphone' UNION SELECT 'Tablet' UNION SELECT 'Laptop' UNION SELECT 'PC' UNION SELECT 'Printer' UNION SELECT 'Server' UNION SELECT 'NAS' UNION SELECT 'Domotic' UNION SELECT 'Game Console' UNION SELECT 'SmartTV' UNION SELECT 'Clock' UNION SELECT 'House Appliance' UNION SELECT 'Phone' UNION SELECT 'AP' UNION SELECT 'Gateway' UNION SELECT 'Firewall' UNION SELECT 'Switch' UNION SELECT 'WLAN' UNION SELECT 'Router' UNION SELECT 'Other') AS all_devices ORDER BY id);" + "value" : "SELECT DISTINCT 9 as ord, dev_DeviceType as id, dev_DeviceType as name FROM Devices WHERE dev_DeviceType NOT IN ('', 'Smartphone', 'Tablet', 'Laptop', 'Mini PC', 'PC', 'Printer', 'Server', 'Singleboard Computer (SBC)', 'NAS', 'Domotic', 'IP Camera', 'Game Console', 'SmartTV', 'TV Decoder', 'Virtual Assistance', 'Clock', 'House Appliance', 'Phone', 'Radio', 'AP', 'Gateway', 'Firewall', 'Hypervisor', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router', 'USB LAN Adapter', 'USB WIFI Adapter') UNION SELECT 0 as ord, '', '❌None' UNION SELECT 1 as ord, '-----', '-- 📱Handhelds --' UNION SELECT 1 as ord, 'Smartphone', 'Smartphone' UNION SELECT 1 as ord, 'Tablet', 'Tablet' UNION SELECT 2 as ord, '-----', '-- 💻Computers --' UNION SELECT 2 as ord, 'Laptop', 'Laptop' UNION SELECT 2 as ord, 'Mini PC', 'Mini PC' UNION SELECT 2 as ord, 'PC', 'PC' UNION SELECT 2 as ord, 'Printer', 'Printer' UNION SELECT 2 as ord, 'Server', 'Server' UNION SELECT 2 as ord, 'Singleboard Computer (SBC)', 'Singleboard Computer (SBC)' UNION SELECT 2 as ord, 'NAS', 'NAS' UNION SELECT 3 as ord, '-----', '-- 🏠Smart home --' UNION SELECT 3 as ord, 'Domotic', 'Domotic' UNION SELECT 3 as ord, 'IP Camera', 'IP Camera' UNION SELECT 3 as ord, 'Game Console', 'Game Console' UNION SELECT 3 as ord, 'SmartTV', 'SmartTV' UNION SELECT 3 as ord, 'TV Decoder', 'TV Decoder' UNION SELECT 3 as ord, 'Virtual Assistance', 'Virtual Assistance' UNION SELECT 4 as ord, '-----', '-- Wired --' UNION SELECT 4 as ord, 'Clock', 'Clock' UNION SELECT 4 as ord, 'House Appliance', 'House Appliance' UNION SELECT 4 as ord, 'Phone', 'Phone' UNION SELECT 4 as ord, 'Radio', 'Radio' UNION SELECT 5 as ord, '-----', '-- 📡Network nodes --' UNION SELECT 5 as ord, 'AP', 'AP' UNION SELECT 5 as ord, 'Gateway', 'Gateway' UNION SELECT 5 as ord, 'Firewall', 'Firewall' UNION SELECT 5 as ord, 'Hypervisor', 'Hypervisor' UNION SELECT 5 as ord, 'Powerline', 'Powerline' UNION SELECT 5 as ord, 'Switch', 'Switch' UNION SELECT 5 as ord, 'WLAN', 'WLAN' UNION SELECT 5 as ord, 'PLC', 'PLC' UNION SELECT 5 as ord, 'Router', 'Router' UNION SELECT 5 as ord, 'USB LAN Adapter', 'USB LAN Adapter' UNION SELECT 5 as ord, 'USB WIFI Adapter', 'USB WIFI Adapter' UNION SELECT 9 as ord, '-----', '-- ⚙Custom --' UNION SELECT 10 as ord, '-----', '-----' UNION SELECT 10 as ord, 'Other', 'Other' ORDER BY 1,2;" }, { "name" : "uilang",