diff options
Diffstat (limited to 'src/zenserver/frontend/html/pages/proxy.js')
| -rw-r--r-- | src/zenserver/frontend/html/pages/proxy.js | 49 |
1 files changed, 9 insertions, 40 deletions
diff --git a/src/zenserver/frontend/html/pages/proxy.js b/src/zenserver/frontend/html/pages/proxy.js index 50e1f255a..4a3524fe3 100644 --- a/src/zenserver/frontend/html/pages/proxy.js +++ b/src/zenserver/frontend/html/pages/proxy.js @@ -39,7 +39,15 @@ export class Page extends ZenPage this._init_view_tabs(connections_section); await this._update(); - this._connect_stats_ws(); + this.connect_stats_ws((all_stats) => { + const data = all_stats["proxy"]; + if (data) + { + this._render_summary(data); + this._render_mappings(data); + this._render_connections(data); + } + }); } async _update() @@ -54,45 +62,6 @@ export class Page extends ZenPage catch (e) { /* service unavailable */ } } - _connect_stats_ws() - { - try - { - const proto = location.protocol === "https:" ? "wss:" : "ws:"; - const ws = new WebSocket(`${proto}//${location.host}/stats`); - - try { this._ws_paused = localStorage.getItem("zen-ws-paused") === "true"; } catch (e) { this._ws_paused = false; } - document.addEventListener("zen-ws-toggle", (e) => { - this._ws_paused = e.detail.paused; - }); - - ws.onmessage = (ev) => { - if (this._ws_paused) - { - return; - } - try - { - const all_stats = JSON.parse(ev.data); - const data = all_stats["proxy"]; - if (data) - { - this._render_summary(data); - this._render_mappings(data); - this._render_connections(data); - } - } - catch (e) { /* ignore parse errors */ } - }; - - ws.onclose = () => { this._stats_ws = null; }; - ws.onerror = () => { ws.close(); }; - - this._stats_ws = ws; - } - catch (e) { /* WebSocket not available */ } - } - _init_record_controls(host) { const container = host.tag().classify("card"); |