Skip to content

Commit db2a351

Browse files
committed
ui: status: hide trivial systemd services in good state
The list of systemd services is getting huge and growing. Roll the trivial ones with just one task and good state into a summary line. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent de8e5bd commit db2a351

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

ui/status.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ <h3>Build processing</h3>
4444
</tr>
4545
</table>
4646
<br />
47+
<div style="display: flex; justify-content: flex-end; align-items: baseline;">
48+
<label>
49+
<input type="checkbox" id="systemd-summary" checked />
50+
Hide okay services
51+
</label>
52+
</div>
4753
<table id="systemd">
4854
<tr>
4955
<th>Service</th>

ui/status.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,57 @@ function systemd_add_one(table, system, sname, v)
212212
mem.setAttribute("style", "text-align: right");
213213
}
214214

215-
function systemd(data_raw, data_local, data_remote)
215+
function systemd_is_okay(v)
216+
{
217+
if (v.TriggeredBy == 0) {
218+
let state = v.ActiveState + " / " + v.SubState;
219+
return state == "active / running" && v.TasksCurrent <= 1;
220+
} else {
221+
return v.Result == "success";
222+
}
223+
}
224+
225+
let systemd_entries = [];
226+
227+
function reload_systemd()
216228
{
217229
var table = document.getElementById("systemd");
230+
const summarize = document.getElementById("systemd-summary").checked;
231+
var hidden = 0;
232+
233+
$("#systemd tr").slice(1).remove();
234+
235+
$.each(systemd_entries, function(i, e) {
236+
if (summarize && systemd_is_okay(e.v)) {
237+
hidden++;
238+
return 1;
239+
}
240+
systemd_add_one(table, e.system, e.name, e.v);
241+
});
242+
243+
if (summarize && hidden) {
244+
var row = table.insertRow();
245+
var cell = row.insertCell(0);
246+
cell.innerHTML = '<span style="font-style: italic;">' + hidden + ' trivial services in good state hidden</span>';
247+
cell.setAttribute("colspan", "5");
248+
}
249+
}
250+
251+
function systemd(data_raw, data_local, data_remote)
252+
{
253+
systemd_entries = [];
218254

219255
$.each(data_local, function(i, v) {
220-
systemd_add_one(table, data_raw, i, v);
256+
systemd_entries.push({system: data_raw, name: i, v: v});
221257
});
222258

223259
$.each(data_remote, function(name, remote) {
224260
$.each(remote["services"], function(service, v) {
225-
systemd_add_one(table, remote, name + "/" + service, v);
261+
systemd_entries.push({system: remote, name: name + "/" + service, v: v});
226262
});
227263
});
264+
265+
reload_systemd();
228266
}
229267

230268
function load_runners(data_raw)
@@ -365,6 +403,9 @@ function status_system(data_raw)
365403
load_runners(data_raw["runners"]);
366404
load_runtime(data_raw["log-files"]);
367405
load_db_size(data_raw["db"]["data"]);
406+
407+
let summary_checkbox = document.getElementById("systemd-summary");
408+
summary_checkbox.addEventListener("change", reload_systemd);
368409
}
369410

370411
function msec_to_str(msec) {

0 commit comments

Comments
 (0)