Merge branch 'ent-9125-Bug-a-la-hora-de-crear-gráficas-personalizadas-desde-el-agente' into 'develop'

Ent 9125 bug a la hora de crear gráficas personalizadas desde el agente

https://brutus.artica.es:8081/artica/pandora_enterprise/-/issues/9125

See merge request artica/pandorafms!4946
This commit is contained in:
Jimmy Olano 2022-06-29 22:25:00 +00:00
commit f07ed9e4e9
1 changed files with 94 additions and 96 deletions

View File

@ -18,7 +18,7 @@ require_once 'include/functions_agents.php';
require_once 'include/functions_custom_graphs.php';
ui_require_javascript_file('calendar');
if (! check_acl($config['id_user'], $id_grupo, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) {
if (!check_acl($config['id_user'], $id_grupo, 'AR') && !check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access (read) to agent '.agents_get_name($id_agente)
@ -53,7 +53,7 @@ $modules_networkmap_no_proc = agents_get_modules(
false,
[
'id_modulo' => 2,
// networkmap type
// Networkmap type.
'id_tipo_modulo' => [
'<>2',
// != generic_proc
@ -133,7 +133,7 @@ if (empty($modules_boolean)) {
$modules_boolean = [];
}
// Cleaned the duplicate $modules and other things
// Cleaned the duplicate $modules and other things.
$modules_others = array_diff_key(
$modules_others,
$modules_networkmap_no_proc
@ -278,7 +278,7 @@ if ($start_date != $current) {
}
if ($combined) {
// Pass the $modules before the ajax call
// Pass the $modules before the ajax call.
echo '<div class="combined-graph-container center w100p"'.'data-period="'.$period.'"'.'data-stacked="'.CUSTOM_GRAPH_LINE.'"'.'data-date="'.$date.'"'.'data-height="'.$height.'"'.'>'.html_print_image('images/spinner.gif', true).'</div>';
} else {
foreach ($modules as $id_module) {
@ -296,7 +296,7 @@ echo '<div id="graph-error-message" class="invisible">';
ui_print_error_message(__('There was an error loading the graph'));
echo '</div>';
// Dialog to save the custom graph
// Dialog to save the custom graph.
echo "<div id='dialog_save_custom_graph' class='invisible'>";
$table = new stdClass();
$table->width = '100%';
@ -314,40 +314,40 @@ $table->data[0][1] = html_print_input_text(
html_print_table($table);
echo "<div style='width: ".$table->width."; text-align: right;'>";
html_print_image(
html_print_image(
'images/spinner.gif',
false,
[
'style' => 'display: none',
'class' => 'loading_save',
]
);
html_print_image(
);
html_print_image(
'images/ok.png',
false,
[
'style' => 'display: none',
'class' => 'ok_save',
]
);
html_print_image(
);
html_print_image(
'images/error_red.png',
false,
[
'style' => 'display: none',
'class' => 'error_save',
]
);
html_print_button(
);
html_print_button(
__('Save'),
'save_custom_graph',
false,
'save_custom_graph_second_step();',
'class="button_save sub save"'
);
echo '</div>';
echo '</div>';
?>
);
echo '</div>';
echo '</div>';
?>
<script type="text/javascript">
$(document).ready(function() {
$("#dialog_save_custom_graph").dialog({
@ -359,7 +359,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
});
});
$('#button-save_custom_graph').click(function (event) {
$('#button-save_custom_graph').click(function(event) {
$("#dialog_save_custom_graph").dialog("open");
});
@ -373,7 +373,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
params["id_modules"] = <?php echo json_encode($modules); ?>;
params["name"] = $("input[name='name_custom_graph']").val();
params["description"] = "<?php echo __('Custom graph create from the tab graphs in the agent.'); ?>";
params["stacked"] = <?php echo CUSTOM_GRAPH_LINE; ?>;
params["stacked"] = parseInt($("#option_type").val());
params["width"] = <?php echo $width; ?>;
params["height"] = <?php echo $height; ?>;
params["events"] = <?php echo $draw_events; ?>;
@ -381,17 +381,16 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
params["save_custom_graph"] = 1;
params["page"] = "include/ajax/graph.ajax";
jQuery.ajax ({
jQuery.ajax({
data: params,
dataType: "json",
type: "POST",
url: "ajax.php",
success: function (data) {
success: function(data) {
$(".loading_save").hide();
if (data.correct) {
$(".ok_save").show();
}
else {
} else {
$(".error_save").show();
$(".button_save").enable();
}
@ -401,7 +400,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
// Load graphs
$(document).ready(function() {
$('#combined').change(function () {
$('#combined').change(function() {
if ($('#combined').val() == 1) {
$('#option_type').empty();
$('#option_type').append($('<option>', {
@ -420,8 +419,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
value: 3,
text: "<?php echo __('Line stack'); ?>"
}));
}
else {
} else {
$('#option_type').empty();
$('#option_type').append($('<option>', {
value: 0,
@ -434,11 +432,11 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
}
});
var getModulesPHP = function () {
var getModulesPHP = function() {
return <?php echo json_encode($modules); ?>;
}
var requestGraph = function (type, data) {
var requestGraph = function(type, data) {
data = data || {};
type = type || 'custom';
data.page = 'include/ajax/graph.ajax';
@ -452,7 +450,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
})
}
var requestCustomGraph = function (graphId, width, height, period, stacked, date, modules) {
var requestCustomGraph = function(graphId, width, height, period, stacked, date, modules) {
return requestGraph('custom', {
page: 'include/ajax/graph.ajax',
print_custom_graph: 1,
@ -466,7 +464,7 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
});
}
var requestSparseGraph = function (moduleId, period, showEvents, width, height, title, showAlerts, date, unit, type_g) {
var requestSparseGraph = function(moduleId, period, showEvents, width, height, title, showAlerts, date, unit, type_g) {
return requestGraph('sparse', {
page: 'include/ajax/graph.ajax',
print_sparse_graph: 1,
@ -483,13 +481,13 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
});
}
var loadCustomGraphs = function () {
$('div.combined-graph-container').each(function (index, el) {
var loadCustomGraphs = function() {
$('div.combined-graph-container').each(function(index, el) {
loadCustomGraph(el);
});
}
var loadCustomGraph = function (element) {
var loadCustomGraph = function(element) {
var $container = $(element);
var $errorMessage = $('div#graph-error-message');
var period = $container.data('period');
@ -516,10 +514,10 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
var modules = getModulesPHP();
var width = $container.width() - 20;
var handleSuccess = function (data) {
var handleSuccess = function(data) {
$container.html(data);
}
var handleError = function (xhr, textStatus, errorThrown) {
var handleError = function(xhr, textStatus, errorThrown) {
$container.html($errorMessage.html());
}
@ -528,13 +526,13 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
.fail(handleError);
}
var loadSparseGraphs = function () {
$('div.sparse-graph-container').each(function (index, el) {
var loadSparseGraphs = function() {
$('div.sparse-graph-container').each(function(index, el) {
loadSparseGraph(el);
});
}
var loadSparseGraph = function (element) {
var loadSparseGraph = function(element) {
var $container = $(element);
var $errorMessage = $('div#graph-error-message');
var moduleId = $container.data('id_module');
@ -559,10 +557,10 @@ echo "<div style='width: ".$table->width."; text-align: right;'>";
var width = $container.width() - 20;
var handleSuccess = function (data) {
var handleSuccess = function(data) {
$container.html(data);
}
var handleError = function (xhr, textStatus, errorThrown) {
var handleError = function(xhr, textStatus, errorThrown) {
$container.html($errorMessage.html());
}