mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-07 06:37:44 +02:00
event log: add pagination
This commit is contained in:
parent
9fdeb58fd3
commit
10392ecc28
@ -23,42 +23,7 @@ class Pref_System extends Handler_Protected {
|
||||
$this->pdo->query("DELETE FROM ttrss_error_log");
|
||||
}
|
||||
|
||||
function index() {
|
||||
|
||||
$severity = isset($_REQUEST["severity"]) ? (int) clean($_REQUEST["severity"]) : E_USER_WARNING;
|
||||
|
||||
print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
|
||||
print "<div dojoType='dijit.layout.AccordionPane' style='padding : 0'
|
||||
title='<i class=\"material-icons\">report</i> ".__('Event Log')."'>";
|
||||
|
||||
if (LOG_DESTINATION == "sql") {
|
||||
|
||||
print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
|
||||
|
||||
print "<div region='top' dojoType='fox.Toolbar'>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.updateEventLog()'>".__('Refresh')."</button>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.clearEventLog()'>".__('Clear')."</button>";
|
||||
|
||||
print "<div class='pull-right'>";
|
||||
|
||||
print __("Severity:") . " ";
|
||||
print_select_hash("severity", $severity,
|
||||
[
|
||||
E_USER_ERROR => __("Errors"),
|
||||
E_USER_WARNING => __("Warnings"),
|
||||
E_USER_NOTICE => __("Everything")
|
||||
], 'dojoType="fox.form.Select" onchange="Helpers.updateEventLog()"');
|
||||
|
||||
print "</div>"; # pull-right
|
||||
|
||||
print "</div>"; # toolbar
|
||||
|
||||
print '<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">';
|
||||
|
||||
private function log_viewer(int $page, int $severity) {
|
||||
print "<table width='100%' cellspacing='10' class='prefErrorLog'>";
|
||||
|
||||
print "<tr class='title'>
|
||||
@ -87,6 +52,9 @@ class Pref_System extends Handler_Protected {
|
||||
$errno_filter_qpart = "true";
|
||||
}
|
||||
|
||||
$limit = 10;
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sth = $this->pdo->prepare("SELECT
|
||||
errno, errstr, filename, lineno, created_at, login, context
|
||||
FROM
|
||||
@ -95,7 +63,7 @@ class Pref_System extends Handler_Protected {
|
||||
$errno_filter_qpart
|
||||
ORDER BY
|
||||
ttrss_error_log.id DESC
|
||||
LIMIT 100");
|
||||
LIMIT $limit OFFSET $offset");
|
||||
|
||||
$sth->execute($errno_values);
|
||||
|
||||
@ -118,6 +86,55 @@ class Pref_System extends Handler_Protected {
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
function index() {
|
||||
|
||||
$severity = (int) ($_REQUEST["severity"] ?? E_USER_WARNING);
|
||||
$page = (int) ($_REQUEST["page"] ?? 0);
|
||||
|
||||
print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
|
||||
print "<div dojoType='dijit.layout.AccordionPane' style='padding : 0'
|
||||
title='<i class=\"material-icons\">report</i> ".__('Event Log')."'>";
|
||||
|
||||
if (LOG_DESTINATION == "sql") {
|
||||
|
||||
print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
|
||||
|
||||
print "<div region='top' dojoType='fox.Toolbar'>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.EventLog.refresh()'>".__('Refresh')."</button>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.EventLog.prevPage()'>".__('<<')."</button>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button' disabled>".T_sprintf('Page %d', $page+1)."</button>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.EventLog.nextPage()'>".__('>>')."</button>";
|
||||
|
||||
print "<button dojoType='dijit.form.Button'
|
||||
onclick='Helpers.EventLog.clear()'>".__('Clear')."</button>";
|
||||
|
||||
print "<div class='pull-right'>";
|
||||
|
||||
print __("Severity:") . " ";
|
||||
print_select_hash("severity", $severity,
|
||||
[
|
||||
E_USER_ERROR => __("Errors"),
|
||||
E_USER_WARNING => __("Warnings"),
|
||||
E_USER_NOTICE => __("Everything")
|
||||
], 'dojoType="fox.form.Select" onchange="Helpers.updateEventLog()"');
|
||||
|
||||
print "</div>"; # pull-right
|
||||
|
||||
print "</div>"; # toolbar
|
||||
|
||||
print '<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">';
|
||||
|
||||
$this->log_viewer($page, $severity);
|
||||
|
||||
} else {
|
||||
print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ class Sanitizer {
|
||||
}
|
||||
|
||||
public static function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) {
|
||||
if (!$owner) $owner = $_SESSION["uid"];
|
||||
|
||||
if (!$owner && isset($_SESSION["uid"]))
|
||||
$owner = $_SESSION["uid"];
|
||||
|
||||
$res = trim($str); if (!$res) return '';
|
||||
|
||||
|
@ -11,11 +11,11 @@ function format_backtrace($trace) {
|
||||
if (is_array($e["args"])) {
|
||||
foreach ($e["args"] as $a) {
|
||||
if (is_object($a)) {
|
||||
array_push($fmt_args, "[" . get_class($a) . "]");
|
||||
array_push($fmt_args, "{" . get_class($a) . "}");
|
||||
} else if (is_array($a)) {
|
||||
array_push($fmt_args, "[" . truncate_string(json_encode($a), 128, "...")) . "]";
|
||||
array_push($fmt_args, "[" . truncate_string(json_encode($a), 256, "...")) . "]";
|
||||
} else {
|
||||
array_push($fmt_args, $a);
|
||||
array_push($fmt_args, truncate_string($a, 256, "..."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,22 +50,38 @@ const Helpers = {
|
||||
|
||||
return false;
|
||||
},
|
||||
updateEventLog: function() {
|
||||
xhrPost("backend.php", { op: "pref-system", severity: dijit.byId("severity").attr('value') }, (transport) => {
|
||||
EventLog: {
|
||||
log_page: 0,
|
||||
refresh: function() {
|
||||
this.log_page = 0;
|
||||
this.update();
|
||||
},
|
||||
update: function() {
|
||||
xhrPost("backend.php", { op: "pref-system", severity: dijit.byId("severity").attr('value'), page: Helpers.EventLog.log_page }, (transport) => {
|
||||
dijit.byId('systemConfigTab').attr('content', transport.responseText);
|
||||
Notify.close();
|
||||
});
|
||||
},
|
||||
clearEventLog: function() {
|
||||
nextPage: function() {
|
||||
this.log_page += 1;
|
||||
this.update();
|
||||
},
|
||||
prevPage: function() {
|
||||
if (this.log_page > 0) this.log_page -= 1;
|
||||
|
||||
this.update();
|
||||
},
|
||||
clear: function() {
|
||||
if (confirm(__("Clear event log?"))) {
|
||||
|
||||
Notify.progress("Loading, please wait...");
|
||||
|
||||
xhrPost("backend.php", {op: "pref-system", method: "clearLog"}, () => {
|
||||
this.updateEventLog();
|
||||
Helpers.EventLog.refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
editProfiles: function() {
|
||||
|
||||
if (dijit.byId("profileEditDlg"))
|
||||
|
Loading…
Reference in New Issue
Block a user