diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-04-03 18:42:43 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-04-03 18:47:25 +0200 |
commit | 7183beef6a70f16318a6feb21e84fe71d57bdd86 (patch) | |
tree | 2d4624abcd249c98f4da8619d6243e73404e3bd8 /vfd-index/src/main | |
parent | c1eed835318e4be95a59eae644aaf2d52e9f974e (diff) | |
download | mavigator-7183beef6a70f16318a6feb21e84fe71d57bdd86.tar.gz mavigator-7183beef6a70f16318a6feb21e84fe71d57bdd86.tar.bz2 mavigator-7183beef6a70f16318a6feb21e84fe71d57bdd86.zip |
index: show error message when websocket closes
Diffstat (limited to 'vfd-index/src/main')
-rw-r--r-- | vfd-index/src/main/scala/vfd/index/Main.scala | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/vfd-index/src/main/scala/vfd/index/Main.scala b/vfd-index/src/main/scala/vfd/index/Main.scala index 779b682..d5b3f64 100644 --- a/vfd-index/src/main/scala/vfd/index/Main.scala +++ b/vfd-index/src/main/scala/vfd/index/Main.scala @@ -47,25 +47,46 @@ object Main { } } - root.appendChild(table(`class` := "table table-hover")( - thead( - tr( - th("System ID"), - th("Type"), - th("Autopilot"), - th("State"), - th(""))), - Rx { - tbody( - for (vehicle <- active().toSeq) yield { - tr( - td(vehicle.systemId), - td(vehicle.vehicleType), - td(vehicle.autopilot), - td(vehicle.state), - td(a(href := "/dashboard/" + vehicle.systemId, `class` := "btn btn-default")("Pilot"))) - }) - }).render) + connection.onclose = (e: dom.Event) => { + while (root.firstChild != null) { + root.removeChild(root.firstChild); + } + root.appendChild( + div(`class`:="alert alert-danger")( + "Connection to server unexpectedly closed. Check server logs for errors." + ).render + ) + + } + + root.appendChild(div( + table(`class` := "table table-hover")( + thead( + tr( + th("System ID"), + th("Type"), + th("Autopilot"), + th("State"), + th("") + ) + ), + Rx { + tbody( + for (vehicle <- active().toSeq) yield { + tr( + td(vehicle.systemId), + td(vehicle.vehicleType), + td(vehicle.autopilot), + td(vehicle.state), + td(a(href := "/dashboard/" + vehicle.systemId, `class` := "btn btn-default")("Pilot")) + ) + } + ) + } + ), + i(`class`:="fa fa-spinner fa-spin")(), + " Listening for heartbeats..." + ).render) } }
\ No newline at end of file |