Downgrade API Level requirements
Added Settings feedback
This commit is contained in:
parent
18299d40e0
commit
a3455599c4
@ -1,19 +1,53 @@
|
||||
namespace eShopOnContainers.Core
|
||||
{
|
||||
public static class GlobalSetting
|
||||
public class GlobalSetting
|
||||
{
|
||||
public const string RegisterWebsite = "http://104.40.62.65/Account/Register";
|
||||
private string _baseEndpoint;
|
||||
private static readonly GlobalSetting _instance = new GlobalSetting();
|
||||
|
||||
public const string CatalogEndpoint = "http://104.40.62.65:5101/";
|
||||
public GlobalSetting()
|
||||
{
|
||||
BaseEndpoint = "http://104.40.62.65";
|
||||
}
|
||||
|
||||
public const string OrdersEndpoint = "http://104.40.62.65:5102/";
|
||||
public static GlobalSetting Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public const string BasketEndpoint = "http://104.40.62.65:5103/";
|
||||
public string BaseEndpoint
|
||||
{
|
||||
get { return _baseEndpoint; }
|
||||
set
|
||||
{
|
||||
_baseEndpoint = value;
|
||||
UpdateEndpoint(_baseEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public const string IdentityEndpoint = "http://104.40.62.65:5105/connect/authorize";
|
||||
public string RegisterWebsite { get; set; }
|
||||
|
||||
public const string LogoutEndpoint = "http://104.40.62.65:5105/connect/endsession";
|
||||
public string CatalogEndpoint { get; set; }
|
||||
|
||||
public const string IdentityCallback = "http://localhost:5003/callback.html";
|
||||
public string OrdersEndpoint { get; set; }
|
||||
|
||||
public string BasketEndpoint { get; set; }
|
||||
|
||||
public string IdentityEndpoint { get; set; }
|
||||
|
||||
public string LogoutEndpoint { get; set; }
|
||||
|
||||
public string IdentityCallback { get; set; }
|
||||
|
||||
private void UpdateEndpoint(string baseEndpoint)
|
||||
{
|
||||
RegisterWebsite = string.Format("{0}/Account/Register", baseEndpoint);
|
||||
CatalogEndpoint = string.Format("{0}:5101", baseEndpoint);
|
||||
OrdersEndpoint = string.Format("{0}:5102", baseEndpoint);
|
||||
BasketEndpoint = string.Format("{0}:5103", baseEndpoint);
|
||||
IdentityEndpoint = string.Format("{0}:5105/connect/authorize", baseEndpoint);
|
||||
LogoutEndpoint = string.Format("{0}:5105/connect/endsession", baseEndpoint);
|
||||
IdentityCallback = "http://localhost:5003/callback.html";
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.BasketEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
|
||||
builder.Path = guidUser;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
|
||||
public async Task<CustomerBasket> UpdateBasketAsync(CustomerBasket customerBasket)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.BasketEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
@ -52,7 +52,7 @@ namespace eShopOnContainers.Core.Services.Basket
|
||||
|
||||
public async Task ClearBasketAsync(string guidUser)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.BasketEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.BasketEndpoint);
|
||||
|
||||
builder.Path = guidUser;
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
|
||||
|
||||
builder.Path = string.Format("api/v1/catalog/items/type/{0}/brand/{1}", catalogTypeId, catalogBrandId);
|
||||
|
||||
@ -42,7 +42,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
|
||||
|
||||
builder.Path = "api/v1/catalog/items";
|
||||
|
||||
@ -68,7 +68,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
|
||||
|
||||
builder.Path = "api/v1/catalog/catalogbrands";
|
||||
|
||||
@ -89,7 +89,7 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.CatalogEndpoint);
|
||||
|
||||
builder.Path = "api/v1/catalog/catalogtypes";
|
||||
|
||||
|
@ -13,15 +13,15 @@ namespace eShopOnContainers.Core.Services.Identity
|
||||
{
|
||||
// Create URI to authorize endpoint
|
||||
var authorizeRequest =
|
||||
new AuthorizeRequest(GlobalSetting.IdentityEndpoint);
|
||||
new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);
|
||||
|
||||
// Dictionary with values for the authorize request
|
||||
var dic = new Dictionary<string, string>();
|
||||
dic.Add("client_id", "js");
|
||||
dic.Add("client_id", "xamarin");
|
||||
dic.Add("response_type", "id_token token");
|
||||
dic.Add("scope", "openid profile basket");
|
||||
|
||||
dic.Add("redirect_uri", GlobalSetting.IdentityCallback);
|
||||
dic.Add("redirect_uri", GlobalSetting.Instance.IdentityCallback);
|
||||
dic.Add("nonce", Guid.NewGuid().ToString("N"));
|
||||
|
||||
// Add CSRF token to protect against cross-site request forgery attacks.
|
||||
@ -36,9 +36,9 @@ namespace eShopOnContainers.Core.Services.Identity
|
||||
public string CreateLogoutRequest(string token)
|
||||
{
|
||||
return string.Format("{0}?id_token_hint={1}&post_logout_redirect_uri={2}",
|
||||
GlobalSetting.LogoutEndpoint,
|
||||
GlobalSetting.Instance.LogoutEndpoint,
|
||||
token,
|
||||
GlobalSetting.IdentityCallback);
|
||||
GlobalSetting.Instance.IdentityCallback);
|
||||
}
|
||||
|
||||
public string DecodeToken(string token)
|
||||
|
@ -16,7 +16,7 @@ namespace eShopOnContainers.Core.Services.Order
|
||||
|
||||
public async Task CreateOrderAsync(Models.Orders.Order newOrder)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.OrdersEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint);
|
||||
|
||||
builder.Path = "api/v1/orders/new";
|
||||
|
||||
@ -29,7 +29,7 @@ namespace eShopOnContainers.Core.Services.Order
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.OrdersEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint);
|
||||
|
||||
builder.Path = "api/v1/orders";
|
||||
|
||||
@ -50,7 +50,7 @@ namespace eShopOnContainers.Core.Services.Order
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.OrdersEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint);
|
||||
|
||||
builder.Path = string.Format("api/v1/orders/{0}", orderId);
|
||||
|
||||
@ -71,7 +71,7 @@ namespace eShopOnContainers.Core.Services.Order
|
||||
{
|
||||
try
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.OrdersEndpoint);
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.OrdersEndpoint);
|
||||
|
||||
builder.Path = "api/v1/orders/cardtypes";
|
||||
|
||||
|
@ -170,7 +170,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
private void Register()
|
||||
{
|
||||
_openUrlService.OpenUrl(GlobalSetting.RegisterWebsite);
|
||||
_openUrlService.OpenUrl(GlobalSetting.Instance.RegisterWebsite);
|
||||
}
|
||||
|
||||
private void Logout()
|
||||
@ -188,7 +188,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
private async void NavigateAsync(string url)
|
||||
{
|
||||
if (url.Contains(GlobalSetting.IdentityCallback))
|
||||
if (url.Contains(GlobalSetting.Instance.IdentityCallback))
|
||||
{
|
||||
// Parse response
|
||||
var authResponse = new AuthorizeResponse(url);
|
||||
|
@ -10,6 +10,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
private string _title;
|
||||
private string _description;
|
||||
private bool _useAzureServices;
|
||||
private string _endpoint;
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
@ -46,6 +47,22 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string Endpoint
|
||||
{
|
||||
get { return _endpoint; }
|
||||
set
|
||||
{
|
||||
_endpoint = value;
|
||||
|
||||
if(!string.IsNullOrEmpty(_endpoint))
|
||||
{
|
||||
UpdateEndpoint(_endpoint);
|
||||
}
|
||||
|
||||
RaisePropertyChanged(() => Endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand MockServicesCommand => new Command(MockServices);
|
||||
|
||||
private void MockServices()
|
||||
@ -58,6 +75,8 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
UpdateInfo();
|
||||
|
||||
Endpoint = GlobalSetting.Instance.BaseEndpoint;
|
||||
|
||||
return base.InitializeAsync(navigationData);
|
||||
}
|
||||
|
||||
@ -74,5 +93,10 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
Description = "Azure Services are real objects that required a valid internet connection";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEndpoint(string endpoint)
|
||||
{
|
||||
GlobalSetting.Instance.BaseEndpoint = endpoint;
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,11 @@ namespace eShopOnContainers.Core.Views
|
||||
|
||||
public async Task AnimateIn()
|
||||
{
|
||||
if (Device.OS == TargetPlatform.Windows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await AnimateItem(Banner, 10500);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,18 @@
|
||||
Value="12, 12, 12, 0" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="HeaderLabelStyle"
|
||||
TargetType="{x:Type Label}">
|
||||
<Setter Property="FontFamily"
|
||||
Value="{StaticResource MontserratRegular}" />
|
||||
<Setter Property="FontSize"
|
||||
Value="{StaticResource LittleSize}" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{StaticResource GreenColor}" />
|
||||
<Setter Property="HorizontalOptions"
|
||||
Value="Start" />
|
||||
</Style>
|
||||
|
||||
<animations:StoryBoard
|
||||
x:Key="MockServicesAnimation"
|
||||
Target="{x:Reference MockServices}">
|
||||
@ -82,6 +94,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="1" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid
|
||||
@ -121,10 +134,31 @@
|
||||
WinPhone="Assets/switchOff.png"/>
|
||||
</controls:ToggleButton.UnCheckedImage>
|
||||
</controls:ToggleButton>
|
||||
<Grid
|
||||
<!-- ENDPOINT -->
|
||||
<StackLayout
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="12, 0, 12, 12"
|
||||
IsVisible="{Binding UseAzureServices}">
|
||||
<Label
|
||||
Text="Endpoint"
|
||||
Style="{StaticResource HeaderLabelStyle}"/>
|
||||
<Entry
|
||||
Text="{Binding Endpoint, Mode=TwoWay}">
|
||||
<Entry.Style>
|
||||
<OnPlatform
|
||||
x:TypeArguments="Style"
|
||||
iOS="{StaticResource EntryStyle}"
|
||||
Android="{StaticResource EntryStyle}"
|
||||
WinPhone="{StaticResource UwpEntryStyle}"/>
|
||||
</Entry.Style>
|
||||
</Entry>
|
||||
</StackLayout>
|
||||
<Grid
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
BackgroundColor="Gray"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
|
@ -16,8 +16,8 @@
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
|
||||
<AndroidStoreUncompressedFileExtensions />
|
||||
<MandroidI18n />
|
||||
|
@ -11,8 +11,8 @@
|
||||
<AssemblyName>eShopOnContainers.Windows</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
|
||||
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@ -174,11 +174,10 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SDKReference Include="WindowsMobile, Version=10.0.14393.0">
|
||||
<SDKReference Include="WindowsMobile, Version=10.0.10586.0">
|
||||
<Name>Windows Mobile Extensions for the UWP</Name>
|
||||
</SDKReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user