Merge branch 'ent-9662-second-round' of brutus.artica.es:artica/pandorafms into ent-9662-second-round

This commit is contained in:
Pablo Aragon 2023-03-13 17:40:06 +01:00
commit 1d6e33f371
3 changed files with 153 additions and 120 deletions

View File

@ -484,7 +484,7 @@ if (is_metaconsole() === false) {
$buttons = [
'list' => [
'active' => false,
'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure='.$pure.'">'.html_print_image('images/load@svg.svg', true, ['title' => __('List alerts'), 'class' => 'main_menu_icon invert_filter']).'</a>',
'text' => '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=list&pure='.$pure.'">'.html_print_image('images/logs@svg.svg', true, ['title' => __('List alerts'), 'class' => 'main_menu_icon invert_filter']).'</a>',
],
'builder' => [
'active' => false,

View File

@ -389,7 +389,7 @@ if (empty($create) === false || empty($view) === false) {
$disabled = ($locked === true) ? 'readonly="readonly"' : '';
if (empty($create) === true) {
$formAction = 'index.php?sec=gservers&sec2=godmode/servers/plugin&tab=$tab&update_plugin=$plugin_id&pure='.$config['pure'];
$formAction = 'index.php?sec=gservers&sec2=godmode/servers/plugin&tab=$tab&update_plugin='.$plugin_id.'&pure='.$config['pure'];
} else {
$formAction = 'index.php?sec=gservers&sec2=godmode/servers/plugin&tab=$tab&create_plugin=1&pure='.$config['pure'];
}
@ -403,69 +403,61 @@ if (empty($create) === false || empty($view) === false) {
$table = new stdClass();
$table->id = 'table-form';
$table->class = 'floating_form';
$table->class = 'filter-table-adv';
$table->style = [];
$table->data['plugin_name_captions'] = $data;
$table->style[0] = 'vertical-align: top';
$table->style[1] = 'vertical-align: top';
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
// General title.
$generalTitleContent = [];
$generalTitleContent[] = html_print_div([ 'style' => 'width: 10px; flex: 0 0 auto; margin-right: 5px;}', 'class' => 'section_table_title_line' ], true);
$generalTitleContent[] = html_print_div([ 'class' => 'section_table_title', 'content' => __('General')], true);
$data[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $generalTitleContent) ], true);
$data[0] = html_print_div([ 'class' => 'section_table_title', 'content' => __('General')], true);
$table->data['general_title'] = $data;
$data = [];
$data[0] = __('Name');
$data[0] = html_print_label_input_block(
__('Name'),
html_print_input_text('form_name', $form_name, '', 100, 255, true, false, false, '')
);
$table->data['plugin_name_captions'] = $data;
$data = [];
$data[0] = html_print_input_text('form_name', $form_name, '', 100, 255, true, false, false, '', 'w100p');
$table->data['plugin_name_inputs'] = $data;
$table->colspan['plugin_name_inputs'][0] = 3;
$data[0] = html_print_label_input_block(
__('Plugin type'),
html_print_select($formPluginType, 'form_plugin_type', $form_plugin_type, '', '', 0, true, false, true, '', false, 'width: 100%')
);
$data = [];
$data[0] = __('Plugin type');
$data[1] = __('Max. timeout');
$table->data['plugin_type_timeout_captions'] = $data;
// $table->colspan['plugin_type'][1] = 3;
$data = [];
$data[0] = html_print_select($formPluginType, 'form_plugin_type', $form_plugin_type, '', '', 0, true);
$timeoutContent = [];
$timeoutContent[] = '<div>'.html_print_extended_select_for_time('form_max_timeout', $form_max_timeout, '', '', '0', false, true).'</div>';
$timeoutContent[] = ui_print_input_placeholder(__('This value only will be applied if is minor than the server general configuration plugin timeout').'<br>'.__('If you set a 0 seconds timeout, the server plugin timeout will be used'), true);
$data[1] = html_print_div(
[
'class' => 'flex flex_column',
'content' => implode('', $timeoutContent),
],
true
$data[1] = html_print_label_input_block(
__('Max. timeout'),
html_print_div(
[
'class' => 'flex flex_column',
'content' => implode('', $timeoutContent),
],
true
)
);
$table->data['plugin_type_timeout_inputs'] = $data;
$table->data['plugin_type_timeout'] = $data;
$data = [];
$data[0] = __('Description');
$table->data['plugin_desc_captions'] = $data;
$data[0] = html_print_label_input_block(
__('Description'),
html_print_textarea('form_description', 4, 50, $form_description, '', true)
);
$data = [];
$data[0] = html_print_textarea('form_description', 4, 50, $form_description, '', true, 'w100p');
$table->colspan['plugin_desc_inputs'][0] = 3;
$table->colspan['plugin_desc_inputs'][0] = 2;
$table->data['plugin_desc_inputs'] = $data;
// Command title.
$commandTitleContent = [];
$commandTitleContent[] = html_print_div([ 'style' => 'width: 10px; flex: 0 0 auto; margin-right: 5px;}', 'class' => 'section_table_title_line' ], true);
$commandTitleContent[] = html_print_div([ 'class' => 'section_table_title', 'content' => __('Command')], true);
$data = [];
$data[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $commandTitleContent) ], true);
$table->data['command_title'] = $data;
// Command title.
$data = [];
$data[0] = __('Plugin command').ui_print_help_tip(__('Specify interpreter and plugin path. The server needs permissions to run it.'), true);
$table->data['plugin_command_caption'] = $data;
$data[0] = html_print_div([ 'class' => 'section_table_title', 'content' => __('Command')], true);
$table->data['command_title'] = $data;
$data = [];
$formExecuteContent = [];
@ -480,45 +472,53 @@ if (empty($create) === false || empty($view) === false) {
true
);
$data[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $formExecuteContent)], true);
$data[0] = html_print_label_input_block(
__('Plugin command'),
html_print_div(['class' => 'flex-row-center', 'content' => implode('', $formExecuteContent)], true).ui_print_input_placeholder(
__('Specify interpreter and plugin path. The server needs permissions to run it.'),
true
)
);
// $data[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $formExecuteContent)], true);
$table->data['plugin_command_inputs'] = $data;
$table->colspan['plugin_command_inputs'][0] = 2;
$data = [];
$data[0] = __('Plug-in parameters');
$table->data['plugin_parameters_caption'] = $data;
$data = [];
$data[0] = html_print_input_text(
'form_parameters',
$parameters,
'',
100,
255,
true,
false,
false,
'',
'command_component command_advanced_conf text_input w100p'
$data[0] = html_print_label_input_block(
__('Plug-in parameters'),
html_print_input_text(
'form_parameters',
$parameters,
'',
100,
255,
true,
false,
false,
'',
'command_component command_advanced_conf text_input'
)
);
$table->data['plugin_parameters_inputs'] = $data;
$table->colspan['plugin_parameters_inputs'][0] = 2;
$data = [];
$data[0] = __('Command preview');
$table->data['plugin_preview_captions'] = $data;
$data = [];
$data[0] = html_print_div(['id' => 'command_preview', 'class' => 'mono'], true);
// $data[0] = __('Command preview');
// $table->data['plugin_preview_captions'] = $data;
// $data = [];
// $data[0] = html_print_div(['id' => 'command_preview', 'class' => 'mono'], true);
$data[0] = html_print_label_input_block(
__('Command preview'),
html_print_div(['id' => 'command_preview', 'class' => 'mono'], true)
);
$table->data['plugin_preview_inputs'] = $data;
$table->colspan['plugin_preview_inputs'][0] = 2;
// Parameters macros title.
$macrosTitleContent = [];
$macrosTitleContent[] = html_print_div([ 'style' => 'width: 10px; flex: 0 0 auto; margin-right: 5px;}', 'class' => 'section_table_title_line' ], true);
$macrosTitleContent[] = html_print_div([ 'class' => 'section_table_title', 'content' => __('Parameters macros')], true);
$data = [];
$data[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $macrosTitleContent) ], true);
$data[0] = html_print_div([ 'class' => 'section_table_title', 'content' => __('Parameters macros')], true);
$table->data['parameters_macros_title'] = $data;
$macros = json_decode($macros, true);
@ -563,53 +563,59 @@ if (empty($create) === false || empty($view) === false) {
}
$datam = [];
$datam[0] = __('Description')."<span class='normal_weight'> ($macro_name)</span>";
$datam[0] = html_print_label_input_block(
__('Description').'<span class="normal_weight">('.$macro_name.')</span>',
html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, false, '', "class='command_macro text_input'", true)
);
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, false, '', "class='command_macro text_input'", true);
$datam[2] = __('Default value')."<span class='normal_weight'> ($macro_name)</span>";
$datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, false, '', "class='command_component command_macro text_input'", true);
$datam[1] = html_print_label_input_block(
__('Default value').'<span class="normal_weight">('.$macro_name.')</span>',
html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, false, '', "class='command_component command_macro text_input'", true)
);
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['plugin_'.$next_name_number][1] = 3;
$table->colspan['plugin_'.$next_name_number][1] = 2;
$datam = [];
$datam[0] = __('Hide value').ui_print_help_tip(
__('This field will show up as dots like a password'),
true
);
$datam[1] = html_print_checkbox_extended(
$macro_hide_value_name,
1,
$macro_hide_value_value,
0,
'',
['class' => 'command_macro'],
true,
'checkbox-'.$macro_hide_value_name
$datam = html_print_label_input_block(
__('Hide value'),
html_print_checkbox_switch(
$macro_hide_value_name,
1,
$macro_hide_value_value,
0,
'',
['class' => 'command_macro'],
true,
'checkbox-'.$macro_hide_value_name
).ui_print_input_placeholder(
__('This field will show up as dots like a password'),
true
)
);
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['plugin_'.$next_name_number][1] = 3;
// $table->colspan['plugin_'.$next_name_number][1] = 3;
$datam = [];
$datam[0] = __('Help')."<span class='normal_weight'> ($macro_name)</span><br><br><br>";
$datam[1] = html_print_textarea(
$macro_help_name,
6,
100,
$macro_help_value,
'class="command_macro" class="w97p"',
true
$datam[0] = html_print_label_input_block(
__('Help').'<span class="normal_weight"> ('.$macro_name.')</span>',
html_print_textarea(
$macro_help_name,
6,
100,
$macro_help_value,
'class="command_macro" class="w97p"',
true
)
);
$datam[1] .= '<br><br><br>';
$table->colspan['plugin_'.$next_name_number][0] = 2;
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$i++;
@ -617,7 +623,7 @@ if (empty($create) === false || empty($view) === false) {
// Add/Delete buttons
$datam = [];
$buttons = '';
if (!$locked) {
$datam[0] = '<a id="add_macro_btn" href="javascript:;">'.'<span class="bolder">'.__('Add macro').'</span>'.'&nbsp;'.html_print_image(
'images/add.png',
@ -627,20 +633,55 @@ if (empty($create) === false || empty($view) === false) {
$datam[0] .= '<div id="next_macro" class="invisible">'.$i.'</div>';
$datam[0] .= '<div id="next_row" class="invisible">'.$next_name_number.'</div>';
$buttons = html_print_anchor(
[
'id' => 'add_macro_btn',
'href' => 'javascript:;',
'content' => html_print_image(
'images/plus@svg.svg',
true,
['class' => 'invert_filter']
),
],
true
);
$buttons .= html_print_div(['id' => 'next_macro', 'class' => 'invisible', 'content' => $i], true);
$buttons .= html_print_div(['id' => 'next_row', 'class' => 'invisible', 'content' => $next_name_number], true);
$delete_macro_style = '';
if ($i <= 2) {
$delete_macro_style = 'display:none;';
}
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.'<a href="javascript:;">'.'<span class="bolder">'.__('Delete macro').'</span>'.'&nbsp;'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>'.'</div>';
// $datam[1] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.'<a href="javascript:;">'.'<span class="bolder">'.__('Delete macro').'</span>'.'&nbsp;'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>'.'</div>';
$buttons .= html_print_anchor(
[
'id' => 'delete_macro_button',
'style' => $delete_macro_style,
'href' => 'javascript:;',
'content' => html_print_image(
'images/delete.svg',
true,
['class' => 'main_menu_icon invert_filter']
),
],
true
);
$datam[0] = html_print_div(
[
'style' => 'flex-direction: row-reverse;justify-content: flex-start;',
'content' => $buttons,
],
true
);
$table->colspan['plugin_action'][0] = 2;
$table->colspan['plugin_action'][2] = 2;
} else {
$table->colspan['plugin_action'][0] = 4;
// $table->colspan['plugin_action'][0] = 4;
}
$table->rowstyle['plugin_action'] = 'text-align:center';
// $table->rowstyle['plugin_action'] = 'text-align:center';
$table->data['plugin_action'] = $datam;

View File

@ -3283,12 +3283,19 @@ function reporting_html_alert_report_actions($table, $item, $pdf=0)
function get_alert_table($data)
{
$table = new StdCLass();
$table->width = '100%';
$table->width = '99%';
$table->data = [];
$table->head = [];
$table->headstyle = [];
$table->cellstyle = [];
$table->headstyle[0] = 'text-align:left;';
$table->size[0] = '25%';
$table->size[1] = '12%';
$table->size[2] = '12%';
$table->size[3] = '12%';
$table->size[4] = '12%';
$table->size[5] = '12%';
$table->size[6] = '12%';
$head = reset($data);
foreach (array_reverse(array_keys($head)) as $name) {
@ -3527,7 +3534,7 @@ function reporting_html_alert_report($table, $item, $pdf=0)
$table->data['alerts']['cell'] = html_print_table($table1, true);
if ($pdf) {
$table1->class = 'pdf_alert_table';
$table1->class = 'info_table';
return html_print_table($table1, true);
}
}
@ -3691,7 +3698,7 @@ function reporting_html_agent_configuration(
$row = [];
$row['name'] = $item['data']['name'];
$row['group'] = $item['data']['group_icon'];
$row['group'] = groups_get_name($item['data']['group'], true);
$row['address'] = $item['data']['os_icon'];
$row['os'] = $item['data']['address'];
$row['description'] = $item['data']['description'];
@ -3732,36 +3739,21 @@ function reporting_html_agent_configuration(
$table1->width = '99%';
$table1->head = [];
$table1->head['name'] = __('Name');
$table1->head['type'] = __('Type');
$table1->head['warning_critical'] = __('Warning<br/>Critical');
$table1->head['threshold'] = __('Threshold');
$table1->head['group_icon'] = __('Group');
$table1->head['description'] = __('Description');
$table1->head['interval'] = __('Interval');
$table1->head['unit'] = __('Unit');
$table1->head['status'] = __('Status');
$table1->head['tags'] = __('Tags');
$table1->align = [];
$table1->align['name'] = 'left';
$table1->align['type'] = 'center';
$table1->align['warning_critical'] = 'right';
$table1->align['threshold'] = 'right';
$table1->align['group_icon'] = 'center';
$table1->align['description'] = 'left';
$table1->align['interval'] = 'right';
$table1->align['unit'] = 'left';
$table1->align['status'] = 'center';
$table1->align['tags'] = 'left';
$table1->align[] = 'left';
$table1->data = [];
foreach ($item['data']['modules'] as $module) {
$row = [];
$row['name'] = $module['name'];
$row['type'] = $module['type_icon'];
$row['warning_critical'] = $module['max_warning'].' / '.$module['min_warning'].'<br>'.$module['max_critical'].' / '.$module['min_critical'];
$row['threshold'] = $module['threshold'];
$row['group_icon'] = ui_print_group_icon($item['data']['group'], true);
$row['description'] = $module['description'];
$row['interval'] = $module['interval'];
$row['unit'] = $module['unit'];