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
7e6e6631
Commit
7e6e6631
authored
Dec 11, 2019
by
Mathieu
Browse files
Fix date format
parent
69a7f0dd
Changes
7
Hide whitespace changes
Inline
Side-by-side
client/src/main/scala/org/openmole-connect/client/AdminPanel.scala
View file @
7e6e6631
...
...
@@ -72,18 +72,16 @@ object AdminPanel {
userPassword
:
String
=
""
,
userRole
:
Role
=
""
,
userOMVersion
:
String
=
""
,
userLastAccess
:
Lo
ng
=
0L
,
userLastAccess
:
Stri
ng
=
""
,
userStatus
:
Status
=
user
,
expanded
:
Boolean
=
false
)
:
ExpandableRow
=
{
val
aVar
=
Var
(
expanded
)
val
lastAccess
=
new
Date
(
userLastAccess
.
toDouble
)
lazy
val
aSubRow
:
StaticSubRow
=
StaticSubRow
({
div
(
height
:=
300
,
rowFlex
)(
groupCell
.
build
(
margin
:=
25
),
label
(
label_primary
,
userOMVersion
),
div
(
l
astAccess
.
toUTCString
),
//.formatted("EEE, d MMM yyyy HH:mm:ss
"),
div
(
userL
astAccess
,
fontSize
:=
"12px"
,
minWidth
:=
"150
"
),
span
(
columnFlex
,
alignItems
.
flexEnd
,
justifyContent
.
flexEnd
)(
button
(
btn_danger
,
"Delete"
,
onclick
:=
{
()
=>
val
userData
=
UserData
(
userName
,
userEmail
,
userPassword
,
userRole
,
userOMVersion
,
userLastAccess
)
...
...
@@ -117,8 +115,8 @@ object AdminPanel {
rows
()
=
us
}
val
addUserButton
=
button
(
btn_
success
,
"Add"
,
onclick
:=
{
()
=>
val
row
=
buildExpandable
(
userRole
=
user
,
expanded
=
true
)
val
addUserButton
=
button
(
btn_
primary
,
"Add"
,
onclick
:=
{
()
=>
val
row
=
buildExpandable
(
userRole
=
user
,
userOMVersion
=
"LATEST"
,
expanded
=
true
)
rows
.
update
(
rows
.
now
:+
row
)
})
...
...
@@ -127,7 +125,10 @@ object AdminPanel {
)
val
editablePanel
=
div
(
maxWidth
:=
1000
,
margin
:=
"40px auto"
)(
addUserButton
(
styles
.
display
.
flex
,
flexDirection
.
row
,
styles
.
justifyContent
.
flexEnd
),
Utils
.
logoutItem
(
styles
.
display
.
flex
,
flexDirection
.
row
,
justifyContent
.
flexEnd
),
div
(
styles
.
display
.
flex
,
flexDirection
.
row
,
justifyContent
.
flexStart
,
marginLeft
:=
50
,
marginBottom
:=
20
,
marginTop
:=
80
)(
addUserButton
(
styles
.
display
.
flex
,
flexDirection
.
row
,
styles
.
justifyContent
.
flexEnd
)
),
Rx
{
div
(
styles
.
display
.
flex
,
flexDirection
.
row
,
styles
.
justifyContent
.
center
)(
EdiTable
(
Seq
(
"Name"
,
"Status"
),
rows
()).
render
(
width
:=
"90%"
)
...
...
client/src/main/scala/org/openmole-connect/client/UserPanel.scala
View file @
7e6e6631
...
...
@@ -24,7 +24,7 @@ object UserPanel {
userRole
:
Role
=
""
,
userStatus
:
Status
=
user
,
userOMVersion
:
String
,
userLastAccess
:
Lo
ng
,
userLastAccess
:
Stri
ng
,
expanded
:
Boolean
=
false
,
upserting
:
(
UserData
)
=>
Unit
)
:
GroupCell
=
{
...
...
client/src/main/scala/org/openmole-connect/client/Utils.scala
0 → 100644
View file @
7e6e6631
package
org.openmoleconnect.client
import
scalatags.JsDom.styles
import
scaladget.bootstrapnative.bsn._
import
scaladget.tools._
import
scalatags.JsDom.all._
object
Utils
{
val
logoutLogo
=
toClass
(
"glyphicon glyphicon-off"
)
val
itemStyle
:
ModifierSeq
=
Seq
(
fontSize
:=
30
,
pointer
,
color
:=
"#337ab7"
)
val
logoutItem
=
div
(
logoutLogo
,
itemStyle
,
onclick
:=
{
()
⇒
org
.
scalajs
.
dom
.
window
.
location
.
href
=
s
"${org.scalajs.dom.window.location.href}logout"
})
}
server/src/main/scala/org/openmole-connect/server/ConnectServlet.scala
View file @
7e6e6631
...
...
@@ -44,7 +44,9 @@ class ConnectServlet(arguments: ConnectServer.ServletArguments) extends Scalatra
def
withAccesToken
(
action
:
TokenData
=>
ActionResult
)
:
Serializable
=
{
Authentication
.
tokenData
(
request
,
TokenType
.
accessToken
)
match
{
case
Some
(
tokenData
:
TokenData
)
=>
action
(
tokenData
)
case
Some
(
tokenData
:
TokenData
)
=>
DB
.
setLastAccess
(
tokenData
.
email
,
JWT
.
now
)
action
(
tokenData
)
case
None
=>
Authentication
.
isValid
(
request
,
TokenType
.
refreshToken
)
match
{
case
true
=>
...
...
@@ -166,9 +168,6 @@ class ConnectServlet(arguments: ConnectServer.ServletArguments) extends Scalatra
val
host
=
Host
(
uuid
,
None
)
buildAndAddCookieToHeader
(
TokenData
.
accessToken
(
host
,
DB
.
Email
(
email
)))
buildAndAddCookieToHeader
(
TokenData
.
refreshToken
(
host
,
DB
.
Email
(
email
)))
println
(
"SET Last access"
)
DB
.
setLastAccess
(
DB
.
Email
(
email
),
JWT
.
now
)
println
(
"ACSS ? "
+
DB
.
get
(
DB
.
Email
(
email
)).
map
{
_
.
lastAccess
})
redirect
(
"/"
)
case
_
=>
Ok
(
connectionHtml
)
}
...
...
server/src/main/scala/org/openmole-connect/server/DB.scala
View file @
7e6e6631
package
org.openmoleconnect.server
import
java.text.SimpleDateFormat
import
java.util
import
shared.Data.UserData
...
...
@@ -39,16 +40,17 @@ object DB {
u
.
password
.
value
,
u
.
role
.
value
,
u
.
omVersion
.
value
,
u
.
lastAccess
.
value
)
}
Utils
.
toStringDate
(
u
.
lastAccess
.
value
))
}
def
toUser
(
uuid
:
UUID
,
userData
:
UserData
)
:
User
=
User
(
userData
.
name
,
Email
(
userData
.
email
),
Password
(
userData
.
password
),
Version
(
userData
.
omVersion
),
userData
.
lastAccess
,
Utils
.
toLongDate
(
userData
.
lastAccess
)
,
Role
(
userData
.
role
),
uuid
uuid
)
class
Users
(
tag
:
Tag
)
extends
Table
[(
UUID
,
String
,
Email
,
Password
,
Role
,
Version
,
Long
)](
tag
,
"USERS"
)
{
...
...
server/src/main/scala/org/openmole-connect/server/Utils.scala
View file @
7e6e6631
package
org.openmoleconnect.server
import
java.text.SimpleDateFormat
import
java.util.Locale
import
org.apache.http.impl.EnglishReasonPhraseCatalog
object
Utils
{
object
openmoleversion
{
...
...
@@ -7,4 +12,15 @@ object Utils {
def
developpement
=
DB
.
Version
(
"FIXME DEV"
)
}
val
DATE_FORMAT
=
"EEE, d MMM yyyy HH:mm:ss"
def
toStringDate
(
date
:
Long
)
=
date
match
{
case
0L
=>
"NEVER CONNECTED"
case
l
=>
new
SimpleDateFormat
(
DATE_FORMAT
,
new
Locale
(
"en"
)).
format
(
l
)
}
def
toLongDate
(
date
:
String
)
=
{
new
SimpleDateFormat
(
DATE_FORMAT
).
parse
(
date
).
getTime
}
}
shared/src/main/scala/shared/Data.scala
View file @
7e6e6631
...
...
@@ -14,7 +14,7 @@ object Data {
val
off
:
Status
=
"Off"
val
error
:
Status
=
"Error"
case
class
UserData
(
name
:
String
,
email
:
String
,
password
:
String
,
role
:
Role
,
omVersion
:
String
,
lastAccess
:
Lo
ng
)
case
class
UserData
(
name
:
String
,
email
:
String
,
password
:
String
,
role
:
Role
,
omVersion
:
String
,
lastAccess
:
Stri
ng
)
case
class
PersonalUserData
(
name
:
String
,
email
:
String
,
password
:
String
,
role
:
Role
)
...
...
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