summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-07-09 09:41:05 +0300
committerDevaev Maxim <[email protected]>2020-07-09 09:41:05 +0300
commit5f1733d0024c70ccaf31964980a6286a7951cbed (patch)
treeb9074dc235835a214b66be2405faa777245a2e3f /web
parent53eb74670d040c9e8745433a2641f18796da365c (diff)
complex info handle
Diffstat (limited to 'web')
-rw-r--r--web/share/js/index/main.js2
-rw-r--r--web/share/js/kvm/session.js40
2 files changed, 22 insertions, 20 deletions
diff --git a/web/share/js/index/main.js b/web/share/js/index/main.js
index 6c315660..24a694b8 100644
--- a/web/share/js/index/main.js
+++ b/web/share/js/index/main.js
@@ -51,7 +51,7 @@ function __setAppText() {
}
function __loadKvmdInfo() {
- let http = tools.makeRequest("GET", "/api/info", function() {
+ let http = tools.makeRequest("GET", "/api/info?fields=meta,extras", function() {
if (http.readyState === 4) {
if (http.status === 200) {
let info = JSON.parse(http.responseText).result;
diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js
index 7b68ac88..e450a962 100644
--- a/web/share/js/kvm/session.js
+++ b/web/share/js/kvm/session.js
@@ -55,36 +55,37 @@ export function Session() {
/************************************************************************/
- var __setAboutInfo = function(state) {
- if (state.meta != null) {
- let text = JSON.stringify(state.meta, undefined, 4).replace(/ /g, "&nbsp;").replace(/\n/g, "<br>");
+ var __setAboutInfoSystem = function(state) {
+ $("about-version").innerHTML = `
+ KVMD: <span class="code-comment">${state.kvmd.version}</span><br>
+ <hr>
+ Streamer: <span class="code-comment">${state.streamer.version} (${state.streamer.app})</span>
+ ${__formatStreamerFeatures(state.streamer.features)}
+ <hr>
+ ${state.kernel.system} kernel:
+ ${__formatUname(state.kernel)}
+ `;
+ };
+
+ var __setAboutInfoMeta = function(state) {
+ if (state != null) {
+ let text = JSON.stringify(state, undefined, 4).replace(/ /g, "&nbsp;").replace(/\n/g, "<br>");
$("about-meta").innerHTML = `
<span class="code-comment">// The Pi-KVM metadata.<br>
- // You can get this json using handle <a target="_blank" href="/api/info">/api/info</a>.<br>
+ // You can get this JSON using handle <a target="_blank" href="/api/info?fields=meta">/api/info?fields=meta</a>.<br>
// In the standard configuration this data<br>
// is specified in the file /etc/kvmd/meta.yaml.</span><br>
<br>
${text}
`;
- if (state.meta.server && state.meta.server.host) {
- $("kvmd-meta-server-host").innerHTML = `Server: ${state.meta.server.host}`;
- document.title = `Pi-KVM Session: ${state.meta.server.host}`;
+ if (state.server && state.server.host) {
+ $("kvmd-meta-server-host").innerHTML = `Server: ${state.server.host}`;
+ document.title = `Pi-KVM Session: ${state.server.host}`;
} else {
$("kvmd-meta-server-host").innerHTML = "";
document.title = "Pi-KVM Session";
}
}
-
- 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) {
@@ -157,7 +158,8 @@ export function Session() {
let data = JSON.parse(event.data);
switch (data.event_type) {
case "pong": __missed_heartbeats = 0; break;
- case "info_state": __setAboutInfo(data.event); break;
+ case "info_system_state": __setAboutInfoSystem(data.event); break;
+ case "info_meta_state": __setAboutInfoMeta(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;