Skip to content

Commit 2123f65

Browse files
committed
Allow filtering by ID, URL, note, pipeline or nick
Default to enabling them all, allow and default enable nick filtering when nicks shown.
1 parent 638a7d6 commit 2123f65

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

dashboard/assets/scripts/dashboard.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,13 @@ class JobsRenderer {
684684
this.firstFilterMatch = null;
685685
for (const job of this.jobs.sorted) {
686686
const w = this.renderInfo[job.ident].logWindow;
687-
if (!query.test(job.url)) {
687+
const show =
688+
(byId("filter-job-id").checked && query.test(job.ident)) ||
689+
(byId("filter-job-url").checked && query.test(job.url)) ||
690+
(byId("filter-job-note").checked && query.test(job.note)) ||
691+
(byId("filter-job-pipeline").checked && (query.test(job.pipeline_id) || query.test(this.pipelines[job.pipeline_id]))) ||
692+
(this.showNicks && byId("filter-job-nick").checked && query.test(job.started_by));
693+
if (!show) {
688694
w.classList.add("log-window-hidden");
689695

690696
unmatchedWindows.push(w);
@@ -1077,6 +1083,11 @@ class Dashboard {
10771083
const showNicks = args.showNicks ? Boolean(Number(args.showNicks)) : false;
10781084
const contextMenu = args.contextMenu ? Boolean(Number(args.contextMenu)) : true;
10791085
this.initialFilter = args.initialFilter ?? "^$";
1086+
const filterJobID = args.filterJobID ? Boolean(Number(args.filterJobID)) : true;
1087+
const filterJobURL = args.filterJobURL ? Boolean(Number(args.filterJobURL)) : true;
1088+
const filterJobNote = args.filterJobNote ? Boolean(Number(args.filterJobNote)) : true;
1089+
const filterJobPipe = args.filterJobPipe ? Boolean(Number(args.filterJobPipe)) : true;
1090+
const filterJobNick = args.filterJobNick ? Boolean(Number(args.filterJobNick)) : true;
10801091
const showAllHeaders = args.showAllHeaders ? Boolean(Number(args.showAllHeaders)) : true;
10811092
const showRunningJobs = args.showRunningJobs ? Boolean(Number(args.showRunningJobs)) : true;
10821093
const showFinishedJobs = args.showFinishedJobs ? Boolean(Number(args.showFinishedJobs)) : true;
@@ -1135,6 +1146,29 @@ class Dashboard {
11351146

11361147
if (!showNicks) {
11371148
addPageStyles(".job-nick-aligned { width: 0; }");
1149+
} else {
1150+
byId("filter-types").lastChild.after(
1151+
h("input", {
1152+
type: "checkbox",
1153+
id: "filter-job-nick",
1154+
onclick: () => { ds.jobsRenderer.applyFilter(); },
1155+
checked: true,
1156+
})
1157+
);
1158+
byId("filter-types").lastChild.after("\n\t\t\t");
1159+
byId("filter-types").lastChild.after(
1160+
h("label", { className: "filter-job", htmlFor: "filter-job-nick", textContent: "Nick" }),
1161+
);
1162+
byId("filter-types").lastChild.after(h("br"));
1163+
byId("filter-types").lastChild.after("\n");
1164+
}
1165+
1166+
byId("filter-job-id").checked = filterJobID;
1167+
byId("filter-job-url").checked = filterJobURL;
1168+
byId("filter-job-note").checked = filterJobNote;
1169+
byId("filter-job-pipeline").checked = filterJobPipe;
1170+
if (showNicks) {
1171+
byId("filter-job-nick").checked = filterJobNick;
11381172
}
11391173

11401174
if (args.initialFilter != null) {
@@ -1320,6 +1354,12 @@ ${String(kbPerSec).padStart(3, "0")} KB/s`;
13201354
ds.showFatalJobs(!byId("show-fatal-jobs").checked);
13211355
} else if (ev.which === 115 /* s */) {
13221356
ds.showAbortedJobs(!byId("show-aborted-jobs").checked);
1357+
} else if (ev.which === 117 /* u */) {
1358+
byId("filter-job-url").click();
1359+
} else if (ev.which === 101 /* e */) {
1360+
byId("filter-job-note").click();
1361+
} else if (ev.which === 112 /* p */) {
1362+
byId("filter-job-pipeline").click();
13231363
}
13241364
}
13251365

dashboard/dashboard.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
float: inline-start;
6666
}
6767

68+
#filter-details {
69+
display: inline flex;
70+
}
71+
72+
#filter-types {
73+
float: inline-start;
74+
}
75+
6876
.padded-page {
6977
padding: 20px 27px 20px 27px;
7078
}
@@ -451,7 +459,21 @@
451459
<a href="https://wiki.archiveteam.org/index.php?title=ArchiveBot" class="underlined-a">ArchiveBot</a>
452460
tracking <span id="num-crawls">0</span> crawls.
453461
See also <a href="pipelines" class="underlined-a">pipeline</a> or <a href="logs/recent" class="underlined-a">job</a> reports.
454-
Logs <input id="filter-box" type="text" size="21" title="Show logs for jobs matching this regular expression. For example ^https?://.*">
462+
<details id="filter-details">
463+
<summary>Logs</summary>
464+
<div id="filter-types">
465+
Search:<br>
466+
<input type="checkbox" id="filter-job-id" onclick="ds.jobsRenderer.applyFilter();" checked>
467+
<label class="filter-job" for="filter-job-id">ID</label><br>
468+
<input type="checkbox" id="filter-job-url" onclick="ds.jobsRenderer.applyFilter();" accesskey="u" checked>
469+
<label class="filter-job" for="filter-job-url">URL</label><br>
470+
<input type="checkbox" id="filter-job-note" onclick="ds.jobsRenderer.applyFilter();" accesskey="e" checked>
471+
<label class="filter-job" for="filter-job-note" title="Explain">Note</label><br>
472+
<input type="checkbox" id="filter-job-pipeline" onclick="ds.jobsRenderer.applyFilter();" accesskey="p" checked>
473+
<label class="filter-job" for="filter-job-pipeline">Pipe</label><br>
474+
</div>
475+
</details>
476+
<input id="filter-box" type="text" size="21" title="Show logs for jobs matching this regular expression. For example ^https?://.*">
455477
<input id="set-filter-all" onclick="ds.setFilter('');" type="button" value="All" class="button">
456478
<input id="set-filter-none" onclick="ds.setFilter('^$');" type="button" value="None" class="button">
457479
<input type="checkbox" id="show-all-headers" onclick="ds.showAllHeaders(this.checked);">
@@ -526,6 +548,9 @@
526548
<li><kbd>b</kbd> - show/hide header+log for failed jobs
527549
<li><kbd>c</kbd> - show/hide header+log for fatal jobs
528550
<li><kbd>s</kbd> - show/hide header+log for aborted jobs
551+
<li><kbd>u</kbd> - enable/disable URL search for job log filter
552+
<li><kbd>e</kbd> - enable/disable note/explain search for job log filter
553+
<li><kbd>p</kbd> - enable/disable pipeline search for job log filter
529554
<li><kbd>?</kbd> - show/hide help text
530555
</ul>
531556
<p>
@@ -542,6 +567,12 @@
542567
</p>
543568
<ul>
544569
<li>To specify an initial filter, add <kbd><span class="url-q-or-amp">?</span>initialFilter=TEXT</kbd> to the dashboard URL. The default is <kbd>^$</kbd>.</li>
570+
<li>To initially disable filtering by job details, add these to the dashboard URL. The default is to filter by them.
571+
<kbd><span class="url-q-or-amp">?</span>filterJobID=0</kbd>
572+
<kbd><span class="url-q-or-amp">?</span>filterJobURL=0</kbd>
573+
<kbd><span class="url-q-or-amp">?</span>filterJobNote=0</kbd>
574+
<kbd><span class="url-q-or-amp">?</span>filterJobPipe=0</kbd>
575+
</li>
545576
<li>To initially hide headers for hidden job logs, add <kbd><span class="url-q-or-amp">?</span>showAllHeaders=0</kbd> to the dashboard URL. The default is to show them.</li>
546577
<li>To initially hide different job types, add these to the dashboard URL. The default is to show them.
547578
<kbd><span class="url-q-or-amp">?</span>showRunningJobs=0</kbd>

0 commit comments

Comments
 (0)