Commit 2ea17d87 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

there is requirement to agree to terms of use

parent 181a2e1c
...@@ -652,6 +652,17 @@ ServerConnector.getModels = function (projectId) { ...@@ -652,6 +652,17 @@ ServerConnector.getModels = function (projectId) {
return models; 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) { ServerConnector.getProject = function (projectId) {
var queryParams = {}; var queryParams = {};
var filterParams = {}; var filterParams = {};
......
...@@ -14,6 +14,7 @@ function User(javaObject) { ...@@ -14,6 +14,7 @@ function User(javaObject) {
this.setMinColor(javaObject.minColor); this.setMinColor(javaObject.minColor);
this.setMaxColor(javaObject.maxColor); this.setMaxColor(javaObject.maxColor);
this.setSimpleColor(javaObject.simpleColor); this.setSimpleColor(javaObject.simpleColor);
this.setTermsOfUseConsent(javaObject.termsOfUseConsent);
} }
User.prototype.setLogin = function(login) { User.prototype.setLogin = function(login) {
...@@ -88,4 +89,12 @@ User.prototype.getPrivileges = function() { ...@@ -88,4 +89,12 @@ User.prototype.getPrivileges = function() {
return this._privileges; return this._privileges;
}; };
User.prototype.setTermsOfUseConsent = function(termsOfUseConsent) {
this._termsOfUseConsent = termsOfUseConsent;
};
User.prototype.isTermsOfUseConsent = function() {
return this._termsOfUseConsent;
};
module.exports = User; module.exports = User;
...@@ -57,6 +57,45 @@ function processUrlGetParams(params) { ...@@ -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() { function insertGoogleAnalyticsCode() {
return ServerConnector.getConfigurationParam(ConfigurationType.GOOGLE_ANALYTICS_IDENTIFIER).then( return ServerConnector.getConfigurationParam(ConfigurationType.GOOGLE_ANALYTICS_IDENTIFIER).then(
function (identifier) { function (identifier) {
...@@ -553,9 +592,14 @@ function create(params) { ...@@ -553,9 +592,14 @@ function create(params) {
return customMap.openSubmap(submapId); return customMap.openSubmap(submapId);
} }
}).then(function () { }).then(function () {
return ServerConnector.getLoggedUser();
}).then(function (user) {
if (leftPanel.isGoogleLicenseConsentRequired()) { 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. ") 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); var result = createResult(customMap);
if (params.isDebug()) { if (params.isDebug()) {
......
...@@ -92,6 +92,18 @@ public class UserController extends BaseController { ...@@ -92,6 +92,18 @@ public class UserController extends BaseController {
return result; 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 * @return the userService
* @see #userService * @see #userService
......
...@@ -111,7 +111,7 @@ public class UserRestImpl { ...@@ -111,7 +111,7 @@ public class UserRestImpl {
value = user.getSimpleColor(); value = user.getSimpleColor();
} else if (column.equals("removed")) { } else if (column.equals("removed")) {
value = user.isRemoved(); value = user.isRemoved();
} else if (column.equals("termsOfUseConsent")) { } else if (column.equals("termsofuseconsent")) {
value = user.isTermsOfUseConsent(); value = user.isTermsOfUseConsent();
} else if (column.equals("privileges") && admin) { } else if (column.equals("privileges") && admin) {
value = preparePrivileges(user); value = preparePrivileges(user);
...@@ -175,4 +175,19 @@ public class UserRestImpl { ...@@ -175,4 +175,19 @@ public class UserRestImpl {
this.layoutService = layoutService; 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);
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment