Browse Source

added JavaScript based filter mechanism

logging
Andreas Gohr 7 months ago
parent
commit
6071f0eef3
  1. 2
      lib/plugins/logviewer/admin.php
  2. 3
      lib/plugins/logviewer/lang/en/lang.php
  3. 21
      lib/plugins/logviewer/script.js
  4. 10
      lib/plugins/logviewer/style.less

2
lib/plugins/logviewer/admin.php

@ -59,7 +59,7 @@ class admin_plugin_logviewer extends DokuWiki_Admin_Plugin
$form->setHiddenField('do', 'admin');
$form->setHiddenField('page', 'logviewer');
$form->setHiddenField('facility', $this->facility);
$form->addTextInput('date','Date*')->attr('type','date')->val($this->date)->addClass('quickselect');
$form->addTextInput('date',$this->getLang('date'))->attr('type','date')->val($this->date)->addClass('quickselect');
$form->addButton('submit','>')->attr('type','submit');
echo $form->toHTML();

3
lib/plugins/logviewer/lang/en/lang.php

@ -6,4 +6,5 @@
*/
$lang['menu'] = 'View Logs';
$lang['date'] = 'Date';
$lang['js']['filter'] = 'Filter Loglines:';

21
lib/plugins/logviewer/script.js

@ -3,6 +3,23 @@
*/
jQuery(function () {
var $dl = jQuery('#plugin__logviewer').find('dl');
if(!$dl.length) return;
$dl.animate({ scrollTop: $dl.prop("scrollHeight")}, 500);
if (!$dl.length) return;
$dl.animate({scrollTop: $dl.prop("scrollHeight")}, 500);
var $filter = jQuery('<input>');
$filter.on('keyup', function (e) {
var re = new RegExp($filter.val(), 'i');
$dl.find('dt').each(function (idx, elem) {
if (elem.innerText.match(re)) {
jQuery(elem).removeClass('hidden');
} else {
jQuery(elem).addClass('hidden');
}
});
});
$dl.before($filter);
$filter.wrap('<label></label>');
$filter.before(LANG.plugins.logviewer.filter + ' ');
});

10
lib/plugins/logviewer/style.less

@ -7,6 +7,12 @@
margin-bottom: 2em;
}
label {
display: block;
margin-top: -1em;
margin-bottom: 1em;
}
dl {
max-height: 80vh;
overflow: auto;
@ -14,6 +20,10 @@
dt {
display: flex;
&.hidden {
display: none;
}
.datetime {
flex: 0 0 auto;
margin-right: 1em;

Loading…
Cancel
Save