Skip to content

Commit b5a0813

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 ee424e3 commit b5a0813

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

dashboard/assets/scripts/dashboard.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,13 @@ class JobsRenderer {
693693
this.firstFilterMatch = null;
694694
for (const job of this.jobs.sorted) {
695695
const w = this.renderInfo[job.ident].logWindow;
696-
if (!query.test(job.url)) {
696+
const show =
697+
(byId("filter-job-id").checked && query.test(job.ident)) ||
698+
(byId("filter-job-url").checked && query.test(job.url)) ||
699+
(byId("filter-job-note").checked && query.test(job.note)) ||
700+
(byId("filter-job-pipeline").checked && (query.test(job.pipeline_id) || query.test(this.pipelines[job.pipeline_id]))) ||
701+
(this.showNicks && byId("filter-job-nick").checked && query.test(job.started_by));
702+
if (!show) {
697703
w.classList.add("log-window-hidden");
698704

699705
unmatchedWindows.push(w);
@@ -1086,6 +1092,11 @@ class Dashboard {
10861092
const showNicks = args.showNicks ? Boolean(Number(args.showNicks)) : false;
10871093
const contextMenu = args.contextMenu ? Boolean(Number(args.contextMenu)) : true;
10881094
this.initialFilter = args.initialFilter ?? "^$";
1095+
const filterJobID = args.filterJobID ? Boolean(Number(args.filterJobID)) : true;
1096+
const filterJobURL = args.filterJobURL ? Boolean(Number(args.filterJobURL)) : true;
1097+
const filterJobNote = args.filterJobNote ? Boolean(Number(args.filterJobNote)) : true;
1098+
const filterJobPipe = args.filterJobPipe ? Boolean(Number(args.filterJobPipe)) : true;
1099+
const filterJobNick = args.filterJobNick ? Boolean(Number(args.filterJobNick)) : true;
10891100
const showAllHeaders = args.showAllHeaders ? Boolean(Number(args.showAllHeaders)) : true;
10901101
const showRunningJobs = args.showRunningJobs ? Boolean(Number(args.showRunningJobs)) : true;
10911102
const showFinishedJobs = args.showFinishedJobs ? Boolean(Number(args.showFinishedJobs)) : true;
@@ -1144,6 +1155,29 @@ class Dashboard {
11441155

11451156
if (!showNicks) {
11461157
addPageStyles(".job-nick-aligned { width: 0; }");
1158+
} else {
1159+
byId("filter-types").lastChild.after(
1160+
h("input", {
1161+
type: "checkbox",
1162+
id: "filter-job-nick",
1163+
onclick: () => { ds.jobsRenderer.applyFilter(); },
1164+
checked: true,
1165+
})
1166+
);
1167+
byId("filter-types").lastChild.after("\n\t\t\t");
1168+
byId("filter-types").lastChild.after(
1169+
h("label", { className: "filter-job", htmlFor: "filter-job-nick", textContent: "Nick" }),
1170+
);
1171+
byId("filter-types").lastChild.after(h("br"));
1172+
byId("filter-types").lastChild.after("\n");
1173+
}
1174+
1175+
byId("filter-job-id").checked = filterJobID;
1176+
byId("filter-job-url").checked = filterJobURL;
1177+
byId("filter-job-note").checked = filterJobNote;
1178+
byId("filter-job-pipeline").checked = filterJobPipe;
1179+
if (showNicks) {
1180+
byId("filter-job-nick").checked = filterJobNick;
11471181
}
11481182

11491183
if (args.initialFilter != null) {
@@ -1329,6 +1363,12 @@ ${String(kbPerSec).padStart(3, "0")} KB/s`;
13291363
ds.showFatalJobs(!byId("show-fatal-jobs").checked);
13301364
} else if (ev.which === 115 /* s */) {
13311365
ds.showAbortedJobs(!byId("show-aborted-jobs").checked);
1366+
} else if (ev.which === 117 /* u */) {
1367+
byId("filter-job-url").click();
1368+
} else if (ev.which === 101 /* e */) {
1369+
byId("filter-job-note").click();
1370+
} else if (ev.which === 112 /* p */) {
1371+
byId("filter-job-pipeline").click();
13321372
}
13331373
}
13341374

dashboard/dashboard.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@
6666
float: inline-start;
6767
}
6868

69+
#filter-details {
70+
display: inline flex;
71+
flex-direction: column;
72+
}
73+
74+
#filter-types {
75+
float: inline-start;
76+
}
77+
6978
.padded-page {
7079
padding: 20px 27px 20px 27px;
7180
}
@@ -452,7 +461,21 @@
452461
<a href="https://wiki.archiveteam.org/index.php?title=ArchiveBot" class="underlined-a">ArchiveBot</a>
453462
tracking <span id="num-crawls">0</span> crawls.
454463
See also <a href="pipelines" class="underlined-a">pipeline</a> or <a href="logs/recent" class="underlined-a">job</a> reports.
455-
Logs <input id="filter-box" type="text" size="21" title="Show logs for jobs matching this regular expression. For example ^https?://.*">
464+
<details id="filter-details">
465+
<summary>Logs</summary>
466+
<div id="filter-types">
467+
Search:<br>
468+
<input type="checkbox" id="filter-job-id" onclick="ds.jobsRenderer.applyFilter();" checked>
469+
<label class="filter-job" for="filter-job-id">ID</label><br>
470+
<input type="checkbox" id="filter-job-url" onclick="ds.jobsRenderer.applyFilter();" accesskey="u" checked>
471+
<label class="filter-job" for="filter-job-url">URL</label><br>
472+
<input type="checkbox" id="filter-job-note" onclick="ds.jobsRenderer.applyFilter();" accesskey="e" checked>
473+
<label class="filter-job" for="filter-job-note" title="Explain">Note</label><br>
474+
<input type="checkbox" id="filter-job-pipeline" onclick="ds.jobsRenderer.applyFilter();" accesskey="p" checked>
475+
<label class="filter-job" for="filter-job-pipeline">Pipe</label><br>
476+
</div>
477+
</details>
478+
<input id="filter-box" type="text" size="21" title="Show logs for jobs matching this regular expression. For example ^https?://.*">
456479
<input id="set-filter-all" onclick="ds.setFilter('');" type="button" value="All" class="button">
457480
<input id="set-filter-none" onclick="ds.setFilter('^$');" type="button" value="None" class="button">
458481
<input type="checkbox" id="show-all-headers" onclick="ds.showAllHeaders(this.checked);">
@@ -527,6 +550,9 @@
527550
<li><kbd>b</kbd> - show/hide header+log for failed jobs
528551
<li><kbd>c</kbd> - show/hide header+log for fatal jobs
529552
<li><kbd>s</kbd> - show/hide header+log for aborted jobs
553+
<li><kbd>u</kbd> - enable/disable URL search for job log filter
554+
<li><kbd>e</kbd> - enable/disable note/explain search for job log filter
555+
<li><kbd>p</kbd> - enable/disable pipeline search for job log filter
530556
<li><kbd>?</kbd> - show/hide help text
531557
</ul>
532558
<p>
@@ -543,6 +569,12 @@
543569
</p>
544570
<ul>
545571
<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>
572+
<li>To initially disable filtering by job details, add these to the dashboard URL. The default is to filter by them.
573+
<kbd><span class="url-q-or-amp">?</span>filterJobID=0</kbd>
574+
<kbd><span class="url-q-or-amp">?</span>filterJobURL=0</kbd>
575+
<kbd><span class="url-q-or-amp">?</span>filterJobNote=0</kbd>
576+
<kbd><span class="url-q-or-amp">?</span>filterJobPipe=0</kbd>
577+
</li>
546578
<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>
547579
<li>To initially hide different job types, add these to the dashboard URL. The default is to show them.
548580
<kbd><span class="url-q-or-amp">?</span>showRunningJobs=0</kbd>

0 commit comments

Comments
 (0)