Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
eResearch
sails-hook-redbox-labarchives
Commits
f99928e8
Commit
f99928e8
authored
Jan 24, 2019
by
Moises Sacal
Browse files
added automatic email for ticket
#25
and fixed ticket
#26
parent
7bdffafc
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
angular/labarchives/dist/main.bundle.js
View file @
f99928e8
This diff is collapsed.
Click to expand it.
angular/labarchives/src/app/components/labarchives-login.component.ts
View file @
f99928e8
...
...
@@ -16,10 +16,13 @@ export class LabarchivesLoginField extends FieldBase<any> {
usernameLabel
:
string
;
passwordLabel
:
string
;
loginLabel
:
string
;
userLoginError
:
string
;
userPasswordError
:
string
;
helpLoginLabel
:
string
;
helpLoginLabelList
:
object
[];
loginHelpImage
:
string
;
loginHelpImageAlt
:
string
;
userEmail
:
string
;
password
:
string
;
submitted
=
false
;
errorMessage
:
string
=
undefined
;
...
...
@@ -39,6 +42,8 @@ export class LabarchivesLoginField extends FieldBase<any> {
this
.
columns
=
options
[
'
columns
'
]
||
[];
this
.
usernameLabel
=
options
[
'
usernameLabel
'
]
||
'
Username
'
;
this
.
passwordLabel
=
options
[
'
passwordLabel
'
]
||
'
Password
'
;
this
.
userLoginError
=
options
[
'
userLoginError
'
]
||
'
Please include username
'
;
this
.
userPasswordError
=
options
[
'
userPasswordError
'
]
||
'
Please include password
'
;
this
.
loginLabel
=
options
[
'
loginLabel
'
]
||
'
Login
'
;
this
.
helpLoginLabel
=
options
[
'
helpLoginLabel
'
]
||
''
;
this
.
helpLoginLabelList
=
options
[
'
helpLoginLabelList
'
]
||
[];
...
...
@@ -50,6 +55,7 @@ export class LabarchivesLoginField extends FieldBase<any> {
registerEvents
()
{
this
.
fieldMap
[
'
List
'
].
field
[
'
checkLoggedIn
'
].
subscribe
(
this
.
checkLogin
.
bind
(
this
));
this
.
setUserEmail
();
}
checkLogin
(
status
:
boolean
)
{
...
...
@@ -57,12 +63,18 @@ export class LabarchivesLoginField extends FieldBase<any> {
this
.
loading
=
false
;
}
async
setUserEmail
()
{
const
userInfo
=
await
this
.
labarchivesService
.
getUserInfo
();
const
user
=
userInfo
[
'
user
'
];
this
.
userEmail
=
user
[
'
email
'
];
}
async
login
(
form
)
{
const
formValid
=
this
.
loginValid
(
form
);
if
(
formValid
===
''
)
{
// TODO: Investigate this. Using this method to remove the trailing Base64 equals ==
form
.
password
=
form
.
password
.
replace
(
/
\+
/g
,
'
-
'
).
replace
(
/
\/
/g
,
'
_
'
).
replace
(
/
\=
+$/
,
''
);
this
.
user
=
{
username
:
form
.
user
name
,
password
:
form
.
password
};
this
.
user
=
{
username
:
this
.
user
Email
,
password
:
form
.
password
};
const
login
=
await
this
.
labarchivesService
.
login
(
this
.
user
.
username
,
this
.
user
.
password
);
if
(
login
.
status
)
{
this
.
loggedIn
=
true
;
...
...
@@ -72,18 +84,17 @@ export class LabarchivesLoginField extends FieldBase<any> {
}
else
{
this
.
errorMessage
=
login
.
message
;
}
}
else
{
this
.
errorMessage
=
formValid
;
}
}
loginValid
(
form
)
{
if
(
!
form
.
user
name
)
{
return
'
Please include username
'
;
if
(
!
form
.
user
Email
)
{
return
this
.
userLoginError
;
}
if
(
!
form
.
password
)
{
return
'
Please include username
'
;
return
this
.
userPasswordError
;
}
return
''
;
}
...
...
@@ -102,7 +113,7 @@ export class LabarchivesLoginField extends FieldBase<any> {
<form #form="ngForm">
<div class="form-group">
<label>{{ field.usernameLabel }}</label>
<input type="text" class="form-control" ngModel
name="username"
<input type="text" class="form-control"
[(
ngModel
)]="field.userEmail" name="userEmail" ngModel
attr.aria-label="{{ field.usernameLabel }}">
</div>
<div class="form-group">
...
...
angular/labarchives/src/app/labarchives.service.ts
View file @
f99928e8
...
...
@@ -89,4 +89,17 @@ export class LabarchivesService extends BaseService {
}
}
public
async
getUserInfo
()
{
const
wsUrl
=
this
.
brandingAndPortalUrl
+
'
/user/info
'
;
try
{
const
result
=
await
this
.
http
.
get
(
wsUrl
,
this
.
options
).
toPromise
();
return
Promise
.
resolve
((
this
.
extractData
(
result
)));
}
catch
(
e
)
{
return
Promise
.
reject
(
new
Error
(
e
));
}
}
}
api/Config.js
View file @
f99928e8
...
...
@@ -12,6 +12,8 @@ class Config {
this
.
domain
=
la
.
domain
;
this
.
parentRecord
=
workspaceConfig
.
parentRecord
;
this
.
provisionerUser
=
workspaceConfig
.
provisionerUser
;
this
.
location
=
la
.
location
;
this
.
description
=
la
.
description
;
this
.
brandingAndPortalUrl
=
''
;
this
.
redboxHeaders
=
{
'
Cache-Control
'
:
'
no-cache
'
,
...
...
api/UserInfo.js
View file @
f99928e8
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
class
UserInfo
{
constructor
(
id
,
orcid
,
fullName
,
notebooks
)
{
constructor
(
id
,
orcid
,
fullName
)
{
this
.
id
=
id
;
this
.
orcid
=
orcid
;
this
.
fullName
=
fullName
;
this
.
notebooks
=
notebooks
[
'
notebook
'
].
map
(
nb
=>
{
const
getDefault
=
nb
[
'
is-default
'
];
const
isDefault
=
getDefault
[
'
_
'
]
!==
'
false
'
;
return
new
Notebook
(
nb
[
'
id
'
],
nb
[
'
name
'
],
isDefault
);
});
}
}
exports
.
UserInfo
=
UserInfo
;
class
Notebook
{
constructor
(
id
,
name
,
isDefault
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
isDefault
=
isDefault
;
}
}
api/controllers/LabarchivesController.js
View file @
f99928e8
...
...
@@ -31,7 +31,7 @@ var Controllers;
rxjs_1
.
Observable
.
fromPromise
(
userInfo
).
flatMap
(
response
=>
{
const
userInfo
=
response
[
'
users
'
];
if
(
userInfo
)
{
info
=
new
UserInfo_1
.
UserInfo
(
userInfo
[
'
id
'
],
userInfo
[
'
orcid
'
],
userInfo
[
'
fullname
'
]
,
userInfo
[
'
notebooks
'
]
);
info
=
new
UserInfo_1
.
UserInfo
(
userInfo
[
'
id
'
],
userInfo
[
'
orcid
'
],
userInfo
[
'
fullname
'
]);
return
WorkspaceService
.
workspaceAppFromUserId
(
userId
,
this
.
config
.
appName
);
}
else
{
...
...
@@ -121,8 +121,8 @@ var Controllers;
rdmpOid
:
rdmp
,
rdmpTitle
:
rdmpTitle
,
title
:
nbName
,
location
:
`https://au-mynotebook.labarchives.com`
,
description
:
'
LabArchives Workspace
'
,
location
:
this
.
config
.
location
,
description
:
this
.
config
.
description
,
type
:
this
.
config
.
recordType
};
return
WorkspaceService
.
createWorkspaceRecord
(
this
.
config
,
username
,
record
,
this
.
config
.
recordType
,
this
.
config
.
workflowStage
);
...
...
config/env/development.js
View file @
f99928e8
...
...
@@ -31,7 +31,9 @@ module.exports = {
appId
:
'
labarchives
'
,
recordType
:
'
labarchives
'
,
workspaceFileName
:
'
README.md
'
,
key
:
{
"
akid
"
:
"
USER
"
,
"
password
"
:
"
PASSWORD
"
}
key
:
{
"
akid
"
:
"
USER
"
,
"
password
"
:
"
PASSWORD
"
},
location
:
'
https://au-mynotebook.labarchives.com
'
,
description
:
'
LabArchives Workspace
'
}
}
};
form-config/labarchives-1.0-draft.js
View file @
f99928e8
...
...
@@ -34,7 +34,9 @@ module.exports = {
definition
:
{
name
:
'
Login
'
,
loginLabel
:
'
Login
'
,
userLoginError
:
'
Please include your UTS email address
'
,
usernameLabel
:
'
UTS email address
'
,
userPasswordError
:
'
Please include your password token
'
,
passwordLabel
:
'
LabArchives password token for external applications
'
,
helpLoginLabel
:
'
To get your Lab Archives password token:
'
,
helpLoginLabelList
:
[
...
...
typescript/api/Config.ts
View file @
f99928e8
...
...
@@ -13,6 +13,8 @@ export class Config {
types
:
any
;
workspaceFileName
:
string
;
key
:
any
;
location
:
string
;
description
:
string
;
constructor
(
workspaces
)
{
const
workspaceConfig
=
workspaces
;
...
...
@@ -27,6 +29,8 @@ export class Config {
this
.
parentRecord
=
workspaceConfig
.
parentRecord
;
this
.
provisionerUser
=
workspaceConfig
.
provisionerUser
;
this
.
location
=
la
.
location
;
this
.
description
=
la
.
description
;
this
.
brandingAndPortalUrl
=
''
;
this
.
redboxHeaders
=
{
...
...
typescript/api/UserInfo.ts
View file @
f99928e8
...
...
@@ -3,23 +3,10 @@ export class UserInfo {
id
:
string
;
orcid
:
string
;
fullName
:
string
;
notebooks
:
Array
<
Notebook
>
;
constructor
(
id
:
string
,
orcid
:
string
,
fullName
:
string
,
notebooks
:
any
)
{
constructor
(
id
:
string
,
orcid
:
string
,
fullName
:
string
)
{
this
.
id
=
id
;
this
.
orcid
=
orcid
;
this
.
fullName
=
fullName
;
this
.
notebooks
=
notebooks
[
'
notebook
'
].
map
(
nb
=>
{
const
getDefault
=
nb
[
'
is-default
'
];
const
isDefault
=
getDefault
[
'
_
'
]
!==
'
false
'
;
return
new
Notebook
(
nb
[
'
id
'
],
nb
[
'
name
'
],
isDefault
);
});
}
}
class
Notebook
{
constructor
(
public
id
:
string
,
public
name
:
string
,
public
isDefault
:
boolean
)
{
}
}
typescript/api/controllers/LabarchivesController.ts
View file @
f99928e8
...
...
@@ -49,7 +49,7 @@ export module Controllers {
Observable
.
fromPromise
(
userInfo
).
flatMap
(
response
=>
{
const
userInfo
=
response
[
'
users
'
];
if
(
userInfo
)
{
info
=
new
UserInfo
(
userInfo
[
'
id
'
],
userInfo
[
'
orcid
'
],
userInfo
[
'
fullname
'
]
,
userInfo
[
'
notebooks
'
]
);
info
=
new
UserInfo
(
userInfo
[
'
id
'
],
userInfo
[
'
orcid
'
],
userInfo
[
'
fullname
'
]);
return
WorkspaceService
.
workspaceAppFromUserId
(
userId
,
this
.
config
.
appName
);
}
else
{
//Doing this because if the password is incorrect labarchives returns a 404!
...
...
@@ -142,8 +142,8 @@ export module Controllers {
rdmpOid
:
rdmp
,
rdmpTitle
:
rdmpTitle
,
title
:
nbName
,
location
:
`https://au-mynotebook.labarchives.com`
,
description
:
'
LabArchives Workspace
'
,
location
:
this
.
config
.
location
,
//
`https://au-mynotebook.labarchives.com`,
description
:
this
.
config
.
description
,
//
'LabArchives Workspace',
type
:
this
.
config
.
recordType
};
return
WorkspaceService
.
createWorkspaceRecord
(
...
...
typescript/api/services/LabarchivesService.ts
View file @
f99928e8
...
...
@@ -40,6 +40,7 @@ export module Services {
}
}
async
userInfo
(
key
:
any
,
userId
:
string
)
{
try
{
if
(
key
&&
key
[
'
akid
'
]
&&
key
[
'
password
'
])
{
...
...
@@ -53,7 +54,6 @@ export module Services {
}
userInfoViaId
async
insertNode
(
key
:
any
,
userId
:
string
,
nbId
:
string
,
displayText
)
{
try
{
if
(
key
&&
key
[
'
akid
'
]
&&
key
[
'
password
'
])
{
...
...
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