From 15f49de80fad83306c9cc3fc7cf0059eb145d521 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 16 Jan 2025 14:46:59 +0100 Subject: [eventlog] Cosmetic changes; nicer UI, sorting, warning, etc. --- modules-available/eventlog/lang/de/template-tags.json | 1 + modules-available/eventlog/lang/en/template-tags.json | 1 + modules-available/eventlog/pages/rules.inc.php | 9 ++++++--- .../eventlog/templates/page-filters-edit-rule.html | 8 ++++++++ .../eventlog/templates/page-filters-rules.html | 16 +++++++++++----- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/modules-available/eventlog/lang/de/template-tags.json b/modules-available/eventlog/lang/de/template-tags.json index 8919d248..286f3f1c 100644 --- a/modules-available/eventlog/lang/de/template-tags.json +++ b/modules-available/eventlog/lang/de/template-tags.json @@ -41,6 +41,7 @@ "lang_messageTemplate": "Nachrichtenvorlage", "lang_messageTemplateHelp": "Sie k\u00f6nnen mittels der Platzhalter %0%, %1%, etc. Bezug auf die Filter oben nehmen. F\u00fcr Filter vom Typ \"regex\" k\u00f6nnen Sie sich mittels %n:1%, %n:2% etc. auf die \"Capture Groups\" des Regul\u00e4ren Ausdrucks beziehen. Des Weiteren k\u00f6nnen numerische Werte durch Suffixe formatiert\/in lesbare Form umgewandelt werden. Geben Sie durch das Suffix an, welche Einheit die zu formatierende Zahl hat: \"b\", \"kb\", \"mb\", \"gb\" f\u00fcr Bytes (resp. Kilo, Mega, etc.), \"ts\" als Unix-Timestamp, \"d\" als Dauer in Sekunden, \"L\" f\u00fcr eine Location-ID.", "lang_noMailConfig": "Keine EMail-Konfiguration", + "lang_noticeEditingExample": "Dies ist ein Beispielfilter. Es wird empfohlen, diese Regel nicht zu editieren oder zu l\u00f6schen, sondern stattdessen eine Kopie zu erstellen.", "lang_optionalDescription": "Beschreibung (als Referenz, wird nicht f\u00fcr die Verarbeitung verwendet)", "lang_port": "Port", "lang_postUseSUBJECTandTEXThint": "Sie k\u00f6nnen die Platzhalter %SUBJECT% und %TEXT% verwenden, die entsprechend des ausgew\u00e4hlten POST-Formats escaped werden.", diff --git a/modules-available/eventlog/lang/en/template-tags.json b/modules-available/eventlog/lang/en/template-tags.json index 1e92eb68..e4cad4a1 100644 --- a/modules-available/eventlog/lang/en/template-tags.json +++ b/modules-available/eventlog/lang/en/template-tags.json @@ -41,6 +41,7 @@ "lang_messageTemplate": "Message template", "lang_messageTemplateHelp": "You can refer to the matched rules above by using their index in percentage-signs, like %0%, %1%, etc. If you use a regex with capture groups, you can refer to them individually by using %n:1%, %n:2% etc. Furthermode, you can format raw numbers by appending \"b\", \"kb\", \"mb\", \"gb\" to interpret the given value as bytes (or kilobytes, megabytes, etc.), \"ts\" if the input value is a unix timestamp, \"d\" to turn a duration in seconds into human readable format, and \"L\" to turn a location id into the according location name.", "lang_noMailConfig": "No mail config", + "lang_noticeEditingExample": "This is an example filter. It's recommended you don't edit or delete it, but instead create a copy first.", "lang_optionalDescription": "Description (for reference only)", "lang_port": "Port", "lang_postUseSUBJECTandTEXThint": "Use %SUBJECT% and %TEXT% placeholders which will be escaped properly, according to chosen POST format.", diff --git a/modules-available/eventlog/pages/rules.inc.php b/modules-available/eventlog/pages/rules.inc.php index 7b43cfdb..ca39b15b 100644 --- a/modules-available/eventlog/pages/rules.inc.php +++ b/modules-available/eventlog/pages/rules.inc.php @@ -96,12 +96,13 @@ class SubPage } else { // LIST $data = []; - $data['filters'] = Database::queryAll('SELECT ruleid, type, title, datafilter, + $data['filters'] = Database::queryAll('SELECT ruleid, type, title, description, datafilter, Count(transportid) AS useCount FROM notification_rule LEFT JOIN notification_rule_x_transport sfxb USING (ruleid) GROUP BY ruleid, title - ORDER BY title, ruleid'); + ORDER BY SIGN(Count(transportid)) DESC, title, ruleid'); + //usort($data['filters']) Permission::addGlobalTags($data['perms'], null, ['filter.rules.edit']); Render::addTemplate('page-filters-rules', $data); } @@ -117,15 +118,17 @@ class SubPage $filterIdx = 0; $knownIdxList = []; if ($id !== 0) { - $data = Database::queryFirst('SELECT ruleid, title, description, type, datafilter, subject, message + $data = Database::queryFirst('SELECT ruleid, title, description, type, datafilter, subject, message, predefid FROM notification_rule WHERE ruleid = :id', ['id' => $id]); if ($data === false) { Message::addError('invalid-rule-id', $id); Util::redirect('?do=eventlog&show=rules'); } + $data['edit_warn'] = $data['predefid'] !== null; if (Request::get('copy', false, 'bool')) { $data['ruleid'] = 0; $data['title'] = ''; + $data['edit_warn'] = false; } $list = json_decode($data['datafilter'], true); if (!is_array($list['list'])) { diff --git a/modules-available/eventlog/templates/page-filters-edit-rule.html b/modules-available/eventlog/templates/page-filters-edit-rule.html index 42d601f2..1ffd73c7 100644 --- a/modules-available/eventlog/templates/page-filters-edit-rule.html +++ b/modules-available/eventlog/templates/page-filters-edit-rule.html @@ -6,6 +6,14 @@ {{lang_createFilter}} {{/ruleid}} +{{#edit_warn}} +
+ + + + {{lang_noticeEditingExample}} +
+{{/edit_warn}}

{{title}}

{{lang_filterExampleHelpText}}

diff --git a/modules-available/eventlog/templates/page-filters-rules.html b/modules-available/eventlog/templates/page-filters-rules.html index 56bf0871..680b71d8 100644 --- a/modules-available/eventlog/templates/page-filters-rules.html +++ b/modules-available/eventlog/templates/page-filters-rules.html @@ -7,7 +7,6 @@ {{lang_id}} {{lang_type}} {{lang_title}} - {{lang_edit}} @@ -15,10 +14,17 @@ {{#filters}} - {{ruleid}} - {{type}} - {{title}} - {{useCount}} + {{ruleid}} + {{type}} + + {{title}} +
{{description}}
+ + + {{#useCount}} + {{useCount}} + {{/useCount}} + -- cgit v1.2.3-55-g7522