Skip to content

Commit c2a1cdb

Browse files
committed
Activity UI: Add display and filtering support for general notices, warnings, errors, and criticals.
- Show "host" in table in case IP is not available - Add new "Server Info" section in action report dialog. "Client Info" section is now optionally hidden. - Add "Details" section in action report dialog.
1 parent 3a1035f commit c2a1cdb

2 files changed

Lines changed: 41 additions & 9 deletions

File tree

htdocs/css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,9 @@ div.td_big {
12061206
.data_grid > ul.grid_row.error > div {
12071207
background: color-mix(in srgb, var(--red) 20%, transparent) !important;
12081208
}
1209+
.data_grid > ul.grid_row.critical > div {
1210+
background: color-mix(in srgb, var(--purple) 20%, transparent) !important;
1211+
}
12091212
.data_grid > ul.grid_row.highlight > div {
12101213
background: color-mix(in srgb, var(--theme-color-highlight) 20%, transparent) !important;
12111214
}

htdocs/js/pages/admin/Activity.class.js

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
3434
if (!args.offset) args.offset = 0;
3535
if (!args.limit) args.limit = config.items_per_page;
3636

37-
var action_items = [].concat( config.ui.list_list ).concat([
37+
var action_items = [].concat( deep_copy_object(config.ui.list_list) ).concat([
3838
{ "id": "jobs", "title": "Jobs", "icon": "timer-outline" },
3939
{ "id": "tickets", "title": "Tickets", "icon": "text-box-outline" },
4040
{ "id": "servers", "title": "Servers", "icon": "router-network" },
@@ -43,6 +43,12 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
4343
]);
4444
sort_by( action_items, 'title' );
4545

46+
action_items[0].group = 'Categories:';
47+
action_items.unshift({ id: 'critical', title: "Critical", icon: "fire-alert" });
48+
action_items.unshift({ id: 'error', title: "Errors", icon: "alert-decagram" });
49+
action_items.unshift({ id: 'warning', title: "Warnings", icon: "alert-rhombus" });
50+
action_items.unshift({ id: 'notice', title: "Notices", icon: "information-outline", group: "General:" });
51+
4652
var date_items = config.ui.date_range_menu_items;
4753

4854
var html = '';
@@ -212,7 +218,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
212218
var self = this;
213219
var query = args.query ? args.query.toString().toLowerCase().trim() : '';
214220

215-
if (args.action) {
221+
if (args.action && config.ui.activity_search_map[args.action]) {
216222
// each action is an alias -- lookup the individual actions for the query
217223
var re = new RegExp( config.ui.activity_search_map[args.action] || '.+' );
218224
var keys = [];
@@ -221,6 +227,9 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
221227
}
222228
if (keys.length) query += ' action:' + keys.join('|');
223229
}
230+
else if (args.action && args.action.match(/^(notice|warning|error|critical)$/)) {
231+
query += ' action:' + args.action;
232+
}
224233

225234
if (args.username) {
226235
query += ' keywords:' + args.username.replace(/\W/g, '_');
@@ -277,7 +286,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
277286

278287
var grid_args = {
279288
resp: resp,
280-
cols: ['Date/Time', 'Type', 'Description', 'User', 'IP Address', 'Actions'],
289+
cols: ['Date/Time', 'Type', 'Description', 'User', 'IP / Host', 'Actions'],
281290
data_type: 'item',
282291
offset: this.args.offset || 0,
283292
limit: this.args.limit,
@@ -469,7 +478,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
469478
// misc
470479
case 'error':
471480
desc = encode_entities( item.description );
472-
color = 'red';
481+
color = 'error';
473482
click = `$P().showActionReport(${idx},'unused')`;
474483
actions.push(`<button class="link" onClick="${click}"><b>Details...</b></button>`);
475484
break;
@@ -479,6 +488,12 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
479488
click = `$P().showActionReport(${idx},'unused')`;
480489
actions.push(`<button class="link" onClick="${click}"><b>Details...</b></button>`);
481490
break;
491+
case 'critical':
492+
desc = encode_entities( item.description );
493+
color = 'critical';
494+
click = `$P().showActionReport(${idx},'unused')`;
495+
actions.push(`<button class="link" onClick="${click}"><b>Details...</b></button>`);
496+
break;
482497
case 'notice':
483498
desc = encode_entities( item.description );
484499
click = `$P().showActionReport(${idx},'unused')`;
@@ -495,7 +510,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
495510
'<div class="td_big" style="white-space:nowrap; font-weight:normal;"><i class="mdi mdi-' + item_type.icon + '">&nbsp;</i>' + item_type.label + '</div>',
496511
'' + desc + '',
497512
'' + self.getNiceUser(item.admin || item.username, true) + '',
498-
self.getNiceIP(item.ip),
513+
item.ip ? self.getNiceIP(item.ip) : (item.hostname ? app.formatHostname(item.hostname) : 'n/a'),
499514
actions.join(' | ') || '&nbsp;'
500515
];
501516
if (color) tds.className = color;
@@ -545,10 +560,18 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
545560
md += '- **Date/Time:** ' + this.getRelativeDateTime(item.epoch).replace(/\&nbsp;<\/i>/g, '</i>') + "\n";
546561

547562
// user info
548-
md += "\n### Client Info\n\n";
549-
md += '- **User:** ' + this.getNiceUser(item.admin || item.username, true) + "\n";
550-
md += '- **IP Addresses:** ' + (item.ips.join(', ') || 'n/a') + "\n";
551-
md += '- **User Agent:** ' + (item.useragent || 'Unknown') + "\n";
563+
if (item.admin || item.username || item.ips.length || item.useragent) {
564+
md += "\n### Client Info\n\n";
565+
md += '- **User:** ' + this.getNiceUser(item.admin || item.username, true) + "\n";
566+
md += '- **IP Addresses:** ' + (item.ips.join(', ') || 'n/a') + "\n";
567+
md += '- **User Agent:** ' + (item.useragent || 'Unknown') + "\n";
568+
}
569+
if (item.server || item.hostname) {
570+
md += "\n### Server Info\n\n";
571+
md += '- **Server ID:** ' + (item.server || 'n/a') + "\n";
572+
md += '- **Hostname:** ' + app.formatHostname(item.hostname || 'n/a') + "\n";
573+
md += '- **IP Address:** ' + (item.ip || 'n/a') + "\n";
574+
}
552575

553576
// headers
554577
if (item.headers) {
@@ -560,6 +583,11 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
560583
md += '```' + "\n";
561584
}
562585

586+
// details
587+
if (item.details) {
588+
md += "\n### Details\n\n" + item.details.trim() + "\n";
589+
}
590+
563591
// the thing
564592
if (item[obj_key]) {
565593
md += "\n### " + item._type.label + " JSON\n\n";
@@ -570,6 +598,7 @@ Page.ActivityLog = class ActivityLog extends Page.PageUtils {
570598
else {
571599
var temp = deep_copy_object(item);
572600
delete temp.headers;
601+
delete temp.details;
573602
delete temp._type;
574603
delete temp._desc;
575604

0 commit comments

Comments
 (0)