Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole-connect
Commits
a878876e
Commit
a878876e
authored
Dec 06, 2019
by
Mathieu
Browse files
Extract UserData from admin panel
parent
70db3d12
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
adminclient/src/main/resources/webapp/WEB-INF/web.xml
deleted
100644 → 0
View file @
70db3d12
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version=
"3.0"
>
<!--
This listener loads a class in the default package called ScalatraBootstrap.
That class should implement org.scalatra.LifeCycle. Your app can be
configured in Scala code there.
-->
<listener>
<listener-class>
org.scalatra.servlet.ScalatraListener
</listener-class>
</listener>
</web-app>
adminclient/src/main/resources/webapp/fonts/gi.otf
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/glyphicons-halflings-regular.eot
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/glyphicons-halflings-regular.svg
deleted
100644 → 0
View file @
70db3d12
This diff is collapsed.
Click to expand it.
adminclient/src/main/resources/webapp/fonts/glyphicons-halflings-regular.ttf
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/glyphicons-halflings-regular.woff
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/glyphicons-halflings-regular.woff2
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/icomoon.eot
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/icomoon.svg
deleted
100644 → 0
View file @
70db3d12
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg
xmlns=
"http://www.w3.org/2000/svg"
>
<metadata>
Generated by IcoMoon
</metadata>
<defs>
<font
id=
"icomoon"
horiz-adv-x=
"1024"
>
<font-face
units-per-em=
"1024"
ascent=
"960"
descent=
"-64"
/>
<missing-glyph
horiz-adv-x=
"1024"
/>
<glyph
unicode=
" "
horiz-adv-x=
"512"
d=
""
/>
<glyph
unicode=
""
glyph-name=
"book"
d=
"M896 832v-832h-672c-53.026 0-96 42.98-96 96s42.974 96 96 96h608v768h-640c-70.398 0-128-57.6-128-128v-768c0-70.4 57.602-128 128-128h768v896h-64zM224.056 128v0c-0.018-0.002-0.038 0-0.056 0-17.672 0-32-14.326-32-32s14.328-32 32-32c0.018 0 0.038 0.002 0.056 0.002v-0.002h607.89v64h-607.89z"
/>
<glyph
unicode=
""
glyph-name=
"power-cord"
d=
"M1024 677.5l-90.506 90.5-178.746-178.752-101.5 101.502 178.75 178.75-90.5 90.5-178.75-178.75-114.748 114.75-86.626-86.624 512.002-512 86.624 86.622-114.752 114.752 178.752 178.75zM794.040 286.21l-443.824 443.824c-95.818-114.904-204.52-292.454-129.396-445.216l-132.248-132.248c-31.112-31.114-31.112-82.024 0-113.136l14.858-14.858c31.114-31.114 82.026-31.114 113.138 0l132.246 132.244c152.764-75.132 330.318 33.566 445.226 129.39z"
/>
<glyph
unicode=
""
glyph-name=
"database"
d=
"M512 960c-282.77 0-512-71.634-512-160v-128c0-88.366 229.23-160 512-160s512 71.634 512 160v128c0 88.366-229.23 160-512 160zM512 416c-282.77 0-512 71.634-512 160v-192c0-88.366 229.23-160 512-160s512 71.634 512 160v192c0-88.366-229.23-160-512-160zM512 128c-282.77 0-512 71.634-512 160v-192c0-88.366 229.23-160 512-160s512 71.634 512 160v192c0-88.366-229.23-160-512-160z"
/>
</font></defs></svg>
\ No newline at end of file
adminclient/src/main/resources/webapp/fonts/icomoon.ttf
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/fonts/icomoon.woff
deleted
100644 → 0
View file @
70db3d12
File deleted
adminclient/src/main/resources/webapp/img/logo.svg
deleted
100644 → 0
View file @
70db3d12
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"505"
height=
"142.6"
viewBox=
"0 0 505 142.6"
>
<g
fill=
"#403D56"
>
<path
d=
"M100 92.6c-13.2 0-24.5-11.3-24.5-24.5S86.8 43.6 100 43.6s24.5 11.3 24.5 24.5c0 13.1-11.4 24.5-24.5 24.5zm0-38.6c-7.4 0-14 6.7-14 14 0 7.4 6.7 14.1 14 14.1 7.4 0 14-6.7 14-14.1 0-7.3-6.7-14-14-14zM130.6 109.4V61h10.5v3.8c2.7-3.4 6.6-4.5 10.6-4.5 8.8 0 15.3 7.6 15.3 16.2s-6.6 16.1-15.3 16.1c-4 0-8.5-1.3-10.6-4.4v21.2h-10.5zm17.9-25.2c4.2 0 7.4-3.6 7.4-7.7s-3.2-7.7-7.4-7.7-7.4 3.6-7.4 7.7 3.2 7.7 7.4 7.7zM206 77.7h-23.9c0 3.6 2.5 7.4 6.7 7.4 3.7 0 6-2.5 6.1-4.7h10.7c-1.8 8.1-8.4 12.2-16.6 12.2-10.6 0-18-6.3-18-16.1 0-9.7 7.6-16.2 18-16.2 9.4 0 17.2 5.6 17.2 15.5-.1.6-.2 1.3-.2 1.9zm-10-4.9s-.5-5.7-6.9-5.7c-6.6 0-6.9 5.7-6.9 5.7H196zM243.3 91.9h-10.5V74.4c0-3.6-1.4-5.6-4.7-5.6s-5.9 3.5-5.9 7.7v15.4h-10.5V61h10.5v3.8c2.1-2.7 5.4-4.5 9.5-4.5 8.3 0 11.6 5.7 11.6 14.1v17.5z"
/>
</g>
<g
fill=
"#A6BF25"
>
<path
d=
"M299.3 91.9l-5.6-32.8-9.3 32.8h-10.3l-9.3-32.8-5.6 32.8h-11.6l9.2-47.6h12.5l9.9 33.4 9.9-33.4h12.5l9.2 47.6h-11.5zM337.3 92.6c-13.2 0-24.5-11.3-24.5-24.5s11.3-24.5 24.5-24.5 24.5 11.3 24.5 24.5c0 13.1-11.3 24.5-24.5 24.5zm0-38.6c-7.4 0-14 6.7-14 14 0 7.4 6.7 14.1 14 14.1 7.4 0 14-6.7 14-14.1 0-7.3-6.6-14-14-14zM368.2 44.3h10.5v38.1h17.1v9.5h-27.6V44.3zM427.9 91.9h-27.6V44.3h27.6v9.5h-17.1v9.5h16.4v9.5h-16.4v9.6h17.1v9.5z"
/>
</g>
</svg>
build.sbt
View file @
a878876e
...
...
@@ -36,16 +36,6 @@ lazy val shared = project.in(file("shared")) settings (defaultSettings: _*) enab
lazy
val
go
=
taskKey
[
Unit
](
"go"
)
lazy
val
client
=
project
.
in
(
file
(
"client"
))
enablePlugins
(
ExecNpmPlugin
)
settings
(
defaultSettings
)
settings
(
skip
in
packageJSDependencies
:=
false
,
libraryDependencies
++=
Seq
(
"com.lihaoyi"
%%%
"scalatags"
%
scalatagsVersion
,
"fr.iscpif.scaladget"
%%%
"tools"
%
scaladgetVersion
,
"fr.iscpif.scaladget"
%%%
"bootstrapnative"
%
scaladgetVersion
,
"org.scala-js"
%%%
"scalajs-dom"
%
scalajsDomVersion
)
)
dependsOn
(
shared
)
lazy
val
adminclient
=
project
.
in
(
file
(
"adminclient"
))
enablePlugins
(
ExecNpmPlugin
)
settings
(
defaultSettings
)
settings
(
skip
in
packageJSDependencies
:=
false
,
libraryDependencies
++=
Seq
(
"com.lihaoyi"
%%%
"scalatags"
%
scalatagsVersion
,
...
...
@@ -118,11 +108,4 @@ lazy val bootstrap = project.in(file("target/bootstrap")) settings (defaultSetti
val
depsCSS
=
(
cssFile
in
client
in
Compile
).
value
copyToTarget
(
jsBuild
,
appTarget
,
clientResources
,
dependencyJS
,
depsCSS
,
"connect"
)
val
jsBuildAdmin
=
(
fullOptJS
in
adminclient
in
Compile
).
value
.
data
val
clientResourcesAdmin
=
(
resourceDirectory
in
adminclient
in
Compile
).
value
val
dependencyJSAdmin
=
(
dependencyFile
in
adminclient
in
Compile
).
value
val
depsCSSAdmin
=
(
cssFile
in
adminclient
in
Compile
).
value
copyToTarget
(
jsBuildAdmin
,
appTarget
,
clientResourcesAdmin
,
dependencyJSAdmin
,
depsCSSAdmin
,
"admin"
)
})
dependsOn
(
client
,
server
)
admin
client/src/main/scala/org/openmole-connect/client/AdminPanel.scala
→
client/src/main/scala/org/openmole-connect/client/AdminPanel.scala
View file @
a878876e
package
org.openmoleconnect.
admin
client
package
org.openmoleconnect.client
import
java.nio.ByteBuffer
...
...
@@ -29,8 +29,6 @@ object AdminPanel {
@JSExportTopLevel
(
"admin"
)
def
admin
()
=
{
// val users: Var[Seq[UserData]] = Var(Seq())
implicit
def
userDataSeqToRows
(
userData
:
Seq
[
UserData
])
:
Seq
[
ExpandableRow
]
=
userData
.
map
{
u
=>
buildExpandable
(
u
.
name
,
u
.
email
,
u
.
password
,
u
.
role
,
running
)
}
...
...
@@ -39,20 +37,15 @@ object AdminPanel {
lazy
val
rowFlex
=
Seq
(
styles
.
display
.
flex
,
flexDirection
.
row
,
justifyContent
.
spaceAround
,
alignItems
.
center
)
lazy
val
columnFlex
=
Seq
(
styles
.
display
.
flex
,
flexDirection
.
column
,
styles
.
justifyContent
.
center
)
lazy
val
roles
=
Seq
(
user
,
shared
.
Data
.
admin
)
lazy
val
roleFilter
=
(
r
:
Role
)
=>
r
==
shared
.
Data
.
admin
lazy
val
rows
:
Var
[
Seq
[
ExpandableRow
]]
=
Var
(
Seq
())
def
save
(
expandableRow
:
ExpandableRow
,
name
:
TextCell
,
email
:
TextCell
,
password
:
PasswordCell
,
role
:
LabelCell
,
status
:
Status
)
:
Unit
=
{
if
(
name
.
get
.
isEmpty
)
def
save
(
expandableRow
:
ExpandableRow
,
userData
:
UserData
)
:
Unit
=
{
if
(
userData
.
name
.
isEmpty
)
rows
.
update
(
rows
.
now
.
filterNot
(
_
==
expandableRow
))
else
{
val
userRole
:
Role
=
role
.
get
val
modifiedUser
=
UserData
(
name
.
get
,
email
.
get
,
password
.
get
,
userRole
)
upsert
(
modifiedUser
)
upsert
(
userData
)
}
}
...
...
@@ -72,23 +65,6 @@ object AdminPanel {
def
buildExpandable
(
userName
:
String
=
""
,
userEmail
:
String
=
""
,
userPassword
:
String
=
""
,
userRole
:
Role
=
""
,
userStatus
:
Status
=
user
,
expanded
:
Boolean
=
false
)
:
ExpandableRow
=
{
val
aVar
=
Var
(
expanded
)
def
roleStyle
(
s
:
Role
)
=
if
(
s
==
shared
.
Data
.
admin
)
label_success
else
label_default
val
name
=
TextCell
(
userName
,
Some
(
"Name"
))
val
email
=
TextCell
(
userEmail
,
Some
(
"Email"
))
val
password
=
PasswordCell
(
userPassword
,
Some
(
"Password"
))
val
role
=
LabelCell
(
userRole
,
roles
,
optionStyle
=
roleStyle
,
title
=
Some
(
"Role"
))
val
rowEdit
=
Var
(
false
)
val
buttonStyle
:
ModifierSeq
=
Seq
(
fontSize
:=
22
,
color
:=
"#23527c"
,
opacity
:=
0.8
)
lazy
val
aSubRow
:
StaticSubRow
=
StaticSubRow
({
div
(
height
:=
120
,
rowFlex
)(
groupCell
.
build
(
margin
:=
25
),
...
...
@@ -108,26 +84,8 @@ object AdminPanel {
LabelCell
(
userStatus
,
Seq
(),
optionStyle
=
statusStyle
),
)),
aSubRow
)
lazy
val
groupCell
:
GroupCell
=
GroupCell
(
div
(
rowFlex
,
width
:=
"100%"
)(
name
.
build
(
padding
:=
10
),
email
.
build
(
padding
:=
10
),
password
.
build
(
padding
:=
10
),
role
.
build
(
padding
:=
10
),
span
(
Rx
{
if
(
rowEdit
())
glyphSpan
(
glyph_save
+++
buttonStyle
+++
toClass
(
"actionIcon"
),
()
=>
{
rowEdit
.
update
(!
rowEdit
.
now
)
save
(
expandableRow
,
name
,
email
,
password
,
role
,
userStatus
)
})
else
glyphSpan
(
glyph_edit2
+++
buttonStyle
+++
toClass
(
"actionIcon"
),
()
=>
{
//button("Edit", btn_default, onclick := { () =>
rowEdit
.
update
(!
rowEdit
.
now
)
groupCell
.
switch
})
}
)
),
name
,
email
,
password
,
role
)
lazy
val
groupCell
:
GroupCell
=
UserPanel
.
editableData
(
userName
,
userEmail
,
userPassword
,
userRole
,
userStatus
,
expanded
,
(
uData
:
UserData
)
=>
save
(
expandableRow
,
uData
))
expandableRow
}
...
...
@@ -146,7 +104,7 @@ object AdminPanel {
height
:=
40.85
)
val
editablePanel
=
div
(
val
editablePanel
=
div
(
maxWidth
:=
1000
,
margin
:=
"40px auto"
)(
addUserButton
(
styles
.
display
.
flex
,
flexDirection
.
row
,
styles
.
justifyContent
.
flexEnd
),
Rx
{
div
(
styles
.
display
.
flex
,
flexDirection
.
row
,
styles
.
justifyContent
.
center
)(
...
...
client/src/main/scala/org/openmole-connect/client/UserPanel.scala
0 → 100644
View file @
a878876e
package
org.openmoleconnect.client
import
rx.Rx
import
scaladget.bootstrapnative._
import
scaladget.tools.toClass
import
scalatags.JsDom.styles
import
scaladget.bootstrapnative.bsn._
import
scaladget.tools._
import
scalatags.JsDom.all._
import
shared.Data._
import
rx._
object
UserPanel
{
lazy
val
rowFlex
=
Seq
(
styles
.
display
.
flex
,
flexDirection
.
row
,
justifyContent
.
spaceAround
,
alignItems
.
center
)
lazy
val
columnFlex
=
Seq
(
styles
.
display
.
flex
,
flexDirection
.
column
,
styles
.
justifyContent
.
center
)
lazy
val
roles
=
Seq
(
user
,
shared
.
Data
.
admin
)
lazy
val
roleFilter
=
(
r
:
Role
)
=>
r
==
shared
.
Data
.
admin
def
editableData
(
userName
:
String
=
""
,
userEmail
:
String
=
""
,
userPassword
:
String
=
""
,
userRole
:
Role
=
""
,
userStatus
:
Status
=
user
,
expanded
:
Boolean
=
false
,
upserting
:
(
UserData
)
=>
Unit
)
:
GroupCell
=
{
val
aVar
=
Var
(
expanded
)
def
roleStyle
(
s
:
Role
)
=
if
(
s
==
shared
.
Data
.
admin
)
label_success
else
label_default
val
name
=
TextCell
(
userName
,
Some
(
"Name"
))
val
email
=
TextCell
(
userEmail
,
Some
(
"Email"
))
val
password
=
PasswordCell
(
userPassword
,
Some
(
"Password"
))
val
role
=
LabelCell
(
userRole
,
roles
,
optionStyle
=
roleStyle
,
title
=
Some
(
"Role"
))
val
rowEdit
=
Var
(
false
)
val
buttonStyle
:
ModifierSeq
=
Seq
(
fontSize
:=
22
,
color
:=
"#23527c"
,
opacity
:=
0.8
)
lazy
val
groupCell
:
GroupCell
=
GroupCell
(
div
(
rowFlex
,
width
:=
"100%"
)(
name
.
build
(
padding
:=
10
),
email
.
build
(
padding
:=
10
),
password
.
build
(
padding
:=
10
),
role
.
build
(
padding
:=
10
),
span
(
Rx
{
if
(
rowEdit
())
glyphSpan
(
glyph_save
+++
buttonStyle
+++
toClass
(
"actionIcon"
),
()
=>
{
val
userRole
:
Role
=
role
.
get
val
modifiedUser
=
UserData
(
name
.
get
,
email
.
get
,
password
.
get
,
userRole
)
upserting
(
modifiedUser
)
rowEdit
.
update
(!
rowEdit
.
now
)
})
else
glyphSpan
(
glyph_edit2
+++
buttonStyle
+++
toClass
(
"actionIcon"
),
()
=>
{
//button("Edit", btn_default, onclick := { () =>
rowEdit
.
update
(!
rowEdit
.
now
)
groupCell
.
switch
})
}
)
),
name
,
email
,
password
,
role
)
groupCell
}
}
server/src/main/scala/org/openmole-connect/server/ConnectServlet.scala
View file @
a878876e
...
...
@@ -249,18 +249,18 @@ class ConnectServlet(arguments: ConnectServer.ServletArguments) extends Scalatra
}
}
def
connectionHtml
=
someHtml
(
"connect"
,
"connection();"
)
def
connectionHtml
=
someHtml
(
"connection();"
)
def
adminHtml
=
someHtml
(
"admin"
,
"admin();"
)
def
adminHtml
=
someHtml
(
"admin();"
)
def
someHtml
(
jsFileName
:
String
,
jsCall
:
String
)
=
{
def
someHtml
(
jsCall
:
String
)
=
{
contentType
=
"text/html"
tags
.
html
(
tags
.
head
(
tags
.
meta
(
tags
.
httpEquiv
:=
"Content-Type"
,
tags
.
content
:=
"text/html; charset=UTF-8"
),
tags
.
link
(
tags
.
rel
:=
"stylesheet"
,
tags
.
`type`
:=
"text/css"
,
href
:=
"css/deps.css"
),
Seq
(
s
"
${jsFileName}-deps.js"
,
s
"${jsFileName}
.js"
).
map
{
Seq
(
s
"
connect-deps.js"
,
"connect
.js"
).
map
{
jf
=>
tags
.
script
(
tags
.
`type`
:=
"text/javascript"
,
tags
.
src
:=
s
"js/$jf "
)
}
),
...
...
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