Skip to content

Commit fbd6cc1

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 fc3235e commit fbd6cc1

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
@@ -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: 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)