Added select filtered modulo to custom graphs conf menu
This commit is contained in:
parent
a8150e3cb5
commit
328a9db1fb
|
@ -327,59 +327,17 @@ echo '<br>';
|
|||
|
||||
// Configuration form.
|
||||
echo '<span id ="none_text" class="invisible">'.__('None').'</span>';
|
||||
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&add_module=1&edit_graph=1&id=".$id_graph."'>";
|
||||
echo "<form id='agentmodules' method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&add_module=1&edit_graph=1&id=".$id_graph."'>";
|
||||
|
||||
echo "<table width='100%' cellpadding='4' cellpadding='4' class='databox filters'>";
|
||||
echo '<tr>';
|
||||
echo "<td colspan='1'>".__('Filter group').'</td>';
|
||||
echo '</tr><tr>';
|
||||
echo "<td colspan='1'>".html_print_select_groups(
|
||||
$config['id_user'],
|
||||
($report_w == true) ? 'RW' : (($report_m == true) ? 'RM' : 'RW'),
|
||||
true,
|
||||
'group',
|
||||
'',
|
||||
'filterByGroup($(\'#group\').val());',
|
||||
'',
|
||||
0,
|
||||
true
|
||||
).'</td>';
|
||||
echo '</tr><tr>';
|
||||
echo "<td class='top'>".__('Agents').ui_print_help_tip(
|
||||
__('If you select several agents, only the common modules will be displayed'),
|
||||
true
|
||||
).'</td>';
|
||||
echo '<td></td>';
|
||||
echo "<td class='top'>".__('Modules').'</td>';
|
||||
echo '</tr><tr>';
|
||||
echo '<td class="w50p">'.html_print_select(
|
||||
agents_get_group_agents(),
|
||||
'id_agents[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'w100p',
|
||||
false,
|
||||
''
|
||||
).'</td>';
|
||||
echo '<td class="select_module_graph"></td>';
|
||||
echo '<td class="w50p">'.html_print_select(
|
||||
[],
|
||||
'module[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'w100p',
|
||||
false,
|
||||
''
|
||||
echo '<td class="w50p" id="select_multiple_modules_filtered">'.html_print_input(
|
||||
[
|
||||
'type' => 'select_multiple_modules_filtered',
|
||||
'uniqId' => 'modules',
|
||||
'class' => 'flex flex-row',
|
||||
|
||||
]
|
||||
).'</td>';
|
||||
echo '</tr><tr>';
|
||||
echo "<td colspan='3'>";
|
||||
|
@ -403,52 +361,34 @@ ui_require_jquery_file('autocomplete');
|
|||
$(document).ready (function () {
|
||||
$(document).data('text_for_module', $("#none_text").html());
|
||||
|
||||
$("#id_agents").change(agent_changed_by_multiple_agents);
|
||||
|
||||
|
||||
$("#submit-add").click(function() {
|
||||
$('#module').map(function(){
|
||||
if ($(this).val() != "0" )
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
|
||||
if($('#module')[0].childElementCount == 1 && ($('#module')[0].value == "" || $('#module')[0].value == "0")) {
|
||||
if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") {
|
||||
alert("<?php echo __('Please, select a module'); ?>");
|
||||
return false;
|
||||
}
|
||||
|
||||
var modules_selected = $(
|
||||
"#filtered-module-modules-modules"
|
||||
).val();
|
||||
var agents_selected = $(
|
||||
"#filtered-module-agents-modules"
|
||||
).val();
|
||||
|
||||
$("#agentmodules").submit( function(eventObj) {
|
||||
$("<input />").attr("type", "hidden")
|
||||
.attr("value", agents_selected)
|
||||
.attr("name", "id_agents")
|
||||
.appendTo("#agentmodules");
|
||||
$("<input />").attr("type", "hidden")
|
||||
.attr("value", modules_selected)
|
||||
.attr("name", "id_modules")
|
||||
.appendTo("#agentmodules");
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function filterByGroup(idGroup) {
|
||||
$('#id_agents').empty ();
|
||||
$('#module').empty();
|
||||
$("#module").append ($("<option></option>").attr ("value", 0).html ('<?php echo __('None'); ?>'));
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/groups/group_list",
|
||||
"get_group_agents" : 1,
|
||||
"id_group" : idGroup,
|
||||
// Add a key prefix to avoid auto sorting in js object conversion
|
||||
"keys_prefix" : "_"
|
||||
},
|
||||
function (data, status) {
|
||||
i = 0
|
||||
jQuery.each (data, function (id, value) {
|
||||
// Remove keys_prefix from the index
|
||||
id = id.substring(1);
|
||||
|
||||
i++;
|
||||
$("#id_agents").append ($("<option></option>").attr ("value", id).html (value));
|
||||
});
|
||||
|
||||
if (i == 0) {
|
||||
$("#id_agents").append ($("<option></option>").attr ("value", 0).html ('<?php echo __('None'); ?>'));
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function added_ids_sorted_items_to_hidden_input() {
|
||||
var ids = '';
|
||||
var first = true;
|
||||
|
|
|
@ -222,8 +222,8 @@ function add_quotes($item)
|
|||
|
||||
if ($add_module === true) {
|
||||
$id_graph = get_parameter('id');
|
||||
$id_modules = get_parameter('module');
|
||||
$id_agents = get_parameter('id_agents');
|
||||
$id_agent_modules = explode(',', get_parameter('id_modules'));
|
||||
$id_agents = explode(',', get_parameter('id_agents'));
|
||||
$weight = get_parameter('weight');
|
||||
|
||||
// Id modules has double entities conversion.
|
||||
|
@ -234,9 +234,7 @@ if ($add_module === true) {
|
|||
// 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");
|
||||
|
@ -244,7 +242,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['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order]);
|
||||
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module, 'weight' => $weight, 'field_order' => $order]);
|
||||
}
|
||||
} else {
|
||||
$result = false;
|
||||
|
|
|
@ -231,13 +231,8 @@ function fmModuleChange(uniqId) {
|
|||
if (data) {
|
||||
jQuery.each(data, function(id, value) {
|
||||
var option = $("<option></option>")
|
||||
.attr(
|
||||
"value",
|
||||
value["id_node"]
|
||||
? value["id_node"] + "|" + value["id_agente_modulo"]
|
||||
: value["id_agente_modulo"]
|
||||
)
|
||||
.html(value["nombre"]);
|
||||
.attr("value", id)
|
||||
.html(value);
|
||||
$("#filtered-module-modules-" + uniqId).append(option);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8455,3 +8455,34 @@ div#err_msg_centralised {
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered > div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
margin: 5px;
|
||||
flex-wrap: wrap;
|
||||
flex: 1 1 320px;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered > div > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered > div > div > * {
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered > div > div > select {
|
||||
min-width: 250px !important;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered > div > div > .select2 {
|
||||
min-width: 250px !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue