`;
+
+ });
+
return listHtml;
}
diff --git a/front/php/server/devices.php b/front/php/server/devices.php
index a05f8b33..38b3b558 100755
--- a/front/php/server/devices.php
+++ b/front/php/server/devices.php
@@ -24,7 +24,6 @@
switch ($action) {
case 'getDeviceData': getDeviceData(); break;
case 'setDeviceData': setDeviceData(); break;
- case 'getNetworkNodes': getNetworkNodes(); break;
case 'deleteDevice': deleteDevice(); break;
case 'deleteAllWithEmptyMACs': deleteAllWithEmptyMACs(); break;
case 'createBackupDB': createBackupDB(); break;
@@ -47,10 +46,8 @@
case 'getDevicesList': getDevicesList(); break;
case 'getDevicesListCalendar': getDevicesListCalendar(); break;
- case 'getOwners': getOwners(); break;
case 'getDeviceTypes': getDeviceTypes(); break;
- case 'getGroups': getGroups(); break;
- case 'getLocations': getLocations(); break;
+
case 'updateNetworkLeaf': updateNetworkLeaf(); break;
case 'overwriteIconType': overwriteIconType(); break;
case 'getIcons': getIcons(); break;
@@ -743,74 +740,9 @@ function getDevicesListCalendar() {
}
-//------------------------------------------------------------------------------
-// Query the List of Owners
-//------------------------------------------------------------------------------
-function getOwners() {
- global $db;
-
- // SQL
- $sql = 'SELECT DISTINCT 1 as dev_Order, dev_Owner
- FROM Devices
- WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
- AND dev_Favorite = 1
- UNION
- SELECT DISTINCT 2 as dev_Order, dev_Owner
- FROM Devices
- WHERE dev_Owner <> "(unknown)" AND dev_Owner <> ""
- AND dev_Favorite = 0
- AND dev_Owner NOT IN
- (SELECT dev_Owner FROM Devices WHERE dev_Favorite = 1)
- 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_Owner']);
- }
-
- // Return json
- echo (json_encode ($tableData));
-}
-
-
//------------------------------------------------------------------------------
// Query Device Data
//------------------------------------------------------------------------------
-function getNetworkNodes() {
- global $db;
-
- // Device Data
- $networkDeviceTypes = str_replace("]", "",(str_replace("[", "", getSettingValue("NETWORK_DEVICE_TYPES"))));
-
-
- $sql = 'SELECT * FROM Devices WHERE dev_DeviceType in ( '. $networkDeviceTypes .' )';
-
- // echo $sql;
-
- $result = $db->query($sql);
-
- // arrays of rows
- $tableData = array();
- while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
- // Push row data
- $tableData[] = array('id' => $row['dev_MAC'],
- 'name' => $row['dev_Name'] );
- }
-
- // Add an empty option at the bottom
- $tableData[] = array('id' => '', 'name' => '❌'.lang("Network_ManageUnassign")); // Add empty option
-
- // Control no rows
- if (empty($tableData)) {
- $tableData = [];
- }
-
- // Return json
- echo (json_encode ($tableData));
-}
//------------------------------------------------------------------------------
function getIcons() {
@@ -951,86 +883,6 @@ function getDeviceTypes() {
// Return json
echo (json_encode ($tableData));
}
-//------------------------------------------------------------------------------
-// Query the List of groups
-//------------------------------------------------------------------------------
-function getGroups() {
- global $db;
-
- // SQL
- $sql = 'SELECT DISTINCT 1 as dev_Order, dev_Group
- FROM Devices
- WHERE dev_Group NOT IN ("(unknown)", "Others") AND dev_Group <> ""
- UNION SELECT 1 as dev_Order, "Always on"
- UNION SELECT 1 as dev_Order, "Friends"
- UNION SELECT 1 as dev_Order, "Personal"
- UNION SELECT 2 as dev_Order, "Others"
- 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_Group']);
- }
-
- // Return json
- echo (json_encode ($tableData));
-}
-
-
-//------------------------------------------------------------------------------
-// Query the List of locations
-//------------------------------------------------------------------------------
-function getLocations() {
- global $db;
-
- // SQL
- $sql = 'SELECT DISTINCT 9 as dev_Order, dev_Location
- FROM Devices
- WHERE dev_Location <> ""
- AND dev_Location NOT IN (
- "Bathroom", "Bedroom", "Dining room", "Hallway",
- "Kitchen", "Laundry", "Living room", "Study",
- "Attic", "Basement", "Garage",
- "Back yard", "Garden", "Terrace",
- "Other")
-
- UNION SELECT 1 as dev_Order, "Bathroom"
- UNION SELECT 1 as dev_Order, "Bedroom"
- UNION SELECT 1 as dev_Order, "Dining room"
- UNION SELECT 1 as dev_Order, "Hall"
- UNION SELECT 1 as dev_Order, "Kitchen"
- UNION SELECT 1 as dev_Order, "Laundry"
- UNION SELECT 1 as dev_Order, "Living room"
- UNION SELECT 1 as dev_Order, "Study"
-
- UNION SELECT 2 as dev_Order, "Attic"
- UNION SELECT 2 as dev_Order, "Basement"
- UNION SELECT 2 as dev_Order, "Garage"
-
- UNION SELECT 3 as dev_Order, "Back yard"
- UNION SELECT 3 as dev_Order, "Garden"
- UNION SELECT 3 as dev_Order, "Terrace"
-
- 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_Location']);
- }
-
- // 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 cd224ef9..ba81eb9f 100755
--- a/front/plugins/newdev_template/config.json
+++ b/front/plugins/newdev_template/config.json
@@ -112,7 +112,7 @@
{
"name" : "value",
"type" : "sql",
- "value" : "SELECT DISTINCT '' as id, '' as name UNION SELECT dev_Owner as id, dev_Owner as name FROM (SELECT dev_Owner FROM Devices UNION SELECT 'House' ) AS all_devices ORDER BY id;"
+ "value" : "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT dev_Owner as id, dev_Owner as name FROM (SELECT dev_Owner FROM Devices UNION SELECT 'House' ) AS all_devices ORDER BY id;"
}
],
"localized": ["name", "description"],
@@ -139,7 +139,7 @@
{
"name" : "value",
"type" : "sql",
- "value" : "SELECT '' as id, '' as name UNION SELECT dev_DeviceType as id, dev_DeviceType as name FROM (SELECT dev_DeviceType FROM Devices 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 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);"
},
{
"name" : "uilang",
@@ -210,7 +210,7 @@
{
"name" : "value",
"type" : "sql",
- "value" : "SELECT DISTINCT '' as id, '' as name UNION SELECT dev_Group as id, dev_Group as name FROM (SELECT dev_Group FROM Devices UNION SELECT 'Personal' ) AS all_devices ORDER BY id;"
+ "value" : "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT dev_Group as id, dev_Group as name FROM (SELECT dev_Group FROM Devices WHERE dev_Group <> '' UNION SELECT 'Personal' UNION SELECT 'Always on' UNION SELECT 'Friends' UNION SELECT 'Others' ) AS all_devices ORDER BY id;"
}
],
"localized": ["name", "description"],
@@ -494,7 +494,7 @@
{
"name" : "value",
"type" : "sql",
- "value" : "SELECT DISTINCT '' as id, '' as name UNION SELECT dev_Location as id, dev_Location as name FROM (SELECT dev_Location FROM Devices where dev_Location not in (null, 'null', '') UNION SELECT 'Bathroom' UNION SELECT 'Bedroom' UNION SELECT 'Dining room' UNION SELECT 'Hall' UNION SELECT 'Kitchen' UNION SELECT 'Laundry' UNION SELECT 'Living room' UNION SELECT 'Study' UNION SELECT 'Attic' UNION SELECT 'Basement' UNION SELECT 'Garage' UNION SELECT 'Back yard' UNION SELECT 'Garden' UNION SELECT 'Terrace') AS all_devices ORDER BY id; "
+ "value" : "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT dev_Location as id, dev_Location as name FROM (SELECT dev_Location FROM Devices where dev_Location not in (null, 'null', '') UNION SELECT 'Bathroom' UNION SELECT 'Bedroom' UNION SELECT 'Dining room' UNION SELECT 'Hall' UNION SELECT 'Kitchen' UNION SELECT 'Laundry' UNION SELECT 'Living room' UNION SELECT 'Study' UNION SELECT 'Attic' UNION SELECT 'Basement' UNION SELECT 'Garage' UNION SELECT 'Back yard' UNION SELECT 'Garden' UNION SELECT 'Terrace') AS all_devices ORDER BY id; "
}
],
"localized": ["name", "description"],
@@ -539,7 +539,7 @@
{
"name" : "value",
"type" : "sql",
- "value" : "SELECT '' as name, '' as id UNION SELECT Dev_Name as name, dev_MAC as id FROM Devices WHERE EXISTS (SELECT 1 FROM Settings WHERE Code_Name = 'NETWORK_DEVICE_TYPES' AND LOWER(value) LIKE '%' || LOWER(dev_DeviceType) || '%' AND dev_DeviceType <> '')"
+ "value" : "SELECT '❌None' as name, '' as id UNION SELECT Dev_Name as name, dev_MAC as id FROM Devices WHERE EXISTS (SELECT 1 FROM Settings WHERE Code_Name = 'NETWORK_DEVICE_TYPES' AND LOWER(value) LIKE '%' || LOWER(dev_DeviceType) || '%' AND dev_DeviceType <> '')"
},
{
"name" : "target_macs",
diff --git a/front/settings.php b/front/settings.php
index ae793682..dc56e6ca 100755
--- a/front/settings.php
+++ b/front/settings.php
@@ -528,23 +528,16 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// generate a list of options for a input select
function generateInputOptions(pluginsData, set, input, isMultiSelect = false)
{
-
- var optionsHtml = ""
-
multi = isMultiSelect ? "multiple" : "";
optionsArray = getSettingOptions(set['Code_Name'] )
- valuesArray = createArray(set['Value']);
-
+ valuesArray = createArray(set['Value']);
- var targetLocation = set['Code_Name'] + "_initSettingDropdown";
-
- // placeholder option which will be replaced on callback
- optionsHtml += ``;
+ // create unique ID
+ var targetLocation = set['Code_Name'] + "_initSettingDropdown";
// execute AJAX callabck + SQL query resolution
- initSettingDropdown(set['Code_Name'] , valuesArray, targetLocation, generateDropdownOptions)
-
+ initSettingDropdown(set['Code_Name'] , valuesArray, targetLocation, generateDropdownOptions)
// main selection dropdown wrapper
input += `
@@ -553,7 +546,8 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
class="form-control"
name="${set['Code_Name']}"
id="${set['Code_Name']}" ${multi}>
- ${optionsHtml}
+
+
`;