#11846 change list elements update post json
This commit is contained in:
parent
f0a3b3af63
commit
172fd83547
|
@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) {
|
|||
$table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true);
|
||||
$table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>';
|
||||
$table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true);
|
||||
$table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true);
|
||||
|
||||
// Second row
|
||||
$table->data[($i + 2)]['icon'] = '';
|
||||
|
@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) {
|
|||
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
echo '<form id="vc_elem_form" method="post" action="index.php?sec=network&sec2=godmode/reporting/visual_console_builder&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'].'">';
|
||||
html_print_input_hidden('action', 'update');
|
||||
} else {
|
||||
echo "<form id='vc_elem_form' method='post' action='index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=0&tab=list_elements&id_visual_console=".$idVisualConsole."'>";
|
||||
html_print_input_hidden('action2', 'update');
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
// Form for multiple delete.
|
||||
|
@ -806,15 +799,14 @@ if (is_metaconsole() === false) {
|
|||
$url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'];
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
|
||||
$buttons = html_print_submit_button(
|
||||
__('Update'),
|
||||
'go',
|
||||
false,
|
||||
[
|
||||
'icon' => 'next',
|
||||
'form' => 'vc_elem_form',
|
||||
'icon' => 'next',
|
||||
'form' => 'vc_elem_form',
|
||||
'onclick' => 'submit_update_json()',
|
||||
],
|
||||
true
|
||||
);
|
||||
|
@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
function submit_update_json() {
|
||||
var array_update = [];
|
||||
$('input[id^=hidden-updated_]').each(function(){
|
||||
var id = $(this).attr('id').split('_')[1];
|
||||
|
||||
var label = $('#hidden-label_'+id).val();
|
||||
var image = $('#image_'+id).val();
|
||||
var width = $('#text-width_'+id).val();
|
||||
var height = $('#text-height_'+id).val();
|
||||
var pos_x = $('#text-left_'+id).val();
|
||||
var pos_y = $('#text-top_'+id).val();
|
||||
var parent = $('#parent_'+id).val();
|
||||
var agent = $('#hidden-agent_'+id).val();
|
||||
var module = $('#module_'+id).val();
|
||||
var period = $('#hidden-period_'+id).val();
|
||||
var map_linked = $('#map_linked_'+id).val();
|
||||
var id_server = $('#id_server_id_'+id).val();
|
||||
var rowtype = $('rowtype_'+id).val();
|
||||
var custom_graph = $('#custom_graph_'+id).val();
|
||||
|
||||
array_update.push({
|
||||
'id': id,
|
||||
'label': label,
|
||||
'image': image,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'pos_x': pos_x,
|
||||
'pos_y': pos_y,
|
||||
'parent': parent,
|
||||
'agent': agent,
|
||||
'module': module,
|
||||
'period': period,
|
||||
'map_linked': map_linked,
|
||||
'rowtype': rowtype,
|
||||
'custom_graph': custom_graph,
|
||||
'id_server': id_server,
|
||||
});
|
||||
});
|
||||
|
||||
var background_width = $('#text-width').val();
|
||||
var background_height = $('#text-height').val();
|
||||
|
||||
if (background_height > 0 && background_width > 0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
data: {
|
||||
page: "godmode/reporting/visual_console_builder",
|
||||
action: "update_json",
|
||||
tab: "list_elements",
|
||||
array_update: JSON.stringify(array_update),
|
||||
id_visual_console: "<?php echo (is_metaconsole() === true) ? $idVisualConsole : $visualConsole['id']; ?>",
|
||||
background: $('#background').val(),
|
||||
background_width: $('#text-width').val(),
|
||||
background_height: $('#text-height').val(),
|
||||
},
|
||||
dataType: "json",
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
confirmDialog({
|
||||
title: "<?php echo __('Error.'); ?>",
|
||||
message: "<?php echo __('The width and height property is required and should greater than 0'); ?>",
|
||||
strOKButton: "<?php echo __('Close'); ?>",
|
||||
hideCancelButton: true,
|
||||
size: 300,
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues(
|
|||
'update',
|
||||
'delete',
|
||||
'multiple_delete',
|
||||
'update_json',
|
||||
],
|
||||
'new'
|
||||
);
|
||||
|
@ -523,6 +524,110 @@ switch ($activeTab) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'update_json':
|
||||
// Update background.
|
||||
$background = get_parameter('background');
|
||||
$width = get_parameter('background_width');
|
||||
$height = get_parameter('background_height');
|
||||
|
||||
if ($width == 0 && $height == 0) {
|
||||
$sizeBackground = getimagesize(
|
||||
$config['homedir'].'/images/console/background/'.$background
|
||||
);
|
||||
$width = $sizeBackground[0];
|
||||
$height = $sizeBackground[1];
|
||||
}
|
||||
|
||||
db_process_sql_update(
|
||||
'tlayout',
|
||||
[
|
||||
'background' => $background,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
],
|
||||
['id' => $idVisualConsole]
|
||||
);
|
||||
|
||||
// Return the updated visual console.
|
||||
$visualConsole = db_get_row_filter(
|
||||
'tlayout',
|
||||
['id' => $idVisualConsole]
|
||||
);
|
||||
|
||||
// Update elements in visual map.
|
||||
$idsElements = db_get_all_rows_filter(
|
||||
'tlayout_data',
|
||||
['id_layout' => $idVisualConsole],
|
||||
[
|
||||
'id',
|
||||
'type',
|
||||
]
|
||||
);
|
||||
|
||||
$array_update = json_decode(io_safe_output(get_parameter('array_update')), true);
|
||||
|
||||
if (count($array_update)) {
|
||||
foreach ($array_update as $row) {
|
||||
$id = $row['id'];
|
||||
$values = [];
|
||||
$values['label'] = $row['label'];
|
||||
$values['image'] = $row['image'];
|
||||
$values['width'] = $row['width'];
|
||||
$values['height'] = $row['height'];
|
||||
$values['pos_x'] = $row['pos_x'];
|
||||
$values['pos_y'] = $row['pos_y'];
|
||||
|
||||
switch ($row['rowtype']) {
|
||||
case NETWORK_LINK:
|
||||
case LINE_ITEM:
|
||||
continue 2;
|
||||
|
||||
break;
|
||||
|
||||
case SIMPLE_VALUE_MAX:
|
||||
case SIMPLE_VALUE_MIN:
|
||||
case SIMPLE_VALUE_AVG:
|
||||
$values['period'] = $row['period'];
|
||||
break;
|
||||
|
||||
case MODULE_GRAPH:
|
||||
$values['period'] = $row['period'];
|
||||
unset($values['image']);
|
||||
break;
|
||||
|
||||
case GROUP_ITEM:
|
||||
$values['id_group'] = $row['group'];
|
||||
break;
|
||||
|
||||
case CIRCULAR_PROGRESS_BAR:
|
||||
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
||||
case PERCENTILE_BUBBLE:
|
||||
case PERCENTILE_BAR:
|
||||
unset($values['height']);
|
||||
break;
|
||||
}
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$values['id_metaconsole'] = $row['id_server'];
|
||||
}
|
||||
|
||||
$values['id_agent'] = $row['agent'];
|
||||
$values['id_agente_modulo'] = $row['module'];
|
||||
$values['id_custom_graph'] = $row['custom_graph'];
|
||||
$values['parent_item'] = $row['parent'];
|
||||
$values['id_layout_linked'] = $row['map_linked'];
|
||||
|
||||
if (enterprise_installed()) {
|
||||
enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id);
|
||||
}
|
||||
|
||||
db_process_sql_update('tlayout_data', $values, ['id' => $id]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$id_element = get_parameter('id_element');
|
||||
$result = db_process_sql_delete('tlayout_data', ['id' => $id_element]);
|
||||
|
|
Loading…
Reference in New Issue