From 245faaf1e2ff4d0fbda292dbb35f4b49426d4380 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Sat, 6 Feb 2016 17:04:28 -0800 Subject: Update web server --- .../src/main/scala/mavigator/Router.scala | 27 ++++++++++------------ .../src/main/twirl/mavigator/views/app.scala.html | 9 +++----- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/mavigator-server/src/main/scala/mavigator/Router.scala b/mavigator-server/src/main/scala/mavigator/Router.scala index 6d442bf..c6740cc 100644 --- a/mavigator-server/src/main/scala/mavigator/Router.scala +++ b/mavigator-server/src/main/scala/mavigator/Router.scala @@ -17,14 +17,6 @@ import play.twirl.api.{ Xml, Txt, Html } object Router { - - /** Serialize Twirl `Html` to `text/html`. */ - implicit val twirlHtmlMarshaller = twirlMarshaller[Html](`text/html`) - - /** Serialize Twirl formats to `String`. */ - def twirlMarshaller[A <: AnyRef: Manifest](contentType: MediaType): ToEntityMarshaller[A] = - Marshaller.StringMarshaller.wrap(contentType)(_.toString) - import Directives._ def route(implicit system: ActorSystem): Route = ( @@ -41,17 +33,15 @@ object Router { } ~ path("dashboard" / IntNumber) { id => get { + + + //get dashboard for remote sys id ??? } } ~ path("mavlink") { get { - /*extractUpgradeToWebsocket{ upgrade => - //upgrade.handleMessagesWith(inSink: Sink[Message, _$3], outSource: Source[Message, _$4]) - ??? - }*/ - val fromWebSocket = Flow[Message].collect{ case BinaryMessage.Strict(data) => data } @@ -60,9 +50,9 @@ object Router { BinaryMessage(bytes) } - val bytes = Uav().connect() + val backend = Uav().connect() - handleWebSocketMessages(fromWebSocket via bytes via toWebSocket) + handleWebSocketMessages(fromWebSocket via backend via toWebSocket) } } ~ pathPrefix("assets") { @@ -79,4 +69,11 @@ object Router { } ) + /** Serialize Twirl `Html` to `text/html`. */ + implicit val twirlHtmlMarshaller = twirlMarshaller[Html](`text/html`) + + /** Serialize Twirl formats to `String`. */ + def twirlMarshaller[A <: AnyRef: Manifest](contentType: MediaType): ToEntityMarshaller[A] = + Marshaller.StringMarshaller.wrap(contentType)(_.toString) + } diff --git a/mavigator-server/src/main/twirl/mavigator/views/app.scala.html b/mavigator-server/src/main/twirl/mavigator/views/app.scala.html index 6985e01..00459a9 100644 --- a/mavigator-server/src/main/twirl/mavigator/views/app.scala.html +++ b/mavigator-server/src/main/twirl/mavigator/views/app.scala.html @@ -18,11 +18,6 @@ document.addEventListener("DOMContentLoaded", function(event) { try { var root0 = document.getElementById("@appId"); - var args0 = { - @args.map{ case (key, value) => - @key: "@value", - } - } while (root0.firstChild) { root0.removeChild(root0.firstChild); @@ -31,7 +26,9 @@ @{appId}().start({ root: root0, assetsBase: "/assets", - args: args0 + args: @args.map{ case (key, value) => + @key: "@value", + } }); } catch(err) { -- cgit v1.2.3