diff options
author | Devaev Maxim <[email protected]> | 2020-06-02 20:59:43 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-06-02 20:59:43 +0300 |
commit | cb9597679d8c9189e671e166de45c707c650bb2f (patch) | |
tree | e0f3e00bafe4c1674f8497e6832f292233d94821 /web/share/js/kvm/session.js | |
parent | fe7c275d1a827f95d40d774e38b928aee493a41b (diff) |
improved info handler
Diffstat (limited to 'web/share/js/kvm/session.js')
-rw-r--r-- | web/share/js/kvm/session.js | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js index 5df1481c..7b68ac88 100644 --- a/web/share/js/kvm/session.js +++ b/web/share/js/kvm/session.js @@ -55,8 +55,8 @@ export function Session() { /************************************************************************/ - var __setKvmdInfo = function(state) { - if (state.meta) { + var __setAboutInfo = function(state) { + if (state.meta != null) { let text = JSON.stringify(state.meta, undefined, 4).replace(/ /g, " ").replace(/\n/g, "<br>"); $("about-meta").innerHTML = ` <span class="code-comment">// The Pi-KVM metadata.<br> @@ -75,8 +75,48 @@ export function Session() { } } - $("about-version-kvmd").innerHTML = state.version.kvmd; - $("about-version-streamer").innerHTML = `${state.version.streamer} (${state.streamer})`; + let sys = state.system; + $("about-version").innerHTML = ` + KVMD: <span class="code-comment">${sys.kvmd.version}</span><br> + <hr> + Streamer: <span class="code-comment">${sys.streamer.version} (${sys.streamer.app})</span> + ${__formatStreamerFeatures(sys.streamer.features)} + <hr> + ${sys.kernel.system} kernel: + ${__formatUname(sys.kernel)} + `; + }; + + var __formatStreamerFeatures = function(features) { + let pairs = []; + for (let field of Object.keys(features).sort()) { + pairs.push([ + field, + (features[field] ? "Yes" : "No"), + ]); + } + return __formatUl(pairs); + }; + + var __formatUname = function(kernel) { + let pairs = []; + for (let field of Object.keys(kernel).sort()) { + if (field != "system") { + pairs.push([ + field[0].toUpperCase() + field.slice(1), + kernel[field], + ]); + } + } + return __formatUl(pairs); + }; + + var __formatUl = function(pairs) { + let text = "<ul>"; + for (let pair of pairs) { + text += `<li>${pair[0]}: <span class="code-comment">${pair[1]}</span></li>`; + } + return text + "</ul>"; }; var __startSession = function() { @@ -117,7 +157,7 @@ export function Session() { let data = JSON.parse(event.data); switch (data.event_type) { case "pong": __missed_heartbeats = 0; break; - case "info_state": __setKvmdInfo(data.event); break; + case "info_state": __setAboutInfo(data.event); break; case "wol_state": __wol.setState(data.event); break; case "hid_state": __hid.setState(data.event); break; case "atx_state": __atx.setState(data.event); break; |