Fix review points
- Fix headers hierarchy - Improve accessibility: - set mouse pointer - make rows focusable - open on key press - add tooltip with "title" - add role and aria attributes - Rename `ParsedLog` to `ParsedLogLine` - Add docs to `ReversedFileReader`'s implementation of `Iterator`'s methods - Add docs to `ParsedLogIterator`'s implementation of `Iterator`'s methods - Remove unnecessary comment - Add more test for parsing log lines and fix some edge cases - Fix function name in snake-case to camelCase - Remove `DIRECTORY_SEPARATOR`
This commit is contained in:
parent
5520f100b2
commit
7f695197aa
10 changed files with 280 additions and 54 deletions
|
@ -1,7 +1,33 @@
|
|||
function log_show_details(id) {
|
||||
(function(){
|
||||
function log_show_details(elm) {
|
||||
const id = elm.id;
|
||||
var hidden = true;
|
||||
document
|
||||
.querySelectorAll('[data-id="' + id + '"]')
|
||||
.forEach(edetails => {
|
||||
hidden = edetails.classList.toggle('hidden');
|
||||
});
|
||||
document
|
||||
.querySelectorAll('[aria-expanded="true"]')
|
||||
.forEach(eexpanded => {
|
||||
eexpanded.setAttribute('aria-expanded', false);
|
||||
});
|
||||
|
||||
if (!hidden) {
|
||||
elm.setAttribute('aria-expanded', true);
|
||||
}
|
||||
}
|
||||
|
||||
document
|
||||
.querySelectorAll('[data-id="' + id + '"]')
|
||||
.querySelectorAll('.log-event')
|
||||
.forEach(elm => {
|
||||
elm.classList.toggle('hidden')
|
||||
elm.addEventListener("click", evt => {
|
||||
log_show_details(evt.currentTarget);
|
||||
});
|
||||
elm.addEventListener("keydown", evt => {
|
||||
if (evt.keyCode == 13 || evt.keyCode == 32) {
|
||||
log_show_details(evt.currentTarget);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
|
@ -1,7 +1,7 @@
|
|||
<div id="adminpage">
|
||||
<h1>{{$title}} - {{$page}}</h1>
|
||||
|
||||
<h3>{{$logname}}</h3>
|
||||
<h2>{{$logname}}</h2>
|
||||
{{if $error }}
|
||||
<div id="admin-error-message-wrapper" class="alert alert-warning">
|
||||
<p>{{$error nofilter}}</p>
|
||||
|
@ -44,14 +44,18 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{foreach $data as $row}}
|
||||
<tr id="ev-{{$row->id}}" onClick="log_show_details('ev-{{$row->id}}')">
|
||||
<tr id="ev-{{$row->id}}" class="log-event"
|
||||
role="button" tabIndex="0"
|
||||
aria-label="View details" aria-haspopup="true" aria-expanded="false"
|
||||
style="cursor:pointer;"
|
||||
title="Click to view details">
|
||||
<td>{{$row->date}}</td>
|
||||
<td>{{$row->level}}</td>
|
||||
<td>{{$row->context}}</td>
|
||||
<td>{{$row->message}}</td>
|
||||
</tr>
|
||||
<tr class="hidden" data-id="ev-{{$row->id}}"><th colspan="4">Data</th></tr>
|
||||
{{foreach $row->get_data() as $k=>$v}}
|
||||
{{foreach $row->getData() as $k=>$v}}
|
||||
<tr class="hidden" data-id="ev-{{$row->id}}">
|
||||
<th>{{$k}}</th>
|
||||
<td colspan="3">
|
||||
|
@ -60,7 +64,7 @@
|
|||
</tr>
|
||||
{{/foreach}}
|
||||
<tr class="hidden" data-id="ev-{{$row->id}}"><th colspan="4">Source</th></tr>
|
||||
{{foreach $row->get_source() as $k=>$v}}
|
||||
{{foreach $row->getSource() as $k=>$v}}
|
||||
<tr class="hidden" data-id="ev-{{$row->id}}">
|
||||
<th>{{$k}}</th>
|
||||
<td colspan="3">{{$v}}</td>
|
||||
|
|
|
@ -98,6 +98,13 @@ details summary {
|
|||
display: list-item;
|
||||
}
|
||||
|
||||
/**
|
||||
* clickable table rows
|
||||
*/
|
||||
.table > tbody > td[role="button"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* mobile aside
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,12 @@ $(function(){
|
|||
$(".log-event").on("click", function(ev) {
|
||||
show_details_for_element(ev.currentTarget);
|
||||
});
|
||||
$(".log-event").on("keydown", function(ev) {
|
||||
if (ev.keyCode == 13 || ev.keyCode == 32) {
|
||||
show_details_for_element(ev.currentTarget);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("[data-previous").on("click", function(ev){
|
||||
var currentid = document.getElementById("logdetail").dataset.rowId;
|
||||
|
@ -37,9 +43,15 @@ $(function(){
|
|||
});
|
||||
|
||||
|
||||
function show_details_for_element(element) {
|
||||
var $modal = $("#logdetail");
|
||||
const $modal = $("#logdetail");
|
||||
|
||||
$modal.on("hidden.bs.modal", function(ev){
|
||||
document
|
||||
.querySelectorAll('[aria-expanded="true"]')
|
||||
.forEach(elm => elm.setAttribute("aria-expanded", false))
|
||||
});
|
||||
|
||||
function show_details_for_element(element) {
|
||||
$modal[0].dataset.rowId = element.id;
|
||||
|
||||
var tr = $modal.find(".main-data tbody tr")[0];
|
||||
|
@ -64,6 +76,7 @@ $(function(){
|
|||
$("[data-next").prop("disabled", $(element).next().length == 0);
|
||||
|
||||
$modal.modal({})
|
||||
element.setAttribute("aria-expanded", true);
|
||||
}
|
||||
|
||||
function recursive_details(s, data, lev=0) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="adminpage">
|
||||
<h1>{{$title}} - {{$page}}</h1>
|
||||
|
||||
<h3>{{$logname}}</h3>
|
||||
<h2>{{$logname}}</h2>
|
||||
{{if $error }}
|
||||
<div id="admin-error-message-wrapper" class="alert alert-warning">
|
||||
<p>{{$error nofilter}}</p>
|
||||
|
@ -59,7 +59,9 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{foreach $data as $row}}
|
||||
<tr id="ev-{{$row->id}}" class="log-event"
|
||||
<tr id="ev-{{$row->id}}" class="log-event"
|
||||
role="button" tabIndex="0"
|
||||
aria-label="View details" aria-haspopup="true" aria-expanded="false"
|
||||
data-data="{{$row->data}}" data-source="{{$row->source}}">
|
||||
<td>{{$row->date}}</td>
|
||||
<td class="
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue