Merge branch 'ent-6410-Wizard-SNMP-SNMP-Interfaces-y-WMI-no-autocompletan-Target-IP-con-IP-del-agente' into 'develop'

Ent 6410 wizard snmp snmp interfaces y wmi no autocompletan target ip con ip del agente

See merge request artica/pandorafms!3588
This commit is contained in:
Daniel Rodriguez 2020-11-03 10:26:24 +01:00
commit 6a31a28679
3 changed files with 84 additions and 2 deletions

View File

@ -294,6 +294,29 @@ class AgentWizard extends HTML
$this->idAgent = get_parameter('id_agente', '');
$this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', '');
if (!empty($this->idAgent)) {
$array_aux = db_get_all_rows_sql(
sprintf(
'SELECT ip FROM taddress ta
INNER JOIN taddress_agent taa ON taa.id_a = ta.id_a
WHERE taa.id_agent = %d',
$this->idAgent
)
);
if (!empty($array_aux)) {
$this->datalist = [];
foreach ($array_aux as $key => $value) {
$this->datalist[] = $value['ip'];
}
}
if (count($this->datalist) === 1 && $this->targetIp === '') {
$this->targetIp = $this->datalist[0];
}
}
$this->server = (int) get_parameter('server', '1');
if ($this->server !== 0) {
$this->serverType = (int) db_get_value(
@ -564,6 +587,18 @@ class AgentWizard extends HTML
],
];
if (!empty($this->datalist)) {
$inputs[] = [
'id' => 'li_address_list',
'arguments' => [
'name' => 'address_list',
'type' => 'datalist',
'value' => $this->datalist,
'return' => true,
],
];
}
$inputs[] = [
'label' => __('Target IP'),
'id' => 'txt-targetIp',
@ -574,6 +609,7 @@ class AgentWizard extends HTML
'class' => '',
'value' => $this->targetIp,
'return' => true,
'list' => 'address_list',
],
];

View File

@ -547,6 +547,7 @@ class HTML
} else {
if ($input['arguments']['type'] != 'hidden'
&& $input['arguments']['type'] != 'hidden_extended'
&& $input['arguments']['type'] != 'datalist'
) {
if (!$direct) {
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';

View File

@ -2032,6 +2032,7 @@ function html_print_input_text_extended(
'required',
'autocomplete',
'form',
'list',
];
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" ');
@ -2257,7 +2258,8 @@ function html_print_input_text(
$onKeyDown='',
$formTo='',
$onKeyUp='',
$disabled=false
$disabled=false,
$list=''
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -2302,6 +2304,10 @@ function html_print_input_text(
$attr['form'] = $formTo;
}
if ($list != '') {
$attr['list'] = $list;
}
return html_print_input_text_extended(
$name,
$value,
@ -4234,7 +4240,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['autofocus']) === true) ? $data['autofocus'] : false),
((isset($data['onKeyDown']) === true) ? $data['onKeyDown'] : ''),
((isset($data['form']) === true) ? $data['form'] : ''),
((isset($data['onKeyUp']) === true) ? $data['onKeyUp'] : '')
((isset($data['onKeyUp']) === true) ? $data['onKeyUp'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['list']) === true) ? $data['list'] : '')
);
break;
@ -4731,6 +4739,14 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output .= html_print_select_multiple_modules_filtered($data);
break;
case 'datalist':
$output .= html_print_datalist(
$data['name'],
$data['value'],
((isset($data['return']) === true) ? $data['return'] : true)
);
break;
default:
// Ignore.
break;
@ -4911,3 +4927,32 @@ function html_print_tabs(array $tabs)
return $result;
}
/**
* Create a datalist.
*
* @param string $id Use custom id.
* @param string $values Input values.
* @param string $returnparam Whether to return an output string or echo now (optional, echo by default).
*
* @return string HTML code if return parameter is true.
*/
function html_print_datalist(
$id,
$values,
$return=false
) {
$result = '<datalist id="'.$id.'">';
foreach ($values as $key => $value) {
$result .= '<option value="'.$value.'">';
}
$result .= '</datalist>';
if ($return) {
return $result;
} else {
echo $result;
}
}