#11835 fix temporary 503 error on update items

This commit is contained in:
Jonathan 2023-08-07 13:12:12 +02:00
parent 67dab1dfb1
commit 70460ac77b
2 changed files with 75 additions and 57 deletions

View File

@ -182,7 +182,7 @@ if ($layoutDatas === false) {
$alternativeStyle = true; $alternativeStyle = true;
$parents = visual_map_get_items_parents($idVisualConsole); $parents = visual_map_get_items_parents($idVisualConsole);
$x = 0;
foreach ($layoutDatas as $layoutData) { foreach ($layoutDatas as $layoutData) {
$idLayoutData = $layoutData['id']; $idLayoutData = $layoutData['id'];
@ -537,7 +537,8 @@ foreach ($layoutDatas as $layoutData) {
$table->data[($i + 1)][5] = ''; $table->data[($i + 1)][5] = '';
$table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true); $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] .= '<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);
// Second row // Second row
$table->data[($i + 2)]['icon'] = ''; $table->data[($i + 2)]['icon'] = '';
@ -778,6 +779,12 @@ foreach ($layoutDatas as $layoutData) {
$alternativeStyle = !$alternativeStyle; $alternativeStyle = !$alternativeStyle;
$i = ($i + 3); $i = ($i + 3);
$x++;
}
$x = (($x * 13) + 14);
if ($x > ini_get('max_input_vars')) {
ui_print_warning_message(__('You have to change the <b>"max_input_vars"</b> and set bigger value on <b>php.ini</b> for update, there is too much elements to update'));
} }
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
@ -888,6 +895,16 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
return false; return false;
}); });
$('select[id^="image_"], input[name^="width_"], input[name^="height"], input[name^="left_"], input[name^="top_"], select[id^="parent_"], input[id^="agent_"], select[id^="module_"]').change(function(){
var id = $(this).attr('id').split('_')[1];
$('#hidden-updated_'+id).val('1');
});
$('select[id^="map_linked"]').change(function(){
var id = $(this).attr('id').split('_')[2];
$('#hidden-updated_'+id).val('1');
});
defineTinyMCE('#tinyMCE_editor'); defineTinyMCE('#tinyMCE_editor');
$("#dialog_label_editor").hide () $("#dialog_label_editor").hide ()

View File

@ -418,7 +418,6 @@ switch ($activeTab) {
case 'update': case 'update':
// Update background // Update background
$background = get_parameter('background'); $background = get_parameter('background');
$background_color = get_parameter('background_color');
$width = get_parameter('width'); $width = get_parameter('width');
$height = get_parameter('height'); $height = get_parameter('height');
@ -433,10 +432,9 @@ switch ($activeTab) {
db_process_sql_update( db_process_sql_update(
'tlayout', 'tlayout',
[ [
'background' => $background, 'background' => $background,
'background_color' => $background_color, 'width' => $width,
'width' => $width, 'height' => $height,
'height' => $height,
], ],
['id' => $idVisualConsole] ['id' => $idVisualConsole]
); );
@ -463,62 +461,65 @@ switch ($activeTab) {
foreach ($idsElements as $idElement) { foreach ($idsElements as $idElement) {
$id = $idElement['id']; $id = $idElement['id'];
$values = []; $update = get_parameter('updated_'.$id, 0);
$values['label'] = get_parameter('label_'.$id, ''); if ($update === '1') {
$values['image'] = get_parameter('image_'.$id, ''); $values = [];
$values['width'] = get_parameter('width_'.$id, 0); $values['label'] = get_parameter('label_'.$id, '');
$values['height'] = get_parameter('height_'.$id, 0); $values['image'] = get_parameter('image_'.$id, '');
$values['pos_x'] = get_parameter('left_'.$id, 0); $values['width'] = get_parameter('width_'.$id, 0);
$values['pos_y'] = get_parameter('top_'.$id, 0); $values['height'] = get_parameter('height_'.$id, 0);
switch ($idElement['type']) { $values['pos_x'] = get_parameter('left_'.$id, 0);
case NETWORK_LINK: $values['pos_y'] = get_parameter('top_'.$id, 0);
case LINE_ITEM: switch ($idElement['type']) {
continue 2; case NETWORK_LINK:
case LINE_ITEM:
continue 2;
break; break;
case SIMPLE_VALUE_MAX: case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN: case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG: case SIMPLE_VALUE_AVG:
$values['period'] = get_parameter('period_'.$id, 0); $values['period'] = get_parameter('period_'.$id, 0);
break; break;
case MODULE_GRAPH: case MODULE_GRAPH:
$values['period'] = get_parameter('period_'.$id, 0); $values['period'] = get_parameter('period_'.$id, 0);
unset($values['image']); unset($values['image']);
break; break;
case GROUP_ITEM: case GROUP_ITEM:
$values['id_group'] = get_parameter('group_'.$id, 0); $values['id_group'] = get_parameter('group_'.$id, 0);
break; break;
case CIRCULAR_PROGRESS_BAR: case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR: case CIRCULAR_INTERIOR_PROGRESS_BAR:
case PERCENTILE_BUBBLE: case PERCENTILE_BUBBLE:
case PERCENTILE_BAR: case PERCENTILE_BAR:
unset($values['height']); unset($values['height']);
break; break;
}
$agentName = get_parameter('agent_'.$id, '');
if (defined('METACONSOLE')) {
$values['id_metaconsole'] = (int) get_parameter('id_server_id_'.$id, '');
$values['id_agent'] = (int) get_parameter('id_agent_'.$id, 0);
} else {
$agent_id = (int) get_parameter('id_agent_'.$id, 0);
$values['id_agent'] = $agent_id;
}
$values['id_agente_modulo'] = get_parameter('module_'.$id, 0);
$values['id_custom_graph'] = get_parameter('custom_graph_'.$id, 0);
$values['parent_item'] = get_parameter('parent_'.$id, 0);
$values['id_layout_linked'] = get_parameter('map_linked_'.$id, 0);
if (enterprise_installed()) {
enterprise_visual_map_update_action_from_list_elements($type, $values, $id);
}
db_process_sql_update('tlayout_data', $values, ['id' => $id]);
} }
$agentName = get_parameter('agent_'.$id, '');
if (defined('METACONSOLE')) {
$values['id_metaconsole'] = (int) get_parameter('id_server_id_'.$id, '');
$values['id_agent'] = (int) get_parameter('id_agent_'.$id, 0);
} else {
$agent_id = (int) get_parameter('id_agent_'.$id, 0);
$values['id_agent'] = $agent_id;
}
$values['id_agente_modulo'] = get_parameter('module_'.$id, 0);
$values['id_custom_graph'] = get_parameter('custom_graph_'.$id, 0);
$values['parent_item'] = get_parameter('parent_'.$id, 0);
$values['id_layout_linked'] = get_parameter('map_linked_'.$id, 0);
if (enterprise_installed()) {
enterprise_visual_map_update_action_from_list_elements($type, $values, $id);
}
db_process_sql_update('tlayout_data', $values, ['id' => $id]);
} }
break; break;