Skip to content

Commit

Permalink
📝 🔖 Version 3.0.0-pre1 (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjf committed Dec 5, 2023
1 parent c3998e5 commit 1281db5
Show file tree
Hide file tree
Showing 122 changed files with 2,015 additions and 1,823 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,4 @@ MigrationBackup/
/Our.Umbraco.GMaps.UmbracoV8/App_Plugins/Our.Umbraco.GMaps
/Our.Umbraco.GMaps.UmbracoV10/App_Plugins/Our.Umbraco.GMaps
/Our.Umbraco.GMaps.UmbracoV10/umbraco/models/ood.flag
**/.DS_Store
54 changes: 0 additions & 54 deletions Our.Umbraco.GMaps.Core/Config/GoogleMapsConfig.cs

This file was deleted.

17 changes: 17 additions & 0 deletions Our.Umbraco.GMaps.Core/Configuration/GoogleMaps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.Serialization;

namespace Our.Umbraco.GMaps.Core.Configuration
{
[DataContract]
public class GoogleMaps
{
[DataMember(Name = "apiKey")]
public string ApiKey { get; set; }

[DataMember(Name = "defaultLocation")]
public string DefaultLocation { get; set; }

[DataMember(Name = "zoomLevel")]
public int? ZoomLevel { get; set; }
}
}
8 changes: 0 additions & 8 deletions Our.Umbraco.GMaps.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,5 @@ internal static class Constants
{
public const string PluginName = "GMaps";
public const string MapPropertyAlias = "Our.Umbraco.GMaps";

internal static class Configuration
{
public const string SectionName = "GoogleMaps";
public const string ApiKey = "ApiKey";
public const string DefaultLocation = "DefaultLocation";
public const string DefaultZoom = "DefaultZoomLevel";
}
}
}
34 changes: 7 additions & 27 deletions Our.Umbraco.GMaps.Core/Controllers/GoogleMapsController.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
using Our.Umbraco.GMaps.Core.Config;
#if NET5_0_OR_GREATER
using Our.Umbraco.GMaps.Core.Configuration;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Controllers;
#else
using System.Web.Http;
using Umbraco.Web.WebApi;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.Mvc;
using Umbraco.Core.Mapping;
#endif
using Microsoft.Extensions.Options;

namespace Our.Umbraco.GMaps.Core.Controllers
{
[PluginController(Constants.PluginName)]
public class GoogleMapsController : UmbracoAuthorizedApiController
{
private readonly GoogleMapsConfig googleMapsConfig;
private GoogleMaps googleMapsConfig;

#if NET5_0_OR_GREATER
public GoogleMapsController(GoogleMapsConfig settings)
#else
public GoogleMapsController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor,
ISqlContext sqlContext, ServiceContext services, GoogleMapsConfig settings,
AppCaches appCaches, IProfilingLogger logger, global::Umbraco.Core.IRuntimeState runtimeState,
UmbracoHelper umbracoHelper) :
base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
#endif
public GoogleMapsController(IOptionsMonitor<GoogleMaps> settings)
{
googleMapsConfig = settings;
googleMapsConfig = settings.CurrentValue;
settings.OnChange(config => googleMapsConfig = config);
}


[HttpGet]
public GoogleMapsConfig GetSettings()
public GoogleMaps GetSettings()
{
return googleMapsConfig;
}
Expand Down
29 changes: 7 additions & 22 deletions Our.Umbraco.GMaps.Core/GoogleMapsBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#if NET5_0_OR_GREATER
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Our.Umbraco.GMaps.Core.Config;
using System;
using Our.Umbraco.GMaps.Core.Configuration;
using System.Linq;
using Umbraco.Cms.Core.DependencyInjection;

Expand All @@ -15,34 +14,20 @@ public static class GoogleMapsBuilderExtensions
/// <param name="builder"></param>
/// <param name="defaultOptions"></param>
/// <returns></returns>
public static IUmbracoBuilder AddGoogleMaps(this IUmbracoBuilder builder, Action<GoogleMapsConfig> defaultOptions = default)
public static IUmbracoBuilder AddGoogleMaps(this IUmbracoBuilder builder)
{
// if the GoogleMapsConfig Service is registered then we assume this has been added before so we don't do it again.
if (builder.Services.FirstOrDefault(x => x.ServiceType == typeof(GoogleMapsConfig)) != null)
if (builder.Services.FirstOrDefault(x => x.ServiceType == typeof(GoogleMaps)) != null)
{
return builder;
}

var options = builder.Services.AddSingleton(r =>
builder.Services.Configure<GoogleMaps>(options =>
{
var ret = new GoogleMapsConfig(builder.Config);
if (defaultOptions != default)
{
//Override with custom details
defaultOptions.Invoke(ret);
}
return ret;
builder.Config.GetSection(nameof(GoogleMaps)).Bind(options);
});


if (defaultOptions != default)
{
//options..Configure(defaultOptions);
}

return builder;
}
}
}
#endif
}
18 changes: 0 additions & 18 deletions Our.Umbraco.GMaps.Core/Models/Address.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,49 @@
using Newtonsoft.Json;
using System.Runtime.Serialization;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif

namespace Our.Umbraco.GMaps.Models
{
public class Address
{
[DataMember(Name = "coordinates")]
[JsonProperty("coordinates")]
#if NET5_0_OR_GREATER
[JsonPropertyName("coordinates")]
#endif
public Location Coordinates { get; set; } = new Location();

[DataMember(Name = "full_address")]
[JsonProperty("full_address")]
#if NET5_0_OR_GREATER
[JsonPropertyName("full_address")]
#endif
public string FullAddress { get; set; }

[DataMember(Name = "streetNumber")]
[JsonProperty("streetNumber")]
#if NET5_0_OR_GREATER
[JsonPropertyName("streetNumber")]
#endif
public string StreetNumber { get; set; }

[DataMember(Name = "street")]
[JsonProperty("street")]
#if NET5_0_OR_GREATER
[JsonPropertyName("street")]
#endif
public string Street { get; set; }

[DataMember(Name = "postalcode")]
[JsonProperty("postalcode")]
#if NET5_0_OR_GREATER
[JsonPropertyName("postalcode")]
#endif
public string PostalCode { get; set; }

[DataMember(Name = "city")]
[JsonProperty("city")]
#if NET5_0_OR_GREATER
[JsonPropertyName("city")]
#endif
public string City { get; set; }

[DataMember(Name = "state")]
[JsonProperty("state")]
#if NET5_0_OR_GREATER
[JsonPropertyName("state")]
#endif
public string State { get; set; }

[DataMember(Name = "country")]
[JsonProperty("country")]
#if NET5_0_OR_GREATER
[JsonPropertyName("country")]
#endif
public string Country { get; set; }

}
Expand Down
4 changes: 0 additions & 4 deletions Our.Umbraco.GMaps.Core/Models/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using Newtonsoft.Json.Converters;
using Our.Umbraco.GMaps.Models;
using System.Runtime.Serialization;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif
namespace Our.Umbraco.GMaps.Core.Models.Configuration
{
public class Config
Expand All @@ -22,10 +20,8 @@ public class Config
public string Zoom { get; set; }

[DataMember(Name = "maptype")]
#if NET5_0_OR_GREATER
[JsonPropertyName("maptype")]
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
#endif
[JsonProperty("maptype")]
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
public MapType MapType { get; set; }
Expand Down
6 changes: 0 additions & 6 deletions Our.Umbraco.GMaps.Core/Models/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System;
using System.Globalization;
using System.Runtime.Serialization;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif

namespace Our.Umbraco.GMaps.Models
{
Expand All @@ -15,16 +13,12 @@ public class Location

[DataMember(Name = "lat")]
[JsonProperty("lat")]
#if NET5_0_OR_GREATER
[JsonPropertyName("lat")]
#endif
public double Latitude { get; set; }

[DataMember(Name = "lng")]
[JsonProperty("lng")]
#if NET5_0_OR_GREATER
[JsonPropertyName("lng")]
#endif
public double Longitude { get; set; }

public bool IsEmpty => Latitude == 0 && Longitude == 0;
Expand Down
6 changes: 0 additions & 6 deletions Our.Umbraco.GMaps.Core/Models/Map.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
using Newtonsoft.Json;
using System.Runtime.Serialization;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif

namespace Our.Umbraco.GMaps.Models
{
public class Map
{
[DataMember(Name = "address")]
[JsonProperty("address")]
#if NET5_0_OR_GREATER
[JsonPropertyName("address")]
#endif
public Address Address { get; set; } = new Address();

[DataMember(Name = "mapconfig")]
[JsonProperty("mapconfig")]
#if NET5_0_OR_GREATER
[JsonPropertyName("mapconfig")]
#endif
public MapConfig MapConfig { get; set; } = new MapConfig();

}
Expand Down
12 changes: 0 additions & 12 deletions Our.Umbraco.GMaps.Core/Models/MapConfig.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif

namespace Our.Umbraco.GMaps.Models
{
public class MapConfig
{
[DataMember(Name = "apikey")]
[JsonProperty("apikey")]
#if NET5_0_OR_GREATER
[JsonPropertyName("apikey")]
#endif
public string ApiKey { get; set; }

[DataMember(Name = "zoom")]
[JsonProperty("zoom")]
#if NET5_0_OR_GREATER
[JsonPropertyName("zoom")]
#endif
public int Zoom { get; set; }

[DataMember(Name = "centerCoordinates")]
[JsonProperty("centerCoordinates")]
#if NET5_0_OR_GREATER
[JsonPropertyName("centerCoordinates")]
#endif
public Location CenterCoordinates { get; set; } = new Location();

[DataMember(Name = "mapstyle")]
[JsonProperty("mapstyle")]
#if NET5_0_OR_GREATER
[JsonPropertyName("mapstyle")]
#endif
public string Style { get; set; }

[DataMember(Name = "maptype")]
[JsonProperty("maptype")]
#if NET5_0_OR_GREATER
[JsonPropertyName("maptype")]
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
#endif
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
public MapType? MapType { get; set; }
}
Expand Down
Loading

0 comments on commit 1281db5

Please sign in to comment.