From a6ddfb678c85048d1710554ba94b2e0a2229d231 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Tue, 10 Dec 2013 15:05:16 +0000 Subject: [PATCH] Move device settings into device edit simplify the interface and make it faster to setup provisioning. --- app/devices/app_config.php | 15 +++- app/devices/app_languages.php | 17 ++++- app/devices/device_edit.php | 126 ++++++++++++++++++++++++++++++++++ app/devices/devices.php | 4 -- 4 files changed, 153 insertions(+), 9 deletions(-) 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 " "; + echo " ".$text['label-settings'].":"; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + $sql = "SELECT * FROM v_device_settings "; + $sql .= "WHERE domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "AND device_uuid = '".$device_uuid."' "; + $sql .= "ORDER by device_setting_subcategory asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $row) { + //if (strlen($row['line_number']) == 0) { $row['line_number'] = "1"; } + 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 "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']." 
\n"; + echo " ".$row['device_setting_subcategory']." \n"; + echo " \n"; + echo " ".$row['device_setting_value']." \n"; + echo " \n"; + echo " ".$row['device_setting_enabled']." \n"; + echo " \n"; + echo " ".$row['device_setting_description']." \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"; + if (strlen($text['description-settings']) > 0) { + echo "
".$text['description-settings']."\n"; + } + echo " "; + echo " "; + echo "\n"; echo "\n"; echo " ".$text['label-device_vendor'].":\n"; diff --git a/app/devices/devices.php b/app/devices/devices.php index cf2a7bc861..2f43126b23 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -115,7 +115,6 @@ else { //echo th_order_by('device_username', $text['label-device_username'], $order_by, $order); //echo th_order_by('device_password', $text['label-device_password'], $order_by, $order); //echo th_order_by('device_time_zone', $text['label-device_time_zone'], $order_by, $order); - echo "".$text['label-tools']."\n"; echo th_order_by('device_description', $text['label-device_description'], $order_by, $order); echo "\n"; if (permission_exists('device_add')) { @@ -144,9 +143,6 @@ else { //echo " ".$row['device_username']." \n"; //echo " ".$row['device_password']." \n"; //echo " ".$row['device_time_zone']." \n"; - echo " \n"; - echo " ".$text['label-settings']."  \n"; - echo " \n"; echo " ".$row['device_description']." \n"; echo " \n"; if (permission_exists('device_edit')) {