-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from FBoucher/vnext
Major upgrade to version 2.0
- Loading branch information
Showing
50 changed files
with
2,277 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// Use IntelliSense to find out which attributes exist for C# debugging | ||
// Use hover for the description of the existing attributes | ||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch and Debug Standalone Blazor WebAssembly App", | ||
"type": "blazorwasm", | ||
"request": "launch", | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/TinyBlazorAdmin.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/TinyBlazorAdmin.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"${workspaceFolder}/TinyBlazorAdmin.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<CascadingAuthenticationState> | ||
<Router AppAssembly="@typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"> | ||
<NotAuthorized> | ||
@if (!context.User.Identity.IsAuthenticated) | ||
{ | ||
<RedirectToLogin /> | ||
} | ||
else | ||
{ | ||
<p>You are not authorized to access this resource.</p> | ||
} | ||
</NotAuthorized> | ||
</AuthorizeRouteView> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> | ||
</CascadingAuthenticationState> |
31 changes: 31 additions & 0 deletions
31
src/adminTools/TinyBlazorAdmin/Data/AzFuncAuthorizationMessageHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace TinyBlazorAdmin.Data | ||
{ | ||
/// <summary> | ||
/// Handler to ensure proper credentials are sent with requests. | ||
/// </summary> | ||
public class AzFuncAuthorizationMessageHandler : AuthorizationMessageHandler | ||
{ | ||
public string Endpoint { get; set; } | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="AzFuncAuthorizationMessageHandler"/> | ||
/// class. | ||
/// </summary> | ||
/// <param name="config"><see cref="IConfiguration"/> to access endpoint.</param> | ||
/// <param name="provider"><see cref="IAccessTokenProvider"/> service.</param> | ||
/// <param name="navigation"><see cref="NavigationManager"/> to navigate based on authentication.</param> | ||
public AzFuncAuthorizationMessageHandler( | ||
IConfiguration config, | ||
IAccessTokenProvider provider, | ||
NavigationManager navigation) : base(provider, navigation) | ||
{ | ||
var section = config.GetSection(nameof(UrlShortenerSecuredService)); | ||
Endpoint = section.GetValue<string>(nameof(Endpoint)); | ||
ConfigureHandler(new[] { Endpoint }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace TinyBlazorAdmin.Data | ||
{ | ||
/// <summary> | ||
/// Service to access the Cosmos DB blog posts. | ||
/// </summary> | ||
public class AzFuncClient | ||
{ | ||
|
||
/// <summary> | ||
/// The <see cref="UrlShortenerSecuredService"/> to retrive credentials. | ||
/// </summary> | ||
private readonly UrlShortenerSecuredService _urlSecuredService; | ||
|
||
/// <summary> | ||
/// Creates a new instance of the <see cref="AzFuncClient"/> class. | ||
/// </summary> | ||
/// <param name="urlSecuredService">The <see cref="UrlShortenerSecuredService"/> to request the token.</param> | ||
public AzFuncClient(UrlShortenerSecuredService urlSecuredService) | ||
{ | ||
_urlSecuredService = urlSecuredService; | ||
} | ||
|
||
|
||
public async Task<ShortUrlList> GetUrlList(){ | ||
var result = await _urlSecuredService.GetUrlList(); | ||
return result; | ||
} | ||
|
||
public async Task<ShortUrlList> CreateShortUrl(ShortUrlRequest shortUrlRequest){ | ||
var result = await _urlSecuredService.CreateShortUrl(shortUrlRequest); | ||
return result; | ||
} | ||
|
||
public async Task<ShortUrlEntity> UpdateShortUrl(ShortUrlEntity editedUrl){ | ||
var result = await _urlSecuredService.UpdateShortUrl(editedUrl); | ||
return result; | ||
} | ||
|
||
public async Task<ShortUrlEntity> ArchiveShortUrl(ShortUrlEntity archivedUrl){ | ||
var result = await _urlSecuredService.ArchiveShortUrl(archivedUrl); | ||
return result; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Linq; | ||
|
||
namespace TinyBlazorAdmin.Data | ||
{ | ||
public class ShortUrlEntity | ||
{ | ||
public string PartitionKey { get; set; } | ||
|
||
public string RowKey { get; set; } | ||
|
||
public string Title { get; set; } | ||
|
||
public string Url { get; set; } | ||
|
||
public string ShortUrl { get; set; } | ||
|
||
public int Clicks { get; set; } | ||
|
||
public ShortUrlEntity(){} | ||
|
||
public static ShortUrlEntity GetEntity(string longUrl, string endUrl) | ||
{ | ||
return new ShortUrlEntity | ||
{ | ||
PartitionKey = endUrl.First().ToString(), | ||
RowKey = endUrl, | ||
Url = longUrl | ||
}; | ||
} | ||
|
||
public string GetDisplayableUrl(){ | ||
|
||
var length = Url.ToString().Length; | ||
if (length >= 50){ | ||
return string.Concat(Url.Substring(0,49), "..."); | ||
} | ||
return Url; | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace TinyBlazorAdmin.Data | ||
{ | ||
public class ShortUrlList | ||
{ | ||
public List<ShortUrlEntity> UrlList { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Linq; | ||
|
||
namespace TinyBlazorAdmin.Data | ||
{ | ||
public class ShortUrlRequest | ||
{ | ||
private string _vanity; | ||
|
||
public string Title { get; set; } | ||
|
||
|
||
public string Vanity { | ||
get{ | ||
return (_vanity != null)?_vanity:string.Empty; | ||
} | ||
set{ | ||
_vanity = value; | ||
} | ||
} | ||
|
||
[Required] | ||
public string Url { get; set; } | ||
|
||
} | ||
} |
Oops, something went wrong.