mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
Merge branch 'ent-12511-error-handeling-en-los-clusters-no-es-del-todo-correcto' into 'develop'
fix error empty clusters pandora_enterprise#12511 See merge request artica/pandorafms!6719
This commit is contained in:
commit
c5687ee1fd
@ -1237,11 +1237,24 @@ if ($new_agent === false) {
|
|||||||
$actionButtons .= html_print_input_hidden('id_agente', $id_agente);
|
$actionButtons .= html_print_input_hidden('id_agente', $id_agente);
|
||||||
|
|
||||||
if (is_management_allowed() === true) {
|
if (is_management_allowed() === true) {
|
||||||
|
$clusters = agents_get_agent_belongs_cluster($id_agente);
|
||||||
|
$cluster_belongs = '';
|
||||||
|
if (empty($clusters) === false) {
|
||||||
|
$clusters = array_reduce(
|
||||||
|
$clusters,
|
||||||
|
function ($carry, $item) {
|
||||||
|
$carry[] = $item['name'];
|
||||||
|
return $carry;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$cluster_belongs = implode(', ', $clusters);
|
||||||
|
}
|
||||||
|
|
||||||
$actionButtons .= html_print_button(
|
$actionButtons .= html_print_button(
|
||||||
__('Delete agent'),
|
__('Delete agent'),
|
||||||
'deleteAgent',
|
'deleteAgent',
|
||||||
false,
|
false,
|
||||||
'deleteAgentDialog('.$id_agente.')',
|
'deleteAgentDialog('.$id_agente.', "'.$cluster_belongs.'")',
|
||||||
[
|
[
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'mode' => 'secondary dialog_opener',
|
'mode' => 'secondary dialog_opener',
|
||||||
@ -1289,10 +1302,18 @@ ui_require_jquery_file('bgiframe');
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAgentDialog($idAgente) {
|
function deleteAgentDialog($idAgente, cluster) {
|
||||||
|
var msg_cluster = '';
|
||||||
|
if(cluster) {
|
||||||
|
msg_cluster = "<?php echo __('This agent belongs to the clusters'); ?>";
|
||||||
|
msg_cluster += ': ';
|
||||||
|
msg_cluster += cluster;
|
||||||
|
msg_cluster += '. ';
|
||||||
|
}
|
||||||
|
|
||||||
confirmDialog({
|
confirmDialog({
|
||||||
title: "<?php echo __('Delete agent'); ?>",
|
title: "<?php echo __('Delete agent'); ?>",
|
||||||
message: "<?php echo __('This action is not reversible. Are you sure'); ?>",
|
message: msg_cluster + "<?php echo __('This action is not reversible. Are you sure'); ?>",
|
||||||
onAccept: function() {
|
onAccept: function() {
|
||||||
window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente);
|
window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente);
|
||||||
}
|
}
|
||||||
|
@ -958,12 +958,33 @@ if ($agents !== false) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($check_aw === true && is_management_allowed() === true) {
|
if ($check_aw === true && is_management_allowed() === true) {
|
||||||
if ($agent['id_os'] != CLUSTER_OS_ID) {
|
$clusters = agents_get_agent_belongs_cluster($agent['id_agente']);
|
||||||
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;';
|
$cluster_belongs = '';
|
||||||
} else {
|
if (empty($clusters) === false) {
|
||||||
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;';
|
$clusters = array_reduce(
|
||||||
|
$clusters,
|
||||||
|
function ($carry, $item) {
|
||||||
|
$carry[] = $item['name'];
|
||||||
|
return $carry;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$cluster_belongs = implode(', ', $clusters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$msg = '';
|
||||||
|
if ($agent['id_os'] == CLUSTER_OS_ID) {
|
||||||
|
$msg .= __('You are going to delete a cluster agent');
|
||||||
|
$msg .= '. ';
|
||||||
|
} else if (empty($cluster_belongs) === false) {
|
||||||
|
$msg .= __('This agent belongs to the clusters');
|
||||||
|
$msg .= ': ';
|
||||||
|
$msg .= $cluster_belongs;
|
||||||
|
$msg .= '. ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg .= __('Are you sure?');
|
||||||
|
$onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;';
|
||||||
|
|
||||||
$agentActionButtons[] = html_print_menu_button(
|
$agentActionButtons[] = html_print_menu_button(
|
||||||
[
|
[
|
||||||
'href' => ui_get_full_url(
|
'href' => ui_get_full_url(
|
||||||
|
@ -4976,13 +4976,38 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* agent belongs to the clusters.
|
||||||
|
*
|
||||||
|
* @param integer $idAgent
|
||||||
|
*
|
||||||
|
* @return array Names clusters.
|
||||||
|
*/
|
||||||
|
function agents_get_agent_belongs_cluster(int $idAgent): array
|
||||||
|
{
|
||||||
|
$sql = sprintf(
|
||||||
|
'SELECT tcluster.name
|
||||||
|
FROM tcluster
|
||||||
|
INNER JOIN tcluster_agent
|
||||||
|
ON tcluster.id = tcluster_agent.id_cluster
|
||||||
|
WHERE tcluster_agent.id_agent = %d',
|
||||||
|
$idAgent
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = db_get_all_rows_sql($sql);
|
||||||
|
if ($result === false) {
|
||||||
|
$result = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array with a list of status agents
|
* Return an array with a list of status agents
|
||||||
*
|
*
|
||||||
* @return array.
|
* @return array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function agents_status_list()
|
function agents_status_list()
|
||||||
{
|
{
|
||||||
$status_list = [];
|
$status_list = [];
|
||||||
|
@ -213,6 +213,10 @@ class Cluster extends Entity
|
|||||||
public function getCounters() :array
|
public function getCounters() :array
|
||||||
{
|
{
|
||||||
$id_agent_modules = $this->getIdsModulesInvolved();
|
$id_agent_modules = $this->getIdsModulesInvolved();
|
||||||
|
if (empty($id_agent_modules) === true) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT SUM( IF(estado = 1, 1, 0) ) AS critical,
|
'SELECT SUM( IF(estado = 1, 1, 0) ) AS critical,
|
||||||
SUM( IF(estado = 2, 1, 0) ) AS warning,
|
SUM( IF(estado = 2, 1, 0) ) AS warning,
|
||||||
|
@ -151,7 +151,11 @@ $agentCountModules = html_print_div(
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids);
|
$alive_animation = '';
|
||||||
|
if (empty($module_involved_ids) === false) {
|
||||||
|
$alive_animation = agents_get_starmap(0, 180, 30, $module_involved_ids);
|
||||||
|
}
|
||||||
|
|
||||||
$output = '<div id="agent_details_first_row" class="w100p cluster-agent-data">';
|
$output = '<div id="agent_details_first_row" class="w100p cluster-agent-data">';
|
||||||
|
|
||||||
$output .= '<div class="flex">';
|
$output .= '<div class="flex">';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user