diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 805e46376a..7fb34b4a22 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -1599,6 +1599,15 @@ class Tree { 'url' => $moduleGraphURL, 'handle' => $winHandle ); + + // Info to be able to open the snapshot image new page + $module['snapshot'] = ui_get_snapshot_link(array( + 'id_module' => $module['id'], + 'last_data' => $module['datos'], + 'timestamp' => $module['timestamp'], + 'interval' => $module['current_interval'], + 'module_name' => $module['name'] + ), true); } // Alerts fired image diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 1ef1d2fc39..9da64a6dbe 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -268,21 +268,14 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head = $last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); $is_snapshot = is_snapshot_data ( $last_data["datos"] ); - if (($config['command_snapshot']) && ($is_snapshot)) { - $handle = 'snapshot_' . $module['id_agente_modulo']; - $url = 'include/procesos.php?agente=' . $row['id_agente_modulo']; - $win_handle = dechex(crc32($handle)); - if (! defined ('METACONSOLE')) { - $link = "winopeng_var('operation/agentes/snapshot_view.php?" . - "id=" . $module['id_agente_modulo'] . - "&refr=" . $module['current_interval'] . - "&label=" . rawurlencode(urlencode(io_safe_output($module['module_name']))) . "','" . $win_handle . "', 700,480)"; - } - else{ - $link = "winopeng_var('$last_data[datos]','',700,480)"; - - } + $link = ui_get_snapshot_link( array( + 'id_module' => $module['id_agente_modulo'], + 'last_data' => $last_data['datos'], + 'timestamp' => $last_data['timestamp'], + 'interval' => $module['current_interval'], + 'module_name' => $module['module_name'] + )); if(!is_image_data($last_data["datos"])){ $salida = '' . diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ec0f1466b8..751b1bf34e 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3919,4 +3919,48 @@ function ui_print_tags_view($title = '', $tags = array()) { $tv .= ''; echo $tv; } + +/** + * @brief Get the link to open a snapshot into a new page + * + * @param Array Params to build the link (see $default_params) + * @param bool Flag to choose de return value: + * true: Get the four params required in the function of pandora.js winopen_var (js use) + * false: Get an inline winopen_var function call (php user) + */ +function ui_get_snapshot_link($params, $only_params = false) { + global $config; + + $default_params = array( + 'id_module' => 0, //id_agente_modulo + 'module_name' => '', + 'interval' => 300, + 'last_data' => '', + 'timestamp' => '0' + ); + + // Merge default params with passed params + $params = array_merge ($default_params, $params); + + // First parameter of js winopeng_var + $page = $config['homeurl_static'] . "/operation/agentes/snapshot_view.php"; + + $url = "$page?" . + "id=" . $params['id_module'] . + "&refr=" . $parms['interval'] . + "×tamp=" . $params['timestamp'] . + "&last_data=" . rawurlencode(urlencode(io_safe_output($params['last_data']))) . + "&label=" . rawurlencode(urlencode(io_safe_output($params['module_name']))); + + // Second parameter of js winopeng_var + $win_handle = dechex(crc32('snapshot_' . $params['id_module'])); + + $link_parts = array ($url, $win_handle, 700, 480); + + // Return only the params to js execution + if ($only_params) return $link_parts; + + // Return the function call to inline js execution + return "winopeng_var('" . implode("', '", $link_parts) . "')"; +} ?> diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 0a122889ee..14996e8e4b 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -402,16 +402,21 @@ var TreeController = { else{ var $graphImage = $(' '); + +'images/chart_curve.png" /> '); } - + $graphImage .addClass('module-graph') .click(function (e) { e.preventDefault(); if(element.statusImageHTML.indexOf('data:image')!=-1){ try { - winopeng_var(element.datos,'',700,480); + winopeng_var( + decodeURI(element.snapshot[0]), + element.snapshot[1], + element.snapshot[2], + element.snapshot[3] + ); } catch (error) { // console.log(error); diff --git a/pandora_console/operation/agentes/snapshot_view.php b/pandora_console/operation/agentes/snapshot_view.php index 302197bc17..5d815b563e 100644 --- a/pandora_console/operation/agentes/snapshot_view.php +++ b/pandora_console/operation/agentes/snapshot_view.php @@ -39,6 +39,16 @@ if (file_exists ('../../include/languages/'.$user_language.'.mo')) { $id = get_parameter('id'); $label = get_parameter ("label"); +$last_data = get_parameter("last_data", ''); +$last_timestamp = get_parameter("timestamp", ''); +// FIXME: Support to old call snapshow_view calls. Remove it when all are migrated +if (empty($last_data)) { + $row = db_get_row_sql("SELECT * + FROM tagente_estado + WHERE id_agente_modulo = $id"); + $last_data = io_safe_output($row["datos"]); + $last_timestamp = $row["timestamp"]; +} // TODO - Put ACL here ?> @@ -61,15 +71,14 @@ $label = get_parameter ("label"); $row = db_get_row_sql("SELECT * FROM tagente_estado WHERE id_agente_modulo = $id"); - + echo "

"; echo __("Current data at"); echo " "; - echo $row["timestamp"]; + echo $last_timestamp; echo "

"; - $datos = io_safe_output($row["datos"]); - if (is_image_data($datos)) { - echo '
image
'; + if (is_image_data($last_data)) { + echo '
image
'; } else { $datos = preg_replace ('/',$datos); $datos = preg_replace ('/\s/i',' ',$datos); echo "
"; - echo $datos; + echo $last_data; echo "
"; ?>