Improved the visual style of the output of the functions that print the agent, module and alert detail views

This commit is contained in:
Alejandro Gallardo Escobar 2015-01-30 20:04:56 +01:00
parent 1127737f83
commit d7831dbb19
1 changed files with 93 additions and 60 deletions

View File

@ -55,55 +55,75 @@ function treeview_printModuleTable($id_module, $server_data = false) {
return; return;
} }
echo '<div id="id_div3" width="450px">'; $table = new StdClass();
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%; min-width: 300px;">'; $table->width = "100%";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();
$table->head[] = __('Module');
$table->head_colspan[] = 2;
$table->data = array();
//Module name //Module name
echo '<tr><td class="datos"><b>'.__('Module name').'</b></td>';
if ($module["disabled"]) if ($module["disabled"])
$cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>"; $cellName = "<em>" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . "<em>";
else else
$cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;"); $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[&hellip;]',"text-transform: uppercase;");
echo '<td class="datos"><b>'.$cellName.'</b></td>'; $row = array();
$row['title'] = __('Name');
$row['data'] = "<b>".$cellName."</b>";
$table->data['name'] = $row;
// Interval // Interval
echo '<tr><td class="datos"><b>' . __('Interval') . '</b></td>'; $row = array();
echo '<td class="datos" colspan="2">' . human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true) . '</td></tr>'; $row['title'] = __('Interval');
$row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true);
$table->data['interval'] = $row;
// Warning Min/Max // Warning Min/Max
echo '<tr><td class="datos"><b>' . __('Warning status') . '</b></td>';
if (modules_is_string_type($module['id_tipo_modulo'])) { if (modules_is_string_type($module['id_tipo_modulo'])) {
echo '<td class="datos" colspan="2">' . __('Str.') . ': ' . $module['str_warning'] . '</td></tr>'; $warning_status_str = __('Str.') . ': ' . $module['str_warning'];
} }
else { else {
echo '<td class="datos" colspan="2">' . __('Min.') . ': ' . $module['min_warning'] . '<br>' . __('Max.') . ': ' . $module['max_warning'] . '</td></tr>'; $warning_status_str = __('Min.') . ': ' . $module['min_warning'] . '<br>' . __('Max.') . ': ' . $module['max_warning'];
} }
$row = array();
$row['title'] = __('Warning status');
$row['data'] = $warning_status_str;
$table->data['watning_status'] = $row;
// Critical Min/Max // Critical Min/Max
echo '<tr><td class="datos"><b>' . __('Critical status') . '</b></td>';
if (modules_is_string_type($module['id_tipo_modulo'])) { if (modules_is_string_type($module['id_tipo_modulo'])) {
echo '<td class="datos" colspan="2">' . __('Str.') . ': ' . $module['str_warning'] . '</td></tr>'; $critical_status_str = __('Str.') . ': ' . $module['str_warning'];
} }
else { else {
echo '<td class="datos" colspan="2">' . __('Min.') . ': ' . $module['min_critical'] . '<br>' . __('Max.') . ': ' . $module['max_critical'] . '</td></tr>'; $critical_status_str = __('Min.') . ': ' . $module['min_critical'] . '<br>' . __('Max.') . ': ' . $module['max_critical'];
} }
$row = array();
$row['title'] = __('Critical status');
$row['data'] = $critical_status_str;
$table->data['critical_status'] = $row;
// Module group // Module group
echo '<tr><td class="datos2"><b>'.__('Module group').'</b></td>';
echo '<td class="datos2" colspan="2">';
$module_group = modules_get_modulegroup_name($module['id_module_group']); $module_group = modules_get_modulegroup_name($module['id_module_group']);
if ($module_group === false) if ($module_group === false)
echo __('Not assigned'); $module_group = __('Not assigned');
else else
echo __("$module_group"); $module_group = __("$module_group");
echo '</td></tr>';
$row = array();
$row['title'] = __('Module group');
$row['data'] = $module_group;
$table->data['module_group'] = $row;
// Description // Description
echo '<tr><td class="datos"><b>'.__('Description').'</b></td>'; $row = array();
echo '<td class="datos" colspan="2">'. ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[&hellip;]') .'</td></tr>'; $row['title'] = __('Description');
$row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[&hellip;]');
$table->data['description'] = $row;
// Tags // Tags
$tags = tags_get_module_tags($module['id_agente_modulo']); $tags = tags_get_module_tags($module['id_agente_modulo']);
@ -135,8 +155,10 @@ function treeview_printModuleTable($id_module, $server_data = false) {
$tags = implode(', ' , $tags); $tags = implode(', ' , $tags);
} }
echo '<tr><td class="datos"><b>'.__('Tags').'</b></td>'; $row = array();
echo '<td class="datos" colspan="2">' . $tags . '</td></tr>'; $row['title'] = __('Tags');
$row['data'] = $tags;
$table->data['tags'] = $row;
// Data // Data
$last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC'))); $last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC')));
@ -145,28 +167,28 @@ function treeview_printModuleTable($id_module, $server_data = false) {
else else
$data = "<span title='" . $last_data["datos"] . "' style='white-space: nowrap;'>" . substr(io_safe_output($last_data['datos']),0,12) . "</span>"; $data = "<span title='" . $last_data["datos"] . "' style='white-space: nowrap;'>" . substr(io_safe_output($last_data['datos']),0,12) . "</span>";
echo '<tr><td class="datos"><b>'.__('Last data').'</b></td>';
echo '<td class="datos" colspan="2">';
if (!empty($last_data['utimestamp'])) { if (!empty($last_data['utimestamp'])) {
echo $data; $last_data_str = $data;
if ($module['unit'] != '') { if ($module['unit'] != '') {
echo "&nbsp;"; $last_data_str .= "&nbsp;";
echo '('.$module['unit'].')'; $last_data_str .= '('.$module['unit'].')';
} }
echo "&nbsp;"; $last_data_str .= "&nbsp;";
html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px')); $last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
} }
else { else {
echo '<i>' . __('No data') . '</i>'; $last_data_str = '<i>' . __('No data') . '</i>';
} }
echo '</td></tr>'; $row = array();
$row['title'] = __('Last data');
$row['data'] = $last_data_str;
$table->data['last_data'] = $row;
//End of table //End of table
echo '</table></div>'; html_print_table($table);
$id_group = agents_get_agent_group($module['id_agente']); $id_group = agents_get_agent_group($module['id_agente']);
$group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
@ -174,10 +196,10 @@ function treeview_printModuleTable($id_module, $server_data = false) {
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) { if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) {
// Actions table // Actions table
echo '<div style="width:90%; text-align: right; min-width: 300px;">'; echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<form id="module_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">'; echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=' . $module['id_agente'] . '&tab=module&edit_module=1&id_agent_module=' . $module['id_agente_modulo'] . $url_hash . '">';
html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"'); html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"');
echo '</form>'; echo '</a>';
echo '</div>'; echo '</div>';
} }
@ -218,42 +240,53 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
return; return;
} }
echo '<div id="id_div3" width="450px">'; $table = new StdClass();
echo '<table cellspacing="4" cellpadding="4" border="0" class="databox alternate" style="width:90%; min-width: 300px;">'; $table->width = "100%";
echo '<tr><th colspan=2 class="datos"><center>' . $module_name . '</center></th></tr>'; $table->style = array();
$table->style['titles'] = 'font-weight: bold; background: #B3B3B3;';
echo '<tr><th class="datos" style="background: #B3B3B3;"><b>'.__('Template').'</b></th>'; $table->head = array();
echo '<th class="datos" style="background: #B3B3B3;"><b>'.__('Actions').'</b></th>'; $table->head[] = __('Alerts') . ": " . $module_name;
$table->head_colspan[] = 2;
$table->data = array();
$row = array();
$row['template'] = __('Template');
$row['actions'] = __('Actions');
$table->data['titles'] = $row;
foreach($module_alerts as $module_alert) { foreach($module_alerts as $module_alert) {
//Template name //Template name
echo '<tr>';
$template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']); $template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']);
echo '<td class="datos">'.$template_name.'</td>';
$actions = alerts_get_alert_agent_module_actions($module_alert['id']); $actions = alerts_get_alert_agent_module_actions($module_alert['id']);
echo '<td class="datos">';
if (empty($actions)) { if (empty($actions)) {
echo '<i>'.__('N/A').'</i>'; $actions_list = '<i>'.__('N/A').'</i>';
} }
else { else {
echo '<ul>'; $actions_list = '<ul>';
foreach($actions as $act) { foreach($actions_list as $act) {
echo '<li>'; $actions_list .= '<li>';
echo $act['name']; $actions_list .= $act['name'];
echo '</li>'; $actions_list .= '</li>';
} }
echo '</ul>'; $actions_list .= '</ul>';
} }
echo '</td></tr>';
$row = array();
$row['template'] = $template_name;
$row['actions'] = $actions_list;
$table->data['last_data'] = $row;
} }
echo '</table>';
html_print_table($table);
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) { if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
// Actions table // Actions table
echo '<div style="width:90%; text-align: right; min-width: 300px;">'; echo '<div style="width:100%; text-align: right; min-width: 300px;">';
echo '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">'; echo '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
html_print_submit_button (__('Go to alerts edition'), 'upd_button', false, 'class="sub search"'); html_print_submit_button (__('Go to alerts edition'), 'upd_button', false, 'class="sub search"');
echo '</form>'; echo '</a>';
echo '</div>'; echo '</div>';
} }
} }
@ -386,9 +419,9 @@ function treeview_printTable($id_agente, $server_data = array()) {
if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$go_to_agent = '<div style="text-align: right;">'; $go_to_agent = '<div style="text-align: right;">';
$go_to_agent .= '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">'; $go_to_agent .= '<a target=_blank href="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
$go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); $go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
$go_to_agent .= '</form>'; $go_to_agent .= '</a>';
$go_to_agent .= '</div>'; $go_to_agent .= '</div>';
$agent_table .= $go_to_agent; $agent_table .= $go_to_agent;