10000 Merge remote-tracking branch 'origin/feature/data-and-ui-customizatio… · ITCSsDeveloper/eShopOnContainers@96c3f5c · GitHub
Skip to content

Commit 96c3f5c

Browse files
committed
Merge remote-tracking branch 'origin/feature/data-and-ui-customization-v2' into dev
# Conflicts: # docker-compose.override.yml # src/Web/WebMVC/WebMVC.csproj # src/Web/WebMVC/wwwroot/css/shared/components/identity/identity.css # src/Web/WebMVC/wwwroot/css/site.min.css # src/Web/WebSPA/AppSettings.cs
2 parents b172fb2 + a6cef80 commit 96c3f5c

98 files changed

Lines changed: 2487 additions & 610 deletions

File tree

  • basket
  • catalog
  • orders
  • Server/Infrastructure
  • Setup
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    docker-compose.override.yml

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -29,6 +29,7 @@ services:
    2929
    - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word
    3030
    - ExternalCatalogBaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5101 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
    3131
    - EventBusConnection=rabbitmq
    32+
    - UseCustomizationData=True
    3233
    ports:
    3334
    - "5101:80"
    3435

    @@ -40,6 +41,7 @@ services:
    4041
    - XamarinCallback=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5105/xamarincallback #localhost do not work for UWP login, so we have to use "external" IP always
    4142
    - ConnectionStrings__DefaultConnection=Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word
    4243
    - MvcClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5100 #Local: You need to open your local dev-machine firewall at range 5100-5105.
    44+
    - UseCustomizationData=True
    4345
    ports:
    4446
    - "5105:80"
    4547

    @@ -50,6 +52,7 @@ services:
    5052
    - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
    5153
    - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
    5254
    - EventBusConnection=rabbitmq
    55+
    - UseCustomizationData=True
    5356
    ports:
    5457
    - "5102:80"
    5558

    @@ -79,6 +82,7 @@ services:
    7982
    - OrderingUrlHC=http://ordering.api/hc
    8083
    - IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser.
    8184
    - BasketUrlHC=http://basket.api/hc
    85+
    - UseCustomizationData=True
    8286
    ports:
    8387
    - "5104:80"
    8488

    @@ -92,6 +96,7 @@ services:
    9296
    - IdentityUrl=http://10.0.75.1:5105
    9397
    - MarketingUrl=http://marketing.api #Local: Use 10.0.75.1 in a "Docker for Windows" environment, if using "localhost" from browser.
    9498
    #Remote: Use ${ESHOP_EXTERNAL_DNS_NAME_OR_IP} if using external IP or DNS name from browser.
    99+
    - UseCustomizationData=True
    95100
    ports:
    96101
    - "5100:80"
    97102

    eShopOnContainers-ServicesAndWebApps.sln

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
    33
    # Visual Studio 15
    44
    VisualStudioVersion = 15.0.26430.12
    55
    MinimumVisualStudioVersion = 10.0.40219.1
    6+
    Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
    7+
    EndProject
    68
    Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{932D8224-11F6-4D07-B109-DA28AD288A63}"
    79
    EndProject
    810
    Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AF739CD-81D8-428D-A08A-0A58372DEBF6}"
    @@ -42,8 +44,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "test\Services\U
    4244
    EndProject
    4345
    Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity.API", "src\Services\Identity\Identity.API\Identity.API.csproj", "{A579E108-5445-403D-A407-339AC4D1611B}"
    4446
    EndProject
    45-
    Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
    46-
    EndProject
    4747
    Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSPA", "src\Web\WebSPA\WebSPA.csproj", "{F16E3C6A-1C94-4EAB-BE91-099618060B68}"
    4848
    EndProject
    4949
    Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "test\Services\IntegrationTests\IntegrationTests.csproj", "{5B810E3D-112E-4857-B197-F09D2FD41E27}"

    eShopOnContainers.sln

    Lines changed: 129 additions & 129 deletions
    Large diffs are not rendered by default.

    src/Services/Catalog/Catalog.API/Catalog.API.csproj

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -21,6 +21,11 @@
    2121
    <Content Include="Pics\**\*;">
    2222
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    2323
    </Content>
    24+
    <Content Include="Setup\**\*;">
    25+
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    26+
    </Content>
    27+
    <Content Remove="Setup\Catalogitems - Copy.zip" />
    28+
    <None Remove="Setup\Catalogitems - Copy.zip" />
    2429
    <Compile Include="IntegrationEvents\EventHandling\AnyFutureIntegrationEventHandler.cs.txt" />
    2530
    <Content Update="web.config;">
    2631
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    @@ -50,6 +55,7 @@
    5055
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
    5156
    <PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
    5257
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
    58+
    <PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
    5359
    </ItemGroup>
    5460

    5561
    <ItemGroup>
    @@ -72,6 +78,9 @@
    7278
    <None Update="Pics\*">
    7379
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    7480
    </None>
    81+
    <None Update="Setup\*">
    82+
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    83+
    </None>
    7584
    </ItemGroup>
    7685

    7786
    </Project>

    src/Services/Catalog/Catalog.API/CatalogSettings.cs

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -5,5 +5,7 @@ public class CatalogSettings
    55
    public string ExternalCatalogBaseUrl {get;set;}
    66

    77
    public string EventBusConnection { get; set; }
    8+
    9+
    public bool UseCustomizationData { get; set; }
    810
    }
    911
    }

    src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -235,7 +235,10 @@ private List<CatalogItem> ChangeUriPlaceholder(List<CatalogItem> items)
    235235

    236236
    items.ForEach(x =>
    237237
    {
    238-
    x.PictureUri = x.PictureUri.Replace("http://externalcatalogbaseurltobereplaced", baseUri);
    238+
    if (!x.PictureUri.Contains('/'))
    239+
    {
    240+
    x.PictureUri = $"{baseUri}/api/v1/pic/{x.PictureUri}";
    241+
    }
    239242
    });
    240243

    241244
    return items;

    src/Services/Catalog/Catalog.API/Controllers/PicController.cs

    Lines changed: 48 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -15,16 +15,58 @@ public PicController(IHostingEnvironment env)
    1515
    _env = env;
    1616
    }
    1717

    18-
    [HttpGet("{id}")]
    18+
    [HttpGet("{filename}")]
    1919
    // GET: /<controller>/
    20-
    public IActionResult GetImage(int id)
    20+
    public IActionResult GetImage(string filename)
    2121
    {
    2222
    var webRoot = _env.WebRootPath;
    23-
    var path = Path.Combine(webRoot, id + ".png");
    23+
    var path = Path.Combine(webRoot, filename);
    2424

    25-
    var buffer = System.IO.File.ReadAllBytes(path);
    26-
    27-
    return File(buffer, "image/png");
    25+
    string imageFileExtension = Path.GetExtension(filename);
    26+
    string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension);
    27+
    28+
    var buffer = System.IO.File.ReadAllBytes(path);
    29+
    30+
    return File(buffer, mimetype);
    31+
    }
    32+
    33+
    private string GetImageMimeTypeFromImageFileExtension(string extension)
    34+
    {
    35+
    string mimetype;
    36+
    37+
    switch (extension)
    38+
    {
    39+
    case "png":
    40+
    mimetype = "image/png";
    41+
    break;
    42+
    case "gif":
    43+
    mimetype = "image/gif";
    44+
    break;
    45+
    case "jpg":
    46+
    case "jpeg":
    47+
    mimetype = "image/jpeg";
    48+
    break;
    49+
    case "bmp":
    50+
    mimetype = "image/bmp";
    51+
    break;
    52+
    case "tiff":
    53+
    mimetype = "image/tiff";
    54+
    break;
    55+
    case "wmf":
    56+
    mimetype = "image/wmf";
    57+
    break;
    58+
    case "jp2":
    59+
    mimetype = "image/jp2";
    60+
    break;
    61+
    case "svg":
    62+
    mimetype = "image/svg+xml";
    63+
    break;
    64+
    default:
    65+
    mimetype = "application/octet-stream";
    66+
    break;
    67+
    }
    68+
    69+
    return mimetype;
    2870
    }
    2971
    }
    3072
    }
    Lines changed: 50 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,50 @@
    1+
    using System;
    2+
    using System.Collections.Generic;
    3+
    using System.Linq;
    4+
    5+
    namespace Catalog.API.Extensions
    6+
    {
    7+
    public static class LinqSelectExtensions
    8+
    {
    9+
    public static IEnumerable<SelectTryResult<TSource, TResult>> SelectTry<TSource, TResult>(this IEnumerable<TSource> enumerable, Func<TSource, TResult> selector)
    10+
    {
    11+
    foreach (TSource element in enumerable)
    12+
    {
    13+
    SelectTryResult<TSource, TResult> returnedValue;
    14+
    try
    15+
    {
    16+
    returnedValue = new SelectTryResult<TSource, TResult>(element, selector(element), null);
    17+
    }
    18+
    catch (Exception ex)
    19+
    {
    20+
    returnedValue = new SelectTryResult<TSource, TResult>(element, default(TResult), ex);
    21+
    }
    22+
    yield return returnedValue;
    23+
    }
    24+
    }
    25+
    26+
    public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<Exception, TResult> exceptionHandler)
    27+
    {
    28+
    return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.CaughtException));
    29+
    }
    30+
    31+
    public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<TSource, Exception, TResult> exceptionHandler)
    32+
    {
    33+
    return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.Source, x.CaughtException));
    34+
    }
    35+
    36+
    public class SelectTryResult<TSource, TResult>
    37+
    {
    38+
    internal SelectTryResult(TSource source, TResult result, Exception exception)
    39+
    {
    40+
    Source = source;
    41+
    Result = result;
    42+
    CaughtException = exception;
    43+
    }
    44+
    45+
    public TSource Source { get; private set; }
    46+
    public TResult Result { get; private set; }
    47+
    public Exception CaughtException { get; private set; }
    48+
    }
    49+
    }
    50+
    }

    0 commit comments

    Comments
     (0)