summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-24 06:30:08 +0300
committerDevaev Maxim <[email protected]>2018-11-24 06:30:08 +0300
commitc168e738057cae115be552e8cf22f500fb5ed0f8 (patch)
treef4fbb3180d77069d5ff688bf6403ea5535e007b9 /web
parentd060125cd3a146b9817aec4cbc8705da91cf5139 (diff)
removed loadInitialState()
Diffstat (limited to 'web')
-rw-r--r--web/js/kvm/atx.js12
-rw-r--r--web/js/kvm/msd.js12
-rw-r--r--web/js/kvm/session.js51
-rw-r--r--web/js/kvm/stream.js13
4 files changed, 20 insertions, 68 deletions
diff --git a/web/js/kvm/atx.js b/web/js/kvm/atx.js
index b75b901b..e4f591d5 100644
--- a/web/js/kvm/atx.js
+++ b/web/js/kvm/atx.js
@@ -14,18 +14,6 @@ function Atx() {
/********************************************************************************/
- self.loadInitialState = function() {
- var http = tools.makeRequest("GET", "/kvmd/atx", function() {
- if (http.readyState === 4) {
- if (http.status === 200) {
- __setButtonsBusy(JSON.parse(http.responseText).result.busy);
- } else {
- setTimeout(self.loadInitialState, 1000);
- }
- }
- });
- };
-
self.setState = function(state) {
__setButtonsBusy(state.busy);
$("atx-power-led").className = (state.leds.power ? "led-green" : "led-gray");
diff --git a/web/js/kvm/msd.js b/web/js/kvm/msd.js
index c59563b7..057dec5b 100644
--- a/web/js/kvm/msd.js
+++ b/web/js/kvm/msd.js
@@ -24,18 +24,6 @@ function Msd() {
/********************************************************************************/
- self.loadInitialState = function() {
- var http = tools.makeRequest("GET", "/kvmd/msd", function() {
- if (http.readyState === 4) {
- if (http.status === 200) {
- self.setState(JSON.parse(http.responseText).result);
- } else {
- setTimeout(self.loadInitialState, 1000);
- }
- }
- });
- };
-
self.setState = function(state) {
__state = state;
__applyState();
diff --git a/web/js/kvm/session.js b/web/js/kvm/session.js
index 04149be3..bcc97fab 100644
--- a/web/js/kvm/session.js
+++ b/web/js/kvm/session.js
@@ -15,39 +15,29 @@ function Session() {
var __init__ = function() {
$("link-led").title = "Not connected yet...";
- __loadKvmdInfo();
__startPoller();
};
/********************************************************************************/
- var __loadKvmdInfo = function() {
- var http = tools.makeRequest("GET", "/kvmd/info", function() {
- if (http.readyState === 4) {
- if (http.status === 200) {
- var info = JSON.parse(http.responseText).result;
- if (info.meta) {
- var text = JSON.stringify(info.meta, 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 /kvmd/info.<br>
- // In the standard configuration this data<br>
- // is specified in the file /etc/kvmd/meta.yaml.</span><br>
- <br>
- ${text}
- `;
- if (info.meta.server && info.meta.server.host) {
- document.title = "Pi-KVM Session - " + info.meta.server.host;
- $("kvmd-meta-server-host").innerHTML = "Server: " + info.meta.server.host;
- }
- }
- $("about-version-kvmd").innerHTML = info.version.kvmd;
- $("about-version-streamer").innerHTML = `${info.version.streamer} (${info.streamer})`;
- } else {
- setTimeout(__loadKvmdInfo, 1000);
- }
+ var __setKvmdInfo = function(state) {
+ if (state.meta) {
+ var text = JSON.stringify(state.meta, 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="/kvmd/info">/kvmd/info</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) {
+ document.title = "Pi-KVM Session - " + state.meta.server.host;
+ $("kvmd-meta-server-host").innerHTML = "Server: " + state.meta.server.host;
}
- });
+ }
+ $("about-version-kvmd").innerHTML = state.version.kvmd;
+ $("about-version-streamer").innerHTML = `${state.version.streamer} (${state.streamer})`;
};
var __startPoller = function() {
@@ -73,9 +63,6 @@ function Session() {
$("link-led").className = "led-green";
$("link-led").title = "Connected";
tools.debug("Session: socket opened:", event);
- __streamer.loadInitialState();
- __atx.loadInitialState();
- __msd.loadInitialState();
__hid.setSocket(__ws);
__missed_heartbeats = 0;
__ping_timer = setInterval(__pingServer, 1000);
@@ -87,7 +74,9 @@ function Session() {
if (event.msg_type === "pong") {
__missed_heartbeats = 0;
} else if (event.msg_type === "event") {
- if (event.msg.event === "streamer_state") {
+ if (event.msg.event === "info_state") {
+ __setKvmdInfo(event.msg.event_attrs);
+ } else if (event.msg.event === "streamer_state") {
__streamer.setState(event.msg.event_attrs);
} else if (event.msg.event === "atx_state") {
__atx.setState(event.msg.event_attrs);
diff --git a/web/js/kvm/stream.js b/web/js/kvm/stream.js
index d543701f..029eee48 100644
--- a/web/js/kvm/stream.js
+++ b/web/js/kvm/stream.js
@@ -38,19 +38,6 @@ function Streamer() {
/********************************************************************************/
- self.loadInitialState = function() {
- var http = tools.makeRequest("GET", "/kvmd/streamer", function() {
- if (http.readyState === 4) {
- if (http.status === 200) {
- self.setState(JSON.parse(http.responseText).result);
- } else {
- self.clearState();
- setTimeout(self.loadInitialState, 1000);
- }
- }
- });
- };
-
self.setState = function(state) {
if (state.state) {
var source = state.state.source;