Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gill-orange committed Oct 14, 2019
1 parent e7b6e23 commit bf24445
Show file tree
Hide file tree
Showing 98 changed files with 5,210 additions and 0 deletions.
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/

# Logs
Logs/

# Generated files
project.lock.json
.vs/

# mstest test results
TestResults

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
packages

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
[Bb]in
[Oo]bj
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
src/.vs/config/applicationhost.config

src/OE_Tenant.Web.Host/wwwroot/Temp/Downloads
src/OE_Tenant.Web.Mvc/wwwroot/Temp/Downloads
src/OE_Tenant.Web.Mvc/Properties/PublishProfiles
src/OE_Tenant.Web.Mvc/node_modules
src/OE_Tenant.Web.Mvc/wwwroot/lib
src/OE_Tenant.Web.Mvc/wwwroot/dist
src/OE_Tenant.Web.Mvc/wwwroot/view-resources/Views/_Bundles
src/OE_Tenant.Web.Mvc/wwwroot/view-resources/Areas/Admin/Views/_Bundles
src/OE_Tenant.Web.Mvc/wwwroot/view-resources/**/*.min.*
src/OE_Tenant.Web.Mvc/wwwroot/Common/**/*.min.*
src/OE_Tenant.Web.Mvc/package-lock.json

src/OE_Tenant.Web.Public/wwwroot/lib
src/OE_Tenant.Web.Public/wwwroot/dist
src/OE_Tenant.Web.Public/wwwroot/Common/_Bundles
src/OE_Tenant.Web.Public/wwwroot/view-resources/Views/_Bundles
src/OE_Tenant.Web.Public/wwwroot/view-resources/**/*.min.*
src/OE_Tenant.Web.Public/wwwroot/Common/**/*.min.*
src/OE_Tenant.Web.Public/node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<RootNamespace>BethanysPieShopHRM.ComponentsLibrary</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.0.0" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions BethanysPieShop.ComponentsLibrary/LocalStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;

namespace BethanysPieShopHRM.ComponentsLibrary
{
public static class LocalStorage
{
public static ValueTask<T> GetAsync<T>(IJSRuntime jsRuntime, string key)
=> jsRuntime.InvokeAsync<T>("blazorLocalStorage.get", key);

public static ValueTask SetAsync(IJSRuntime jsRuntime, string key, object value)
=> jsRuntime.InvokeVoidAsync("blazorLocalStorage.set", key, value);

public static ValueTask DeleteAsync(IJSRuntime jsRuntime, string key)
=> jsRuntime.InvokeVoidAsync("blazorLocalStorage.delete", key);
}
}
24 changes: 24 additions & 0 deletions BethanysPieShop.ComponentsLibrary/Map/Map.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@using System
@using System.Collections.Generic
@using System.Threading.Tasks
@using Microsoft.AspNetCore.Components
@using Microsoft.JSInterop
@using BethanysPieShopHRM.ComponentsLibrary.Map
@inject IJSRuntime JSRuntime

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

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

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

protected async override Task OnAfterRenderAsync(bool firstRender)
{
await JSRuntime.InvokeVoidAsync(
"deliveryMap.showOrUpdate",
elementId,
Markers);
}
}
14 changes: 14 additions & 0 deletions BethanysPieShop.ComponentsLibrary/Map/Marker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BethanysPieShopHRM.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; }
}
}
9 changes: 9 additions & 0 deletions BethanysPieShop.ComponentsLibrary/Map/Point.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BethanysPieShopHRM.ComponentsLibrary.Map
{
public class Point
{
public double X { get; set; }

public double Y { get; set; }
}
}
28 changes: 28 additions & 0 deletions BethanysPieShop.ComponentsLibrary/content/authPopup.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
})();
79 changes: 79 additions & 0 deletions BethanysPieShop.ComponentsLibrary/content/deliveryMap.js
Original file line number Diff line number Diff line change
@@ -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));
}
}
})();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bf24445

Please sign in to comment.