Minor improvements

This commit is contained in:
jose.gonzalez@pandorafms.com 2022-11-24 10:00:42 +01:00
parent 6eb9319a7a
commit 9d0f465874
2 changed files with 47 additions and 122 deletions

View File

@ -329,10 +329,6 @@ if ($module_action === 'delete') {
} }
} }
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
default:
$result = db_process_sql_delete( $result = db_process_sql_delete(
'tagente_estado', 'tagente_estado',
['id_agente_modulo' => $id_agent_module_del] ['id_agente_modulo' => $id_agent_module_del]
@ -348,28 +344,6 @@ if ($module_action === 'delete') {
if ($result === false) { if ($result === false) {
$error++; $error++;
} }
break;
case 'oracle':
$result = db_process_delete_temp(
'tagente_estado',
'id_agente_modulo',
$id_agent_module_del
);
if ($result === false) {
$error++;
}
$result = db_process_delete_temp(
'tagente_datos_inc',
'id_agente_modulo',
$id_agent_module_del
);
if ($result === false) {
$error++;
}
break;
}
// Trick to detect if we are deleting a synthetic module (avg or arithmetic). // Trick to detect if we are deleting a synthetic module (avg or arithmetic).
// If result is empty then module doesn't have this type of submodules. // If result is empty then module doesn't have this type of submodules.
@ -378,7 +352,7 @@ if ($module_action === 'delete') {
[$id_agent_module_del] [$id_agent_module_del]
); );
$result_ops_synthetic = json_decode($ops_json); $result_ops_synthetic = json_decode($ops_json);
if (!empty($result_ops_synthetic)) { if (empty($result_ops_synthetic) === false) {
$result = enterprise_hook( $result = enterprise_hook(
'modules_delete_synthetic_operations', 'modules_delete_synthetic_operations',
[$id_agent_module_del] [$id_agent_module_del]
@ -392,13 +366,13 @@ if ($module_action === 'delete') {
[$id_agent_module_del] [$id_agent_module_del]
); );
$count_components = 1; $count_components = 1;
if (!empty($result_components)) { if (empty($result_components) === false) {
// Get number of components pending to delete to know when it's needed to update orders. // Get number of components pending to delete to know when it's needed to update orders.
$num_components = count($result_components); $num_components = count($result_components);
$last_target_module = 0; $last_target_module = 0;
foreach ($result_components as $id_target_module) { foreach ($result_components as $id_target_module) {
// Detects change of component or last component to update orders. // Detects change of component or last component to update orders.
if (($count_components == $num_components) || ($last_target_module != $id_target_module) if (($count_components === $num_components) || ($last_target_module !== $id_target_module)
) { ) {
$update_orders = true; $update_orders = true;
} else { } else {
@ -424,14 +398,14 @@ if ($module_action === 'delete') {
} }
// Check for errors. // Check for errors.
if ((int) $error == 0) { if ((int) $error === 0) {
$count_correct_delete_modules++; $count_correct_delete_modules++;
} }
} }
if ($print_result_msg === true) { if ($print_result_msg === true) {
$count_modules_to_delete = count($id_agent_modules_delete); $count_modules_to_delete = count($id_agent_modules_delete);
if ($count_correct_delete_modules == 0) { if ($count_correct_delete_modules === 0) {
ui_print_error_message( ui_print_error_message(
sprintf( sprintf(
__('There was a problem completing the operation. Applied to 0/%d modules.'), __('There was a problem completing the operation. Applied to 0/%d modules.'),
@ -439,7 +413,7 @@ if ($module_action === 'delete') {
) )
); );
} else { } else {
if ($count_correct_delete_modules == $count_modules_to_delete) { if ($count_correct_delete_modules === $count_modules_to_delete) {
ui_print_success_message(__('Operation finished successfully.')); ui_print_success_message(__('Operation finished successfully.'));
} else { } else {
ui_print_error_message( ui_print_error_message(
@ -487,7 +461,7 @@ if ($module_action === 'delete') {
) )
); );
} else { } else {
if ($updated_count == $count_modules_to_disable) { if ($updated_count === $count_modules_to_disable) {
ui_print_success_message(__('Operation finished successfully.')); ui_print_success_message(__('Operation finished successfully.'));
} else { } else {
ui_print_error_message( ui_print_error_message(
@ -527,56 +501,28 @@ switch ($sortField) {
case 'name': case 'name':
switch ($sort) { switch ($sort) {
case 'up': case 'up':
$selectNameUp = $selected;
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
default: default:
$selectNameUp = $selected;
$order[] = [ $order[] = [
'field' => 'tagente_modulo.nombre', 'field' => 'tagente_modulo.nombre',
'order' => 'ASC', 'order' => 'ASC',
]; ];
break; break;
case 'oracle':
$order[] = [
'field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)',
'order' => 'ASC',
];
break;
}
break;
case 'down': case 'down':
$selectNameDown = $selected; $selectNameDown = $selected;
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
default:
$order[] = [ $order[] = [
'field' => 'tagente_modulo.nombre', 'field' => 'tagente_modulo.nombre',
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
case 'oracle':
$order[] = [
'field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)',
'order' => 'DESC',
];
break;
}
break;
default:
// Do none.
break;
} }
break; break;
case 'server': case 'server':
switch ($sort) { switch ($sort) {
case 'up': case 'up':
default:
$selectServerUp = $selected; $selectServerUp = $selected;
$order[] = [ $order[] = [
'field' => 'id_modulo', 'field' => 'id_modulo',
@ -591,16 +537,13 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Do none.
break;
} }
break; break;
case 'type': case 'type':
switch ($sort) { switch ($sort) {
case 'up': case 'up':
default:
$selectTypeUp = $selected; $selectTypeUp = $selected;
$order[] = [ $order[] = [
'field' => 'id_tipo_modulo', 'field' => 'id_tipo_modulo',
@ -615,16 +558,13 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Do none.
break;
} }
break; break;
case 'interval': case 'interval':
switch ($sort) { switch ($sort) {
case 'up': case 'up':
default:
$selectIntervalUp = $selected; $selectIntervalUp = $selected;
$order[] = [ $order[] = [
'field' => 'module_interval', 'field' => 'module_interval',
@ -639,10 +579,6 @@ switch ($sortField) {
'order' => 'DESC', 'order' => 'DESC',
]; ];
break; break;
default:
// Do none.
break;
} }
break; break;
@ -655,29 +591,16 @@ switch ($sortField) {
$selectTypeDown = false; $selectTypeDown = false;
$selectIntervalUp = false; $selectIntervalUp = false;
$selectIntervalDown = false; $selectIntervalDown = false;
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
default:
$order[] = [ $order[] = [
'field' => 'nombre', 'field' => 'nombre',
'order' => 'ASC', 'order' => 'ASC',
]; ];
break; break;
case 'oracle':
$order[] = [
'field' => 'dbms_lob.substr(nombre,4000,1)',
'order' => 'ASC',
];
break;
}
break;
} }
// Build the order sql. // Build the order sql.
if (!empty($order)) { if (empty($order) === false) {
$order_sql = ' ORDER BY '; $order_sql = ' ORDER BY ';
} }
@ -747,12 +670,12 @@ if ($agent_tags !== true) {
} }
$paginate_module = false; $paginate_module = false;
if (isset($config['paginate_module'])) { if (isset($config['paginate_module']) === true) {
$paginate_module = $config['paginate_module']; $paginate_module = (bool) $config['paginate_module'];
} }
if ($paginate_module) { if ($paginate_module === true) {
if (!isset($limit_sql)) { if (isset($limit_sql) === false) {
$limit_sql = sprintf( $limit_sql = sprintf(
'LIMIT %s, %s', 'LIMIT %s, %s',
$offset, $offset,
@ -795,7 +718,7 @@ $sql_total_modules = sprintf(
$total_modules = db_get_value_sql($sql_total_modules); $total_modules = db_get_value_sql($sql_total_modules);
$total_modules = isset($total_modules) ? $total_modules : 0; $total_modules = (isset($total_modules) === true) ? $total_modules : 0;
if ($modules === false) { if ($modules === false) {
ui_print_empty_data(__('No available data to show')); ui_print_empty_data(__('No available data to show'));
@ -811,7 +734,7 @@ $url = sprintf(
urlencode($search_string) urlencode($search_string)
); );
if ($paginate_module) { if ($paginate_module === true) {
ui_pagination($total_modules, $url); ui_pagination($total_modules, $url);
} }

View File

@ -104,11 +104,13 @@
.info_table tr > td:first-child, .info_table tr > td:first-child,
.info_table tr > th:first-child { .info_table tr > th:first-child {
padding-left: 5px; /*padding-left: 5px;*/
padding-left: 10px;
} }
.info_table tr > td:last-child, .info_table tr > td:last-child,
.info_table tr > th:last-child { .info_table tr > th:last-child {
padding-right: 5px; /*padding-right: 5px;*/
padding-right: 10px;
} }
.info_table tr:first-child > th { .info_table tr:first-child > th {