summaryrefslogtreecommitdiff
path: root/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js')
-rw-r--r--web/js/kvm/atx.js15
-rw-r--r--web/js/kvm/msd.js102
-rw-r--r--web/js/kvm/session.js9
-rw-r--r--web/js/kvm/stream.js8
4 files changed, 78 insertions, 56 deletions
diff --git a/web/js/kvm/atx.js b/web/js/kvm/atx.js
index 6a641ac9..ed5f045e 100644
--- a/web/js/kvm/atx.js
+++ b/web/js/kvm/atx.js
@@ -15,17 +15,12 @@ function Atx() {
/********************************************************************************/
self.setState = function(state) {
- $("atx-power-led").className = (state.leds.power ? "led-green" : "led-gray");
- $("atx-hdd-led").className = (state.leds.hdd ? "led-red" : "led-gray");
+ $("atx-power-led").className = ((state && state.leds.power) ? "led-green" : "led-gray");
+ $("atx-hdd-led").className = ((state && state.leds.hdd) ? "led-red" : "led-gray");
- wm.switchDisabled($("atx-power-button"), state.busy);
- wm.switchDisabled($("atx-power-button-long"), state.busy);
- wm.switchDisabled($("atx-reset-button"), state.busy);
- };
-
- self.clearState = function() {
- $("atx-power-led").className = "led-gray";
- $("atx-hdd-led").className = "led-gray";
+ wm.switchDisabled($("atx-power-button"), (!state || state.busy));
+ wm.switchDisabled($("atx-power-button-long"), (!state || state.busy));
+ wm.switchDisabled($("atx-reset-button"), (!state || state.busy));
};
var __clickButton = function(button, confirm_msg) {
diff --git a/web/js/kvm/msd.js b/web/js/kvm/msd.js
index 39578cdd..c23de99d 100644
--- a/web/js/kvm/msd.js
+++ b/web/js/kvm/msd.js
@@ -89,49 +89,75 @@ function Msd() {
};
var __applyState = function() {
- if (__state.connected_to === "server") {
- $("msd-another-another-user-uploads").style.display = "none";
- $("msd-led").className = "led-green";
- $("msd-status").innerHTML = $("msd-led").title = "Connected to Server";
- $("msd-another-another-user-uploads").style.display = "none";
- } else if (__state.busy) {
- if (!__upload_http) {
- $("msd-another-another-user-uploads").style.display = "block";
+ if (__state) {
+ if (__state.connected_to === "server") {
+ $("msd-another-another-user-uploads").style.display = "none";
+ $("msd-led").className = "led-green";
+ $("msd-status").innerHTML = $("msd-led").title = "Connected to Server";
+ } else if (__state.busy) {
+ if (!__upload_http) {
+ $("msd-another-another-user-uploads").style.display = "block";
+ }
+ $("msd-led").className = "led-yellow-rotating-fast";
+ $("msd-status").innerHTML = $("msd-led").title = "Uploading new image";
+ } else {
+ $("msd-another-another-user-uploads").style.display = "none";
+ $("msd-led").className = "led-gray";
+ if (__state.in_operate) {
+ $("msd-status").innerHTML = $("msd-led").title = "Connected to KVM";
+ } else {
+ $("msd-status").innerHTML = $("msd-led").title = "Unavailable";
+ }
}
- $("msd-led").className = "led-yellow-rotating-fast";
- $("msd-status").innerHTML = $("msd-led").title = "Uploading new image";
+
+ $("msd-not-in-operate").style.display = (__state.in_operate ? "none" : "block");
+ $("msd-current-image-broken").style.display = (
+ __state.in_operate && __state.info.image &&
+ !__state.info.image.complete && !__state.busy ? "block" : "none"
+ );
+
+ $("msd-current-image-name").innerHTML = (__state.in_operate && __state.info.image ? __state.info.image.name : "None");
+ $("msd-current-image-size").innerHTML = (__state.in_operate && __state.info.image ? __formatSize(__state.info.image.size) : "None");
+ $("msd-storage-size").innerHTML = (__state.in_operate ? __formatSize(__state.info.size) : "Unavailable");
+
+ wm.switchDisabled($("msd-switch-to-kvm-button"), (!__state.in_operate || __state.connected_to === "kvm" || __state.busy));
+ wm.switchDisabled($("msd-switch-to-server-button"), (!__state.in_operate || __state.connected_to === "server" || __state.busy));
+ wm.switchDisabled($("msd-select-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || __upload_http));
+ wm.switchDisabled($("msd-upload-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || !__image_file));
+ wm.switchDisabled($("msd-abort-uploading-button"), (!__state.in_operate || !__upload_http));
+ wm.switchDisabled($("msd-reset-button"), (!__state.in_operate || __upload_http));
+
+ $("msd-new-image").style.display = (__image_file ? "block" : "none");
+ $("msd-progress").setAttribute("data-label", "Waiting for upload ...");
+ $("msd-progress-value").style.width = "0%";
+ $("msd-new-image-name").innerHTML = (__image_file ? __image_file.name : "");
+ $("msd-new-image-size").innerHTML = (__image_file ? __formatSize(__image_file.size) : "");
+
} else {
$("msd-another-another-user-uploads").style.display = "none";
$("msd-led").className = "led-gray";
- if (__state.in_operate) {
- $("msd-status").innerHTML = $("msd-led").title = "Connected to KVM";
- } else {
- $("msd-status").innerHTML = $("msd-led").title = "Unavailable";
- }
- }
+ $("msd-status").innerHTML = "";
+ $("msd-led").title = "";
+ $("msd-not-in-operate").style.display = "none";
+ $("msd-current-image-broken").style.display = "none";
+ $("msd-current-image-name").innerHTML = "";
+ $("msd-current-image-size").innerHTML = "";
+ $("msd-storage-size").innerHTML = "";
+
+ wm.switchDisabled($("msd-switch-to-kvm-button"), true);
+ wm.switchDisabled($("msd-switch-to-server-button"), true);
+ wm.switchDisabled($("msd-select-new-image-button"), true);
+ wm.switchDisabled($("msd-upload-new-image-button"), true);
+ wm.switchDisabled($("msd-abort-uploading-button"), true);
+ wm.switchDisabled($("msd-reset-button"), true);
- $("msd-not-in-operate").style.display = (__state.in_operate ? "none" : "block");
- $("msd-current-image-broken").style.display = (
- __state.in_operate && __state.info.image &&
- !__state.info.image.complete && !__state.busy ? "block" : "none"
- );
-
- $("msd-current-image-name").innerHTML = (__state.in_operate && __state.info.image ? __state.info.image.name : "None");
- $("msd-current-image-size").innerHTML = (__state.in_operate && __state.info.image ? __formatSize(__state.info.image.size) : "None");
- $("msd-storage-size").innerHTML = (__state.in_operate ? __formatSize(__state.info.size) : "Unavailable");
-
- wm.switchDisabled($("msd-switch-to-kvm-button"), (!__state.in_operate || __state.connected_to === "kvm" || __state.busy));
- wm.switchDisabled($("msd-switch-to-server-button"), (!__state.in_operate || __state.connected_to === "server" || __state.busy));
- wm.switchDisabled($("msd-select-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || __upload_http));
- wm.switchDisabled($("msd-upload-new-image-button"), (!__state.in_operate || __state.connected_to !== "kvm" || __state.busy || !__image_file));
- wm.switchDisabled($("msd-abort-uploading-button"), (!__state.in_operate || !__upload_http));
- wm.switchDisabled($("msd-reset-button"), (!__state.in_operate || __upload_http));
-
- $("msd-new-image").style.display = (__image_file ? "block" : "none");
- $("msd-progress").setAttribute("data-label", "Waiting for upload ...");
- $("msd-progress-value").style.width = "0%";
- $("msd-new-image-name").innerHTML = (__image_file ? __image_file.name : "");
- $("msd-new-image-size").innerHTML = (__image_file ? __formatSize(__image_file.size) : "");
+ $("msd-select-new-image-file").value = "";
+ $("msd-new-image").style.display = "none";
+ $("msd-progress").setAttribute("data-label", "");
+ $("msd-progress-value").style.width = "0%";
+ $("msd-new-image-name").innerHTML = "";
+ $("msd-new-image-size").innerHTML = "";
+ }
};
var __formatSize = function(size) {
diff --git a/web/js/kvm/session.js b/web/js/kvm/session.js
index 9589abab..e3e74160 100644
--- a/web/js/kvm/session.js
+++ b/web/js/kvm/session.js
@@ -81,12 +81,12 @@ function Session() {
} else if (event.msg_type === "event") {
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);
} else if (event.msg.event === "msd_state") {
__msd.setState(event.msg.event_attrs);
+ } else if (event.msg.event === "streamer_state") {
+ __streamer.setState(event.msg.event_attrs);
}
}
};
@@ -110,9 +110,10 @@ function Session() {
__ping_timer = null;
}
- __streamer.clearState();
- __atx.clearState();
__hid.setSocket(null);
+ __atx.setState(null);
+ __msd.setState(null);
+ __streamer.setState(null);
__ws = null;
setTimeout(function() {
diff --git a/web/js/kvm/stream.js b/web/js/kvm/stream.js
index 2133349a..01ded5bc 100644
--- a/web/js/kvm/stream.js
+++ b/web/js/kvm/stream.js
@@ -39,7 +39,7 @@ function Streamer() {
/********************************************************************************/
self.setState = function(state) {
- if (state.state) {
+ if (state && state.state) {
var source = state.state.source;
var stream = state.state.stream;
@@ -82,7 +82,7 @@ function Streamer() {
if (stream.clients_stat.hasOwnProperty(__client_id)) {
__client_fps = stream.clients_stat[__client_id].fps;
} else {
- self.clearState();
+ __clearState();
}
if (!__prev) {
@@ -110,11 +110,11 @@ function Streamer() {
__updateStreamHeader(true);
} else {
- self.clearState();
+ __clearState();
}
};
- self.clearState = function() {
+ var __clearState = function() {
tools.info("Stream: refreshing ...");
$("stream-image").className = "stream-image-inactive";