mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Added custom field combo values in agent custom field
Former-commit-id: 55ca33d3de14c868e1eec3f32179b33dc3ff589b
This commit is contained in:
parent
88f1f16a5a
commit
d4f5482e99
@ -143,5 +143,9 @@ INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Pag
|
|||||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Users login',
|
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Users login',
|
||||||
'Starting Session \d+\ of user (.*)',
|
'Starting Session \d+\ of user (.*)',
|
||||||
'user', 0);
|
'user', 0);
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
-- Add column in table `tagent_custom_fields`
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(200) DEFAULT '';
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -2034,3 +2034,7 @@ INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`,
|
|||||||
-- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
-- Add column in table `tagent_custom_fields`
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(200) DEFAULT '';
|
||||||
|
@ -708,6 +708,13 @@ foreach ($fields as $field) {
|
|||||||
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
$combo = [];
|
||||||
|
$combo = $field['combo_values'];
|
||||||
|
$combo = explode(',', $combo);
|
||||||
|
$combo_values = [];
|
||||||
|
foreach ($combo as $value) {
|
||||||
|
$combo_values[$value] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$custom_value = db_get_value_filter(
|
$custom_value = db_get_value_filter(
|
||||||
'description',
|
'description',
|
||||||
@ -747,6 +754,28 @@ foreach ($fields as $field) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($field['combo_values'] !== '') {
|
||||||
|
$data[1] = html_print_select(
|
||||||
|
$combo_values,
|
||||||
|
'customvalue_'.$field['id_field'],
|
||||||
|
$custom_value,
|
||||||
|
'',
|
||||||
|
__('None'),
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,7 +786,7 @@ if (!empty($fields)) {
|
|||||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||||
|
|
||||||
|
|
||||||
// The context help about the learning mode
|
// The context help about the learning mode.
|
||||||
if ($modo == 0) {
|
if ($modo == 0) {
|
||||||
echo "<span id='modules_not_learning_mode_context_help' style=''>";
|
echo "<span id='modules_not_learning_mode_context_help' style=''>";
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,13 +25,16 @@ $id_field = (int) get_parameter('id_field', 0);
|
|||||||
$name = (string) get_parameter('name', '');
|
$name = (string) get_parameter('name', '');
|
||||||
$display_on_front = (bool) get_parameter('display_on_front', 0);
|
$display_on_front = (bool) get_parameter('display_on_front', 0);
|
||||||
$is_password_type = (bool) get_parameter('is_password_type', 0);
|
$is_password_type = (bool) get_parameter('is_password_type', 0);
|
||||||
|
$is_combo_enable = (bool) get_parameter('is_combo_enable', 0);
|
||||||
// Header
|
$combo_values = (string) get_parameter('combo_values', '');
|
||||||
|
// Header.
|
||||||
if ($id_field) {
|
if ($id_field) {
|
||||||
$field = db_get_row_filter('tagent_custom_fields', ['id_field' => $id_field]);
|
$field = db_get_row_filter('tagent_custom_fields', ['id_field' => $id_field]);
|
||||||
$name = $field['name'];
|
$name = $field['name'];
|
||||||
$display_on_front = $field['display_on_front'];
|
$display_on_front = $field['display_on_front'];
|
||||||
$is_password_type = $field['is_password_type'];
|
$is_password_type = $field['is_password_type'];
|
||||||
|
$combo_values = $field['combo_values'];
|
||||||
|
$is_combo_enable = $config['is_combo_enable'];
|
||||||
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
|
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||||
} else {
|
} else {
|
||||||
ui_print_page_header(__('Create agent custom field'), 'images/custom_field.png', false, '', true, '');
|
ui_print_page_header(__('Create agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||||
@ -40,17 +43,87 @@ if ($id_field) {
|
|||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'databox filters';
|
$table->class = 'databox filters';
|
||||||
|
$table->id = 'configure_field';
|
||||||
$table->style[0] = 'font-weight: bold';
|
$table->style[0] = 'font-weight: bold';
|
||||||
$table->style[2] = 'font-weight: bold';
|
$table->style[2] = 'font-weight: bold';
|
||||||
|
$table->style[4] = 'font-weight: bold';
|
||||||
|
$table->style[6] = 'font-weight: bold';
|
||||||
|
|
||||||
|
echo "<div id='message_set_password' title='".__('Agent Custom Fields Information')."' style='display:none;'>";
|
||||||
|
echo "<p style='text-align: center;font-weight: bold;'>".__('You cannot set the Password type until you clear the combo values and click on update button.').'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo "<div id='message_set_combo' title='".__('Agent Custom Fields Information')."' style='display:none;'>";
|
||||||
|
echo "<p style='text-align: center;font-weight: bold;'>".__('You cannot unset the enable combo until you clear the combo values and click on update.').'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo "<div id='message_no_set_password' title='".__('Agent Custom Fields Information')."' style='display:none;'>";
|
||||||
|
echo "<p style='text-align: center;font-weight: bold;'>".__('If you select Enabled combo the Password type will be disabled.').'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo "<div id='message_no_set_combo' title='".__('Agent Custom Fields Information')."' style='display:none;'>";
|
||||||
|
echo "<p style='text-align: center;font-weight: bold;'>".__('If you select Passord type the Enabled combo will be disabled.').'</p>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
|
||||||
$table->data = [];
|
$table->data = [];
|
||||||
|
|
||||||
$table->data[0][0] = __('Name');
|
$table->data[0][0] = __('Name');
|
||||||
$table->data[0][1] = html_print_input_text('name', $name, '', 35, 100, true);
|
$table->data[0][1] = html_print_input_text(
|
||||||
|
'name',
|
||||||
|
$name,
|
||||||
|
'',
|
||||||
|
35,
|
||||||
|
100,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
$table->data[0][2] = __('Pass type').ui_print_help_tip(__('The fields with pass type enabled will be displayed like html input type pass in html'), true);
|
$table->data[1][0] = __('Pass type').ui_print_help_tip(
|
||||||
$table->data[0][3] = html_print_checkbox('is_password_type', 1, $is_password_type, true);
|
__('The fields with pass type enabled will be displayed like html input type pass in html'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table->data[1][1] = html_print_checkbox_switch(
|
||||||
|
'is_password_type',
|
||||||
|
1,
|
||||||
|
$is_password_type,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
$table->data[0][4] = __('Display on front').ui_print_help_tip(__('The fields with display on front enabled will be displayed into the agent details'), true);
|
$table->data[2][0] = __('Display on front').ui_print_help_tip(
|
||||||
$table->data[0][5] = html_print_checkbox('display_on_front', 1, $display_on_front, true);
|
__('The fields with display on front enabled will be displayed into the agent details'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table->data[2][1] = html_print_checkbox_switch(
|
||||||
|
'display_on_front',
|
||||||
|
1,
|
||||||
|
$display_on_front,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->data[3][0] = __('Enabled combo');
|
||||||
|
$table->data[3][1] = html_print_checkbox_switch_extended(
|
||||||
|
'is_combo_enable',
|
||||||
|
0,
|
||||||
|
$config['is_combo_enable'],
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->rowstyle[4] = 'display: none;';
|
||||||
|
$table->data[4][0] = __('Combo values').ui_print_help_tip(
|
||||||
|
__('Set values separated by comma'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table->data[4][1] = html_print_input_text(
|
||||||
|
'combo_values',
|
||||||
|
io_safe_output($combo_values),
|
||||||
|
'',
|
||||||
|
35,
|
||||||
|
200,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
echo '<form name="field" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/fields_manager">';
|
echo '<form name="field" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/fields_manager">';
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
@ -67,3 +140,67 @@ if ($id_field) {
|
|||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready (function () {
|
||||||
|
if($('input[type=hidden][name=update_field]').val() == 1 && $('input[type=text][name=combo_values]').val() != ''){
|
||||||
|
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||||
|
$('#configure_field-4').show();
|
||||||
|
$('input[type=checkbox][name=is_password_type]').change(function (e) {
|
||||||
|
dialog_message("#message_set_password");
|
||||||
|
$('input[type=checkbox][name=is_password_type]').prop('checked', false);
|
||||||
|
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||||
|
$('#configure_field-4').show();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
$('input[type=checkbox][name=is_combo_enable]').change(function (e) {
|
||||||
|
if($('input[type=text][name=combo_values]').val() != '' && $('input[type=checkbox][name=is_combo_enable]').prop('checked', true)){
|
||||||
|
dialog_message("#message_set_combo");
|
||||||
|
$('input[type=checkbox][name=is_combo_enable]').prop('checked', true);
|
||||||
|
$('#configure_field-4').show();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('input[type=checkbox][name=is_combo_enable]').change(function () {
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$('#configure_field-4').show();
|
||||||
|
dialog_message("#message_no_set_password");
|
||||||
|
$('#configure_field-1').hide();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#configure_field-4').hide();
|
||||||
|
$('#configure_field-1').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('input[type=checkbox][name=is_password_type]').change(function () {
|
||||||
|
if( $(this).is(":checked")){
|
||||||
|
dialog_message("#message_no_set_combo");
|
||||||
|
$('#configure_field-3').hide();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#configure_field-3').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function dialog_message(message_id) {
|
||||||
|
$(message_id)
|
||||||
|
.css("display", "inline")
|
||||||
|
.dialog({
|
||||||
|
modal: true,
|
||||||
|
show: "blind",
|
||||||
|
hide: "blind",
|
||||||
|
width: "400px",
|
||||||
|
buttons: {
|
||||||
|
Close: function() {
|
||||||
|
$(this).dialog("close");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
@ -26,7 +26,7 @@ if (!check_acl($config['id_user'], 0, 'PM')) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header
|
// Header.
|
||||||
ui_print_page_header(__('Agents custom fields manager'), 'images/custom_field.png', false, '', true, '');
|
ui_print_page_header(__('Agents custom fields manager'), 'images/custom_field.png', false, '', true, '');
|
||||||
|
|
||||||
$create_field = (bool) get_parameter('create_field');
|
$create_field = (bool) get_parameter('create_field');
|
||||||
@ -36,10 +36,12 @@ $id_field = (int) get_parameter('id_field', 0);
|
|||||||
$name = (string) get_parameter('name', '');
|
$name = (string) get_parameter('name', '');
|
||||||
$display_on_front = (int) get_parameter('display_on_front', 0);
|
$display_on_front = (int) get_parameter('display_on_front', 0);
|
||||||
$is_password_type = (int) get_parameter('is_password_type', 0);
|
$is_password_type = (int) get_parameter('is_password_type', 0);
|
||||||
|
$combo_values = (string) get_parameter('combo_values', '');
|
||||||
|
$combo_value_selected = (string) get_parameter('combo_value_selected', '');
|
||||||
|
|
||||||
// Create field
|
// Create field.
|
||||||
if ($create_field) {
|
if ($create_field) {
|
||||||
// Check if name field is empty
|
// Check if name field is empty.
|
||||||
if ($name == '') {
|
if ($name == '') {
|
||||||
ui_print_error_message(__('The name must not be empty'));
|
ui_print_error_message(__('The name must not be empty'));
|
||||||
} else if ($name == db_get_value('name', 'tagent_custom_fields', 'name', $name)) {
|
} else if ($name == db_get_value('name', 'tagent_custom_fields', 'name', $name)) {
|
||||||
@ -51,20 +53,22 @@ if ($create_field) {
|
|||||||
'name' => $name,
|
'name' => $name,
|
||||||
'display_on_front' => $display_on_front,
|
'display_on_front' => $display_on_front,
|
||||||
'is_password_type' => $is_password_type,
|
'is_password_type' => $is_password_type,
|
||||||
|
'combo_values' => $combo_values,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
ui_print_success_message(__('Field successfully created'));
|
ui_print_success_message(__('Field successfully created'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update field
|
// Update field.
|
||||||
if ($update_field) {
|
if ($update_field) {
|
||||||
// Check if name field is empty
|
// Check if name field is empty.
|
||||||
if ($name != '') {
|
if ($name != '') {
|
||||||
$values = [
|
$values = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'display_on_front' => $display_on_front,
|
'display_on_front' => $display_on_front,
|
||||||
'is_password_type' => $is_password_type,
|
'is_password_type' => $is_password_type,
|
||||||
|
'combo_values' => $combo_values,
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = db_process_sql_update('tagent_custom_fields', $values, ['id_field' => $id_field]);
|
$result = db_process_sql_update('tagent_custom_fields', $values, ['id_field' => $id_field]);
|
||||||
@ -79,7 +83,7 @@ if ($update_field) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete field
|
// Delete field.
|
||||||
if ($delete_field) {
|
if ($delete_field) {
|
||||||
$result = db_process_sql_delete(
|
$result = db_process_sql_delete(
|
||||||
'tagent_custom_fields',
|
'tagent_custom_fields',
|
||||||
|
@ -689,6 +689,13 @@ foreach ($fields as $field) {
|
|||||||
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
__('This field allows url insertion using the BBCode\'s url tag').'.<br />'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.<br /><br />'.__('e.g.: [url=google.com]Google web search[/url]'),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
$combo = [];
|
||||||
|
$combo = $field['combo_values'];
|
||||||
|
$combo = explode(',', $combo);
|
||||||
|
$combo_values = [];
|
||||||
|
foreach ($combo as $value) {
|
||||||
|
$combo_values[$value] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$custom_value = db_get_value_filter('description', 'tagent_custom_data', ['id_field' => $field['id_field'], 'id_agent' => $id_agente]);
|
$custom_value = db_get_value_filter('description', 'tagent_custom_data', ['id_field' => $field['id_field'], 'id_agent' => $id_agente]);
|
||||||
|
|
||||||
@ -714,6 +721,28 @@ foreach ($fields as $field) {
|
|||||||
$data[1] = html_print_textarea('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true);
|
$data[1] = html_print_textarea('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($field['combo_values'] !== '') {
|
||||||
|
$data[1] = html_print_select(
|
||||||
|
$combo_values,
|
||||||
|
'customvalue_'.$field['id_field'],
|
||||||
|
$custom_value,
|
||||||
|
'',
|
||||||
|
__('No change'),
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user