mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
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.
|
// Configuration form.
|
||||||
echo '<span id ="none_text" class="invisible">'.__('None').'</span>';
|
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 "<table width='100%' cellpadding='4' cellpadding='4' class='databox filters'>";
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo "<td colspan='1'>".__('Filter group').'</td>';
|
echo '<td class="w50p" id="select_multiple_modules_filtered">'.html_print_input(
|
||||||
echo '</tr><tr>';
|
[
|
||||||
echo "<td colspan='1'>".html_print_select_groups(
|
'type' => 'select_multiple_modules_filtered',
|
||||||
$config['id_user'],
|
'uniqId' => 'modules',
|
||||||
($report_w == true) ? 'RW' : (($report_m == true) ? 'RM' : 'RW'),
|
'class' => 'flex flex-row',
|
||||||
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,
|
|
||||||
''
|
|
||||||
).'</td>';
|
).'</td>';
|
||||||
echo '</tr><tr>';
|
echo '</tr><tr>';
|
||||||
echo "<td colspan='3'>";
|
echo "<td colspan='3'>";
|
||||||
@ -403,52 +361,34 @@ ui_require_jquery_file('autocomplete');
|
|||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
$(document).data('text_for_module', $("#none_text").html());
|
$(document).data('text_for_module', $("#none_text").html());
|
||||||
|
|
||||||
$("#id_agents").change(agent_changed_by_multiple_agents);
|
|
||||||
|
|
||||||
|
|
||||||
$("#submit-add").click(function() {
|
$("#submit-add").click(function() {
|
||||||
$('#module').map(function(){
|
if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") {
|
||||||
if ($(this).val() != "0" )
|
|
||||||
$(this).prop('selected', true);
|
|
||||||
});
|
|
||||||
|
|
||||||
if($('#module')[0].childElementCount == 1 && ($('#module')[0].value == "" || $('#module')[0].value == "0")) {
|
|
||||||
alert("<?php echo __('Please, select a module'); ?>");
|
alert("<?php echo __('Please, select a module'); ?>");
|
||||||
return false;
|
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() {
|
function added_ids_sorted_items_to_hidden_input() {
|
||||||
var ids = '';
|
var ids = '';
|
||||||
var first = true;
|
var first = true;
|
||||||
|
@ -222,8 +222,8 @@ function add_quotes($item)
|
|||||||
|
|
||||||
if ($add_module === true) {
|
if ($add_module === true) {
|
||||||
$id_graph = get_parameter('id');
|
$id_graph = get_parameter('id');
|
||||||
$id_modules = get_parameter('module');
|
$id_agent_modules = explode(',', get_parameter('id_modules'));
|
||||||
$id_agents = get_parameter('id_agents');
|
$id_agents = explode(',', get_parameter('id_agents'));
|
||||||
$weight = get_parameter('weight');
|
$weight = get_parameter('weight');
|
||||||
|
|
||||||
// Id modules has double entities conversion.
|
// Id modules has double entities conversion.
|
||||||
@ -234,9 +234,7 @@ if ($add_module === true) {
|
|||||||
// to browse in db.
|
// to browse in db.
|
||||||
io_safe_input_array($id_modules);
|
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 != '') {
|
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");
|
$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'];
|
$order = $order['field_order'];
|
||||||
foreach ($id_agent_modules as $id_agent_module) {
|
foreach ($id_agent_modules as $id_agent_module) {
|
||||||
$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]);
|
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module, 'weight' => $weight, 'field_order' => $order]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
@ -231,13 +231,8 @@ function fmModuleChange(uniqId) {
|
|||||||
if (data) {
|
if (data) {
|
||||||
jQuery.each(data, function(id, value) {
|
jQuery.each(data, function(id, value) {
|
||||||
var option = $("<option></option>")
|
var option = $("<option></option>")
|
||||||
.attr(
|
.attr("value", id)
|
||||||
"value",
|
.html(value);
|
||||||
value["id_node"]
|
|
||||||
? value["id_node"] + "|" + value["id_agente_modulo"]
|
|
||||||
: value["id_agente_modulo"]
|
|
||||||
)
|
|
||||||
.html(value["nombre"]);
|
|
||||||
$("#filtered-module-modules-" + uniqId).append(option);
|
$("#filtered-module-modules-" + uniqId).append(option);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8455,3 +8455,34 @@ div#err_msg_centralised {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
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…
x
Reference in New Issue
Block a user