diff --git a/app/devices/app_config.php b/app/devices/app_config.php index f3b7ce32ac..446c313cf5 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -2,7 +2,7 @@ //application details $apps[$x]['name'] = "Devices"; $apps[$x]['uuid'] = "4efa1a1a-32e7-bf83-534b-6c8299958a8e"; - $apps[$x]['category'] = "Switch";; + $apps[$x]['category'] = "Switch"; $apps[$x]['subcategory'] = ""; $apps[$x]['version'] = ""; $apps[$x]['license'] = "Mozilla Public License 1.1"; @@ -86,7 +86,7 @@ $apps[$x]['permissions'][$y]['name'] = "device_line_delete"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; - + $y++; $apps[$x]['permissions'][$y]['name'] = "device_setting_view"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; @@ -283,7 +283,7 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the password."; $z++; - + $y = 3; //table array index $z = 0; //field array index $apps[$x]['db'][$y]['table'] = "v_device_settings"; @@ -303,6 +303,15 @@ $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "device_uuid"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "device_setting_category"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index d5f02d92f2..309bf764c4 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -185,6 +185,7 @@ $text['description-device_description']['pt-pt'] = "Introduza a descrição."; $text['description-device_description']['fr-fr'] = ""; + //general translations $text['label-true']['en-us'] = "true"; $text['label-true']['pt-pt'] = "sim"; $text['label-true']['fr-fr'] = "Oui"; @@ -220,7 +221,7 @@ $text['label-tools']['en-us'] = "Tools"; $text['label-tools']['pt-pt'] = "Ferramentas"; $text['label-tools']['fr-fr'] = "Outils"; - + $text['label-settings']['en-us'] = "Settings"; $text['label-settings']['pt-pt'] = "Definições"; $text['label-settings']['fr-fr'] = "Configurations"; @@ -244,7 +245,7 @@ $text['message-required']['en-us'] = "Please provide: "; $text['message-required']['pt-pt'] = "Por favor indique: "; $text['message-required']['fr-fr'] = "Merci d'indiquer: "; - + $text['label-category']['en-us'] = "Category"; $text['label-category']['pt-pt'] = "Categoria"; $text['label-category']['fr-fr'] = "Catégorie"; @@ -253,6 +254,18 @@ $text['description-category']['pt-pt'] = "Introduza a categoria."; $text['description-category']['fr-fr'] = ""; + $text['label-device_setting_name']['en-us'] = "Name"; + $text['label-device_setting_name']['pt-pt'] = "Name"; + $text['label-device_setting_name']['fr-fr'] = "Nom"; + + $text['label-device_setting_value']['en-us'] = "Value"; + $text['label-device_setting_value']['pt-pt'] = "Valor"; + $text['label-device_setting_value']['fr-fr'] = "Valeur"; + + $text['label-device_setting_description']['en-us'] = "Description"; + $text['label-device_setting_description']['pt-pt'] = ""; + $text['label-device_setting_description']['fr-fr'] = ""; + $text['label-subcategory']['en-us'] = "Subcategory"; $text['label-subcategory']['pt-pt'] = "Subcategoria"; $text['label-subcategory']['fr-fr'] = "Sous-Catégorie"; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index f58958b685..f82cb2b498 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -74,6 +74,13 @@ require_once "resources/require.php"; $user_id = check_str($_POST["user_id"]); $auth_id = check_str($_POST["auth_id"]); $password = check_str($_POST["password"]); + //settings + //$device_setting_category = check_str($_POST["device_setting_category"]); + $device_setting_subcategory = check_str($_POST["device_setting_subcategory"]); + //$device_setting_name = check_str($_POST["device_setting_name"]); + $device_setting_value = check_str($_POST["device_setting_value"]); + $device_setting_enabled = check_str($_POST["device_setting_enabled"]); + $device_setting_description = check_str($_POST["device_setting_description"]); } //use the mac address to find the vendor @@ -238,6 +245,38 @@ require_once "resources/require.php"; unset($sql); } + //add the device settings + if (strlen($device_setting_subcategory) > 0 && permission_exists('device_setting_add')) { + $device_setting_category = "provision"; + $device_setting_name = "text"; + $sql = "insert into v_device_settings "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "device_uuid, "; + $sql .= "device_setting_uuid, "; + $sql .= "device_setting_category, "; + $sql .= "device_setting_subcategory, "; + $sql .= "device_setting_name, "; + $sql .= "device_setting_value, "; + $sql .= "device_setting_enabled, "; + $sql .= "device_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$device_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$device_setting_category', "; + $sql .= "'$device_setting_subcategory', "; + $sql .= "'$device_setting_name', "; + $sql .= "'$device_setting_value', "; + $sql .= "'$device_setting_enabled', "; + $sql .= "'$device_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + //write the provision files require_once "app/provision/provision_write.php"; @@ -478,6 +517,93 @@ require_once "resources/require.php"; echo " "; echo " "; + echo "
| ".$text['label-device_setting_name']." | \n"; + echo "".$text['label-device_setting_value']." | \n"; + echo "".$text['label-enabled']." | \n"; + echo "".$text['label-device_setting_description']." | \n"; + echo "\n"; + echo " |
| \n"; + echo " ".$row['device_setting_subcategory']." \n"; + echo " | \n"; + echo "\n"; + echo " ".$row['device_setting_value']." \n"; + echo " | \n"; + echo "\n"; + echo " ".$row['device_setting_enabled']." \n"; + echo " | \n"; + echo "\n"; + echo " ".$row['device_setting_description']." \n"; + echo " | \n"; + echo "\n"; + if (permission_exists('device_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('device_delete')) { + echo " $v_link_label_delete\n"; + } + echo " | \n"; + echo "
| \n"; + echo " \n"; + echo " | \n"; + + echo "\n"; + echo " \n"; + echo " | \n"; + + echo "\n"; + echo " \n"; + echo " | \n"; + + echo "\n"; + echo " \n"; + echo " | \n"; + + echo "\n"; + echo " \n"; + echo " | \n"; + echo "