Move device settings into device edit simplify the interface and make it faster to setup provisioning.

This commit is contained in:
Mark Crane
2013-12-10 15:05:16 +00:00
parent b5c09c7934
commit 5b2a187bc7
4 changed files with 153 additions and 9 deletions

View File

@@ -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'] = "";

View File

@@ -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";

View File

@@ -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 " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-settings'].":</td>";
echo " <td class='vtable' align='left'>";
echo " <table width='75%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vtable'>".$text['label-device_setting_name']."</td>\n";
echo " <td class='vtable'>".$text['label-device_setting_value']."</td>\n";
echo " <td class='vtable'>".$text['label-enabled']."</td>\n";
echo " <td class='vtable'>".$text['label-device_setting_description']."</td>\n";
echo " <td>&nbsp;</td>\n";
echo " </tr>\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 " <tr>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_setting_subcategory']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_setting_value']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_setting_enabled']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_setting_description']."&nbsp;\n";
echo " </td>\n";
echo " <td>\n";
if (permission_exists('device_edit')) {
echo " <a href='device_setting_edit.php?device_uuid=".$row['device_uuid']."&id=".$row['device_setting_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
}
if (permission_exists('device_delete')) {
echo " <a href='device_setting_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_setting_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo " </tr>\n";
}
echo "<tr>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_setting_subcategory' style='width: 120px;' maxlength='255' value=\"$device_setting_subcategory\">\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_setting_value' style='width: 120px;' maxlength='255' value=\"$device_setting_value\">\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='device_setting_enabled' style='width: 90px;'>\n";
echo " <option value=''></option>\n";
if ($device_setting_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($device_setting_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_setting_description' style='width: 150px;' maxlength='255' value=\"$device_setting_description\">\n";
echo "</td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
if (strlen($text['description-settings']) > 0) {
echo " <br>".$text['description-settings']."\n";
}
echo " </td>";
echo " </tr>";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_vendor'].":\n";

View File

@@ -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 "<th>".$text['label-tools']."</th>\n";
echo th_order_by('device_description', $text['label-device_description'], $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('device_add')) {
@@ -144,9 +143,6 @@ else {
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_username']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_password']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_time_zone']."&nbsp;</td>\n";
echo " <td valign='middle' class='".$row_style[$c]."'>\n";
echo " <a href='device_settings.php?id=".$row['device_uuid']."'>".$text['label-settings']."</a>&nbsp;&nbsp;\n";
echo " </td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['device_description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
if (permission_exists('device_edit')) {