Merge branch 'ent-8849-13468-Anadir-links-web-en-los-custom-fileds-de-agente' into 'develop'
implemented custom field See merge request artica/pandorafms!5271
This commit is contained in:
commit
f9bb893aae
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tagent_custom_fields` ADD `is_link_enabled` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
|
||||
COMMIT;
|
|
@ -872,6 +872,35 @@ foreach ($fields as $field) {
|
|||
true,
|
||||
true
|
||||
);
|
||||
} else if ($field['is_link_enabled']) {
|
||||
list($link_text, $link_url) = json_decode($custom_value, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$link_text = '';
|
||||
$link_url = '';
|
||||
}
|
||||
|
||||
$data_field[1] = '<span style="line-height: 3.5;">'.__('Link text:').'</span>';
|
||||
$data_field[1] .= '<br>';
|
||||
$data_field[1] .= html_print_textarea(
|
||||
'customvalue_'.$field['id_field'].'[]',
|
||||
2,
|
||||
65,
|
||||
$link_text,
|
||||
'class="min-height-30px',
|
||||
true
|
||||
);
|
||||
$data_field[1] .= '<br>';
|
||||
$data_field[1] .= '<span style="line-height: 3.5;">'.__('Link URL:').'</span>';
|
||||
$data_field[1] .= '<br>';
|
||||
$data_field[1] .= html_print_textarea(
|
||||
'customvalue_'.$field['id_field'].'[]',
|
||||
2,
|
||||
65,
|
||||
$link_url,
|
||||
'class="min-height-30px',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$data_field[1] = html_print_textarea(
|
||||
'customvalue_'.$field['id_field'],
|
||||
|
|
|
@ -238,7 +238,15 @@ if ($create_agent) {
|
|||
$field_values = [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$field_values[$field['id_field']] = (string) get_parameter_post('customvalue_'.$field['id_field'], '');
|
||||
$field_value = get_parameter_post('customvalue_'.$field['id_field'], '');
|
||||
|
||||
if ($field['is_link_enabled']) {
|
||||
$field_value = json_encode($field_value);
|
||||
} else {
|
||||
$field_value = (string) $field_value;
|
||||
}
|
||||
|
||||
$field_values[$field['id_field']] = $field_value;
|
||||
}
|
||||
|
||||
// Check if agent exists (BUG WC-50518-2).
|
||||
|
@ -999,7 +1007,22 @@ if ($update_agent) {
|
|||
$field_values = [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$field_values[$field['id_field']] = (string) get_parameter_post('customvalue_'.$field['id_field'], '');
|
||||
$field_value = get_parameter_post('customvalue_'.$field['id_field'], '');
|
||||
|
||||
if ($field['is_link_enabled']) {
|
||||
if ($field_value[1] !== '') {
|
||||
$parsed_url = parse_url($field_value[1]);
|
||||
if (empty($parsed_url['scheme']) === true) {
|
||||
$field_value[1] = 'http://'.ltrim($field_value[1], '/');
|
||||
}
|
||||
}
|
||||
|
||||
$field_value = json_encode($field_value);
|
||||
} else {
|
||||
$field_value = (string) $field_value;
|
||||
}
|
||||
|
||||
$field_values[$field['id_field']] = $field_value;
|
||||
}
|
||||
|
||||
foreach ($field_values as $key => $value) {
|
||||
|
|
|
@ -30,6 +30,8 @@ $display_on_front = (bool) get_parameter('display_on_front', 0);
|
|||
$is_password_type = (bool) get_parameter('is_password_type', 0);
|
||||
$is_combo_enable = (bool) get_parameter('is_combo_enable', 0);
|
||||
$combo_values = (string) get_parameter('combo_values', '');
|
||||
$is_link_enabled = (bool) get_parameter('is_link_enabled', 0);
|
||||
|
||||
// Header.
|
||||
if ($id_field) {
|
||||
$field = db_get_row_filter('tagent_custom_fields', ['id_field' => $id_field]);
|
||||
|
@ -38,6 +40,7 @@ if ($id_field) {
|
|||
$is_password_type = $field['is_password_type'];
|
||||
$combo_values = $field['combo_values'] ? $field['combo_values'] : '';
|
||||
$is_combo_enable = $config['is_combo_enable'];
|
||||
$is_link_enabled = $field['is_link_enabled'];
|
||||
ui_print_page_header(__('Update agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||
} else {
|
||||
ui_print_page_header(__('Create agent custom field'), 'images/custom_field.png', false, '', true, '');
|
||||
|
@ -128,6 +131,17 @@ $table->data[4][1] = html_print_textarea(
|
|||
true
|
||||
);
|
||||
|
||||
$table->data[5][0] = __('Link type');
|
||||
$table->data[5][1] = html_print_checkbox_switch_extended(
|
||||
'is_link_enabled',
|
||||
1,
|
||||
$is_link_enabled,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
echo '<form name="field" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/fields_manager">';
|
||||
html_print_table($table);
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
|
@ -167,25 +181,46 @@ $(document).ready (function () {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
if ($('input[type=checkbox][name=is_link_enabled]').is(":checked") === true) {
|
||||
$('#configure_field-1').hide();
|
||||
$('#configure_field-3').hide();
|
||||
} else {
|
||||
$('#configure_field-1').show();
|
||||
$('#configure_field-3').show();
|
||||
}
|
||||
|
||||
$('input[type=checkbox][name=is_link_enabled]').change(function () {
|
||||
if( $(this).is(":checked") ){
|
||||
$('#configure_field-1').hide();
|
||||
$('#configure_field-3').hide();
|
||||
} else{
|
||||
$('#configure_field-1').show();
|
||||
$('#configure_field-3').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('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();
|
||||
$('#configure_field-5').hide();
|
||||
}
|
||||
else{
|
||||
$('#configure_field-4').hide();
|
||||
$('#configure_field-1').show();
|
||||
$('#configure_field-5').show();
|
||||
}
|
||||
});
|
||||
$('input[type=checkbox][name=is_password_type]').change(function () {
|
||||
if( $(this).is(":checked")){
|
||||
dialog_message("#message_no_set_combo");
|
||||
$('#configure_field-3').hide();
|
||||
$('#configure_field-5').hide();
|
||||
}
|
||||
else{
|
||||
$('#configure_field-3').show();
|
||||
$('#configure_field-5').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,11 +38,12 @@ $display_on_front = (int) get_parameter('display_on_front', 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', '');
|
||||
$is_link_enabled = (bool) get_parameter('is_link_enabled', 0);
|
||||
|
||||
// Create field.
|
||||
if ($create_field) {
|
||||
// Check if name field is empty.
|
||||
if ($name == '') {
|
||||
if ($name === '') {
|
||||
ui_print_error_message(__('The name must not be empty'));
|
||||
} else if ($name == db_get_value('name', 'tagent_custom_fields', 'name', $name)) {
|
||||
ui_print_error_message(__('The name must be unique'));
|
||||
|
@ -54,6 +55,7 @@ if ($create_field) {
|
|||
'display_on_front' => $display_on_front,
|
||||
'is_password_type' => $is_password_type,
|
||||
'combo_values' => $combo_values,
|
||||
'is_link_enabled' => $is_link_enabled,
|
||||
]
|
||||
);
|
||||
ui_print_success_message(__('Field successfully created'));
|
||||
|
@ -63,12 +65,13 @@ if ($create_field) {
|
|||
// Update field.
|
||||
if ($update_field) {
|
||||
// Check if name field is empty.
|
||||
if ($name != '') {
|
||||
if ($name !== '') {
|
||||
$values = [
|
||||
'name' => $name,
|
||||
'display_on_front' => $display_on_front,
|
||||
'is_password_type' => $is_password_type,
|
||||
'combo_values' => $combo_values,
|
||||
'is_link_enabled' => $is_link_enabled,
|
||||
];
|
||||
|
||||
$result = db_process_sql_update('tagent_custom_fields', $values, ['id_field' => $id_field]);
|
||||
|
|
|
@ -546,6 +546,19 @@ foreach ($fields as $field) {
|
|||
|
||||
if ($custom_value[0]['is_password_type']) {
|
||||
$data[1] = '••••••••';
|
||||
} else if ($field['is_link_enabled'] === '1') {
|
||||
list($link_text, $link_url) = json_decode($custom_value[0]['description'], true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$link_text = '';
|
||||
$link_url = '';
|
||||
}
|
||||
|
||||
if ($link_text === '') {
|
||||
$link_text = $link_url;
|
||||
}
|
||||
|
||||
$data[1] = '<a href="'.$link_url.'">'.$link_text.'</a>';
|
||||
} else {
|
||||
$data[1] = $custom_value[0]['description'];
|
||||
}
|
||||
|
|
|
@ -2103,6 +2103,7 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields` (
|
|||
`display_on_front` TINYINT NOT NULL DEFAULT 0,
|
||||
`is_password_type` TINYINT NOT NULL DEFAULT 0,
|
||||
`combo_values` TEXT ,
|
||||
`is_link_enabled` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id_field`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
|
@ -1189,7 +1189,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `p
|
|||
|
||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`, `no_delete`) VALUES (9,'Packet Loss','Checks for dropped packages after X seconds of testing. It returns % of dropped packets. It uses ping flood mode to launch 50 consecutive pings to a remote destination. On local, stable networks, value should be 0.
',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_ _field2_', 1);
|
||||
|
||||
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,''),(2,'Department',0,0,''),(3,'Additional ID',0,0,''),(4,'eHorusID',0,0,'');
|
||||
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,'',0),(2,'Department',0,0,'',0),(3,'Additional ID',0,0,'',0),(4,'eHorusID',0,0,'',0);
|
||||
|
||||
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','','');
|
||||
|
||||
|
|
Loading…
Reference in New Issue