fixes MC graphs in network link + vc links between mc and nodes
This commit is contained in:
parent
da2ee342e6
commit
d2b166c295
|
@ -87,7 +87,12 @@ function load_modal(settings) {
|
|||
div.id = "div-modal-" + uniq;
|
||||
div.style.display = "none";
|
||||
|
||||
document.getElementById("main").append(div);
|
||||
if (document.getElementById("main") == null) {
|
||||
// MC env.
|
||||
document.getElementById("page").append(div);
|
||||
} else {
|
||||
document.getElementById("main").append(div);
|
||||
}
|
||||
|
||||
var id_modal_target = "#div-modal-" + uniq;
|
||||
|
||||
|
|
|
@ -1462,6 +1462,11 @@ class Item extends CachedModel
|
|||
$result['linked_layout_node_id'] = $linked_layout_node_id;
|
||||
}
|
||||
|
||||
if ($id_layout_linked > 0 && $linked_layout_node_id > 0) {
|
||||
// VC in node linked, force link status to enabled.
|
||||
$result['enable_link'] = 1;
|
||||
}
|
||||
|
||||
$linked_layout_status_type = static::notEmptyStringOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
|
@ -2205,7 +2210,7 @@ class Item extends CachedModel
|
|||
*
|
||||
* @return array Array all VCs.
|
||||
*/
|
||||
public function getAllVisualConsole(int $id):array
|
||||
public static function getAllVisualConsole(int $id):array
|
||||
{
|
||||
// Extract all VC except own.
|
||||
$result = db_get_all_rows_filter(
|
||||
|
@ -2220,7 +2225,7 @@ class Item extends CachedModel
|
|||
// Extract all VC for each node.
|
||||
if (is_metaconsole() === true) {
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
$meta_servers = metaconsole_get_servers();
|
||||
$meta_servers = (array) metaconsole_get_servers();
|
||||
foreach ($meta_servers as $server) {
|
||||
if (metaconsole_load_external_db($server) !== NOERR) {
|
||||
metaconsole_restore_db();
|
||||
|
@ -2281,14 +2286,18 @@ class Item extends CachedModel
|
|||
if ($fields === false) {
|
||||
$fields = [];
|
||||
} else {
|
||||
$fields = \array_reduce(
|
||||
$fields,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id']] = $item['name'];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
$rs = [];
|
||||
foreach ($fields as $k => $v) {
|
||||
if (isset($v['id']) === true && isset($v['name']) === true) {
|
||||
// Modern environments use id-name format.
|
||||
$rs[$v['id']] = $v;
|
||||
} else {
|
||||
// In MC environments is key-value.
|
||||
$rs[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$fields = $rs;
|
||||
}
|
||||
|
||||
$getAllVisualConsoleValue = $values['linkedLayoutId'];
|
||||
|
|
|
@ -660,12 +660,26 @@ class View extends \HTML
|
|||
'stacked' => $stacked,
|
||||
];
|
||||
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
$params['id_server'] = $server_id;
|
||||
// Interface FROM.
|
||||
if (isset($itemFrom['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
$cnn = \enterprise_hook(
|
||||
'metaconsole_get_connection_by_id',
|
||||
[ $itemFrom['id_metaconsole'] ]
|
||||
);
|
||||
|
||||
if (\enterprise_hook('metaconsole_connect', [$cnn]) !== NOERR) {
|
||||
throw new \Exception(__('Failed to connect to node'));
|
||||
}
|
||||
|
||||
$params['server_id'] = $itemFrom['id_metaconsole'];
|
||||
} else {
|
||||
$params['server_id'] = null;
|
||||
}
|
||||
|
||||
// Interface FROM.
|
||||
$from = new \PandoraFMS\Module((int) $itemFrom['id_agente_modulo']);
|
||||
|
||||
if ((bool) $from->isInterfaceModule() === true) {
|
||||
$interface_name = $from->getInterfaceName();
|
||||
if ($interface_name !== null) {
|
||||
|
@ -703,6 +717,12 @@ class View extends \HTML
|
|||
// Graph.
|
||||
echo '<div id="stat-win-interface-graph from">';
|
||||
|
||||
if (isset($itemFrom['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
\enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
|
||||
\graphic_combined_module(
|
||||
array_values($interface_traffic_modules),
|
||||
$params,
|
||||
|
@ -711,10 +731,34 @@ class View extends \HTML
|
|||
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
if (isset($itemFrom['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
\enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
}
|
||||
|
||||
// Interface TO.
|
||||
if (isset($itemTo['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
$cnn = \enterprise_hook(
|
||||
'metaconsole_get_connection_by_id',
|
||||
[ $itemTo['id_metaconsole'] ]
|
||||
);
|
||||
|
||||
if (\enterprise_hook('metaconsole_connect', [$cnn]) !== NOERR) {
|
||||
throw new \Exception(__('Failed to connect to node'));
|
||||
}
|
||||
|
||||
$params['server_id'] = $itemTo['id_metaconsole'];
|
||||
} else {
|
||||
$params['server_id'] = null;
|
||||
}
|
||||
|
||||
$to = new \PandoraFMS\Module((int) $itemTo['id_agente_modulo']);
|
||||
|
||||
if ((bool) $to->isInterfaceModule() === true) {
|
||||
$interface_name = $to->getInterfaceName();
|
||||
if ($interface_name !== null) {
|
||||
|
@ -752,6 +796,12 @@ class View extends \HTML
|
|||
// Graph.
|
||||
echo '<div id="stat-win-interface-graph to">';
|
||||
|
||||
if (isset($itemTo['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
\enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
|
||||
\graphic_combined_module(
|
||||
array_values($interface_traffic_modules),
|
||||
$params,
|
||||
|
@ -760,6 +810,12 @@ class View extends \HTML
|
|||
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
if (isset($itemTo['id_metaconsole']) === true
|
||||
&& (bool) is_metaconsole() === true
|
||||
) {
|
||||
\enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo __('Failed to generate charts: %s', $e->getMessage());
|
||||
|
|
Loading…
Reference in New Issue