mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
#12350 added agent name editing
This commit is contained in:
parent
071427e60b
commit
86671c7211
@ -357,7 +357,18 @@ if ($new_agent === false) {
|
||||
$tableAgent->data['caption_name'][0] = __('Agent name');
|
||||
$tableAgent->rowclass['name'] = 'w540px';
|
||||
$tableAgent->cellstyle['name'][0] = 'width: 100%;';
|
||||
$tableAgent->data['name'][0] = html_print_input_text('agente', $nombre_agente, '', 76, 100, true, false, false, '', 'w100p');
|
||||
$tableAgent->data['name'][0] = html_print_input_text(
|
||||
'agente',
|
||||
$nombre_agente,
|
||||
'',
|
||||
76,
|
||||
100,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
'w100p'
|
||||
);
|
||||
$tableAgent->data['name'][0] .= html_print_div(
|
||||
[
|
||||
'class' => 'moduleIdBox',
|
||||
@ -365,6 +376,28 @@ if ($new_agent === false) {
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Other than Linux, Solaris, AIX, BSD, HPUX, MacOs, and Windows.
|
||||
if ($id_os !== '1' && $id_os !== '2' && $id_os !== '3' && $id_os !== '4'
|
||||
&& $id_os !== '5' && $id_os !== '7' && $id_os !== '8'
|
||||
) {
|
||||
$tableAgent->data['name'][0] .= html_print_anchor(
|
||||
[
|
||||
'content' => html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'border' => 0,
|
||||
'title' => __('Edit agent name'),
|
||||
'class' => 'main_menu_icon invert_filter after_input_icon forced_title clickable',
|
||||
'onclick' => 'editAgent()',
|
||||
]
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// Agent options for QR code.
|
||||
$agent_options_update = 'agent_options_update';
|
||||
}
|
||||
@ -1429,7 +1462,6 @@ ui_require_jquery_file('bgiframe');
|
||||
128
|
||||
);
|
||||
}
|
||||
$("#text-agente").prop('readonly', true);
|
||||
|
||||
|
||||
// Disable fixed ip button if empty.
|
||||
@ -1458,4 +1490,37 @@ ui_require_jquery_file('bgiframe');
|
||||
$('#basic_options').addClass('invisible');
|
||||
}
|
||||
}
|
||||
|
||||
function editAgent() {
|
||||
$(`#text-agente`).attr(`readonly`, false);
|
||||
const title = '<?php echo __('Warning'); ?>';
|
||||
const text = '<?php echo __('Change the internal name of the agent may cause duplicity and malfunction'); ?>';
|
||||
const id = uniqId();
|
||||
$("body").append('<div title="' + title + '" id="' + id + '"></div>');
|
||||
$("#" + id).empty();
|
||||
$("#" + id).append(text);
|
||||
$("#" + id).dialog({
|
||||
height: 150,
|
||||
width: 528,
|
||||
opacity: 1,
|
||||
modal: true,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title,
|
||||
closeOnEscape: true,
|
||||
buttons: [{
|
||||
text: "OK",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}],
|
||||
open: function(event, ui) {
|
||||
$(".ui-dialog-titlebar-close").hide();
|
||||
},
|
||||
}).show();
|
||||
}
|
||||
</script>
|
||||
|
@ -956,6 +956,13 @@ if ($update_agent) {
|
||||
$mssg_warning = 0;
|
||||
$id_agente = (int) get_parameter_post('id_agente');
|
||||
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', ''));
|
||||
$repeated_name = db_get_row_sql(
|
||||
sprintf(
|
||||
'SELECT nombre FROM tagente WHERE id_agente <> %s AND nombre like "%s"',
|
||||
$id_agente,
|
||||
$nombre_agente
|
||||
)
|
||||
);
|
||||
$alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
|
||||
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
|
||||
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
@ -1084,14 +1091,17 @@ if ($update_agent) {
|
||||
}
|
||||
}
|
||||
|
||||
// Verify if there is another agent with the same name but different ID.
|
||||
if (empty($repeated_name) === false) {
|
||||
ui_print_error_message(__('Agent with repeated name'));
|
||||
}
|
||||
|
||||
if ($mssg_warning) {
|
||||
ui_print_warning_message(__('The ip or dns name entered cannot be resolved'));
|
||||
}
|
||||
|
||||
// Verify if there is another agent with the same name but different ID.
|
||||
if ($alias == '') {
|
||||
ui_print_error_message(__('No agent alias specified'));
|
||||
// If there is an agent with the same name, but a different ID.
|
||||
}
|
||||
|
||||
if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
|
||||
@ -1152,6 +1162,10 @@ if ($update_agent) {
|
||||
'vul_scan_enabled' => $vul_scan_enabled,
|
||||
];
|
||||
|
||||
if (empty($repeated_name) === true) {
|
||||
$values['nombre'] = $nombre_agente;
|
||||
}
|
||||
|
||||
if ($config['metaconsole_agent_cache'] == 1) {
|
||||
$values['update_module_count'] = 1;
|
||||
// Force an update of the agent cache.
|
||||
|
Loading…
x
Reference in New Issue
Block a user