From 435570653ef922135731d71b95904aa760ac1d11 Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Mon, 4 Dec 2017 17:00:30 +0100 Subject: [PATCH] #366 refactor, add map configuration section in basic settings and system page, remove possibility to override the map configuration in the other conf page --- .../api/admin/LocationApiController.java | 30 ++++--------------- .../alfio/model/system/ConfigurationKeys.java | 11 +++---- .../configuration/basic-settings.html | 29 ++++++++++++++++++ .../admin/partials/configuration/system.html | 28 +++++++++++++++++ .../feature/configuration/configuration.js | 16 ++++++++++ .../js/admin/ng-app/admin-application.js | 2 +- .../resources/js/admin/service/service.js | 4 +-- 7 files changed, 87 insertions(+), 33 deletions(-) diff --git a/src/main/java/alfio/controller/api/admin/LocationApiController.java b/src/main/java/alfio/controller/api/admin/LocationApiController.java index c9c48c001d..b177c81323 100644 --- a/src/main/java/alfio/controller/api/admin/LocationApiController.java +++ b/src/main/java/alfio/controller/api/admin/LocationApiController.java @@ -66,26 +66,13 @@ public String getTimezone(@RequestParam("lat") double lat, @RequestParam("lng") @RequestMapping("/location/static-map-image") public String getMapImage( @RequestParam("lat") String lat, - @RequestParam("lng") String lng, - @RequestParam(value = "orgId", required = false) Integer orgId, - @RequestParam(value = "eventId", required = false) Integer eventId) { - - Function pathKeyBuilder = (key) -> { - if(orgId == null && eventId == null) { - return Configuration.getSystemConfiguration(key); - } else if (eventId == null) { - return Configuration.from(orgId, key); - } else { - return Configuration.from(orgId, eventId, key); - } - }; - - Map> geoInfoConfiguration = getGeoConf(pathKeyBuilder); - + @RequestParam("lng") String lng) { + Map> geoInfoConfiguration = getGeoConf(); return LocationDescriptor.getMapUrl(lat, lng, geoInfoConfiguration); } - private Map> getGeoConf(Function pathKeyBuilder) { + private Map> getGeoConf() { + Function pathKeyBuilder = (key) -> Configuration.getSystemConfiguration(key); return configurationManager.getStringConfigValueFrom( pathKeyBuilder.apply(ConfigurationKeys.MAPS_PROVIDER), pathKeyBuilder.apply(ConfigurationKeys.MAPS_CLIENT_API_KEY), @@ -95,19 +82,12 @@ private Map> getGeoConf(Function pathKeyBuilder = (key) -> Configuration.getSystemConfiguration(key); - - Map> geoInfoConfiguration = getGeoConf(pathKeyBuilder); - + Map> geoInfoConfiguration = getGeoConf(); ConfigurationKeys.GeoInfoProvider provider = LocationDescriptor.getProvider(geoInfoConfiguration); - Map apiKeys = new HashMap<>(); - geoInfoConfiguration.forEach((k,v) -> { v.ifPresent(value -> apiKeys.put(k, value)); }); - return new ProviderAndKeys(provider, apiKeys); } diff --git a/src/main/java/alfio/model/system/ConfigurationKeys.java b/src/main/java/alfio/model/system/ConfigurationKeys.java index 5264e22397..eba93aa41e 100644 --- a/src/main/java/alfio/model/system/ConfigurationKeys.java +++ b/src/main/java/alfio/model/system/ConfigurationKeys.java @@ -33,10 +33,10 @@ public enum ConfigurationKeys { BASE_URL("Base application url", false, SettingCategory.GENERAL, ComponentType.TEXT, true, EnumSet.of(SYSTEM), true), - MAPS_PROVIDER("Select the maps provider (Google, Here)", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), - MAPS_CLIENT_API_KEY("Google maps' client api key", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), - MAPS_HERE_APP_ID("HERE map App ID", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), - MAPS_HERE_APP_CODE("HERE map App Code", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), + MAPS_PROVIDER("Select the maps provider (Google, Here)", false, SettingCategory.MAP, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), + MAPS_CLIENT_API_KEY("Google maps' client api key", false, SettingCategory.MAP, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), + MAPS_HERE_APP_ID("HERE map App ID", false, SettingCategory.MAP, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), + MAPS_HERE_APP_CODE("HERE map App Code", false, SettingCategory.MAP, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), RECAPTCHA_API_KEY("Recaptcha api key", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true), @@ -165,7 +165,8 @@ public enum SettingCategory { INVOICE("Invoice settings"), INVOICE_EU("Invoice settings for EU"), MAIL("E-Mail settings"), - ALFIO_PI("Offline check-in and badge printing"); + ALFIO_PI("Offline check-in and badge printing"), + MAP("Maps settings"); private final String description; SettingCategory(String description) { diff --git a/src/main/webapp/resources/angular-templates/admin/partials/configuration/basic-settings.html b/src/main/webapp/resources/angular-templates/admin/partials/configuration/basic-settings.html index c21280e286..904f58b56b 100644 --- a/src/main/webapp/resources/angular-templates/admin/partials/configuration/basic-settings.html +++ b/src/main/webapp/resources/angular-templates/admin/partials/configuration/basic-settings.html @@ -60,6 +60,35 @@

E-Mail

+ + +
+

+ +

+

+ +

+
+ +
+
+ +
+
+ +
+
+ + +
+

+ +

+

+ +

+
+ +
+
+ +
+
+ +
+
+