Module manager upgrade

This commit is contained in:
jose.gonzalez@pandorafms.com 2022-12-05 13:39:51 +01:00
parent 445a8161cf
commit 912f1d0d7a
4 changed files with 122 additions and 63 deletions

View File

@ -244,7 +244,7 @@ $table_simple->rowclass['tcp_send_receive'] = 'field_half_width';
$table_simple->rowclass['caption_configuration_data'] = 'field_half_width pdd_t_10px';
$table_simple->rowclass['textarea_configuration_data'] = 'field_half_width';
$table_simple->rowclass['configuration_data'] = 'field_half_width';
$table_simple->cellstyle['configuration_data'][0] = 'justify-content: flex-end;';
$table_simple->cellstyle['configuration_data'][0] = 'justify-content: flex-end;padding-top: 10px;';
$table_simple->rowclass['caption_module_name'] = 'field_half_width pdd_t_10px';
$table_simple->rowclass['module_name'] = 'field_half_width';
@ -641,6 +641,22 @@ if ($cps_module > 0) {
$cps_array[$cps_inc] = __('Enabled');
}
// JS Scripts for ff thresholds.
ob_start();
?>
<script>
$(document).ready(function(){
ffStateChange('<?php echo (int) $each_ff; ?>');
});
function ffStateChange(state) {
var type = (parseInt(state) === 0) ? 'all' : 'each';
$('tr[id*="ff_thresholds"]').css('display', 'none');
$('tr[id*="ff_thresholds_'+type+'"]').css('display', 'flex');
}
</script>
<?php
$ffThresholdsScript = ob_get_clean();
// Advanced form part.
$table_advanced = new stdClass();
@ -977,6 +993,9 @@ if ((int) $moduletype === MODULE_DATA) {
}
$table_advanced->data['execution_interval'][0] .= html_print_input_hidden('moduletype', $moduletype, true);
// Cron table styles.
$table_advanced->cellstyle['cron_from_select'][0] = 'padding: 0; margin: 0 -4px; width: 100%;';
$table_advanced->cellstyle['cron_to_select'][0] = 'padding: 0; margin: 0 -4px; width: 100%;';
if (isset($id_agente) === true && (int) $moduletype === MODULE_DATA) {
$has_remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]);
@ -1018,19 +1037,25 @@ $table_advanced->data['dynamic_threshold_interval'][0] = html_print_extended_sel
'0',
10,
true,
'width:150px',
'width:100%',
false,
$classdisabledBecauseInPolicy,
$disabledBecauseInPolicy
);
$table_advanced->data['dynamic_threshold_interval'][1] .= '<a onclick=advanced_option_dynamic()>'.html_print_image(
'images/cog.png',
true,
$table_advanced->data['dynamic_threshold_interval'][1] = html_print_anchor(
[
'title' => __('Advanced options Dynamic Threshold'),
'class' => 'invert_filter',
]
).'</a>';
'onClick' => 'advanced_option_dynamic()',
'content' => html_print_image(
'images/cog.png',
true,
[
'title' => __('Advanced options Dynamic Threshold'),
'class' => 'invert_filter',
]
),
],
true
);
$table_advanced->rowclass['caption_adv_dynamic_threshold_interval'] = 'hide_dinamic pdd_t_10px';
$table_advanced->rowclass['adv_dynamic_threshold_interval'] = 'hide_dinamic';
@ -1072,19 +1097,22 @@ $table_advanced->data['adv_dynamic_threshold_interval'][2] = html_print_checkbox
);
// FF stands for Flip-flop.
$table_advanced->data['caption_ff_thresholds'][0] = __('FF threshold').' ';
$table_advanced->data['ff_thresholds'][0] .= html_print_switch_radio_button(
$table_advanced->data['caption_ff_main_thresholds'][0] = __('FF threshold').' ';
$table_advanced->data['ff_main_thresholds'][0] .= html_print_switch_radio_button(
[
html_print_radio_button_extended('each_ff', 0, __('All state changing'), $each_ff, false, '', '', true, false, '', 'ff_all_state'),
html_print_radio_button_extended('each_ff', 1, __('Each state changing'), $each_ff, false, '', '', true, false, '', 'ff_each_state'),
html_print_radio_button_extended('each_ff', 0, __('All state changing'), $each_ff, false, 'ffStateChange(0)', '', true, false, '', 'ff_all_state'),
html_print_radio_button_extended('each_ff', 1, __('Each state changing'), $each_ff, false, 'ffStateChange(1)', '', true, false, '', 'ff_each_state'),
],
[],
[ 'add_content' => $ffThresholdsScript ],
true
);
$table_advanced->rowclass['caption_all_ff_thresholds'] = 'all_ff_thresholds_visibility pdd_t_10px';
$table_advanced->rowclass['all_ff_thresholds'] = 'all_ff_thresholds_visibility';
$table_advanced->data['caption_all_ff_thresholds'][0] = __('Change all states');
$table_advanced->data['all_ff_thresholds'][0] = html_print_input_text(
$table_advanced->rowclass['caption_ff_thresholds_all'] = 'w50p ff_thresholds_line pdd_t_10px';
$table_advanced->rowclass['ff_thresholds_all'] = 'w50p ff_thresholds_line';
$table_advanced->cellclass['caption_ff_thresholds_all'][0] = 'w50p';
$table_advanced->cellclass['ff_thresholds_all'][0] = 'w50p';
$table_advanced->data['caption_ff_thresholds_all'][0] = __('Change all states');
$table_advanced->data['ff_thresholds_all'][0] = html_print_input_text(
'ff_event',
$ff_event,
'',
@ -1097,13 +1125,19 @@ $table_advanced->data['all_ff_thresholds'][0] = html_print_input_text(
$classdisabledBecauseInPolicy
);
$table_advanced->rowclass['caption_each_ff_thresholds'] = 'each_ff_thresholds_visibility pdd_t_10px';
$table_advanced->data['caption_each_ff_thresholds'][0] = __('To normal');
$table_advanced->data['caption_each_ff_thresholds'][1] = __('To warning');
$table_advanced->data['caption_each_ff_thresholds'][2] = __('To critical');
$table_advanced->rowclass['caption_ff_thresholds_each'] = 'w50p ff_thresholds_line pdd_t_10px';
$table_advanced->rowclass['ff_thresholds_each'] = 'w50p ff_thresholds_line';
$table_advanced->cellclass['caption_ff_thresholds_each'][0] = 'w33p';
$table_advanced->cellclass['caption_ff_thresholds_each'][1] = 'w33p';
$table_advanced->cellclass['caption_ff_thresholds_each'][2] = 'w33p';
$table_advanced->cellclass['ff_thresholds_each'][0] = 'w33p';
$table_advanced->cellclass['ff_thresholds_each'][1] = 'w33p';
$table_advanced->cellclass['ff_thresholds_each'][2] = 'w33p';
$table_advanced->data['caption_ff_thresholds_each'][0] = __('To normal');
$table_advanced->data['caption_ff_thresholds_each'][1] = __('To warning');
$table_advanced->data['caption_ff_thresholds_each'][2] = __('To critical');
$table_advanced->rowclass['each_ff_thresholds'] = 'each_ff_thresholds_visibility';
$table_advanced->data['each_ff_thresholds'][0] = html_print_input_text(
$table_advanced->data['ff_thresholds_each'][0] = html_print_input_text(
'ff_event_normal',
$ff_event_normal,
'',
@ -1116,7 +1150,7 @@ $table_advanced->data['each_ff_thresholds'][0] = html_print_input_text(
$classdisabledBecauseInPolicy
);
$table_advanced->data['each_ff_thresholds'][1] = html_print_input_text(
$table_advanced->data['ff_thresholds_each'][1] = html_print_input_text(
'ff_event_warning',
$ff_event_warning,
'',
@ -1129,7 +1163,7 @@ $table_advanced->data['each_ff_thresholds'][1] = html_print_input_text(
$classdisabledBecauseInPolicy
);
$table_advanced->data['each_ff_thresholds'][2] = html_print_input_text(
$table_advanced->data['ff_thresholds_each'][2] = html_print_input_text(
'ff_event_critical',
$ff_event_critical,
'',
@ -1491,7 +1525,6 @@ if ($id_agent_module) {
html_print_input_hidden('module_relations_count', $relations_count);
ui_require_jquery_file('json');
?>
<script type="text/javascript">

View File

@ -2239,32 +2239,32 @@ function html_print_extended_select_for_time(
*/
function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', $month='*', $wday='*', $return=false, $disabled=false, $to=false, $advanced=false, $adv_mode_name='')
{
// Hours
// Hours.
for ($i = 0; $i < 24; $i++) {
$hours[$i] = $i;
}
// Minutes
// Minutes.
for ($i = 0; $i < 60; $i++) {
$minutes[$i] = $i;
// If minute is not a multiple of 5, then add style to option in order to hide it from minute select but still is a valid value that input can adopt. We want this in case a value that is not a multiple of 5 is entered in module's data configuration.
if (($i % 5) != 0) {
if (($i % 5) !== 0) {
$minutes_hidden_options[$i] = 'display: none;';
}
}
// Month days
// Month days.
for ($i = 1; $i <= 31; $i++) {
$mdays[$i] = $i;
}
// Months
// Months.
for ($i = 1; $i <= 12; $i++) {
$months[$i] = date('F', mktime(0, 0, 0, $i, 1));
}
// Days of the week
// Days of the week.
$wdays = [
__('Sunday'),
__('Monday'),
@ -2275,30 +2275,36 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
__('Saturday'),
];
// Print selectors
// Print selectors.
$table = new stdClass();
$table->id = 'cron';
$table->width = '100%';
$table->class = 'databox data';
$table->head[0] = __('Hour');
$table->head[1] = __('Minute');
$table->head[2] = __('Month day');
$table->head[3] = __('Month');
$table->head[4] = __('Week day');
$table->class = 'table_section cron_section';
$table->style = [];
$table->style[0] = 'width: 20%;';
$table->style[1] = 'width: 20%;';
$table->style[2] = 'width: 20%;';
$table->style[3] = 'width: 20%;';
$table->style[4] = 'width: 20%;';
$table->data[0][0] = __('Hour');
$table->data[0][1] = __('Minute');
$table->data[0][2] = __('Month day');
$table->data[0][3] = __('Month');
$table->data[0][4] = __('Week day');
if ($advanced === false) {
if ($to) {
$table->data[0][0] = html_print_select($hours, 'hour_to', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][1] = html_print_select($minutes, 'minute_to', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[0][2] = html_print_select($mdays, 'mday_to', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][3] = html_print_select($months, 'month_to', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_to', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
if ($to === true) {
$table->data[1][0] = html_print_select($hours, 'hour_to', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][1] = html_print_select($minutes, 'minute_to', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[1][2] = html_print_select($mdays, 'mday_to', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][3] = html_print_select($months, 'month_to', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][4] = html_print_select($wdays, 'wday_to', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
} else {
$table->data[0][0] = html_print_select($hours, 'hour_from', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][1] = html_print_select($minutes, 'minute_from', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[0][2] = html_print_select($mdays, 'mday_from', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][3] = html_print_select($months, 'month_from', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[0][4] = html_print_select($wdays, 'wday_from', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][0] = html_print_select($hours, 'hour_from', $hour, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][1] = html_print_select($minutes, 'minute_from', $minute, '', __('Any'), '*', true, false, false, '', $disabled, false, $minutes_hidden_options);
$table->data[1][2] = html_print_select($mdays, 'mday_from', $mday, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][3] = html_print_select($months, 'month_from', $month, '', __('Any'), '*', true, false, false, '', $disabled);
$table->data[1][4] = html_print_select($wdays, 'wday_from', $wday, '', __('Any'), '*', true, false, false, '', $disabled);
}
} else {
if ($adv_mode_name !== '') {
@ -2321,7 +2327,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
'Valid values: [0-23], [0-23]-[0-23], *, or step value (example: */3, 10/5)'
);
$table->data[0][1] = html_print_extended_select_for_downtime_cron(
$table->data[1][1] = html_print_extended_select_for_downtime_cron(
'cron_minute'.$adv_mode_name,
$minutes,
$minute,
@ -2337,7 +2343,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
'Valid values: [0-59], [0-59]-[0-59], *, or step value (example: */5, 10/1)'
);
$table->data[0][2] = html_print_extended_select_for_downtime_cron(
$table->data[1][2] = html_print_extended_select_for_downtime_cron(
'cron_mday'.$adv_mode_name,
$mdays,
$mday,
@ -2353,7 +2359,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
'Valid values: [1-31], [1-31]-[1-31], *, or step value (example: */5, 7/2)'
);
$table->data[0][3] = html_print_extended_select_for_downtime_cron(
$table->data[1][3] = html_print_extended_select_for_downtime_cron(
'cron_month'.$adv_mode_name,
$months,
$month,
@ -2369,7 +2375,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*',
'Valid values: [1-12], [1-12]-[1-12], *, or step value (example: */3, 9/1)'
);
$table->data[0][4] = html_print_extended_select_for_downtime_cron(
$table->data[1][4] = html_print_extended_select_for_downtime_cron(
'cron_wday'.$adv_mode_name,
$wdays,
$wday,
@ -4007,22 +4013,22 @@ function html_print_radio_button_extended(
$output .= ' />';
if (is_array($label)) {
if (!empty($label)) {
$output .= '<label for="'.$htmlid.'" title="'.$label['help_tip'].'">'.$label['label'].'</label>'."\n";
if (empty($label) === false) {
$output .= '<label id="label-'.$htmlid.'" for="'.$htmlid.'" title="'.$label['help_tip'].'">'.$label['label'].'</label>'."\n";
}
} else {
if ($label != '') {
$output .= '<label for="'.$htmlid.'">'.$label.'</label>'."\n";
$output .= '<label id="label-'.$htmlid.'" for="'.$htmlid.'">'.$label.'</label>'."\n";
}
}
if ($modal && !enterprise_installed()) {
if ($modal === true && enterprise_installed() === false) {
$output .= "
<div id='".$message."' class='publienterprise publicenterprise_div' title='Community version'><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>
";
}
if ($return) {
if ($return === true) {
return $output;
}
@ -4064,11 +4070,18 @@ function html_print_radio_button($name, $value, $label='', $checkedvalue='', $re
*/
function html_print_switch_radio_button(array $switches, array $attributes=[], bool $return=false)
{
// By default, the content are only the switches added.
$content = implode('', $switches);
// If you want add more content, you can attach in attributes.
if (isset($attributes['add_content']) === true) {
$content .= $attributes['add_content'];
}
return html_print_div(
[
'id' => ($attributes['id'] ?? ''),
'class' => 'switch_radio_button '.($attributes['class'] ?? ''),
'content' => implode('', $switches),
'content' => $content,
],
$return
);

View File

@ -6005,7 +6005,7 @@ div#status_pie {
.white_table_graph_fixed table {
background-color: #fff;
padding: 20px;
padding: 0 20px 20px;
}
.white_table_graph_fixed table td {
@ -10535,7 +10535,7 @@ tr.bring_next_field {
width: 50%;
}
.field_quarter_width td {
.field_quarter_width {
width: 25%;
}

View File

@ -430,3 +430,16 @@ a.pandora_pagination.current:hover {
height: 10px;
background-color: aqua;
}
.cron_section {
padding: 0 !important;
}
.cron_section td {
font-size: 10pt !important;
color: #8a96a6;
}
.ff_thresholds_line input {
width: 100%;
}