From f9c88a4a40911813c72158111522a4bf207392c1 Mon Sep 17 00:00:00 2001
From: slerena <slerena@gmail.com>
Date: Wed, 22 Jun 2011 17:21:50 +0000
Subject: [PATCH] 2011-06-21 Sancho Lerena <slerena@artica.es>

    * include/functions_ui.php: Improved function ui_print_string_substr to
    render a span with a predefined font size.

    * godmode/setup/os.list.php,
    godmode/groups/modu_group_list.php,
    godmode/groups/group_list.php,
    godmode/alerts/alert_commands.php: Show element's ID in tables, useful
    to use later in CLI, CVS importer or other tool.

    * godmode/agentes/module_manager.php
    godmode/agentes/module_manager_editor_common.php: Show warning/critical
    thresholds instead max/min values for module, much more useful. Aesthetic
    changes on editor and description visualization.

    * godmode/agentes/agent_manager.php: Added a direct link to delete current
    agent from main agent edit section.

    * operation/agentes/status_monitor.php,
    operation/agentes/estado_monitores.php: usability fixes on desc. size
    and table width.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4480 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     | 23 ++++++++++++++++
 .../godmode/agentes/agent_manager.php         | 11 ++++++--
 .../godmode/agentes/module_manager.php        | 26 +++++++++++++++----
 .../agentes/module_manager_editor_common.php  | 14 +++++-----
 .../godmode/alerts/alert_commands.php         | 17 ++++++------
 pandora_console/godmode/groups/group_list.php | 25 +++++++++---------
 .../godmode/groups/modu_group_list.php        | 16 +++++++-----
 pandora_console/godmode/setup/os.list.php     | 14 +++++-----
 pandora_console/include/functions_ui.php      | 11 +++++---
 .../operation/agentes/estado_monitores.php    |  7 ++---
 .../operation/agentes/status_monitor.php      |  4 +--
 11 files changed, 113 insertions(+), 55 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 3a6efdea73..cb321d8f1f 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,26 @@
+2011-06-21 Sancho Lerena <slerena@artica.es>
+
+    * include/functions_ui.php: Improved function ui_print_string_substr to
+    render a span with a predefined font size.
+
+    * godmode/setup/os.list.php,
+    godmode/groups/modu_group_list.php,
+    godmode/groups/group_list.php, 
+    godmode/alerts/alert_commands.php: Show element's ID in tables, useful 
+    to use later in CLI, CVS importer or other tool.
+
+    * godmode/agentes/module_manager.php
+    godmode/agentes/module_manager_editor_common.php: Show warning/critical
+    thresholds instead max/min values for module, much more useful. Aesthetic
+    changes on editor and description visualization.
+
+    * godmode/agentes/agent_manager.php: Added a direct link to delete current
+    agent from main agent edit section.
+
+    * operation/agentes/status_monitor.php,
+    operation/agentes/estado_monitores.php: usability fixes on desc. size 
+    and table width.
+ 
 2011-06-21 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
 
 	* include/styles/ie.css
diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index 6b89619cb8..fbef6577d4 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -102,7 +102,9 @@ $table->data[0][0] = __('Agent name') .
 $table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 30, 100,true); 
 
 if ($id_agente) {
-	$table->data[0][1] .= '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">';
+
+    $table->data[0][1] .= "&nbsp;<b>".__("ID")."</b>&nbsp; $id_agente &nbsp;";
+	$table->data[0][1] .= '&nbsp;&nbsp;<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">';
 	$table->data[0][1] .= html_print_image ("images/lupa.png", true, array ("border" => 0, "title" => __('Agent detail')));
 	$table->data[0][1] .= '</a>';
 }
@@ -110,12 +112,17 @@ if ($id_agente) {
 // Remote configuration available
 if (!$new_agent) {
 	if (file_exists ($filename['md5'])) {
-		$table->data[0][1] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'&amp;disk_conf='.$agent_md5.'">';
+		$table->data[0][1] .= '&nbsp;&nbsp;<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'&amp;disk_conf='.$agent_md5.'">';
 		$table->data[0][1] .= html_print_image ("images/application_edit.png", true, array ("border" => 0, "title" => __('This agent can be remotely configured')));
 		$table->data[0][1] .= '</a>'.ui_print_help_tip (__('You can remotely edit this agent configuration'), true);
 	}
 }
 
+// Delete link from here
+if (!$new_agent) {
+$table->data[0][1] .= "&nbsp;&nbsp;<span align='right'><a title='".__("Delete agent")."' href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'><img src='images/cross.png'></a>";
+}
+
 $table->data[1][0] = __('IP Address');
 $table->data[1][1] = html_print_input_text ('direccion', $direccion_agente, '', 16, 100, true);
 
diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php
index ea9d0986fd..1843177865 100644
--- a/pandora_console/godmode/agentes/module_manager.php
+++ b/pandora_console/godmode/agentes/module_manager.php
@@ -262,7 +262,7 @@ $modules = db_get_all_rows_filter ('tagente_modulo',
 		'order' => $order),
 	array ('id_agente_modulo', 'id_tipo_modulo', 'descripcion', 'nombre',
 		'max', 'min', 'module_interval', 'id_modulo', 'id_module_group',
-		'disabled',));
+		'disabled','max_warning', 'min_warning', 'max_critical', 'min_critical'));
 
 if ($modules === false) {
 	echo "<div class='nf'>".__('No available data to show')."</div>";
@@ -286,7 +286,10 @@ $table->head[4] = __('Interval') . ' ' .
 	'<a href="' . $url . '&sort_field=interval&sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp)) . '</a>' .
 	'<a href="' . $url . '&sort_field=interval&sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown)) . '</a>';
 $table->head[5] = __('Description');
-$table->head[6] = __('Max/Min');
+$table->head[6] = __('Warn');
+
+
+
 $table->head[7] = __('Action');
 
 $table->style = array ();
@@ -410,11 +413,24 @@ foreach ($modules as $module) {
 		$data[4] = $agent_interval;
 	}
 	
-	$data[5] = ui_print_truncate_text($module['descripcion'], 25, false);
+	$data[5] = ui_print_string_substr ($module["descripcion"], 32, true, 9);
 	
 	// MAX / MIN values
-	$data[6] = $module["max"] ? $module["max"] : __('N/A');
-	$data[6] .= ' / '.($module["min"] != $module['max']? $module["min"] : __('N/A'));
+    $data[6] = "<span style='font-size: 8px'>";
+
+    if ($module["max_warning"] != $module["min_warning"]){
+        $data[6] .= format_for_graph ($module["max_warning"]) ."/". format_for_graph ($module["min_warning"]);
+    } else {
+        $data[6] .= __("N/A");
+    }
+
+    $data[6] .= " - ";
+
+    if ($module["max_critical"] != $module["min_critical"]){
+        $data[6] .= format_for_graph($module["max_critical"]) ."/". format_for_graph ($module["min_critical"]);
+    } else {
+        $data[6] .= __("N/A");
+    }
 
 	// Delete module
 	$data[7] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true);
diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php
index d319a04a72..cfff264d4d 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_common.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_common.php
@@ -169,19 +169,19 @@ $table_simple->data[1][3] = html_print_select_from_sql ('SELECT id_mg, name FROM
 	true, false, true, $disabledBecauseInPolicy);
 
 $table_simple->data[2][0] = __('Warning status').' ' . ui_print_help_icon ('warning_status', true);
-$table_simple->data[2][1] = '<em>'.__('Min.').'</em>';
+$table_simple->data[2][1] = '<em>'.__('Min. ').'</em></span>';
 $table_simple->data[2][1] .= html_print_input_text ('min_warning', $min_warning,
-	'', 5, 255, true, $disabledBecauseInPolicy);
+	'', 10, 255, true, $disabledBecauseInPolicy);
 $table_simple->data[2][1] .= '<br /><em>'.__('Max.').'</em>';
 $table_simple->data[2][1] .= html_print_input_text ('max_warning', $max_warning,
-	'', 5, 255, true, $disabledBecauseInPolicy);
+	'', 10, 255, true, $disabledBecauseInPolicy);
 $table_simple->data[2][2] = __('Critical status').' ' . ui_print_help_icon ('critical_status', true);
-$table_simple->data[2][3] = '<em>'.__('Min.').'</em>';
+$table_simple->data[2][3] = '<em>'.__('Min. ').'</em>';
 $table_simple->data[2][3] .= html_print_input_text ('min_critical', $min_critical,
-	'', 5, 255, true, $disabledBecauseInPolicy);
+	'', 10, 255, true, $disabledBecauseInPolicy);
 $table_simple->data[2][3] .= '<br /><em>'.__('Max.').'</em>';
 $table_simple->data[2][3] .= html_print_input_text ('max_critical', $max_critical,
-	'', 5, 255, true, $disabledBecauseInPolicy);
+	'', 10, 255, true, $disabledBecauseInPolicy);
 
 /* FF stands for Flip-flop */
 $table_simple->data[3][0] = __('FF threshold').' ' . ui_print_help_icon ('ff_threshold', true);
@@ -215,7 +215,7 @@ $table_advanced->data[2][1] = html_print_input_text ('module_interval', $interva
 	
 $table_advanced->data[2][2] = __('Post process').' ' . ui_print_help_icon ('postprocess', true);
 $table_advanced->data[2][3] = html_print_input_text ('post_process',
-	$post_process, '', 12, 25, true, $disabledBecauseInPolicy);
+	$post_process, '', 15, 25, true, $disabledBecauseInPolicy);
 
 $table_advanced->data[3][0] = __('Min. Value');
 $table_advanced->data[3][1] = html_print_input_text ('min', $min, '', 5, 15, true, $disabledBecauseInPolicy);
diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php
index 5e7871b8db..ae326641b3 100644
--- a/pandora_console/godmode/alerts/alert_commands.php
+++ b/pandora_console/godmode/alerts/alert_commands.php
@@ -127,14 +127,15 @@ $table->width = '90%';
 $table->data = array ();
 $table->head = array ();
 $table->head[0] = __('Name');
-$table->head[1] = __('Description');
-$table->head[2] = __('Delete');
+$table->head[1] = __('ID');
+$table->head[2] = __('Description');
+$table->head[3] = __('Delete');
 $table->style = array ();
 $table->style[0] = 'font-weight: bold';
 $table->size = array ();
-$table->size[2] = '40px';
+$table->size[3] = '40px';
 $table->align = array ();
-$table->align[2] = 'center';
+$table->align[3] = 'center';
 
 $commands = db_get_all_rows_in_table ('talert_commands');
 if ($commands === false)
@@ -148,11 +149,11 @@ foreach ($commands as $command) {
 			$command['name'].'</a>';
 	else
 		$data[0] = $command['name'];
-	
-	$data[1] = $command['description'];
-	$data[2] = '';
+	$data[1] = $command['id'];
+	$data[2] = $command['description'];
+	$data[3] = '';
 	if (! $command['internal'])
-		$data[2] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'"
+		$data[3] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'"
 			onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
 			html_print_image("images/cross.png", true) . '</a>';
 	
diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php
index 8e4ba3d62a..4d2f5e3cb8 100644
--- a/pandora_console/godmode/groups/group_list.php
+++ b/pandora_console/godmode/groups/group_list.php
@@ -195,16 +195,16 @@ if ($delete_group) {
 		 
 }
 
-
-$table->width = '65%';
+$table->width = '90%';
 $table->head = array ();
 $table->head[0] = __('Name');
-$table->head[1] = __('Icon');
-$table->head[2] = __('Alerts');
-$table->head[3] = __('Actions');
+$table->head[1] = __('ID');
+$table->head[2] = __('Icon');
+$table->head[3] = __('Alerts');
+$table->head[4] = __('Actions');
 $table->align = array ();
-$table->align[1] = 'center';
-$table->align[3] = 'center';
+$table->align[2] = 'center';
+$table->align[4] = 'center';
 $table->data = array ();
 
 $groups = users_get_groups_tree ($config['id_user'], "AR", true);
@@ -283,14 +283,15 @@ foreach ($groups as $id_group => $group) {
 	else {
 		$data[0] = '<strong>'.$tabulation . ' '. ui_print_truncate_text($group['nombre']).'</strong>';
 	}
-	$data[1] = ui_print_group_icon($group['id_grupo'], true);
-	$data[2] = $group['disabled'] ? __('Disabled') : __('Enabled');
+	$data[1] = $group['id_grupo'];
+	$data[2] = ui_print_group_icon($group['id_grupo'], true);
+	$data[3] = $group['disabled'] ? __('Disabled') : __('Enabled');
 	if ($group['id_grupo'] == 0) {
-		$data[3] = '';
+		$data[4] = '';
 	}
 	else {
-		$data[3] = '<a href="index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'].'">' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0'));
-		$data[3] .= '<a href="index.php?sec=gagente&sec2=godmode/groups/group_list&id_group='.$id_group.'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0'));
+		$data[4] = '<a href="index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'].'">' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0'));
+		$data[4] .= '<a href="index.php?sec=gagente&sec2=godmode/groups/group_list&id_group='.$id_group.'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0'));
 	}
 	
 	array_push ($table->data, $data);
diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php
index aa3c10f2a0..3c245cf73e 100644
--- a/pandora_console/godmode/groups/modu_group_list.php
+++ b/pandora_console/godmode/groups/modu_group_list.php
@@ -105,12 +105,14 @@ if ($delete_group) {
 		echo "<h3 class='suc'>".__('Group successfully deleted')."</h3>";
 }
 
-$table->width = '65%';
+$table->width = '500px';
 $table->head = array ();
-$table->head[0] = __('Name');
-$table->head[1] = __('Delete');
+$table->head[0] = __('ID');
+$table->head[1] = __('Name');
+$table->head[2] = __('Delete');
 $table->align = array ();
-$table->align[1] = 'center';
+$table->align[1] = 'left';
+$table->align[2] = 'center';
 $table->data = array ();
 
 $sql = "SELECT * 
@@ -120,9 +122,9 @@ $groups = db_get_all_rows_sql ($sql, true);
 
 foreach ($groups as $id_group ) {
 	$data = array ();
-	
-	$data[0] = '<strong><a href="index.php?sec=gagente&sec2=godmode/groups/configure_modu_group&id_group='.$id_group["id_mg"].'">' . ui_print_truncate_text($id_group["name"], 50).'</a></strong>';
-	$data[1] = '<a href="index.php?sec=gagente&sec2=godmode/groups/modu_group_list&id_group='.$id_group["id_mg"].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("border" => '0')) . '</a>';
+	$data[0] = 	$id_group["id_mg"];
+	$data[1] = '<strong><a href="index.php?sec=gagente&sec2=godmode/groups/configure_modu_group&id_group='.$id_group["id_mg"].'">' . ui_print_truncate_text($id_group["name"], 50).'</a></strong>';
+	$data[2] = '<a href="index.php?sec=gagente&sec2=godmode/groups/modu_group_list&id_group='.$id_group["id_mg"].'&delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("border" => '0')) . '</a>';
 	
 	array_push ($table->data, $data);
 }
diff --git a/pandora_console/godmode/setup/os.list.php b/pandora_console/godmode/setup/os.list.php
index 84383a8b35..f81e923dd7 100644
--- a/pandora_console/godmode/setup/os.list.php
+++ b/pandora_console/godmode/setup/os.list.php
@@ -28,13 +28,14 @@ $table = null;
 
 $table->width = '80%';
 $table->head[0] = '';
-$table->head[1] = __('Name');
-$table->head[2] = __('Description');
-$table->head[3] = '';
+$table->head[1] = __('ID');
+$table->head[2] = __('Name');
+$table->head[3] = __('Description');
+$table->head[4] = '';
 $table->align[0] = 'center';
-$table->align[3] = 'center';
+$table->align[4] = 'center';
 $table->size[0] = '20px';
-$table->size[3] = '20px';
+$table->size[4] = '20px';
 
 $osList = db_get_all_rows_in_table('tconfig_os');
 
@@ -42,6 +43,7 @@ $table->data = array();
 foreach ($osList as $os) {
 	$data = array();
 	$data[] = ui_print_os_icon($os['id_os'], false, true);
+	$data[] = $os['id_os'];
 	$data[] = '<a href="index.php?sec=gsetup&sec2=godmode/setup/os&action=edit&tab=builder&id_os=' . $os['id_os'] . '">' . io_safe_output($os['name']) . '</a>';
 	$data[] = ui_print_truncate_text(io_safe_output($os['description']), 25, true, true);
 	if ($os['id_os'] > 13) {
@@ -56,4 +58,4 @@ foreach ($osList as $os) {
 }
 
 html_print_table($table);
-?>
\ No newline at end of file
+?>
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 1dcf75df93..76553ae16a 100644
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -595,10 +595,11 @@ function ui_format_alert_row ($alert, $compound = false, $agent = true, $url = '
  * @param string The string to be cut
  * @param int At how much characters to cut
  * @param bool Whether to return or print it out
+ * @param int Size font (fixed) in px, applyed as CSS style (optional)
  *
  * @return An HTML string
  */
-function ui_print_string_substr ($string, $cutoff = 16, $return = false) {
+function ui_print_string_substr ($string, $cutoff = 16, $return = false, $fontsize = 0) {
 	if (empty ($string)) {
 		return "";
 	}
@@ -610,8 +611,12 @@ function ui_print_string_substr ($string, $cutoff = 16, $return = false) {
 		$string3 = "";
 	}
 
-	
-	$string = '<span title="'.io_safe_input($string2).'">'.mb_substr ($string2, 0, $cutoff, "UTF-8").$string3.'</span>';
+	$font_size_mod = "";
+
+    if ($fontsize > 0){
+        $font_size_mod = "style='font-size: ".$fontsize."px'";
+    }
+	$string = '<span '.$font_size_mod.' title="'.io_safe_input($string2).'">'.mb_substr ($string2, 0, $cutoff, "UTF-8").$string3.'</span>';
 
 	if ($return === false) {
 		echo $string;
diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php
index 951b1d071c..d971960500 100644
--- a/pandora_console/operation/agentes/estado_monitores.php
+++ b/pandora_console/operation/agentes/estado_monitores.php
@@ -195,7 +195,7 @@ $modules = db_get_all_rows_sql ($sql);
 if (empty ($modules)) {
 	$modules = array ();
 }
-$table->width = 750;
+$table->width = "100%";
 $table->cellpadding = 4;
 $table->cellspacing = 4;
 $table->class = "databox";
@@ -316,13 +316,14 @@ foreach ($modules as $module) {
 	if (check_acl ($config['id_user'], $id_grupo, "AW")) 
 	  $data[2] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'&amp;tab=module&amp;id_agent_module='.$module["id_agente_modulo"].'&amp;edit_module='.$module["id_modulo"].'">' . html_print_image("images/config.png", true, array("alt" => '0', "border" => "")) . '</a>';
 	  
-	$data[3] = ui_print_string_substr ($module["nombre"], 25, true);
+	$data[3] = ui_print_string_substr ($module["nombre"], 30, true);
+
 	//Adds tag context information
 	if (tags_get_modules_tag_count($module['id_agente_modulo']) > 0) {
 		$data[3] .= ' <a class="tag_details" href="ajax.php?page=operation/agentes/estado_monitores&get_tag_tooltip=1&id_agente_modulo='.$module['id_agente_modulo'].'">' .
 		html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . '</a> ';
 	}
-	$data[4] = ui_print_string_substr ($module["descripcion"], 30, true);
+	$data[4] = ui_print_string_substr ($module["descripcion"], 40, true, 9);
 
 	$status = STATUS_MODULE_WARNING;
 	$title = "";
diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php
index 032d723765..4e63b1052c 100644
--- a/pandora_console/operation/agentes/status_monitor.php
+++ b/pandora_console/operation/agentes/status_monitor.php
@@ -316,7 +316,7 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
 
 $table->cellpadding = 4;
 $table->cellspacing = 4;
-$table->width = 750;
+$table->width = "100%";
 $table->class = "databox";
 
 $table->head = array ();
@@ -406,7 +406,7 @@ foreach ($result as $row) {
 	
 	$data[2] = html_print_image("images/" . modules_show_icon_type ($row["module_type"]), true); 
 	
-	$data[3] = mb_strimwidth (io_safe_output($row["module_name"]), 0, 30);
+	$data[3] = ui_print_string_substr ($row["module_name"], 45, true, 9);
 
 	$data[4] = ($row['module_interval'] == 0) ? $row['agent_interval'] : $row['module_interval'];