Fixed custom graph

This commit is contained in:
Daniel Maya 2021-01-04 12:53:42 +01:00
parent 05645afd44
commit c11c122032
1 changed files with 20 additions and 12 deletions

View File

@ -62,8 +62,14 @@ final class ModuleGraph extends Item
$return = parent::encode($data); $return = parent::encode($data);
$id_custom_graph = static::extractIdCustomGraph($data); $id_custom_graph = static::extractIdCustomGraph($data);
if ($id_custom_graph !== null) { if (!empty($id_custom_graph)) {
$return['id_custom_graph'] = $id_custom_graph; if (\is_metaconsole()) {
$explode_custom_graph = explode('|', $id_custom_graph);
$return['id_custom_graph'] = $explode_custom_graph[0];
$return['id_metaconsole'] = $explode_custom_graph[1];
} else {
$return['id_custom_graph'] = $id_custom_graph;
}
} }
$type_graph = static::getTypeGraph($data); $type_graph = static::getTypeGraph($data);
@ -89,7 +95,7 @@ final class ModuleGraph extends Item
*/ */
private static function extractIdCustomGraph(array $data) private static function extractIdCustomGraph(array $data)
{ {
return static::parseIntOr( return static::notEmptyStringOr(
static::issetInArray( static::issetInArray(
$data, $data,
[ [
@ -362,6 +368,7 @@ final class ModuleGraph extends Item
'show_legend' => $showLegend, 'show_legend' => $showLegend,
'return_img_base_64' => true, 'return_img_base_64' => true,
'show_title' => false, 'show_title' => false,
'server_id' => $metaconsoleId,
]; ];
$paramsCombined = [ $paramsCombined = [
@ -414,6 +421,7 @@ final class ModuleGraph extends Item
'show_legend' => $showLegend, 'show_legend' => $showLegend,
'show_title' => false, 'show_title' => false,
'dashboard' => true, 'dashboard' => true,
'server_id' => $metaconsoleId,
]; ];
if ($imageOnly !== false) { if ($imageOnly !== false) {
@ -452,16 +460,16 @@ final class ModuleGraph extends Item
true, true,
'RR' 'RR'
); );
}
$data = array_reduce( $data = array_reduce(
$data, $data,
function ($carry, $item) { function ($carry, $item) {
$carry[$item['id_graph']] = $item['name']; $carry[$item['id_graph']] = $item['name'];
return $carry; return $carry;
}, },
[] []
); );
}
return $data; return $data;
} }