From 5e5d9db1b3415b1b578468e9d39f0b97dfa93d77 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Tue, 25 May 2021 14:10:36 +0200 Subject: [PATCH] logs view: update frio template add search and filter columns support. add "prev/next" buttons to details popup --- view/theme/frio/js/module/admin/logs/view.js | 58 ++++++++++++++++--- view/theme/frio/templates/admin/logs/view.tpl | 53 +++++++++++++++-- 2 files changed, 99 insertions(+), 12 deletions(-) diff --git a/view/theme/frio/js/module/admin/logs/view.js b/view/theme/frio/js/module/admin/logs/view.js index fc19af28a..149d019e9 100644 --- a/view/theme/frio/js/module/admin/logs/view.js +++ b/view/theme/frio/js/module/admin/logs/view.js @@ -1,10 +1,51 @@ $(function(){ - $(".log-event").on("click", function(ev) { - var $modal = $("#logdetail"); - var tr = $modal.find(".main-data tbody tr")[0]; - tr.innerHTML = ev.currentTarget.innerHTML; - var data = JSON.parse(ev.currentTarget.dataset.source); + /* 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 */ + $(".log-event").on("click", function(ev) { + 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) { + var $modal = $("#logdetail"); + + $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); $modal.find(".source-data td").each(function(i,elm){ var k = elm.dataset.value; elm.innerText = data[k]; @@ -12,15 +53,18 @@ $(function(){ var elm = $modal.find(".event-data")[0]; elm.innerHTML = ""; - var data = ev.currentTarget.dataset.data; + var data = element.dataset.data; if (data !== "") { elm.innerHTML = "

Data

"; data = JSON.parse(data); elm.innerHTML += recursive_details("", data); } + $("[data-previous").prop("disabled", $(element).prev().length == 0); + $("[data-next").prop("disabled", $(element).next().length == 0); + $modal.modal({}) - }) + } function recursive_details(s, data, lev=0) { for(var k in data) { diff --git a/view/theme/frio/templates/admin/logs/view.tpl b/view/theme/frio/templates/admin/logs/view.tpl index 99a96befd..1bc026916 100755 --- a/view/theme/frio/templates/admin/logs/view.tpl +++ b/view/theme/frio/templates/admin/logs/view.tpl @@ -6,13 +6,54 @@

{{$error nofilter}}

- {{else}} + {{else}} +
+
+ +
+
+ Show all +
+
+ - - + + @@ -28,14 +69,14 @@ {{elseif $row->level == "NOTICE"}}bg-info {{elseif $row->level == "DEBUG"}}text-muted {{/if}} - ">{{$row->level}} + ">{{$row->level}} {{/foreach}}
DateLevelContext + + + + + + Message
{{$row->context}} {{$row->message}}
- {{/if}} + {{/if}}