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;
|
|
|
|
if (!location.href.indexOf("?") < 0) {
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("[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]);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function show_details_for_element(element) {
|
2021-03-27 18:36:55 +01:00
|
|
|
var $modal = $("#logdetail");
|
|
|
|
|
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];
|
|
|
|
elm.innerHTML = "";
|
2021-05-25 14:10:36 +02:00
|
|
|
var data = element.dataset.data;
|
2021-03-27 18:36:55 +01:00
|
|
|
if (data !== "") {
|
|
|
|
elm.innerHTML = "<h3>Data</h3>";
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
});
|