Skip to content
Permalink
Browse files

Add project files.

  • Loading branch information...
ADefWebserver committed Apr 26, 2019
1 parent 6871c7c commit 3b887ec9b2af1087e95d4a538b99dfc28821df66
Showing with 4,993 additions and 0 deletions.
  1. +21 −0 BlazingComponents/BlazingComponents.csproj
  2. +13 −0 BlazingComponents/TemplatedDialog.razor
  3. +36 −0 BlazingComponents/TemplatedList.razor
  4. +9 −0 BlazingPizza.ComponentsLibrary/Authentication/UserState.cs
  5. +64 −0 BlazingPizza.ComponentsLibrary/Authentication/UserStateProvider.razor
  6. +21 −0 BlazingPizza.ComponentsLibrary/BlazingPizza.ComponentsLibrary.csproj
  7. +19 −0 BlazingPizza.ComponentsLibrary/Map/Map.razor
  8. +13 −0 BlazingPizza.ComponentsLibrary/Map/Marker.cs
  9. +9 −0 BlazingPizza.ComponentsLibrary/Map/Point.cs
  10. +28 −0 BlazingPizza.ComponentsLibrary/content/authPopup.js
  11. +79 −0 BlazingPizza.ComponentsLibrary/content/deliveryMap.js
  12. BIN BlazingPizza.ComponentsLibrary/content/leaflet/images/layers-2x.png
  13. BIN BlazingPizza.ComponentsLibrary/content/leaflet/images/layers.png
  14. BIN BlazingPizza.ComponentsLibrary/content/leaflet/images/marker-icon-2x.png
  15. BIN BlazingPizza.ComponentsLibrary/content/leaflet/images/marker-icon.png
  16. BIN BlazingPizza.ComponentsLibrary/content/leaflet/images/marker-shadow.png
  17. +635 −0 BlazingPizza.ComponentsLibrary/content/leaflet/leaflet.css
  18. +5 −0 BlazingPizza.ComponentsLibrary/content/leaflet/leaflet.js
  19. +19 −0 BlazingPizza.Shared/BlazingPizza.Shared.csproj
  20. +29 −0 BlazingPizza.Shared/LatLong.cs
  21. +23 −0 BlazingPizza.Shared/Order.cs
  22. +75 −0 BlazingPizza.Shared/OrderWithStatus.cs
  23. +45 −0 BlazingPizza.Shared/Pizza.cs
  24. +20 −0 BlazingPizza.Shared/PizzaSpecial.cs
  25. +11 −0 BlazingPizza.Shared/PizzaTopping.cs
  26. +13 −0 BlazingPizza.Shared/Topping.cs
  27. +43 −0 BlazingPizza.sln
  28. +7 −0 BlazingPizza/App.razor
  29. +26 −0 BlazingPizza/BlazingPizza.csproj
  30. +63 −0 BlazingPizza/Classes/OrderState.cs
  31. +72 −0 BlazingPizza/Controllers/OrdersController.cs
  32. +16 −0 BlazingPizza/Controllers/PizzasController.cs
  33. +26 −0 BlazingPizza/Controllers/SpecialsController.cs
  34. +26 −0 BlazingPizza/Controllers/ToppingsController.cs
  35. +52 −0 BlazingPizza/Controllers/UserController.cs
  36. +35 −0 BlazingPizza/Data/PizzaStoreContext.cs
  37. +195 −0 BlazingPizza/Data/SeedData.cs
  38. +88 −0 BlazingPizza/Pages/Index.razor
  39. +38 −0 BlazingPizza/Pages/MyOrders.razor
  40. +106 −0 BlazingPizza/Pages/OrderDetails.razor
  41. +142 −0 BlazingPizza/Pages/_Host.cshtml
  42. +1 −0 BlazingPizza/Pages/_Imports.razor
  43. +28 −0 BlazingPizza/Program.cs
  44. +27 −0 BlazingPizza/Properties/launchSettings.json
  45. +92 −0 BlazingPizza/Shared/ConfigurePizzaDialog.razor
  46. +18 −0 BlazingPizza/Shared/ConfiguredPizzaItem.razor
  47. +24 −0 BlazingPizza/Shared/ForceSignInLayout.razor
  48. +22 −0 BlazingPizza/Shared/MainLayout.razor
  49. +24 −0 BlazingPizza/Shared/UserInfo.razor
  50. +99 −0 BlazingPizza/Startup.cs
  51. +11 −0 BlazingPizza/_Imports.razor
  52. +15 −0 BlazingPizza/appsettings.Development.json
  53. +10 −0 BlazingPizza/appsettings.json
  54. BIN BlazingPizza/pizza.db
  55. +7 −0 BlazingPizza/wwwroot/css/bootstrap/bootstrap.min.css
  56. +1 −0 BlazingPizza/wwwroot/css/bootstrap/bootstrap.min.css.map
  57. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-300.woff
  58. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-300.woff2
  59. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-500.woff
  60. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-500.woff2
  61. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-700.woff
  62. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-700.woff2
  63. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-regular.woff
  64. BIN BlazingPizza/wwwroot/css/font/quicksand-v8-latin-regular.woff2
  65. +40 −0 BlazingPizza/wwwroot/css/font/quicksand.css
  66. +86 −0 BlazingPizza/wwwroot/css/open-iconic/FONT-LICENSE
  67. +21 −0 BlazingPizza/wwwroot/css/open-iconic/ICON-LICENSE
  68. +114 −0 BlazingPizza/wwwroot/css/open-iconic/README.md
  69. +1 −0 BlazingPizza/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css
  70. BIN BlazingPizza/wwwroot/css/open-iconic/font/fonts/open-iconic.eot
  71. BIN BlazingPizza/wwwroot/css/open-iconic/font/fonts/open-iconic.otf
  72. +543 −0 BlazingPizza/wwwroot/css/open-iconic/font/fonts/open-iconic.svg
  73. BIN BlazingPizza/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf
  74. BIN BlazingPizza/wwwroot/css/open-iconic/font/fonts/open-iconic.woff
  75. +675 −0 BlazingPizza/wwwroot/css/site.css
  76. BIN BlazingPizza/wwwroot/favicon.ico
  77. +77 −0 BlazingPizza/wwwroot/img/bike.svg
  78. +117 −0 BlazingPizza/wwwroot/img/logo.svg
  79. +106 −0 BlazingPizza/wwwroot/img/pizza-slice.svg
  80. BIN BlazingPizza/wwwroot/img/pizzas/bacon.jpg
  81. BIN BlazingPizza/wwwroot/img/pizzas/brit.jpg
  82. BIN BlazingPizza/wwwroot/img/pizzas/cheese.jpg
  83. BIN BlazingPizza/wwwroot/img/pizzas/margherita.jpg
  84. BIN BlazingPizza/wwwroot/img/pizzas/meaty.jpg
  85. BIN BlazingPizza/wwwroot/img/pizzas/mushroom.jpg
  86. BIN BlazingPizza/wwwroot/img/pizzas/pepperoni.jpg
  87. BIN BlazingPizza/wwwroot/img/pizzas/salad.jpg
  88. +72 −0 BlazingPizza/wwwroot/img/user.svg
  89. BIN BlazingPizza/wwwroot/leaflet/images/layers-2x.png
  90. BIN BlazingPizza/wwwroot/leaflet/images/layers.png
  91. BIN BlazingPizza/wwwroot/leaflet/images/marker-icon-2x.png
  92. BIN BlazingPizza/wwwroot/leaflet/images/marker-icon.png
  93. BIN BlazingPizza/wwwroot/leaflet/images/marker-shadow.png
  94. +635 −0 BlazingPizza/wwwroot/leaflet/leaflet.css
  95. +5 −0 BlazingPizza/wwwroot/leaflet/leaflet.js
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
<EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
</ItemGroup>

</Project>
@@ -0,0 +1,13 @@
@if (Show)
{
<div class="dialog-container">
<div class="dialog">
@ChildContent
</div>
</div>
}

@functions {
[Parameter] RenderFragment ChildContent { get; set; }
[Parameter] bool Show { get; set; }
}
@@ -0,0 +1,36 @@
@typeparam TItem

@if (items == null)
{
@LoadingContent
}
else if (items.Count == 0)
{
@EmptyContent
}
else
{
<div class="list-group @ListGroupClass">
@foreach (var item in items)
{
<div class="list-group-item">
@ItemContent(item)
</div>
}
</div>
}

@functions {
List<TItem> items;

[Parameter] Func<Task<List<TItem>>> Loader { get; set; }
[Parameter] RenderFragment LoadingContent { get; set; }
[Parameter] RenderFragment EmptyContent { get; set; }
[Parameter] RenderFragment<TItem> ItemContent { get; set; }
[Parameter] string ListGroupClass { get; set; }

protected override async Task OnParametersSetAsync()
{
items = await Loader();
}
}
@@ -0,0 +1,9 @@
namespace BlazingPizza.ComponentsLibrary.Authentication
{
public class UserState
{
public bool IsLoggedIn { get; set; }

public string DisplayName { get; set; }
}
}
@@ -0,0 +1,64 @@
@using Microsoft.JSInterop
@using System.Net.Http
@inject HttpClient HttpClient
@inject IJSRuntime JSRuntime

<CascadingValue Value="@this">
@ChildContent
</CascadingValue>

@functions {
private List<TaskCompletionSource<bool>> pendingSignInFlows = new List<TaskCompletionSource<bool>>();

[Parameter] RenderFragment ChildContent { get; set; }

public UserState CurrentUser { get; private set; }

public bool IsLoggedIn => CurrentUser?.IsLoggedIn ?? false;

protected override async Task OnInitAsync()
{
CurrentUser = await HttpClient.GetJsonAsync<UserState>($"/user");
}

public async Task SignIn()
{
await JSRuntime.InvokeAsync<object>("openLoginPopup", new DotNetObjectRef(this));
}

public async Task SignOut()
{
// Transition to "loading" state synchronously, then asynchronously update
CurrentUser = null;
StateHasChanged();

CurrentUser = await HttpClient.PutJsonAsync<UserState>($"/user/signout", null);
StateHasChanged();
}

public Task<bool> TrySignInAsync()
{
if (IsLoggedIn)
{
return Task.FromResult(true);
}

var resultTcs = new TaskCompletionSource<bool>();
pendingSignInFlows.Add(resultTcs);
_ = SignIn();
return resultTcs.Task;
}

[JSInvokable]
public void OnSignInStateChanged(UserState newUserState)
{
CurrentUser = newUserState;
StateHasChanged();

foreach (var tcs in pendingSignInFlows)
{
tcs.SetResult(newUserState.IsLoggedIn);
}
pendingSignInFlows.Clear();
}
}
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
<EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
</ItemGroup>

</Project>
@@ -0,0 +1,19 @@
@using Microsoft.JSInterop
@inject IJSRuntime JSRuntime

<div id="@elementId" style="height: 100%; width: 100%;"></div>

@functions {
string elementId = $"map-{Guid.NewGuid().ToString("D")}";

[Parameter] double Zoom { get; set; }
[Parameter] List<Marker> Markers { get; set; }

protected async override Task OnAfterRenderAsync()
{
await JSRuntime.InvokeAsync<object>(
"deliveryMap.showOrUpdate",
elementId,
Markers);
}
}
@@ -0,0 +1,13 @@
namespace BlazingPizza.ComponentsLibrary.Map
{
public class Marker
{
public string Description { get; set; }

public double X { get; set; }

public double Y { get; set; }

public bool ShowPopup { get; set; }
}
}
@@ -0,0 +1,9 @@
namespace BlazingPizza.ComponentsLibrary.Map
{
public class Point
{
public double X { get; set; }

public double Y { get; set; }
}
}
@@ -0,0 +1,28 @@
(function () {
var userInfoComponent;

window.openLoginPopup = function (component) {
if (userInfoComponent) {
userInfoComponent.dispose();
}

userInfoComponent = component;
var popup = window.open('user/signin?returnUrl=' + encodeURIComponent(location.href), 'loginWindow', 'width=600,height=600');

// Poll to see if it's closed before completion
var intervalHandle = setInterval(function () {
if (popup.closed) {
clearInterval(intervalHandle);
onLoginPopupFinished({ isLoggedIn: false });
}
}, 250);
};

window.onLoginPopupFinished = function (userState) {
if (userInfoComponent) {
userInfoComponent.invokeMethod('OnSignInStateChanged', userState);
userInfoComponent.dispose();
userInfoComponent = null;
}
};
})();
@@ -0,0 +1,79 @@
(function () {
var tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var tileAttribution = 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>';

// Global export
window.deliveryMap = {
showOrUpdate: function (elementId, markers) {
var elem = document.getElementById(elementId);
if (!elem) {
throw new Error('No element with ID ' + elementId);
}

// Initialize map if needed
if (!elem.map) {
elem.map = L.map(elementId);
elem.map.addedMarkers = [];
L.tileLayer(tileUrl, { attribution: tileAttribution }).addTo(elem.map);
}

var map = elem.map;
if (map.addedMarkers.length !== markers.length) {
// Markers have changed, so reset
map.addedMarkers.forEach(marker => marker.removeFrom(map));
map.addedMarkers = markers.map(m => {
return L.marker([m.y, m.x]).bindPopup(m.description).addTo(map);
});

// Auto-fit the view
var markersGroup = new L.featureGroup(map.addedMarkers);
map.fitBounds(markersGroup.getBounds().pad(0.3));

// Show applicable popups. Can't do this until after the view was auto-fitted.
markers.forEach((marker, index) => {
if (marker.showPopup) {
map.addedMarkers[index].openPopup();
}
});
} else {
// Same number of markers, so update positions/text without changing view bounds
markers.forEach((marker, index) => {
animateMarkerMove(
map.addedMarkers[index].setPopupContent(marker.description),
marker,
4000);
});
}
}
};

function animateMarkerMove(marker, coords, durationMs) {
if (marker.existingAnimation) {
cancelAnimationFrame(marker.existingAnimation.callbackHandle);
}

marker.existingAnimation = {
startTime: new Date(),
durationMs: durationMs,
startCoords: { x: marker.getLatLng().lng, y: marker.getLatLng().lat },
endCoords: coords,
callbackHandle: window.requestAnimationFrame(() => animateMarkerMoveFrame(marker))
};
}

function animateMarkerMoveFrame(marker) {
var anim = marker.existingAnimation;
var proportionCompleted = (new Date().valueOf() - anim.startTime.valueOf()) / anim.durationMs;
var coordsNow = {
x: anim.startCoords.x + (anim.endCoords.x - anim.startCoords.x) * proportionCompleted,
y: anim.startCoords.y + (anim.endCoords.y - anim.startCoords.y) * proportionCompleted
};

marker.setLatLng([coordsNow.y, coordsNow.x]);

if (proportionCompleted < 1) {
marker.existingAnimation.callbackHandle = window.requestAnimationFrame(
() => animateMarkerMoveFrame(marker));
}
}
})();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 3b887ec

Please sign in to comment.
You can’t perform that action at this time.