collapsable area in agents ips

This commit is contained in:
alejandro.campos@artica.es 2024-03-18 13:46:50 +01:00
parent a31f96314f
commit a32844d08a
2 changed files with 47 additions and 10 deletions

View File

@ -2311,27 +2311,36 @@ function agents_get_agent_with_ip($ip_address)
/** /**
* Get all IP addresses of an agent * Get all IP addresses of an agent
* *
* @param int Agent id * @param int Agent id
* @param bool Order by id
* *
* @return array Array with the IP address of the given agent or an empty array. * @return array Array with the IP address of the given agent or an empty array.
*/ */
function agents_get_addresses($id_agent) function agents_get_addresses(
{ $id_agent,
$order_by_id=false
) {
$order_clause = ($order_by_id === true) ? 'ORDER BY taddress.id_a' : '';
if (is_array($id_agent)) { if (is_array($id_agent)) {
$sql = sprintf( $sql = sprintf(
'SELECT ip 'SELECT ip
FROM taddress_agent, taddress FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a WHERE taddress_agent.id_a = taddress.id_a
AND id_agent IN (%s)', AND id_agent IN (%s)
implode(',', $id_agent) %s',
implode(',', $id_agent),
$order_clause
); );
} else { } else {
$sql = sprintf( $sql = sprintf(
'SELECT ip 'SELECT ip
FROM taddress_agent, taddress FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a WHERE taddress_agent.id_a = taddress.id_a
AND id_agent = %d', AND id_agent = %d
$id_agent %s',
$id_agent,
$order_clause
); );
} }

View File

@ -142,7 +142,7 @@ if (empty($agent['os_version']) !== true) {
$table_status->data['agent_os_version'][1] = $os_agent_text; $table_status->data['agent_os_version'][1] = $os_agent_text;
} }
$addresses = agents_get_addresses($id_agente); $addresses = agents_get_addresses($id_agente, true);
$address = agents_get_address($id_agente); $address = agents_get_address($id_agente);
foreach ($addresses as $k => $add) { foreach ($addresses as $k => $add) {
@ -154,8 +154,26 @@ foreach ($addresses as $k => $add) {
if (empty($address) === false) { if (empty($address) === false) {
$address_text = '<span class="bolder" >'.$address.'</span>'; $address_text = '<span class="bolder" >'.$address.'</span>';
if (!empty($addresses) === true) { if (!empty($addresses) === true) {
foreach ($addresses as $sec_address) { if (count($addresses) > 3) {
$address_text .= '<br/><span class="italic">'.$sec_address.'</span>'; $address_text .= '&nbsp&nbsp<span id="deploy_sec_ips">'.html_print_image(
'images/sort_down_black.png',
true,
['alt' => 'down']
).'</span>';
$address_text .= '<div id="secondary_ips" class="invisible">';
}
$first_key = key($addresses);
foreach ($addresses as $key => $sec_address) {
if ($first_key !== $key) {
$address_text .= '<br/>';
}
$address_text .= '<span class="italic">'.$sec_address.'</span>';
}
if (count($addresses) > 3) {
$address_text .= '</div>';
} }
} }
@ -638,3 +656,13 @@ if (isset($table_interface) === true) {
true true
); );
} }
?>
<script type="text/javascript">
$(document).ready (function () {
$('#deploy_sec_ips').on('click', function() {
$('#secondary_ips').toggle();
});
});
</script>