Added searchbar to select multiple modules on custom graph

This commit is contained in:
Calvo 2022-01-26 11:52:49 +01:00
parent f383586dcc
commit 5b624fc388
4 changed files with 20 additions and 19 deletions

View File

@ -331,7 +331,7 @@ echo "<form id='agentmodules' method='post' action='index.php?sec=reporting&sec
echo "<table width='100%' cellpadding='4' cellpadding='4' class='databox filters'>";
echo '<tr>';
echo '<td class="w50p" id="select_multiple_modules_filtered">'.html_print_input(
echo '<td class="w50p pdd_50px" id="select_multiple_modules_filtered">'.html_print_input(
[
'type' => 'select_multiple_modules_filtered',
'uniqId' => 'modules',

View File

@ -222,7 +222,7 @@ function add_quotes($item)
if ($add_module === true) {
$id_graph = get_parameter('id');
$id_agent_modules = explode(',', get_parameter('id_modules'));
$id_modules = explode(',', get_parameter('id_modules'));
$id_agents = explode(',', get_parameter('id_agents'));
$weight = get_parameter('weight');
@ -230,11 +230,10 @@ if ($add_module === true) {
// Safe output remove all entities.
io_safe_output_array($id_modules, '');
// We need to put the entities again
// to browse in db.
io_safe_input_array($id_modules);
$id_agent_modules = db_get_all_rows_sql(
'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')"
);
if (count($id_agent_modules) > 0 && $id_agent_modules != '') {
$order = db_get_row_sql("SELECT `field_order` from tgraph_source WHERE id_graph=$id_graph ORDER BY `field_order` DESC");
@ -242,7 +241,7 @@ if ($add_module === true) {
$order = $order['field_order'];
foreach ($id_agent_modules as $id_agent_module) {
$order++;
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module, 'weight' => $weight, 'field_order' => $order]);
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order]);
}
} else {
$result = false;

View File

@ -1491,11 +1491,11 @@ function html_print_select_multiple_modules_filtered(array $data):string
$output .= '<div>';
$output .= html_print_input(
[
'type' => 'text',
'name' => 'agent-searchBar-'.$uniqId,
'onKeyUp' => 'searchAgent(\''.$uniqId.'\')',
'value' => __('Type for search...'),
'return' => true,
'type' => 'text',
'name' => 'agent-searchBar-'.$uniqId,
'onKeyUp' => 'searchAgent(\''.$uniqId.'\')',
'placeholder' => __('Type to search agents'),
'return' => true,
]
);
@ -1504,11 +1504,11 @@ function html_print_select_multiple_modules_filtered(array $data):string
$output .= '<div>';
$output .= html_print_input(
[
'type' => 'text',
'name' => 'module-searchBar-'.$uniqId,
'onKeyUp' => 'searchModule(\''.$uniqId.'\')',
'return' => true,
'value' => 'test',
'type' => 'text',
'name' => 'module-searchBar-'.$uniqId,
'onKeyUp' => 'searchModule(\''.$uniqId.'\')',
'return' => true,
'placeholder' => __('Type to search modules'),
]
);

View File

@ -8501,6 +8501,8 @@ div#err_msg_centralised {
min-width: 250px !important;
}
#select_multiple_modules_filtered > div > div > select {
max-width: 250px !important;
#select_multiple_modules_filtered > div > div > input {
max-width: 250px;
width: 95%;
height: 95%;
}