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-08 15:31:05 +01:00
commit 2934ff25ff
11 changed files with 915 additions and 571 deletions

View File

@ -325,7 +325,7 @@ if ($edit === false) {
$table_simple->data['module_n_type'][1] = '<span class="result_info_text">'.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')</span>'; $table_simple->data['module_n_type'][1] = '<span class="result_info_text">'.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')</span>';
} else { } else {
$idModuleType = (isset($id_module_type) === true) ? $idModuleType : ''; $idModuleType = (isset($id_module_type) === true) ? $id_module_type : '';
// Removed web analysis and log4x from select. // Removed web analysis and log4x from select.
$tipe_not_in = '24, 25'; $tipe_not_in = '24, 25';
if (is_metaconsole() === true) { if (is_metaconsole() === true) {

View File

@ -128,6 +128,7 @@ if ($page === 'enterprise/godmode/policies/policy_modules') {
// In ICMP modules, port is not configurable. // In ICMP modules, port is not configurable.
if ($id_module_type !== 6 && $id_module_type !== 7) { if ($id_module_type !== 6 && $id_module_type !== 7) {
$tcp_port = (empty($tcp_port) === false) ? $tcp_port : get_parameter('tcp_port');
$data[1] = html_print_input_text( $data[1] = html_print_input_text(
'tcp_port', 'tcp_port',
$tcp_port, $tcp_port,

View File

@ -15,7 +15,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,8 +29,6 @@
global $config; global $config;
check_login(); check_login();
$agent_d = check_acl($config['id_user'], 0, 'AD'); $agent_d = check_acl($config['id_user'], 0, 'AD');
@ -54,23 +52,33 @@ require_once $config['homedir'].'/include/functions_cron.php';
// Buttons. // Buttons.
$buttons = [ $buttons = [
'text' => "<a href='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>".html_print_image( 'text' => "<a href='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>".html_print_image(
'images/list.png', 'images/logs@svg.svg',
true, true,
[ [
'title' => __('List'), 'title' => __('List'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'</a>', ).'</a>',
]; ];
// Header. // Header.
ui_print_page_header( ui_print_standard_header(
__('Scheduled Downtime'), __('Scheduled Downtime'),
'images/gm_monitoring.png', 'images/gm_monitoring.png',
false, false,
'', '',
true, true,
$buttons $buttons,
[
[
'link' => '',
'label' => __('Tools'),
],
[
'link' => '',
'label' => __('Scheduled Downtime'),
],
]
); );
// Recursion group filter. // Recursion group filter.
@ -813,227 +821,7 @@ if (users_can_manage_group_all('AW') === true || $disabled) {
$return_all_group = true; $return_all_group = true;
} }
$table = new StdClass();
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->data[0][0] = __('Name');
$table->data[0][1] = html_print_input_text(
'name',
$name,
'',
25,
40,
true,
$disabled_in_execution
);
$table->data[1][0] = __('Group');
$table->data[1][1] = '<div class="w250px">'.html_print_select_groups(
false,
$access,
$return_all_group,
'id_group',
$id_group,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
).'</div>';
$table->data[2][0] = __('Description');
$table->data[2][1] = html_print_textarea(
'description',
3,
35,
$description,
'',
true
);
$table->data[3][0] = __('Type').ui_print_help_tip(
__('Quiet: Modules will not generate events or fire alerts.').'<br>'.__('Disable Agents: Disables the selected agents.').'<br>'.__('Disable Alerts: Disable alerts for the selected agents.'),
true
);
$table->data[3][1] = html_print_select(
[
'quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'),
'disable_agent_modules' => __('Disable Modules'),
'disable_agents_alerts' => __('Disabled only Alerts'),
],
'type_downtime',
$type_downtime,
'change_type_downtime()',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
);
$table->data[4][0] = __('Execution');
$table->data[4][1] = html_print_select(
[
'once' => __('Once'),
'periodically' => __('Periodically'),
'cron' => __('Cron from/to'),
],
'type_execution',
$type_execution,
'change_type_execution();',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
);
$days = array_combine(range(1, 31), range(1, 31)); $days = array_combine(range(1, 31), range(1, 31));
$table->data[5][0] = __('Configure the time').'&nbsp;';
;
$table->data[5][1] = "
<div id='once_time' style='display: none;'>
<table>
<tr>
<td>".__('From:').'</td>
<td>'.html_print_input_text('once_date_from', $once_date_from, '', 10, 10, true, $disabled_in_execution).html_print_input_text('once_time_from', $once_time_from, '', 9, 9, true, $disabled_in_execution).'</td>
</tr>
<tr>
<td>'.__('To:').'</td>
<td>'.html_print_input_text('once_date_to', $once_date_to, '', 10, 10, true).html_print_input_text('once_time_to', $once_time_to, '', 9, 9, true)."</td>
</tr>
</table>
</div>
<div id='periodically_time' style='display: none;'>
<table>
<tr><td>".ui_get_using_system_timezone_warning().'</td></tr>
<tr>
<td>'.__('Type Periodicity:').'&nbsp;'.html_print_select(
[
'weekly' => __('Weekly'),
'monthly' => __('Monthly'),
],
'type_periodicity',
$type_periodicity,
'change_type_periodicity();',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
)."</td>
</tr>
<tr>
<td colspan='2'>
<table id='weekly_item' style='display: none;'>
<tr>
<td>".__('Mon').html_print_checkbox('monday', 1, $monday, true, $disabled_in_execution).'</td>
<td>'.__('Tue').html_print_checkbox('tuesday', 1, $tuesday, true, $disabled_in_execution).'</td>
<td>'.__('Wed').html_print_checkbox('wednesday', 1, $wednesday, true, $disabled_in_execution).'</td>
<td>'.__('Thu').html_print_checkbox('thursday', 1, $thursday, true, $disabled_in_execution).'</td>
<td>'.__('Fri').html_print_checkbox('friday', 1, $friday, true, $disabled_in_execution).'</td>
<td>'.__('Sat').html_print_checkbox('saturday', 1, $saturday, true, $disabled_in_execution).'</td>
<td>'.__('Sun').html_print_checkbox('sunday', 1, $sunday, true, $disabled_in_execution)."</td>
</tr>
</table>
<table id='monthly_item' style='display: none;'>
<tr>
<td>".__('From day:').'</td>
<td>'.html_print_select(
$days,
'periodically_day_from',
$periodically_day_from,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
).'</td>
<td>'.__('To day:').'</td>
<td>'.html_print_select(
$days,
'periodically_day_to',
$periodically_day_to,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
).'</td>
<td>'.ui_print_help_tip(__('The end day must be higher than the start day'), true).'</td>
</tr>
</table>
<table>
<tr>
<td>'.__('From hour:').'</td>
<td>'.html_print_input_text(
'periodically_time_from',
$periodically_time_from,
'',
7,
7,
true,
$disabled_in_execution
).ui_print_help_tip(
__('The end time must be higher than the start time'),
true
).'</td>
<td>'.__('To hour:').'</td>
<td>'.html_print_input_text(
'periodically_time_to',
$periodically_time_to,
'',
7,
7,
true,
$disabled_in_execution
).ui_print_help_tip(
__('The end time must be higher than the start time'),
true
).'</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="cron_time" style="display: none;">
<table class="w100p">
<tr>
<td>'.__('Cron from:').'</td>
<td>'.html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, false, false, true, 'from').'</td>
</tr>
<tr>
<td>'.__('Cron to:').'</td>
<td>'.html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, false, true, true, 'to').'</td>
</tr>
</table>
</div>';
if ($id_downtime > 0) {
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
} else {
echo '<form method="POST" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor">';
}
// Editor form.
html_print_table($table);
echo "<td valign=top style='width:300px;padding-left:20px;'>";
$filter_group = (int) get_parameter('filter_group', 0); $filter_group = (int) get_parameter('filter_group', 0);
@ -1074,15 +862,320 @@ if (empty($agents) || $disabled_in_execution) {
$disabled_add_button = true; $disabled_add_button = true;
} }
// Show available agents to include into downtime
$table = new StdClass();
$table->class = 'databox filters';
$table->width = '100%';
$table->data = [];
$table->size[0] = '25%';
$table->data[0][0] = __('Group filter'); $table = new StdClass();
$table->data[0][1] = html_print_select_groups( $table->class = 'databox filter-table-adv';
$table->id = 'principal_table_scheduled';
$table->width = '100%';
$table->size = [];
$table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = [];
$table->data['first_title'][] = html_print_div(
[
'class' => 'section_table_title',
'content' => __('Editor'),
],
true
);
$table->data[0][] = html_print_label_input_block(
__('Name'),
html_print_input_text(
'name',
$name,
'',
25,
40,
true,
$disabled_in_execution
)
);
$table->data[0][] = html_print_label_input_block(
__('Group'),
html_print_select_groups(
false,
$access,
$return_all_group,
'id_group',
$id_group,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
)
);
$table->data[1][] = html_print_label_input_block(
__('Description'),
html_print_textarea(
'description',
3,
35,
$description,
'',
true
)
);
$table->data[1][] = html_print_label_input_block(
__('Type'),
html_print_select(
[
'quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'),
'disable_agent_modules' => __('Disable Modules'),
'disable_agents_alerts' => __('Disabled only Alerts'),
],
'type_downtime',
$type_downtime,
'change_type_downtime()',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
).ui_print_input_placeholder(
__('Quiet: Modules will not generate events or fire alerts.').'<br>'.__('Disable Agents: Disables the selected agents.').'<br>'.__('Disable Alerts: Disable alerts for the selected agents.'),
true
)
);
$table->data[2][] = html_print_label_input_block(
__('Execution'),
html_print_select(
[
'once' => __('Once'),
'periodically' => __('Periodically'),
'cron' => __('Cron from/to'),
],
'type_execution',
$type_execution,
'change_type_execution();',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
)
);
$timeInputs = [];
$timeInputs[] = html_print_div(
[
'id' => 'once_time',
'style' => 'display: none',
'content' => html_print_div(
[
'class' => '',
'content' => html_print_input_text(
'once_date_from',
$once_date_from,
'',
10,
10,
true,
$disabled_in_execution
).html_print_input_text(
'once_time_from',
$once_time_from,
'',
9,
9,
true,
$disabled_in_execution
).'<span class="margin-lr-10 result_info_text">'.__(
'To'
).'</span>'.html_print_input_text(
'once_date_to',
$once_date_to,
'',
10,
10,
true
).html_print_input_text(
'once_time_to',
$once_time_to,
'',
9,
9,
true
),
],
true
),
],
true
);
$timeInputs[] = html_print_div(
[
'id' => 'periodically_time',
'style' => 'display: none',
'content' => html_print_div(
[
'class' => 'filter-table-adv-manual w50p',
'content' => html_print_label_input_block(
__('Type Periodicity'),
html_print_select(
[
'weekly' => __('Weekly'),
'monthly' => __('Monthly'),
],
'type_periodicity',
$type_periodicity,
'change_type_periodicity();',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
)
),
],
true
).html_print_div(
[
'id' => 'weekly_item',
'class' => '',
'content' => '<ul class="flex-row-center mrgn_top_15px mrgn_btn_15px">
<li class="flex">'.__('Mon').html_print_checkbox('monday', 1, $monday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Tue').html_print_checkbox('tuesday', 1, $tuesday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Wed').html_print_checkbox('wednesday', 1, $wednesday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Thu').html_print_checkbox('thursday', 1, $thursday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Fri').html_print_checkbox('friday', 1, $friday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Sat').html_print_checkbox('saturday', 1, $saturday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
<li class="flex">'.__('Sun').html_print_checkbox('sunday', 1, $sunday, true, $disabled_in_execution, '', false, ['label_style' => 'margin: 0 5px;' ]).'</li>
</ul>',
],
true
).html_print_div(
[
'id' => 'monthly_item',
'style' => 'margin-top: 12px;',
'class' => 'filter-table-adv-manual flex-row-start w50p',
'content' => html_print_label_input_block(
__('From day'),
html_print_select(
$days,
'periodically_day_from',
$periodically_day_from,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
),
[ 'div_style' => 'flex: 50; margin-right: 5px;' ]
).html_print_label_input_block(
__('To day'),
html_print_select(
$days,
'periodically_day_to',
$periodically_day_to,
'',
'',
0,
true,
false,
true,
'',
$disabled_in_execution
).ui_print_input_placeholder(
__('The end day must be higher than the start day'),
true
),
[ 'div_style' => 'flex: 50; margin-left: 5px;' ]
),
],
true
).html_print_div(
[
'class' => 'filter-table-adv-manual flex-row-start w50p',
'content' => html_print_label_input_block(
__('From hour'),
html_print_input_text(
'periodically_time_from',
$periodically_time_from,
'',
7,
7,
true,
$disabled_in_execution
).ui_print_input_placeholder(
__('The start time must be lower than the end time'),
true
),
[ 'div_style' => 'flex: 50; margin-right: 5px;' ]
).html_print_label_input_block(
__('To hour'),
html_print_input_text(
'periodically_time_to',
$periodically_time_to,
'',
7,
7,
true,
$disabled_in_execution
).ui_print_input_placeholder(
__('The end time must be higher than the start time'),
true
),
[ 'div_style' => 'flex: 50; margin-left: 5px;' ]
),
],
true
).ui_get_using_system_timezone_warning(),
],
true
);
$timeInputs[] = html_print_div(
[
'id' => 'cron_time',
'style' => 'display: none',
'content' => html_print_label_input_block(
__('Cron from'),
html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, false, false, true, 'from')
).html_print_label_input_block(
__('Cron to'),
html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, false, true, true, 'to')
),
],
true
);
$table->colspan[3][0] = 2;
$table->data[3][0] = html_print_label_input_block(
__('Configure the time'),
implode('', $timeInputs)
);
$table->data[4][] = html_print_div(
[
'class' => 'section_table_title',
'content' => __('Filtering'),
],
true
);
$table->data[5][] = html_print_label_input_block(
__('Group filter'),
html_print_select_groups(
false, false,
$access, $access,
$return_all_group, $return_all_group,
@ -1097,16 +1190,47 @@ $table->data[0][1] = html_print_select_groups(
'', '',
false, false,
'min-width:180px;margin-right:15px;' 'min-width:180px;margin-right:15px;'
)
); );
$table->data[0][2] = __('Recursion').'&nbsp&nbsp'.html_print_checkbox('recursion', 1, $recursion, true, false, '');
$table->data[1][0] = __('Available agents'); $table->data[5][] = html_print_label_input_block(
$table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'min-width: 250px;width: 70%;'); __('Recursion'),
html_print_checkbox_switch(
'recursion',
1,
$recursion,
true,
false,
''
)
);
$table->colspan[6][0] = 2;
$availableModules = html_print_label_input_block(
__('Available agents'),
html_print_select(
$agents,
'id_agents[]',
-1,
'',
__('Any'),
-2,
true,
true,
true,
'',
false,
'min-width: 250px;width: 70%;'
),
[
'div_class' => 'flex-column',
'div_style' => 'flex: 33',
]
);
$table->rowid[2] = 'available_modules_selection_mode'; $availableModules .= html_print_label_input_block(
__('Selection mode'),
$table->data[2][1] = html_print_select( html_print_select(
[ [
'common' => __('Show common modules'), 'common' => __('Show common modules'),
'all' => __('Show all modules'), 'all' => __('Show all modules'),
@ -1122,16 +1246,16 @@ $table->data[2][1] = html_print_select(
'', '',
false, false,
'min-width:180px;' 'min-width:180px;'
),
[
'div_class' => 'available_modules_selection_mode flex-column',
'div_style' => 'flex: 33',
]
); );
$availableModules .= html_print_label_input_block(
$table->rowid[3] = 'available_modules'; __('Available modules'),
$table->data[3][0] = __('Available modules:').ui_print_help_tip( html_print_select(
__('Only for type Quiet for downtimes.'),
true
);
$table->data[3][1] = html_print_select(
[], [],
'module[]', 'module[]',
'', '',
@ -1144,35 +1268,61 @@ $table->data[3][1] = html_print_select(
'', '',
false, false,
'min-width: 250px;width: 70%;' 'min-width: 250px;width: 70%;'
).ui_print_input_placeholder(
__('Only for type Quiet for downtimes.'),
true
),
[
'div_class' => 'available_modules flex-column',
'div_style' => 'flex: 33',
]
);
$table->data[6][0] = html_print_div(
[
'style' => 'flex-direction: row;align-items: flex-start;',
'content' => $availableModules,
],
true
); );
// Print agent table. // Print agent table.
if ($id_downtime > 0) {
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
} else {
echo '<form method="POST" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor">';
}
html_print_table($table); html_print_table($table);
echo '<br /><br /><br />'; $buttons = '';
html_print_input_hidden('id_agent', $id_agent); html_print_input_hidden('id_agent', $id_agent);
echo '<div class="action-buttons w100p" >';
if ($id_downtime > 0) { if ($id_downtime > 0) {
html_print_input_hidden('update_downtime', 1); html_print_input_hidden('update_downtime', 1);
html_print_input_hidden('id_downtime', $id_downtime); html_print_input_hidden('id_downtime', $id_downtime);
html_print_submit_button( $buttons .= html_print_submit_button(
__('Update'), __('Update'),
'updbutton', 'updbutton',
false, false,
'class="sub upd"' ['icon' => 'update'],
true
); );
} else { } else {
html_print_input_hidden('create_downtime', 1); html_print_input_hidden('create_downtime', 1);
html_print_submit_button( $buttons .= html_print_submit_button(
__('Add'), __('Add'),
'crtbutton', 'crtbutton',
false, false,
'class="sub wand"' ['icon' => 'wand'],
true
); );
} }
echo '</div>'; html_print_action_buttons(
$buttons
);
html_print_input_hidden('all_common_modules', ''); html_print_input_hidden('all_common_modules', '');
echo '</form>'; echo '</form>';
@ -1208,11 +1358,17 @@ if (empty($downtimes_agents)) {
$table->head[2] = __('OS'); $table->head[2] = __('OS');
$table->head[3] = __('Last contact'); $table->head[3] = __('Last contact');
$table->head['count_modules'] = __('Modules'); $table->head['count_modules'] = __('Modules');
$table->align = [];
$table->align[0] = 'center';
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[4] = 'center';
if (!$running) { if (!$running) {
$table->head[5] = __('Actions'); $table->head[5] = __('Actions');
$table->align[5] = 'center'; $table->align[5] = 'right';
$table->size[5] = '5%'; $table->size[5] = '10%';
} }
foreach ($downtimes_agents as $downtime_agent) { foreach ($downtimes_agents as $downtime_agent) {
@ -1232,7 +1388,13 @@ if (empty($downtimes_agents)) {
WHERE id_grupo = '.$downtime_agent['id_grupo'] WHERE id_grupo = '.$downtime_agent['id_grupo']
); );
$data[2] = ui_print_os_icon($downtime_agent['id_os'], true, true); $data[2] = html_print_div(
[
'class' => 'main_menu_icon invert_filter',
'content' => ui_print_os_icon($downtime_agent['id_os'], false, true),
],
true
);
$data[3] = $downtime_agent['ultimo_contacto']; $data[3] = $downtime_agent['ultimo_contacto'];
@ -1251,10 +1413,10 @@ if (empty($downtimes_agents)) {
if (!$running) { if (!$running) {
$data[5] = ''; $data[5] = '';
if ($type_downtime !== 'disable_agents') { if ($type_downtime !== 'disable_agents') {
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>'; $data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/edit.svg', true, ['alt' => __('Edit'), 'class' => 'main_menu_icon invert_filter']).'</a>';
} }
$data[5] .= '<a href="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>'; $data[5] .= '<a href="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/delete.svg', true, ['alt' => __('Delete'), 'class' => 'main_menu_icon invert_filter']).'</a>';
} }
$table->data['agent_'.$downtime_agent['id_agente']] = $data; $table->data['agent_'.$downtime_agent['id_agente']] = $data;
@ -1263,17 +1425,7 @@ if (empty($downtimes_agents)) {
html_print_table($table); html_print_table($table);
} }
$table = new stdClass(); ui_print_spinner('Loading');
$table->id = 'loading';
$table->width = '100%';
$table->colspan['loading'][0] = '6';
$table->style[0] = 'text-align: center;';
$table->data = [];
$table->data['loading'] = [];
$table->data['loading'][0] = html_print_image('images/spinner.gif', true);
echo "<div class='invisible'>";
html_print_table($table);
echo '</div>';
$table = new stdClass(); $table = new stdClass();
$table->id = 'editor'; $table->id = 'editor';
@ -1577,13 +1729,13 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
switch ($("#type_downtime").val()) { switch ($("#type_downtime").val()) {
case 'disable_agents_alerts': case 'disable_agents_alerts':
case 'disable_agents': case 'disable_agents':
$("#available_modules").hide(); $(".available_modules").hide();
$("#available_modules_selection_mode").hide(); $(".available_modules_selection_mode").hide();
break; break;
case 'quiet': case 'quiet':
case 'disable_agent_modules': case 'disable_agent_modules':
$("#available_modules_selection_mode").show(); $(".available_modules_selection_mode").show();
$("#available_modules").show(); $(".available_modules").show();
break; break;
} }
} }

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -89,7 +89,7 @@ if (is_ajax() === true) {
[ [
'id' => 'agent_modules_affected_planned_downtime', 'id' => 'agent_modules_affected_planned_downtime',
'class' => 'info_table', 'class' => 'info_table',
'style' => 'width: 100%', 'style' => 'width: 99%',
'columns' => $columns, 'columns' => $columns,
'column_names' => $column_names, 'column_names' => $column_names,
'ajax_url' => 'godmode/agentes/planned_downtime.list', 'ajax_url' => 'godmode/agentes/planned_downtime.list',
@ -103,6 +103,7 @@ if (is_ajax() === true) {
], ],
'search_button_class' => 'sub filter float-right', 'search_button_class' => 'sub filter float-right',
'form' => [ 'form' => [
'class' => 'filter-table-adv',
'inputs' => [ 'inputs' => [
[ [
'label' => __('Agents'), 'label' => __('Agents'),
@ -207,13 +208,23 @@ if ($migrate_malformed === true) {
} }
// Header. // Header.
ui_print_page_header( ui_print_standard_header(
__('Scheduled Downtime'), __('Scheduled Downtime'),
'images/gm_monitoring.png', 'images/gm_monitoring.png',
false, false,
'', '',
true, true,
'' [],
[
[
'link' => '',
'label' => __('Tools'),
],
[
'link' => '',
'label' => __('Scheduled Downtime'),
],
],
); );
$id_downtime = (int) get_parameter('id_downtime', 0); $id_downtime = (int) get_parameter('id_downtime', 0);
@ -308,34 +319,8 @@ $filter_params['module_name'] = $module_name;
$filter_params_str = http_build_query($filter_params); $filter_params_str = http_build_query($filter_params);
// Table filter. // From/To inputs.
$table_form = new StdClass(); $date_inputs = html_print_input_text(
$table_form->class = 'databox filters';
$table_form->width = '100%';
$table_form->rowstyle = [];
$table_form->cellstyle[0] = ['width: 100px;'];
$table_form->cellstyle[1] = ['width: 100px;'];
$table_form->cellstyle[1][2] = 'display: flex; align-items: center;';
$table_form->cellstyle[2] = ['width: 100px;'];
$table_form->cellstyle[3] = ['text-align: right;'];
$table_form->colspan[3][0] = 3;
$table_form->data = [];
$row = [];
// Search text.
$row[] = __('Search');
$row[] = html_print_input_text(
'search_text',
$search_text,
'',
50,
250,
true
);
// Dates.
$date_inputs = __('From').'&nbsp;'.html_print_input_text(
'date_from', 'date_from',
$date_from, $date_from,
'', '',
@ -343,8 +328,8 @@ $date_inputs = __('From').'&nbsp;'.html_print_input_text(
10, 10,
true true
); );
$date_inputs .= '&nbsp;&nbsp;'; $date_inputs .= '&nbsp;'.__('To').'&nbsp;';
$date_inputs .= __('To').'&nbsp;'.html_print_input_text( $date_inputs .= html_print_input_text(
'date_to', 'date_to',
$date_to, $date_to,
'', '',
@ -352,11 +337,6 @@ $date_inputs .= __('To').'&nbsp;'.html_print_input_text(
10, 10,
true true
); );
$row[] = $date_inputs;
$table_form->data[] = $row;
$row = [];
// Execution type. // Execution type.
$execution_type_fields = [ $execution_type_fields = [
@ -364,29 +344,6 @@ $execution_type_fields = [
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
'cron' => __('Cron'), 'cron' => __('Cron'),
]; ];
$row[] = __('Execution type');
$row[] = html_print_select(
$execution_type_fields,
'execution_type',
$execution_type,
'',
__('Any'),
'',
true,
false,
false
);
// Show past downtimes.
$row[] = __('Show past downtimes').'&nbsp;&nbsp;&nbsp;&nbsp;'.html_print_switch(
[
'name' => 'archived',
'value' => $show_archived,
]
);
$table_form->data[] = $row;
$row = [];
// Agent. // Agent.
$params = []; $params = [];
@ -397,36 +354,89 @@ $params['return'] = true;
$params['print_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'agent_id'; $params['hidden_input_idagent_name'] = 'agent_id';
$params['hidden_input_idagent_value'] = $agent_id; $params['hidden_input_idagent_value'] = $agent_id;
$row[] = __('Agent');
$row[] = ui_print_agent_autocomplete_input($params);
// Module. // Table filter.
$row[] = __('Module').'&nbsp;'.html_print_autocomplete_modules( $table_form = new stdClass();
$table_form->class = 'filter-table-adv';
$table_form->id = 'filter_scheduled_downtime';
$table_form->width = '100%';
$table_form->rowstyle = [];
$table_form->cellstyle[0] = ['width: 100px;'];
$table_form->cellstyle[1] = ['width: 100px;'];
$table_form->cellstyle[1][2] = 'display: flex; align-items: center;';
$table_form->cellstyle[2] = ['width: 100px;'];
$table_form->cellstyle[3] = ['text-align: right;'];
$table_form->data = [];
// Search text.
$table_form->data[0][] = html_print_label_input_block(
__('Search'),
html_print_input_text(
'search_text',
$search_text,
'',
50,
250,
true
)
);
// From / To.
$table_form->data[0][] = html_print_label_input_block(
__('Between dates'),
html_print_div(
[
'class' => 'flex-content-left',
'content' => $date_inputs,
],
true
)
);
// Show past downtimes.
$table_form->data[0][] = html_print_label_input_block(
__('Show past downtimes'),
html_print_switch(
[
'name' => 'archived',
'value' => $show_archived,
]
)
);
// Execution type.
$table_form->data[1][] = html_print_label_input_block(
__('Execution type'),
html_print_select(
$execution_type_fields,
'execution_type',
$execution_type,
'',
__('Any'),
'',
true,
false,
false
)
);
$table_form->data[1][] = html_print_label_input_block(
__('Agent'),
ui_print_agent_autocomplete_input($params)
);
$table_form->data[1][] = html_print_label_input_block(
__('Module'),
html_print_autocomplete_modules(
'module_name', 'module_name',
$module_name, $module_name,
false, false,
true, true,
'', '',
[], [],
true,
0,
30,
true true
)
); );
$table_form->data[] = $row;
$row = [];
$row[] = html_print_submit_button(
__('Search'),
'search',
false,
[
'icon' => 'search',
'mode' => 'mini',
],
true
);
$table_form->data[] = $row;
// End of table filter. // End of table filter.
// Useful to know if the user has done a form filtering. // Useful to know if the user has done a form filtering.
$filter_performed = false; $filter_performed = false;
@ -629,40 +639,85 @@ if ($downtimes === false && $filter_performed === false) {
// No downtimes cause the user performed a search. // No downtimes cause the user performed a search.
// Filter form. // Filter form.
echo '<form method="post" action="'.$url_list.'">'; echo '<form method="post" action="'.$url_list.'">';
html_print_table($table_form); $outputTable = html_print_table($table_form, true);
$outputTable .= html_print_div(
[
'class' => 'action-buttons-right-forced',
'content' => html_print_submit_button(
__('Filter'),
'search',
false,
[
'icon' => 'search',
'mode' => 'mini',
],
true
),
],
true
);
ui_toggle(
$outputTable,
'<span class="subsection_header_title">'.__('Filters').'</span>',
__('Filters'),
'',
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
echo '</form>'; echo '</form>';
// Info message. // Info message.
echo '<div class="nf">'.__('No scheduled downtime').'</div>'; ui_print_info_message(__('No scheduled downtime'));
// Create button. // Create button.
if ($write_permisson === true) { if ($write_permisson === true) {
echo '<form method="post" class="display_in" action="'.$url_editor.'">'; echo '<form method="post" class="display_in" action="'.$url_editor.'">';
html_print_div( html_print_action_buttons(
[ html_print_submit_button(
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Create'), __('Create'),
'create', 'create',
false, false,
['icon' => 'next'], ['icon' => 'next'],
true true
), )
]
); );
echo '</form>'; echo '</form>';
} }
} else { } else {
// Has downtimes. // Has downtimes.
echo '<form method="post" action="'.$url_list.'">'; echo '<form method="post" action="'.$url_list.'">';
html_print_table($table_form); $outputTable = html_print_table($table_form, true);
echo '</form>'; $outputTable .= html_print_div(
[
ui_pagination( 'class' => 'action-buttons-right-forced',
$downtimes_number, 'content' => html_print_submit_button(
$url_list.'&'.$filter_params_str, __('Search'),
$offset 'search',
false,
[
'icon' => 'search',
'mode' => 'mini',
],
true
),
],
true
); );
ui_toggle(
$outputTable,
'<span class="subsection_header_title">'.__('Filters').'</span>',
__('Filters'),
'',
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
echo '</form>';
// User groups with AR, AD or AW permission. // User groups with AR, AD or AW permission.
$groupsAD = users_get_groups($config['id_user'], $access); $groupsAD = users_get_groups($config['id_user'], $access);
@ -762,17 +817,17 @@ if ($downtimes === false && $filter_performed === false) {
$settings = [ $settings = [
'url' => ui_get_full_url('ajax.php', false, false, false), 'url' => ui_get_full_url('ajax.php', false, false, false),
'loadingText' => __('Loading, this operation might take several minutes...'), 'loadingText' => __('Loading, this operation might take several minutes...'),
'title' => __('Agents / Modules affected'), 'title' => __('Elements affected'),
'id' => $downtime['id'], 'id' => $downtime['id'],
]; ];
$data['agents_modules'] = '<a href="#" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>'; $data['agents_modules'] = '<a href="#" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>';
$data['agents_modules'] .= html_print_image( $data['agents_modules'] .= html_print_image(
'images/search_big.png', 'images/details.svg',
true, true,
[ [
'title' => __('Agents and modules affected'), 'title' => __('Agents and modules affected'),
'style' => 'width:22px; height: 22px;', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['agents_modules'] .= '</a>'; $data['agents_modules'] .= '</a>';
@ -789,15 +844,21 @@ if ($downtimes === false && $filter_performed === false) {
$url_list_params = $url_list.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str; $url_list_params = $url_list.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['stop'] = '<a href="'.$url_list_params.'">'; $data['stop'] = '<a href="'.$url_list_params.'">';
$data['stop'] .= html_print_image( $data['stop'] .= html_print_image(
'images/cancel.png', 'images/fail@svg.svg',
true, true,
['title' => __('Stop downtime')] [
'title' => __('Stop downtime'),
'class' => 'main_menu_icon invert_filter',
]
); );
} else { } else {
$data['stop'] = html_print_image( $data['stop'] = html_print_image(
'images/cancel.png', 'images/fail@svg.svg',
true, true,
['title' => __('Stop downtime')] [
'title' => __('Stop downtime'),
'class' => 'main_menu_icon invert_filter',
]
); );
} }
} else { } else {
@ -812,11 +873,11 @@ if ($downtimes === false && $filter_performed === false) {
// Copy. // Copy.
$data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image( $data['copy'] .= html_print_image(
'images/copy.png', 'images/copy.svg',
true, true,
[ [
'title' => __('Copy'), 'title' => __('Copy'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['copy'] .= '</a>'; $data['copy'] .= '</a>';
@ -824,11 +885,11 @@ if ($downtimes === false && $filter_performed === false) {
// Edit. // Edit.
$data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image( $data['edit'] .= html_print_image(
'images/config.png', 'images/configuration@svg.svg',
true, true,
[ [
'title' => __('Update'), 'title' => __('Update'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['edit'] .= '</a>'; $data['edit'] .= '</a>';
@ -837,11 +898,11 @@ if ($downtimes === false && $filter_performed === false) {
$url_delete = $url_list.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str; $url_delete = $url_list.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['delete'] = '<a id="delete_downtime" href="'.$url_delete.'">'; $data['delete'] = '<a id="delete_downtime" href="'.$url_delete.'">';
$data['delete'] .= html_print_image( $data['delete'] .= html_print_image(
'images/cross.png', 'images/delete.svg',
true, true,
[ [
'title' => __('Delete'), 'title' => __('Delete'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['delete'] .= '</a>'; $data['delete'] .= '</a>';
@ -858,22 +919,22 @@ if ($downtimes === false && $filter_performed === false) {
// Copy. // Copy.
$data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image( $data['copy'] .= html_print_image(
'images/copy.png', 'images/copy.svg',
true, true,
[ [
'title' => __('Copy'), 'title' => __('Copy'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['copy'] .= '</a>'; $data['copy'] .= '</a>';
// Edit. // Edit.
$data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image( $data['edit'] .= html_print_image(
'images/config.png', 'images/configuration@svg.svg',
true, true,
[ [
'title' => __('Update'), 'title' => __('Update'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
); );
$data['edit'] .= '</a>'; $data['edit'] .= '</a>';
@ -910,44 +971,47 @@ if ($downtimes === false && $filter_performed === false) {
} }
html_print_table($table); html_print_table($table);
ui_pagination( $tablePagination = ui_pagination(
$downtimes_number, $downtimes_number,
$url_list.'&'.$filter_params_str, $url_list.'&'.$filter_params_str,
$offset, $offset,
0, 0,
false,
'offset',
true, true,
'pagination-bottom' 'offset',
false
); );
echo '<div class="action-buttons" style="width: '.$table->width.'">'; $actionsButtons = '';
// CSV export button.
echo '<div class="display_in">';
html_print_button(
__('Export to CSV'),
'csv_export',
false,
'blockResubmit($(this)); location.href=\'godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'\'',
'class="sub next"'
);
echo '</div>';
// Create button. // Create button.
if ($write_permisson === true) { if ($write_permisson === true) {
echo '&nbsp;'; $actionsButtons .= '<form method="post" action="'.$url_editor.'" class="display_in" >';
echo '<form method="post" action="'.$url_editor.'" class="display_in" >'; $actionsButtons .= html_print_submit_button(
html_print_submit_button(
__('Create'), __('Create'),
'create', 'create',
false, false,
'class="sub next"' ['icon' => 'next'],
true
); );
echo '</form>'; $actionsButtons .= '</form>';
} }
echo '</div>'; // CSV export button.
$actionsButtons .= html_print_button(
__('Export to CSV'),
'csv_export',
false,
'blockResubmit($(this)); location.href="godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'"',
[
'icon' => 'load',
'mode' => 'secondary',
],
true
);
html_print_action_buttons(
$actionsButtons,
[ 'right_content' => $tablePagination ]
);
} }
ui_require_jquery_file( ui_require_jquery_file(

View File

@ -2330,7 +2330,10 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
$adv_mode_name = '_'.$adv_mode_name; $adv_mode_name = '_'.$adv_mode_name;
} }
$table->data[0][0] = html_print_extended_select_for_downtime_cron( $table->data[1][0] = html_print_div(
[
'class' => '',
'content' => html_print_extended_select_for_downtime_cron(
'cron_hour'.$adv_mode_name, 'cron_hour'.$adv_mode_name,
$hours, $hours,
$hour, $hour,
@ -2344,9 +2347,15 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
false, false,
0, 0,
'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)' 'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)'
),
],
true
); );
$table->data[1][1] = html_print_extended_select_for_downtime_cron( $table->data[1][1] = html_print_div(
[
'class' => '',
'content' => html_print_extended_select_for_downtime_cron(
'cron_minute'.$adv_mode_name, 'cron_minute'.$adv_mode_name,
$minutes, $minutes,
$minute, $minute,
@ -2360,9 +2369,15 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
false, false,
0, 0,
'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)' 'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)'
),
],
true
); );
$table->data[1][2] = html_print_extended_select_for_downtime_cron( $table->data[1][2] = html_print_div(
[
'class' => '',
'content' => html_print_extended_select_for_downtime_cron(
'cron_mday'.$adv_mode_name, 'cron_mday'.$adv_mode_name,
$mdays, $mdays,
$mday, $mday,
@ -2376,9 +2391,15 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
false, false,
0, 0,
'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)' 'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)'
),
],
true
); );
$table->data[1][3] = html_print_extended_select_for_downtime_cron( $table->data[1][3] = html_print_div(
[
'class' => '',
'content' => html_print_extended_select_for_downtime_cron(
'cron_month'.$adv_mode_name, 'cron_month'.$adv_mode_name,
$months, $months,
$month, $month,
@ -2392,9 +2413,15 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
false, false,
0, 0,
'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)' 'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)'
),
],
true
); );
$table->data[1][4] = html_print_extended_select_for_downtime_cron( $table->data[1][4] = html_print_div(
[
'class' => '',
'content' => html_print_extended_select_for_downtime_cron(
'cron_wday'.$adv_mode_name, 'cron_wday'.$adv_mode_name,
$wdays, $wdays,
$wday, $wday,
@ -2408,6 +2435,9 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
false, false,
0, 0,
'Valid values: [0-6], [0-6]-[0-6], *, or step value (example: */2, 3/1)' 'Valid values: [0-6], [0-6]-[0-6], *, or step value (example: */2, 3/1)'
),
],
true
); );
} }
@ -4186,7 +4216,7 @@ function html_print_switch_radio_button(array $switches, array $attributes=[], b
* @param string $checked Set the button to be marked (optional, unmarked by default). * @param string $checked Set the button to be marked (optional, unmarked by default).
* @param boolean $disabled Disable the button (optional, button enabled by default). * @param boolean $disabled Disable the button (optional, button enabled by default).
* @param string $script Script to execute when onClick event is triggered (optional). * @param string $script Script to execute when onClick event is triggered (optional).
* @param string $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). * @param mixed $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional).
* @param boolean $return Whether to return an output string or echo now (optional, echo by default). * @param boolean $return Whether to return an output string or echo now (optional, echo by default).
* @param string $id Custom id. * @param string $id Custom id.
* @param string $customAttributes Custom Attribute for customized checkbox. * @param string $customAttributes Custom Attribute for customized checkbox.
@ -4217,6 +4247,7 @@ function html_print_checkbox_extended(
$inputClass = 'custom_checkbox_input'; $inputClass = 'custom_checkbox_input';
$labelClass = 'custom_checkbox'; $labelClass = 'custom_checkbox';
$labelStyle = ' ';
if (is_array($attributes) === true) { if (is_array($attributes) === true) {
$tmpAttributes = []; $tmpAttributes = [];
@ -4230,6 +4261,10 @@ function html_print_checkbox_extended(
$labelClass .= ' '.$value; $labelClass .= ' '.$value;
break; break;
case 'label_style':
$labelStyle .= 'style="'.$value.'"';
break;
default: default:
$tmpAttributes[] = $key.'="'.$value.'"'; $tmpAttributes[] = $key.'="'.$value.'"';
break; break;
@ -4241,7 +4276,7 @@ function html_print_checkbox_extended(
$id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
$output = '<label class="'.$labelClass.'">'; $output = '<label class="'.$labelClass.'"'.$labelStyle.'>';
$output .= '<input class="'.$inputClass.'" name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : ''); $output .= '<input class="'.$inputClass.'" name="'.$name.'" type="checkbox" value="'.$value.'" '.($checked ? 'checked="checked"' : '');
$output .= (empty($id) === true) ? ' id="checkbox-'.$id_aux.'"' : ' id="'.$id.'"'; $output .= (empty($id) === true) ? ' id="checkbox-'.$id_aux.'"' : ' id="'.$id.'"';
$output .= (empty($script) === false) ? ' onclick="'.$script.'"' : ''; $output .= (empty($script) === false) ? ' onclick="'.$script.'"' : '';
@ -6629,34 +6664,32 @@ function html_print_extended_select_for_downtime_cron(
$disabled, $disabled,
'font-size: xx-small;'.$select_style 'font-size: xx-small;'.$select_style
); );
echo ' <a href="javascript:">'.html_print_image( echo ' <a style="margin: 7px" href="javascript:">'.html_print_image(
'images/edit.svg', 'images/edit.svg',
true, true,
[ [
'class' => $uniq_name.'_toggler main_menu_icon invert_filter', 'class' => $uniq_name.'_toggler main_menu_icon invert_filter',
'alt' => __('Custom'), 'alt' => __('Custom'),
'title' => __('Custom'), 'title' => __('Custom'),
'style' => 'width: 18px;', // 'style' => 'margin: 7px;',
] ]
).'</a>'; ).'</a>';
echo '</div>'; echo '</div>';
$help_tooltip = ($text_help !== '') ? ui_print_help_tip(__($text_help), true) : '';
echo '<div id="'.$uniq_name.'_manual" class="w100p inline_line">'; echo '<div id="'.$uniq_name.'_manual" class="w100p inline_line">';
html_print_input_text($uniq_name.'_text', $selected, '', 20); html_print_input_text($uniq_name.'_text', $selected, '', 20, 20, false, false, false, '', 'w100p');
html_print_input_hidden($name, $selected, false, $uniq_name); html_print_input_hidden($name, $selected, false, $uniq_name);
echo ' <a href="javascript:">'.$help_tooltip.'&nbsp'.html_print_image( echo ' <a href="javascript:">'.html_print_image(
'images/logs@svg.svg', 'images/logs@svg.svg',
true, true,
[ [
'class' => $uniq_name.'_toggler main_menu_icon invert_filter', 'class' => $uniq_name.'_toggler main_menu_icon invert_filter',
'alt' => __('List'), 'alt' => __('List'),
'title' => __('List'), 'title' => __('List'),
'style' => 'width: 18px;', 'style' => 'margin: 7px;',
] ]
).'</a>'; ).'</a>';
echo ($text_help !== '') ? ui_print_help_tip(__($text_help), true, '', false, 'margin: 13px 0 0 5px;') : '';
echo '</div>'; echo '</div>';
$select_init_func = (is_numeric($selected) === true || $selected === '*') ? 'post_process_select_init' : 'post_process_select_init_inv'; $select_init_func = (is_numeric($selected) === true || $selected === '*') ? 'post_process_select_init' : 'post_process_select_init_inv';

View File

@ -612,8 +612,8 @@ function snmp_browser_print_oid(
$table->head[1] = __('OID Information'); $table->head[1] = __('OID Information');
$output .= html_print_table($table, true); $output .= html_print_table($table, true);
$url = 'index.php?'.'sec=gmodules&'.'sec2=godmode/modules/manage_network_components'; $url = 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components';
$output .= '<form id="snmp_create_module" class="center mrgn_10px" target="_blank" method="post" action="'.$url.'">'; $output .= '<form id="snmp_create_module" class="center mrgn_10px flex" target="_blank" method="post" action="'.$url.'">';
$output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true); $output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true);
$output .= html_print_input_hidden('id_component_type', 2, true); $output .= html_print_input_hidden('id_component_type', 2, true);
$output .= html_print_input_hidden('type', 17, true); $output .= html_print_input_hidden('type', 17, true);
@ -638,10 +638,11 @@ function snmp_browser_print_oid(
__('Create network component'), __('Create network component'),
'create_network_component', 'create_network_component',
false, false,
'class="sub add float-left mrgn_right_20px"', 'class="buttonButton mrgn_right_20px"',
true true
); );
if (isset($_POST['print_create_agent_module'])) {
// Hidden by default. // Hidden by default.
$output .= html_print_button( $output .= html_print_button(
__('Create agent module'), __('Create agent module'),
@ -651,6 +652,7 @@ function snmp_browser_print_oid(
'class="sub add invisible"', 'class="sub add invisible"',
true true
); );
}
// Select agent modal. // Select agent modal.
$output .= snmp_browser_print_create_modules(true); $output .= snmp_browser_print_create_modules(true);
@ -685,7 +687,8 @@ function snmp_browser_print_container(
$width='100%', $width='100%',
$height='60%', $height='60%',
$display='', $display='',
$show_massive_buttons=false $show_massive_buttons=false,
$toggle=false
) { ) {
global $config; global $config;
@ -948,8 +951,22 @@ function snmp_browser_print_container(
); );
$table->data[2] .= '</div>'; $table->data[2] .= '</div>';
if ($toggle == true) {
$print_create_agent_module = 1;
} else {
$print_create_agent_module = 0;
}
$searchForm = '<form onsubmit="snmpBrowse(); return false;">'; $searchForm = '<form onsubmit="snmpBrowse(); return false;">';
$searchForm .= html_print_table($table, true); $searchForm .= html_print_table($table, true);
$searchForm .= html_print_input_hidden(
'print_create_agent_module',
$print_create_agent_module,
true,
false,
false,
'print_create_agent_module'
);
$searchForm .= html_print_div( $searchForm .= html_print_div(
[ [
'class' => 'action-buttons', 'class' => 'action-buttons',
@ -969,6 +986,7 @@ function snmp_browser_print_container(
$searchForm .= '</form>'; $searchForm .= '</form>';
if ($toggle == true) {
ui_toggle( ui_toggle(
$searchForm, $searchForm,
'<span class="subsection_header_title">'.__('Filters').'</span>', '<span class="subsection_header_title">'.__('Filters').'</span>',
@ -980,6 +998,7 @@ function snmp_browser_print_container(
'white-box-content', 'white-box-content',
'box-flat white_table_graph fixed_filter_bar' 'box-flat white_table_graph fixed_filter_bar'
); );
}
// Search tools. // Search tools.
$table2 = new stdClass(); $table2 = new stdClass();
@ -1101,6 +1120,62 @@ function snmp_browser_print_container(
); );
$output .= '</div>'; $output .= '</div>';
if ($toggle === false) {
// This extra div that can be handled by jquery's dialog.
$output .= '<div id="snmp_browser_container" style="display:none">';
$output .= '<div style="text-align: left; width: '.$width.'; height: '.$height.';">';
$output .= '<div class="w100p">';
$output .= '<form onsubmit="snmpBrowse(); return false;">';
$output .= html_print_table($table, true);
$output .= html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Execute'),
'srcbutton',
false,
[
'mode' => 'mini',
'icon' => 'cog',
],
true
),
],
true
);
$output .= '</form></div>';
if (isset($snmp_version) === false) {
$snmp_version = null;
}
if ($snmp_version == 3) {
$output .= '<div id="snmp3_browser_options">';
} else {
$output .= '<div id="snmp3_browser_options" style="display: none;">';
}
$output .= ui_toggle(
html_print_table($table3, true),
__('SNMP v3 options'),
'',
'',
true,
true
);
$output .= '</div>';
$output .= '<div class="search_options">';
$output .= ui_toggle(
html_print_table($table2, true),
__('Search options'),
'',
'',
true,
true
);
$output .= '</div>';
}
// SNMP tree container. // SNMP tree container.
$output .= '<div class="snmp_tree_container" id="snmp_tree_container" style="display:none">'; $output .= '<div class="snmp_tree_container" id="snmp_tree_container" style="display:none">';
$output .= html_print_input_hidden('search_count', 0, true); $output .= html_print_input_hidden('search_count', 0, true);

View File

@ -2508,6 +2508,10 @@ function ui_print_help_tip(
$style='', $style='',
$blink=false $blink=false
) { ) {
if (empty($img) === true) {
$img = 'images/info@svg.svg';
}
$output = '<a href="javascript:" class="tip" style="'.$style.'" >'; $output = '<a href="javascript:" class="tip" style="'.$style.'" >';
$output .= html_print_image( $output .= html_print_image(
$img, $img,

View File

@ -257,6 +257,8 @@ function snmpGet(oid) {
var snmp3_privacy_pass = $("#password-snmp3_browser_privacy_pass").val(); var snmp3_privacy_pass = $("#password-snmp3_browser_privacy_pass").val();
var ajax_url = $("#hidden-ajax_url").val(); var ajax_url = $("#hidden-ajax_url").val();
var server_to_exec = $("#server_to_exec").val(); var server_to_exec = $("#server_to_exec").val();
var target_port = $("#target_port").val();
var print_create_agent_module = $("#print_create_agent_module").val();
// Check for a custom action // Check for a custom action
var custom_action = $("#hidden-custom_action").val(); var custom_action = $("#hidden-custom_action").val();
@ -280,6 +282,8 @@ function snmpGet(oid) {
params["action"] = "snmpget"; params["action"] = "snmpget";
params["custom_action"] = custom_action; params["custom_action"] = custom_action;
params["page"] = "include/ajax/snmp_browser.ajax"; params["page"] = "include/ajax/snmp_browser.ajax";
params["target_port"] = target_port;
params["print_create_agent_module"] = print_create_agent_module;
// SNMP get! // SNMP get!
jQuery.ajax({ jQuery.ajax({
@ -560,7 +564,7 @@ function snmpBrowserWindow() {
background: "black" background: "black"
}, },
width: 1000, width: 1000,
height: 500 height: 800
}); });
} }

View File

@ -11587,3 +11587,12 @@ ul.tag-editor {
.max-width-100p { .max-width-100p {
max-width: 100%; max-width: 100%;
} }
/* Datatables overrides */
.ui-dialog .ui-dialog-titlebar-close {
right: 1em !important;
}
.ui-dialog .ui-dialog-titlebar {
display: block !important;
}

View File

@ -530,6 +530,7 @@ table.filter-table-adv td {
vertical-align: top; vertical-align: top;
} }
div.filter-table-adv-manual > div,
table.filter-table-adv td > div { table.filter-table-adv td > div {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -537,6 +538,7 @@ table.filter-table-adv td > div {
align-items: normal; align-items: normal;
} }
div.filter-table-adv-manual > div label,
table.filter-table-adv td > div label { table.filter-table-adv td > div label {
color: #161628; color: #161628;
font-size: 13px; font-size: 13px;

View File

@ -93,7 +93,7 @@ ui_print_standard_header(
); );
// SNMP tree container. // SNMP tree container.
snmp_browser_print_container(false, '100%', '60%', '', true); snmp_browser_print_container(false, '100%', '60%', '', true, true);
// Div for modal. // Div for modal.
echo '<div id="modal" style="display:none"></div>'; echo '<div id="modal" style="display:none"></div>';
@ -655,7 +655,7 @@ function show_add_module() {
snmp3_auth_pass : $('#password-snmp3_browser_auth_pass').val(), snmp3_auth_pass : $('#password-snmp3_browser_auth_pass').val(),
snmp3_privacy_method : $('#snmp3_browser_privacy_method').val(), snmp3_privacy_method : $('#snmp3_browser_privacy_method').val(),
snmp3_privacy_pass : $('#password-snmp3_browser_privacy_pass').val(), snmp3_privacy_pass : $('#password-snmp3_browser_privacy_pass').val(),
tcp_port : $('#target_port').val(),
}; };
// Append values to form. // Append values to form.