New function pandora ux, let open pics from base64 image modules #90

(cherry picked from commit 22973e9f1299098ab674431139a52a3cb7ad6e41)
This commit is contained in:
enriquecd 2016-10-26 18:39:41 +02:00
parent c358f1195d
commit db721782c5
3 changed files with 83 additions and 110 deletions

View File

@ -177,7 +177,7 @@ if ($get_module_detail) {
"Data" => array(
"data",
"modules_format_data",
"align" => "left",
"align" => "center",
"width" => "230px"),
);
@ -185,14 +185,14 @@ if ($get_module_detail) {
$columns["Time"] = array(
"utimestamp",
"modules_format_time",
"align" => "left",
"align" => "center",
"width" => "50px");
}
else {
$columns["Timestamp"] = array(
"utimestamp",
"modules_format_timestamp",
"align" => "left",
"align" => "center",
"width" => "50px");
}
@ -249,7 +249,7 @@ if ($get_module_detail) {
foreach ($columns as $col => $attr) {
if ($attr[1] != "modules_format_data") {
$data[] = $attr[1] ($row[$attr[0]]);
$data[] = date('d F Y - h:i:s A', $row['utimestamp']);
}
elseif (($config['command_snapshot']) && (preg_match ("/[\n]+/i", $row[$attr[0]]))) {
@ -283,16 +283,17 @@ if ($get_module_detail) {
$data[] = io_safe_input($row[$attr[0]]);
}
else if (is_numeric($row[$attr[0]]) && !modules_is_string_type($row['module_type']) ) {
switch($row['module_type']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0')
$data[] = human_milliseconds_to_string($row['data']);
else
$data[] = (double) $row[$attr[0]];
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
break;
default:
$data[] = (double) $row[$attr[0]];
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
break;
}
//~ $data[] = (double) $row[$attr[0]];
@ -302,7 +303,7 @@ if ($get_module_detail) {
$data[] = 'No data';
}
else {
$data[] = io_safe_input($row[$attr[0]]);
$data[] = "<a target='_blank' href='".io_safe_input($row[$attr[0]])."'><img style='width:300px' src='".io_safe_input($row[$attr[0]])."'></a>";
}
}
}
@ -751,12 +752,6 @@ if ($list_modules) {
}
//End of title of group
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module['datos'] = io_safe_input($module['datos']);
}
$data = array ();
if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) {
@ -871,7 +866,6 @@ if ($list_modules) {
modules_get_status($module['id_agente_modulo'], $module['estado'],
$module_value, $status, $title);
$data[5] = ui_print_status_image($status, $title, true);
if (!$show_context_help_first_time) {
$show_context_help_first_time = true;
@ -881,7 +875,6 @@ if ($list_modules) {
}
}
if ($module["id_tipo_modulo"] == 24) {
// log4x
switch($module["datos"]) {
@ -934,10 +927,10 @@ if ($list_modules) {
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0')
$salida = human_milliseconds_to_string($module['datos']);
else
$salida = format_numeric($module['datos']);
$salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision']));
break;
default:
$salida = format_numeric($module['datos']);
$salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision']));
break;
}
break;
@ -950,10 +943,10 @@ if ($list_modules) {
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0')
$salida = human_milliseconds_to_string($module['datos']);
else
$salida = format_numeric($module['datos']);
$salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision']));
break;
default:
$salida = format_numeric($module['datos']);
$salida = remove_right_zeros(number_format($module["datos"], $config['graph_precision']));
break;
}
}
@ -963,72 +956,9 @@ if ($list_modules) {
}
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$module_value = $module["datos"];
}
else {
$module_value = io_safe_output($module["datos"]);
}
// If carriage returns present... then is a "Snapshot" data (full command output)
$is_snapshot = is_snapshot_data ( $module_value );
if (($config['command_snapshot']) && ($is_snapshot)) {
$handle = "snapshot" . "_" . $module["id_agente_modulo"];
$url = 'include/procesos.php?agente=' . $module["id_agente_modulo"];
$win_handle = dechex(crc32($handle));
$link ="winopeng_var('operation/agentes/snapshot_view.php?" .
"id=" . $module["id_agente_modulo"] .
"&refr=" . $module["current_interval"] .
"&label=" . rawurlencode(urlencode(io_safe_output($module["nombre"]))) . "','".$win_handle."', 700,480)";
$salida = '<a href="javascript:'.$link.'">' .
html_print_image("images/default_list.png", true,
array(
"border" => '0',
"alt" => "",
"title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
}
else {
//Fixed the goliat sends the strings from web
//without HTML entities
if ($module['id_tipo_modulo'] == $id_type_web_content_string) {
$sub_string = substr($module_value, 0, 12);
}
else {
//Fixed the data from Selenium Plugin
if ($module_value != strip_tags($module_value)) {
$module_value = io_safe_input($module_value);
$sub_string = substr($module_value, 0, 12);
}
else {
$sub_string = substr(io_safe_output($module_value),0, 12);
}
}
if ($module_value == $sub_string) {
$salida = $module["datos"];
}
else {
$salida = "<span " .
"id='hidden_value_module_" . $module["id_agente_modulo"] . "'
style='display: none;'>" .
$module_value .
"</span>" .
"<span " .
"id='value_module_" . $module["id_agente_modulo"] . "'
title='" . $module_value . "' " .
"style='white-space: nowrap;'>" .
'<span id="value_module_text_' . $module["id_agente_modulo"] . '">' .
$sub_string . '</span> ' .
"<a href='javascript: toggle_full_value(" . $module["id_agente_modulo"] . ")'>" .
html_print_image("images/rosette.png", true) . "</a>" . "</span>";
}
}
$salida = ui_print_module_string_value(
$module["datos"], $module["id_agente_modulo"],
$module["current_interval"], $module["module_name"]);
}
}
@ -1061,7 +991,9 @@ if ($list_modules) {
"refresh=" . SECONDS_10MINUTES . "&amp;" .
"draw_events=$draw_events', 'day_".$win_handle."')";
if(!is_snapshot_data($module['datos'])){
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
}
$server_name = '';
$data[8] .= "<a href='javascript: " .
"show_module_detail_dialog(" .
@ -1106,14 +1038,6 @@ if ($list_modules) {
return false;
});
function toggle_full_value(id) {
text = $("#hidden_value_module_" + id).html();
old_text = $("#value_module_text_" + id).html();
$("#hidden_value_module_" + id).html(old_text);
$("#value_module_text_" + id).html(text);
}
/* ]]> */
</script>
<?php

View File

@ -393,19 +393,41 @@ var TreeController = {
if (typeof element.showGraphs != 'undefined' && element.showGraphs != 0) {
// Graph pop-up
if (typeof element.moduleGraph != 'undefined') {
if(element.statusImageHTML.indexOf('data:image')!=-1){
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/photo.png" /> ');
}
else{
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
+'images/chart_curve.png" /> ');
}
$graphImage
.addClass('module-graph')
.click(function (e) {
e.preventDefault();
if(element.statusImageHTML.indexOf('data:image')!=-1){
try {
winopeng('operation/agentes/snapshot_view.php?id='+element.id+'&refr=&label='+element.name);
}
catch (error) {
// console.log(error);
}
}
else{
try {
winopeng(element.moduleGraph.url, element.moduleGraph.handle);
}
catch (error) {
// console.log(error);
}
}
});
$content.append($graphImage);

View File

@ -1206,8 +1206,12 @@ if (!empty($result)) {
$link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')';
$data[7] = '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . '</a>';
$data[7] = '';
if(!is_snapshot_data($row['datos'])){
$data[7] = '<a href="javascript:'.$link.'">' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . '</a>';
}
$data[7] .= '<a href="javascript: ' .
'show_module_detail_dialog(' .
$row['id_agente_modulo'] . ', '.
@ -1277,12 +1281,19 @@ if (!empty($result)) {
"id=" . $row['id_agente_modulo'] .
"&refr=" . $row['current_interval'] .
"&label=" . rawurlencode(urlencode(io_safe_output($row['module_name']))) . "','" . $win_handle . "', 700,480)";
if(!is_snapshot_data($row['datos'])){
$salida = '<a href="javascript:' . $link . '">' .
html_print_image('images/default_list.png', true,
array('border' => '0',
'alt' => '',
'title' => __('Snapshot view'))) . '</a> &nbsp;&nbsp;';
}else{
$salida = '<a href="javascript:' . $link . '">' .
html_print_image('images/photo.png', true,
array('border' => '0',
'alt' => '',
'title' => __('Snapshot view'))) . '</a> &nbsp;&nbsp;';
}
}
else {
@ -1429,11 +1440,27 @@ $('#moduletype').click(function(){
period = <?php echo SECONDS_1DAY; ?>;
}
}
var server_name = '';
var extra_parameters = '';
if ($('input[name=selection_mode]:checked').val()) {
period = $('#period').val();
var selection_mode = $('input[name=selection_mode]:checked').val();
var date_from = $('#text-date_from').val();
var time_from = $('#text-time_from').val();
var date_to = $('#text-date_to').val();
var time_to = $('#text-time_to').val();
extra_parameters = '&selection_mode=' + selection_mode + '&date_from=' + date_from + '&date_to=' + date_to + '&time_from=' + time_from + '&time_to=' + time_to;
}
title = <?php echo "\"" . __("Module: ") . "\"" ?>;
$.ajax({
type: "POST",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period,
data: "page=include/ajax/module&get_module_detail=1&server_name="+server_name+"&id_agent="+id_agent+"&id_module=" + module_id+"&offset="+offset+"&period="+period + extra_parameters,
dataType: "html",
success: function(data) {
$("#monitor_details_window").hide ()