Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
2ea17d87
Commit
2ea17d87
authored
May 28, 2018
by
Piotr Gawron
Browse files
there is requirement to agree to terms of use
parent
181a2e1c
Changes
5
Show whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/ServerConnector.js
View file @
2ea17d87
...
...
@@ -652,6 +652,17 @@ ServerConnector.getModels = function (projectId) {
return
models
;
});
};
/**
* TODO REMOVE when API v12 appears (this is just a workaround)
*/
ServerConnector
.
updateTermsOfUse
=
function
(
user
,
value
)
{
var
self
=
this
;
var
url
=
ServerConnector
.
getUserUrl
({
login
:
user
.
getLogin
()});
url
+=
"
/updateTermsOfUse?value=
"
+
value
;
return
self
.
readFile
(
url
);
};
ServerConnector
.
getProject
=
function
(
projectId
)
{
var
queryParams
=
{};
var
filterParams
=
{};
...
...
frontend-js/src/main/js/map/data/User.js
View file @
2ea17d87
...
...
@@ -14,6 +14,7 @@ function User(javaObject) {
this
.
setMinColor
(
javaObject
.
minColor
);
this
.
setMaxColor
(
javaObject
.
maxColor
);
this
.
setSimpleColor
(
javaObject
.
simpleColor
);
this
.
setTermsOfUseConsent
(
javaObject
.
termsOfUseConsent
);
}
User
.
prototype
.
setLogin
=
function
(
login
)
{
...
...
@@ -88,4 +89,12 @@ User.prototype.getPrivileges = function() {
return
this
.
_privileges
;
};
User
.
prototype
.
setTermsOfUseConsent
=
function
(
termsOfUseConsent
)
{
this
.
_termsOfUseConsent
=
termsOfUseConsent
;
};
User
.
prototype
.
isTermsOfUseConsent
=
function
()
{
return
this
.
_termsOfUseConsent
;
};
module
.
exports
=
User
;
frontend-js/src/main/js/minerva.js
View file @
2ea17d87
...
...
@@ -57,6 +57,45 @@ function processUrlGetParams(params) {
}
function
requestConsent
(
user
,
termsOfUseUrl
)
{
var
dialog
=
document
.
createElement
(
"
div
"
);
var
dialogContent
=
document
.
createElement
(
"
div
"
);
dialogContent
.
appendChild
(
functions
.
createElement
({
type
:
"
span
"
,
content
:
"
I agree to the minerva <a href='
"
+
termsOfUseUrl
+
"
' target='_blank'>Terms of Use</a>.
"
}));
var
checkbox
=
functions
.
createElement
({
type
:
"
input
"
,
inputType
:
"
checkbox
"
,
style
:
"
float: left
"
});
var
okButton
=
functions
.
createElement
({
type
:
"
button
"
,
content
:
"
OK
"
,
className
:
"
ui-button ui-corner-all ui-widget
"
,
onclick
:
function
()
{
return
ServerConnector
.
updateTermsOfUse
(
user
,
$
(
checkbox
).
is
(
'
:checked
'
)).
then
(
function
()
{
$
(
dialog
).
dialog
(
"
close
"
);
}).
catch
(
GuiConnector
.
alert
);
}
});
$
(
okButton
).
prop
(
"
disabled
"
,
true
);
$
(
checkbox
).
change
(
function
()
{
$
(
okButton
).
prop
(
"
disabled
"
,
!
$
(
checkbox
).
is
(
'
:checked
'
));
});
dialogContent
.
appendChild
(
checkbox
);
dialogContent
.
appendChild
(
okButton
);
dialog
.
appendChild
(
dialogContent
);
document
.
body
.
appendChild
(
dialog
);
$
(
dialog
).
dialog
({
classes
:
{
"
ui-dialog
"
:
"
ui-state-error
"
},
modal
:
true
,
closeOnEscape
:
false
,
title
:
"
Terms of Use
"
}).
siblings
(
'
.ui-dialog-titlebar
'
).
css
(
"
background
"
,
"
red
"
);
$
(
"
.ui-dialog-titlebar-close
"
,
$
(
dialog
).
dialog
().
siblings
(
'
.ui-dialog-titlebar
'
)).
hide
();
$
(
dialog
).
dialog
(
"
open
"
);
}
function
insertGoogleAnalyticsCode
()
{
return
ServerConnector
.
getConfigurationParam
(
ConfigurationType
.
GOOGLE_ANALYTICS_IDENTIFIER
).
then
(
function
(
identifier
)
{
...
...
@@ -553,9 +592,14 @@ function create(params) {
return
customMap
.
openSubmap
(
submapId
);
}
}).
then
(
function
()
{
return
ServerConnector
.
getLoggedUser
();
}).
then
(
function
(
user
)
{
if
(
leftPanel
.
isGoogleLicenseConsentRequired
())
{
GuiConnector
.
alert
(
"
Some data overlays doesn't have consent to the terms of the <a href='https://cloud.google.com/maps-platform/terms/' target='_blank'>license of Google Maps Platform</a>. To be able to visualize them you must edit data overlay.
"
)
}
if
(
user
.
getLogin
()
!==
"
anonymous
"
&&
!
user
.
isTermsOfUseConsent
())
{
requestConsent
(
user
);
}
var
result
=
createResult
(
customMap
);
if
(
params
.
isDebug
())
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java
View file @
2ea17d87
...
...
@@ -92,6 +92,18 @@ public class UserController extends BaseController {
return
result
;
}
/**
* TODO remove when API 12 will be released!!!
*/
@RequestMapping
(
value
=
"/users/{login:.+}/updateTermsOfUse"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
Map
<
String
,
Object
>
updateTermsOfUse
(
@CookieValue
(
value
=
Configuration
.
AUTH_TOKEN
)
String
token
,
@PathVariable
(
value
=
"login"
)
String
login
,
//
@RequestParam
(
value
=
"value"
)
String
value
,
//
HttpServletResponse
response
//
)
throws
SecurityException
,
ObjectNotFoundException
{
return
userRest
.
updateTermsOfUse
(
token
,
login
,
value
);
}
/**
* @return the userService
* @see #userService
...
...
rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java
View file @
2ea17d87
...
...
@@ -111,7 +111,7 @@ public class UserRestImpl {
value
=
user
.
getSimpleColor
();
}
else
if
(
column
.
equals
(
"removed"
))
{
value
=
user
.
isRemoved
();
}
else
if
(
column
.
equals
(
"terms
OfU
se
C
onsent"
))
{
}
else
if
(
column
.
equals
(
"terms
ofu
se
c
onsent"
))
{
value
=
user
.
isTermsOfUseConsent
();
}
else
if
(
column
.
equals
(
"privileges"
)
&&
admin
)
{
value
=
preparePrivileges
(
user
);
...
...
@@ -175,4 +175,19 @@ public class UserRestImpl {
this
.
layoutService
=
layoutService
;
}
public
Map
<
String
,
Object
>
updateTermsOfUse
(
String
token
,
String
login
,
String
value
)
throws
SecurityException
,
ObjectNotFoundException
{
User
ownUserData
=
userService
.
getUserByToken
(
token
);
if
(
ownUserData
==
null
||
ownUserData
.
getLogin
().
equals
(
"anonymous"
))
{
throw
new
ObjectNotFoundException
(
"User doesn't exist"
);
}
if
(!
ownUserData
.
getLogin
().
equals
(
login
))
{
throw
new
SecurityException
(
"Access denied"
);
}
ownUserData
.
setTermsOfUseConsent
(
value
.
equalsIgnoreCase
(
"true"
));
userService
.
updateUser
(
ownUserData
);
Set
<
String
>
columnSet
=
createUserColumnSet
(
""
);
return
prepareUse
(
ownUserData
,
columnSet
,
true
);
}
}
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