log.widget.php: allow mutliple select

This commit is contained in:
kulikov-a 2021-03-15 12:56:14 +03:00
parent 7d0b4b539b
commit fef578578b

View File

@ -58,7 +58,7 @@ if (is_numeric($pconfig['filterlogentries'])) {
}
if (!empty($pconfig['filterlogentriesinterfaces'])) {
$config['widgets']['filterlogentriesinterfaces'] = $pconfig['filterlogentriesinterfaces'];
$config['widgets']['filterlogentriesinterfaces'] = implode(',', $pconfig['filterlogentriesinterfaces']);
} elseif (isset($config['widgets']['filterlogentriesinterfaces'])) {
unset($config['widgets']['filterlogentriesinterfaces']);
}
@ -82,8 +82,14 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
const field_type_icons = {'pass': 'fa-play', 'block': 'fa-ban', 'rdr': 'fa-exchange', 'nat': 'fa-exchange'};
var interface_descriptions = {};
var nentriesinterfaces = "<?= $nentriesinterfaces ?>".split(",");
ajaxGet('/api/diagnostics/interface/getInterfaceNames', {}, function(data, status) {
interface_descriptions = data;
$.each(interface_descriptions, function(i_d, i_name){
$('#filterlogentriesinterfaces').append($.inArray(i_d, nentriesinterfaces) > -1 ? $('<option>', {value:i_d, text:i_name, selected: "selected" }) : $('<option>', {value:i_d, text:i_name }));
});
$('#filterlogentriesinterfaces').selectpicker('refresh');
fetch_log();
});
function fetch_log(){
var record_spec = [];
@ -107,14 +113,10 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
}
let record;
let showinterfaces = $("#filterlogentriesinterfaces").val();
while ((record=data.pop()) != null) {
var intf = record['interface'];
if (interface_descriptions[record['interface']] != undefined) {
intf = interface_descriptions[record['interface']].toLowerCase();
}
if ($("#filterlogentriesinterfaces").val() == "" || $("#filterlogentriesinterfaces").val() == intf) {
if (showinterfaces.length == 0 || $.inArray(intf, showinterfaces) > -1) {
if ((filtact.length == 0 || filtact.indexOf(record['action']) !== -1) && record['__digest__'] != last_digest) {
var log_tr = $("<tr>");
log_tr.hide();
@ -177,7 +179,6 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
setTimeout(fetch_log, update_interval_ms);
}
fetch_log();
});
</script>
@ -199,13 +200,7 @@ $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ?
<?php endfor ?>
</select><br/>
<label for="filterlogentriesinterfaces"><?= gettext('Interfaces to display:'); ?></label><br/>
<select id="filterlogentriesinterfaces" name="filterlogentriesinterfaces" class="selectpicker_widget">
<option value=""><?= gettext('All') ?></option>
<?php foreach (get_configured_interface_with_descr() as $iface => $ifacename): ?>
<option value="<?= html_safe($iface) ?>" <?= $nentriesinterfaces == $iface ? 'selected="selected"' : '' ?>>
<?= html_safe($ifacename) ?>
</option>
<?php endforeach ?>
<select id="filterlogentriesinterfaces" name="filterlogentriesinterfaces[]" class="selectpicker_widget" multiple="multiple" title=<?= gettext('All'); ?>>
</select><br/><br/>
<table style="width:348px">
<tr>