Commit f908511d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

there is field in configuration allowing to provide Google Maps API key

parent 41d9a37d
......@@ -3,6 +3,7 @@
var ConfigurationType = {
DEFAULT_MAP: "DEFAULT_MAP",
GOOGLE_ANALYTICS_IDENTIFIER: "GOOGLE_ANALYTICS_IDENTIFIER",
GOOGLE_MAPS_API_KEY: "GOOGLE_MAPS_API_KEY",
LOGO_IMG: "LOGO_IMG",
LOGO_LINK: "LOGO_LINK",
LEGEND_FILES: "LEGEND_FILES",
......
......@@ -299,4 +299,28 @@ Functions.distance = function(p1, el2) {
return Math.sqrt(distToSegmentSquared(p1, el2.start, el2.end));
}
};
Functions.loadScript = function (url) {
return new Promise(function (resolve) {
var scriptExists = false;
var scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--;) {
if (scripts[i].src === url)
scriptExists = true;
}
if (!scriptExists) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = function () {
resolve();
};
head.appendChild(script);
} else {
resolve();
}
});
};
module.exports = Functions;
This diff is collapsed.
......@@ -131,7 +131,37 @@ public enum ConfigurationElementType {
/**
* Color used for undefined overlay values.
*/
SIMPLE_COLOR_VAL("Overlay color when no values are defined", "00FF00", ConfigurationElementEditType.COLOR, false);
SIMPLE_COLOR_VAL("Overlay color when no values are defined", "00FF00", ConfigurationElementEditType.COLOR, false),
/**
* Color used for 0 overlay value.
*/
NEUTRAL_COLOR_VAL("Don't touch [12.0.x compatibility]", "FFFFFF", ConfigurationElementEditType.COLOR, false),
/**
* Opacity of data overlay objects in the frontend.
*/
OVERLAY_OPACITY("Don't touch [12.0.x compatibility]", "0.8", ConfigurationElementEditType.DOUBLE, false),
/**
* Default content of the email when requesting for an account in the system.
*/
REQUEST_ACCOUNT_DEFAULT_CONTENT("Don't touch [12.0.x compatibility]",
"Dear Disease map team,\nI would like to request an account in the system.\nKind regards",
ConfigurationElementEditType.STRING, true),
DEFAULT_VIEW_PROJECT("Don't touch [12.0.x compatibility]", "true", ConfigurationElementEditType.STRING, true),
DEFAULT_EDIT_COMMENTS_PROJECT("Don't touch [12.0.x compatibility]", "false", ConfigurationElementEditType.STRING,
true),
DEFAULT_LAYOUT_MANAGEMENT("Don't touch [12.0.x compatibility]", "false", ConfigurationElementEditType.STRING, true),
SHOW_REACTION_TYPE("Don't touch [12.0.x compatibility]", "true", ConfigurationElementEditType.STRING, true),
GOOGLE_MAPS_API_KEY("Google Maps API key", "", ConfigurationElementEditType.STRING, false),
;
/**
* Default value of the configuration parameter (it will be used only when
......
......@@ -11,9 +11,6 @@
<h:head>
<!-- Google Maps API version 3.20 -->
<script src="https://maps.google.com/maps/api/js?libraries=drawing&amp;v=3.26" type="text/javascript"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"/>
<script src="https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.min.js" type="text/javascript"/>
......
......@@ -12,8 +12,6 @@
<link rel="shortcut icon" href="./resources/images/favicon.png" type="image/png"/>
<ui:include src="/WEB-INF/components/admin/statistics.xhtml"/>
<script src="https://maps.google.com/maps/api/js?libraries=drawing&amp;v=3.26" type="text/javascript"/>
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
......@@ -38,9 +36,7 @@
minerva.GuiConnector.init();
minerva.ServerConnector.getSessionData(null);
minerva.ServerConnector.login().then(function () {
return minerva.ServerConnector.getProject()
});
function login() {
......@@ -71,6 +67,16 @@
});
}
});
return minerva.ServerConnector.login().then(function () {
return minerva.ServerConnector.getConfiguration();
}).then(function (configuration) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "https://maps.google.com/maps/api/js?libraries=drawing&v=3.26&key=" + configuration.getOption("GOOGLE_MAPS_API_KEY");
head.appendChild(script);
});
}
//]]>
......
Supports Markdown
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