Fix selector modules only string in VC barsgraph and donutgraph

This commit is contained in:
Daniel Barbero Martin 2020-02-13 09:55:49 +01:00
parent 10972a2364
commit c96dd8e930
4 changed files with 113 additions and 87 deletions

View File

@ -3714,6 +3714,12 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$params['value'] = $agent_name;
$params['javascript_is_function_select'] = true;
if (isset($data['get_only_string_modules']) === true
&& $data['get_only_string_modules'] === true
) {
$params['get_only_string_modules'] = $data['get_only_string_modules'];
}
if (isset($data['module_input']) === true
&& $data['module_input'] === true
) {
@ -3755,12 +3761,18 @@ function html_print_input($data, $wrapper='div', $input_only=false)
0 => __('Select an Agent first'),
];
} else {
$string_filter .= '';
if ($data['get_only_string_modules'] === true) {
$string_filter = 'AND id_tipo_modulo IN (17,23,3,10,33,36)';
}
$sql = sprintf(
'SELECT id_agente_modulo, nombre
FROM tagente_modulo
WHERE id_agente = %d
AND delete_pending = 0',
$data['agent_id']
AND delete_pending = 0 %s',
$data['agent_id'],
$string_filter
);
if (is_metaconsole() === true) {

View File

@ -340,57 +340,67 @@ final class BarsGraph extends Item
$height = (int) $data['height'];
}
if ($typeGraph === 'horizontal') {
$graph = \hbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
if (empty($moduleData) === true) {
$image = ui_get_full_url(
'images/image_problem_area.png',
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
$gridColor,
null,
null,
true
);
} else {
$graph = \vbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
\ui_get_full_url(
'images/image_problem_area.png',
false,
false,
false
),
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
true,
false,
$gridColor,
true
false,
false
);
$graph = base64_encode(file_get_contents($image));
} else {
if ($typeGraph === 'horizontal') {
$graph = \hbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
'images/image_problem_area.png',
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
$gridColor,
null,
null,
true
);
} else {
$graph = \vbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
\ui_get_full_url(
'images/image_problem_area.png',
false,
false,
false
),
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
true,
false,
$gridColor,
true
);
}
}
// Restore connection.
@ -483,16 +493,17 @@ final class BarsGraph extends Item
$inputs[] = [
'label' => __('Agent'),
'arguments' => [
'type' => 'autocomplete_agent',
'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'type' => 'autocomplete_agent',
'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'get_only_string_modules' => true,
],
];
@ -500,14 +511,15 @@ final class BarsGraph extends Item
$inputs[] = [
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'get_only_string_modules' => true,
],
];
}

View File

@ -210,16 +210,17 @@ final class DonutGraph extends Item
$inputs[] = [
'label' => __('Agent'),
'arguments' => [
'type' => 'autocomplete_agent',
'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'type' => 'autocomplete_agent',
'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'get_only_string_modules' => true,
],
];
@ -227,14 +228,15 @@ final class DonutGraph extends Item
$inputs[] = [
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'get_only_string_modules' => true,
],
];

View File

@ -685,7 +685,7 @@ if (is_ajax()) {
);
if ($get_only_string_modules) {
$filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33)';
$filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33,36)';
}
// Status selector.