Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openmole
gate
Commits
474fb9fb
Commit
474fb9fb
authored
Aug 04, 2014
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test with case class
parent
96f90045
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
17 deletions
+36
-17
Client.scala
client/src/main/scala/fr/iscpif/client/Client.scala
+18
-5
ScalaTraJSTagsWireRxBuild.scala
project/ScalaTraJSTagsWireRxBuild.scala
+4
-3
ScalatraBootstrap.scala
server/src/main/scala/ScalatraBootstrap.scala
+3
-0
MyScalatraServlet.scala
server/src/main/scala/fr/iscpif/app/MyScalatraServlet.scala
+2
-1
default.jade
server/src/main/webapp/default.jade
+3
-8
Shared.scala
shared/Shared.scala
+6
-0
No files found.
client/src/main/scala/fr/iscpif/client/Client.scala
View file @
474fb9fb
...
...
@@ -21,30 +21,43 @@ import JsRxTags._
object
Client
{
val
helloValue
=
Var
(
0
)
val
caseClassValue
=
Var
(
"empty"
)
@JSExport
def
run
()
{
val
submitButton
=
button
(
"Click me"
)(
val
submitButton
1
=
button
(
"Click me"
)(
cursor
:=
"pointer"
,
onclick
:=
{
()
=>
Post
[
Api
](
_
.
hello
(
5
)).
foreach
{
i
=>
helloValue
()
=
helloValue
()
+
i
onclick
:=
{
()
=>
Post
[
Api
](
_
.
hello
(
5
)).
foreach
{
i
=>
helloValue
()
=
helloValue
()
+
i
}
}
).
render
val
submitButton2
=
button
(
"Click me"
)(
cursor
:=
"pointer"
,
onclick
:=
{
()
=>
Post
[
Api
](
_
.
caseClass
(
MyCaseClass
(
"Hello !"
))).
foreach
{
s
=>
caseClassValue
()
=
s
}
false
}
).
render
Rx
{
dom
.
document
.
body
.
appendChild
(
submitButton
)
dom
.
document
.
body
.
appendChild
(
submitButton1
)
dom
.
document
.
body
.
appendChild
(
submitButton2
)
dom
.
document
.
body
.
appendChild
(
h1
(
helloValue
).
render
)
dom
.
document
.
body
.
appendChild
(
h1
(
caseClassValue
).
render
)
}
}
}
object
Post
extends
autowire
.
Client
[
Web
]
{
override
def
callRequest
(
req
:
Request
)
:
Future
[
String
]
=
{
val
url
=
req
.
path
.
mkString
(
"/"
)
println
(
" URL "
+
url
)
dom
.
extensions
.
Ajax
.
post
(
url
=
"http://localhost:8080/"
+
url
,
data
=
upickle
.
write
(
req
.
args
)
...
...
project/ScalaTraJSTagsWireRxBuild.scala
View file @
474fb9fb
...
...
@@ -11,8 +11,9 @@ object ScalaTraJSTagsWireRxBuild extends Build {
val
ScalaVersion
=
"2.11.1"
val
ScalatraVersion
=
"2.3.0"
lazy
val
shared
=
project
.
in
(
file
(
"./shared"
))
.
settings
(
scalaVersion
:=
ScalaVersion
)
lazy
val
shared
=
project
.
in
(
file
(
"./shared"
)).
settings
(
scalaVersion
:=
ScalaVersion
).
settings
(
jsManagerSettings
:
_
*
)
lazy
val
client
=
Project
(
"client"
,
...
...
@@ -29,7 +30,7 @@ object ScalaTraJSTagsWireRxBuild extends Build {
"org.scala-lang.modules.scalajs"
%%%
"scalajs-dom"
%
"0.6"
,
"org.scala-lang.modules.scalajs"
%%%
"scalajs-jquery"
%
"0.6"
),
jsCall
:=
"
Plo
t().run();"
,
jsCall
:=
"
Clien
t().run();"
,
outputPath
:=
"server/src/main/webapp/"
)
).
dependsOn
(
shared
)
...
...
server/src/main/scala/ScalatraBootstrap.scala
View file @
474fb9fb
...
...
@@ -6,6 +6,9 @@ import scala.concurrent.ExecutionContext.Implicits.global
class
ScalatraBootstrap
extends
LifeCycle
{
override
def
init
(
context
:
ServletContext
)
{
//val serv = new MyScalatraServlet
// pluginROutes.foreach{serv.addRoute}
context
.
mount
(
new
MyScalatraServlet
,
"/*"
)
}
}
server/src/main/scala/fr/iscpif/app/MyScalatraServlet.scala
View file @
474fb9fb
...
...
@@ -11,6 +11,7 @@ import scala.concurrent.Await
object
Server
extends
Api
{
def
hello
(
a
:
Int
)
=
a
*
3
def
caseClass
(
c
:
MyCaseClass
)
=
c
.
oo
}
class
MyScalatraServlet
extends
ServertestStack
{
...
...
@@ -27,6 +28,6 @@ class MyScalatraServlet extends ServertestStack {
autowire
.
Request
(
Seq
(
basePath
)
++
multiParams
(
"splat"
).
head
.
split
(
"/"
),
upickle
.
read
[
Map
[
String
,
String
]](
request
.
body
))
),
Duration
.
Inf
)
}
}
server/src/main/webapp/default.jade
View file @
474fb9fb
html
head
meta(charset="utf-8")
link(rel="stylesheet" href="css/styles.css")
link(rel="stylesheet" href="css/bootstrap.min.css")
script( type="text/javascript" src="js/d3.v3.min.js")
script( type="text/javascript" src="js/jquery-2.1.1.min.js")
script(type="text/javascript" src="js/bootstrap.min.js")
script(type="text/javascript" src="js/ui-fastopt.js")
script(type="text/javascript" src="js/ui-opt.js")
script(type="text/javascript" src="js/client-fastopt.js")
script(type="text/javascript" src="js/client-opt.js")
body
script="Plot().run();"
\ No newline at end of file
script="Client().run();"
\ No newline at end of file
shared/Shared.scala
View file @
474fb9fb
package
shared
import
scala.annotation.ClassfileAnnotation
import
scala.scalajs.js.annotation.JSExport
class
Web
extends
ClassfileAnnotation
@JSExport
case
class
MyCaseClass
(
oo
:
String
)
@Web
trait
Api
{
def
hello
(
a
:
Int
)
:
Int
def
caseClass
(
cc
:
MyCaseClass
)
:
String
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment