2021-03-27 18:36:55 +01:00
|
|
|
$(function(){
|
2021-05-25 14:10:36 +02:00
|
|
|
|
|
|
|
/* column filter */
|
|
|
|
$("a[data-filter]").on("click", function(ev) {
|
|
|
|
var filter = this.dataset.filter;
|
|
|
|
var value = this.dataset.filterValue;
|
|
|
|
var re = RegExp(filter+"=[a-z]*");
|
|
|
|
var newhref = location.href;
|
2022-12-09 22:24:37 +01:00
|
|
|
if (location.href.indexOf("?") < 0) {
|
2021-05-25 14:10:36 +02:00
|
|
|
newhref = location.href + "?" + filter + "=" + value;
|
|
|
|
} else if (location.href.match(re)) {
|
|
|
|
newhref = location.href.replace(RegExp(filter+"=[a-z]*"), filter+"="+value);
|
|
|
|
} else {
|
|
|
|
newhref = location.href + "&" + filter + "=" + value;
|
|
|
|
}
|
|
|
|
location.href = newhref;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
/* log details dialog */
|
2021-03-27 18:36:55 +01:00
|
|
|
$(".log-event").on("click", function(ev) {
|
2021-05-25 14:10:36 +02:00
|
|
|
show_details_for_element(ev.currentTarget);
|
|
|
|
});
|
2021-08-20 09:47:53 +02:00
|
|
|
$(".log-event").on("keydown", function(ev) {
|
|
|
|
if (ev.keyCode == 13 || ev.keyCode == 32) {
|
|
|
|
show_details_for_element(ev.currentTarget);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-05-25 14:10:36 +02:00
|
|
|
|
|
|
|
$("[data-previous").on("click", function(ev){
|
|
|
|
var currentid = document.getElementById("logdetail").dataset.rowId;
|
|
|
|
var $elm = $("#" + currentid).prev();
|
|
|
|
if ($elm.length == 0) return;
|
|
|
|
show_details_for_element($elm[0]);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("[data-next").on("click", function(ev){
|
|
|
|
var currentid = document.getElementById("logdetail").dataset.rowId;
|
|
|
|
var $elm = $("#" + currentid).next();
|
|
|
|
if ($elm.length == 0) return;
|
|
|
|
show_details_for_element($elm[0]);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-08-20 09:47:53 +02:00
|
|
|
const $modal = $("#logdetail");
|
2021-03-27 18:36:55 +01:00
|
|
|
|
2021-08-20 09:47:53 +02:00
|
|
|
$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) {
|
2021-05-25 14:10:36 +02:00
|
|
|
$modal[0].dataset.rowId = element.id;
|
|
|
|
|
|
|
|
var tr = $modal.find(".main-data tbody tr")[0];
|
|
|
|
tr.innerHTML = element.innerHTML;
|
|
|
|
|
|
|
|
var data = JSON.parse(element.dataset.source);
|
2021-03-27 18:36:55 +01:00
|
|
|
$modal.find(".source-data td").each(function(i,elm){
|
|
|
|
var k = elm.dataset.value;
|
|
|
|
elm.innerText = data[k];
|
|
|
|
});
|
|
|
|
|
|
|
|
var elm = $modal.find(".event-data")[0];
|
2022-07-28 18:06:31 +02:00
|
|
|
const event_data_header = $modal.find(".event-data-header")[0];
|
|
|
|
|
|
|
|
// Cleanup event data
|
|
|
|
event_data_header.hidden = true;
|
2021-03-27 18:36:55 +01:00
|
|
|
elm.innerHTML = "";
|
2022-07-28 18:06:31 +02:00
|
|
|
|
|
|
|
// Fill out event data
|
2021-05-25 14:10:36 +02:00
|
|
|
var data = element.dataset.data;
|
2021-03-27 18:36:55 +01:00
|
|
|
if (data !== "") {
|
2022-07-28 18:06:31 +02:00
|
|
|
event_data_header.hidden = false;
|
2021-03-27 18:36:55 +01:00
|
|
|
data = JSON.parse(data);
|
|
|
|
elm.innerHTML += recursive_details("", data);
|
|
|
|
}
|
|
|
|
|
2021-05-25 14:10:36 +02:00
|
|
|
$("[data-previous").prop("disabled", $(element).prev().length == 0);
|
|
|
|
$("[data-next").prop("disabled", $(element).next().length == 0);
|
|
|
|
|
2021-03-27 18:36:55 +01:00
|
|
|
$modal.modal({})
|
2021-08-20 09:47:53 +02:00
|
|
|
element.setAttribute("aria-expanded", true);
|
2021-05-25 14:10:36 +02:00
|
|
|
}
|
2021-03-27 18:36:55 +01:00
|
|
|
|
|
|
|
function recursive_details(s, data, lev=0) {
|
|
|
|
for(var k in data) {
|
|
|
|
if (data.hasOwnProperty(k)) {
|
|
|
|
var v = data[k];
|
|
|
|
var open = lev > 1 ? "" : "open";
|
|
|
|
s += "<details " + open + "><summary>" + k + "</summary>";
|
|
|
|
if (typeof v === 'object' && v !== null) {
|
|
|
|
s = recursive_details(s, v, lev+1);
|
|
|
|
} else {
|
|
|
|
s += $("<pre>").text(v)[0].outerHTML;
|
|
|
|
}
|
|
|
|
s += "</details>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
});
|