mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Merge branch 'ent-1850-no-hay-opcion-command-line-snapshot-en-meta-3' into 'develop'
[Snapshots] Fixed snapshots in metaconsole. Changed functionallity but preserve all way to work See merge request artica/pandorafms!1361
This commit is contained in:
commit
f65aebf532
@ -1599,6 +1599,15 @@ class Tree {
|
|||||||
'url' => $moduleGraphURL,
|
'url' => $moduleGraphURL,
|
||||||
'handle' => $winHandle
|
'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
|
// Alerts fired image
|
||||||
|
@ -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'));
|
$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"] );
|
$is_snapshot = is_snapshot_data ( $last_data["datos"] );
|
||||||
|
|
||||||
if (($config['command_snapshot']) && ($is_snapshot)) {
|
if (($config['command_snapshot']) && ($is_snapshot)) {
|
||||||
$handle = 'snapshot_' . $module['id_agente_modulo'];
|
$link = ui_get_snapshot_link( array(
|
||||||
$url = 'include/procesos.php?agente=' . $row['id_agente_modulo'];
|
'id_module' => $module['id_agente_modulo'],
|
||||||
$win_handle = dechex(crc32($handle));
|
'last_data' => $last_data['datos'],
|
||||||
if (! defined ('METACONSOLE')) {
|
'timestamp' => $last_data['timestamp'],
|
||||||
$link = "winopeng_var('operation/agentes/snapshot_view.php?" .
|
'interval' => $module['current_interval'],
|
||||||
"id=" . $module['id_agente_modulo'] .
|
'module_name' => $module['module_name']
|
||||||
"&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)";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_image_data($last_data["datos"])){
|
if(!is_image_data($last_data["datos"])){
|
||||||
$salida = '<a href="javascript:' . $link . '">' .
|
$salida = '<a href="javascript:' . $link . '">' .
|
||||||
|
@ -3919,4 +3919,48 @@ function ui_print_tags_view($title = '', $tags = array()) {
|
|||||||
$tv .= '</div>';
|
$tv .= '</div>';
|
||||||
echo $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) . "')";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -402,16 +402,21 @@ var TreeController = {
|
|||||||
else{
|
else{
|
||||||
|
|
||||||
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
var $graphImage = $('<img src="'+(controller.baseURL.length > 0 ? controller.baseURL : '')
|
||||||
+'images/chart_curve.png" /> ');
|
+'images/chart_curve.png" /> ');
|
||||||
}
|
}
|
||||||
|
|
||||||
$graphImage
|
$graphImage
|
||||||
.addClass('module-graph')
|
.addClass('module-graph')
|
||||||
.click(function (e) {
|
.click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(element.statusImageHTML.indexOf('data:image')!=-1){
|
if(element.statusImageHTML.indexOf('data:image')!=-1){
|
||||||
try {
|
try {
|
||||||
winopeng_var(element.datos,'',700,480);
|
winopeng_var(
|
||||||
|
decodeURI(element.snapshot[0]),
|
||||||
|
element.snapshot[1],
|
||||||
|
element.snapshot[2],
|
||||||
|
element.snapshot[3]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
// console.log(error);
|
// console.log(error);
|
||||||
|
@ -39,6 +39,16 @@ if (file_exists ('../../include/languages/'.$user_language.'.mo')) {
|
|||||||
|
|
||||||
$id = get_parameter('id');
|
$id = get_parameter('id');
|
||||||
$label = get_parameter ("label");
|
$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
|
// TODO - Put ACL here
|
||||||
?>
|
?>
|
||||||
@ -61,15 +71,14 @@ $label = get_parameter ("label");
|
|||||||
$row = db_get_row_sql("SELECT *
|
$row = db_get_row_sql("SELECT *
|
||||||
FROM tagente_estado
|
FROM tagente_estado
|
||||||
WHERE id_agente_modulo = $id");
|
WHERE id_agente_modulo = $id");
|
||||||
|
|
||||||
echo "<h2 style='text-align:center;' id='title_snapshot_view'>";
|
echo "<h2 style='text-align:center;' id='title_snapshot_view'>";
|
||||||
echo __("Current data at");
|
echo __("Current data at");
|
||||||
echo " ";
|
echo " ";
|
||||||
echo $row["timestamp"];
|
echo $last_timestamp;
|
||||||
echo "</h2>";
|
echo "</h2>";
|
||||||
$datos = io_safe_output($row["datos"]);
|
if (is_image_data($last_data)) {
|
||||||
if (is_image_data($datos)) {
|
echo '<center><img src="' . $last_data . '" alt="image" style="width:100%"/></center>';
|
||||||
echo '<center><img src="' . $datos . '" alt="image" style="width:100%"/></center>';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$datos = preg_replace ('/</', '<', $datos);
|
$datos = preg_replace ('/</', '<', $datos);
|
||||||
@ -77,7 +86,7 @@ $label = get_parameter ("label");
|
|||||||
$datos = preg_replace ('/\n/i','<br>',$datos);
|
$datos = preg_replace ('/\n/i','<br>',$datos);
|
||||||
$datos = preg_replace ('/\s/i',' ',$datos);
|
$datos = preg_replace ('/\s/i',' ',$datos);
|
||||||
echo "<div id='result_div' style='width: 100%; height: 100%; overflow: scroll; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
|
echo "<div id='result_div' style='width: 100%; height: 100%; overflow: scroll; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
|
||||||
echo $datos;
|
echo $last_data;
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -88,16 +97,16 @@ $label = get_parameter ("label");
|
|||||||
div.css('overflow-y', 'auto');
|
div.css('overflow-y', 'auto');
|
||||||
var w2 = $('div', div).innerWidth();
|
var w2 = $('div', div).innerWidth();
|
||||||
$(div).remove();
|
$(div).remove();
|
||||||
|
|
||||||
return (w1 - w2);
|
return (w1 - w2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
width = $("#result_div").css("width");
|
width = $("#result_div").css("width");
|
||||||
width = width.replace("px", "");
|
width = width.replace("px", "");
|
||||||
width = parseInt(width);
|
width = parseInt(width);
|
||||||
$("#result_div").css("width", (width - getScrollbarWidth()) + "px");
|
$("#result_div").css("width", (width - getScrollbarWidth()) + "px");
|
||||||
|
|
||||||
height = $("#result_div").css("height");
|
height = $("#result_div").css("height");
|
||||||
height = height.replace("px", "");
|
height = height.replace("px", "");
|
||||||
height = parseInt(height);
|
height = parseInt(height);
|
||||||
|
@ -1361,19 +1361,13 @@ if (!empty($result)) {
|
|||||||
$is_snapshot = is_snapshot_data ( $module_value );
|
$is_snapshot = is_snapshot_data ( $module_value );
|
||||||
|
|
||||||
if (($config['command_snapshot']) && ($is_snapshot)) {
|
if (($config['command_snapshot']) && ($is_snapshot)) {
|
||||||
$handle = 'snapshot_' . $row['id_agente_modulo'];
|
$link = ui_get_snapshot_link( array(
|
||||||
$url = 'include/procesos.php?agente=' . $row['id_agente_modulo'];
|
'id_module' => $row['id_agente_modulo'],
|
||||||
$win_handle = dechex(crc32($handle));
|
'last_data' => $row['datos'],
|
||||||
if (! defined ('METACONSOLE')) {
|
'timestamp' => $row['timestamp'],
|
||||||
$link = "winopeng_var('operation/agentes/snapshot_view.php?" .
|
'interval' => $row['current_interval'],
|
||||||
"id=" . $row['id_agente_modulo'] .
|
'module_name' => $row['module_name']
|
||||||
"&refr=" . $row['current_interval'] .
|
));
|
||||||
"&label=" . rawurlencode(urlencode(io_safe_output($row['module_name']))) . "','" . $win_handle . "', 700,480)";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$link = "winopeng_var('$row[datos]','',700,480)";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_image_data($row['datos'])){
|
if(!is_image_data($row['datos'])){
|
||||||
$salida = '<a href="javascript:' . $link . '">' .
|
$salida = '<a href="javascript:' . $link . '">' .
|
||||||
|
Loading…
x
Reference in New Issue
Block a user