diff --git a/web/about.html b/web/about.html index e5e0f8c..09f3770 100644 --- a/web/about.html +++ b/web/about.html @@ -10,18 +10,21 @@ } -
diff --git a/web/bootstrap/template.xsl b/web/bootstrap/template.xsl index 7822935..be7d594 100644 --- a/web/bootstrap/template.xsl +++ b/web/bootstrap/template.xsl @@ -21,6 +21,7 @@ + @@ -51,6 +52,9 @@ +
diff --git a/web/bootstrap/templates/index.xml b/web/bootstrap/templates/index.xml index 3cd2173..3432eea 100644 --- a/web/bootstrap/templates/index.xml +++ b/web/bootstrap/templates/index.xml @@ -8,10 +8,6 @@

Server statistics

- - - - diff --git a/web/global.js b/web/global.js new file mode 100644 index 0000000..d5f155e --- /dev/null +++ b/web/global.js @@ -0,0 +1,14 @@ +(function () { + function server_disconnected() { + $("#server_status_message_container")[0].className = "btn-danger"; + $("#server_status_message").text("Disconnected"); + } + + function server_connected() { + $("#server_status_message_container")[0].className = ""; + $("#server_status_message").text("Connected"); + } + + Ocamlmsg.$open_hooks.push(server_connected); + Ocamlmsg.$close_hooks.push(server_disconnected); +})(); diff --git a/web/index.html b/web/index.html index 246da84..dd296a8 100644 --- a/web/index.html +++ b/web/index.html @@ -10,26 +10,25 @@ } -

Server statistics

Server StatusOK
Connection count
- - - - diff --git a/web/index.js b/web/index.js index 58d9201..4865b5c 100644 --- a/web/index.js +++ b/web/index.js @@ -1,6 +1,4 @@ function server_disconnected() { - $("#server_ok")[0].className = "btn-danger"; - $("#server_ok").text("Disconnected"); $("#server_stats_connection_count").text("—"); $("#server_stats_boot_time").text("—"); $("#server_stats_uptime").text("—"); @@ -9,8 +7,6 @@ function server_disconnected() { function refresh_server_stats() { $.getJSON("/_/server_stats", function (data) { - $("#server_ok")[0].className = "btn-success"; - $("#server_ok").text("OK"); $("#server_stats_connection_count").text(data.connection_count); $("#server_stats_boot_time").text(new Date(data.boot_time * 1000)); $("#server_stats_uptime").text(data.uptime); @@ -30,17 +26,17 @@ function ui_main() { refresh_server_stats(); setInterval(refresh_server_stats, 5000); + Ocamlmsg.$open_hooks.push(function (event, stream) { + refresh_server_stats(); + Ocamlmsg.post(stream.id, {"test":true}); + Ocamlmsg.create("fanout", ["system.log"], "completion1"); + Ocamlmsg.subscribe("meta", "system.log", "sub_messages", "completion2"); + Ocamlmsg.subscribe("system.log", "", "log_messages", "completion3"); + }); + Ocamlmsg.$close_hooks.push(server_disconnected); Ocamlmsg.install_tap({ - open: function (event, stream) { - refresh_server_stats(); - Ocamlmsg.post(stream.id, {"test":true}); - Ocamlmsg.create("fanout", ["system.log"], "completion1"); - Ocamlmsg.subscribe("meta", "system.log", "sub_messages", "completion2"); - Ocamlmsg.subscribe("system.log", "", "log_messages", "completion3"); - }, message: function (event, stream) { $("#debug_container").append(JSON.stringify(event.data) + "\n"); }, - close: server_disconnected }); } diff --git a/web/nodes.html b/web/nodes.html index c7c37ee..63d53fb 100644 --- a/web/nodes.html +++ b/web/nodes.html @@ -10,18 +10,21 @@ } -

Nodes

diff --git a/web/ocamlmsg.js b/web/ocamlmsg.js index 6c6fa4f..ab2dbe0 100644 --- a/web/ocamlmsg.js +++ b/web/ocamlmsg.js @@ -2,6 +2,17 @@ var Ocamlmsg = { $tap: null, $args: null, + $open_hooks: [], + $close_hooks: [], + + run_open_hooks: function (event, stream) { + $.each(Ocamlmsg.$open_hooks, function (i, f) { f(event, stream); }); + }, + + run_close_hooks: function (event, stream) { + $.each(Ocamlmsg.$close_hooks, function (i, f) { f(event, stream); }); + }, + _send: function (msg) { Ocamlmsg.$tap.send({data: JSON.stringify(msg)}); }, @@ -63,10 +74,10 @@ var Ocamlmsg = { dataType: "json", enableXDR: true, - open: args.open, + open: Ocamlmsg.run_open_hooks, message: args.message, - error: args.close, - close: args.close + error: Ocamlmsg.run_close_hooks, + close: Ocamlmsg.run_close_hooks }); },
Server StatusOK
Connection count