Skip to content

Commit

Permalink
Merge pull request #127 from FBoucher/vnext
Browse files Browse the repository at this point in the history
New Release v0.6
  • Loading branch information
FBoucher authored Jun 21, 2020
2 parents dddd55f + 853da17 commit 01dfbc3
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 107 deletions.
8 changes: 4 additions & 4 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ version: 1
update_configs:
- package_manager: "dotnet:nuget"
directory: "/src/shortenerTools"
update_schedule: "weekly"
update_schedule: "monthly"
default_assignees:
- "fboucher"
default_reviewers:
- "fboucher"
target_branch: "dev"
target_branch: "vnext"
- package_manager: "dotnet:nuget"
directory: "/src/adminTools/adminBlazorWebsite/src"
update_schedule: "weekly"
update_schedule: "monthly"
default_assignees:
- "fboucher"
default_reviewers:
- "fboucher"
target_branch: "dev"
target_branch: "vnext"
21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

5 changes: 4 additions & 1 deletion src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace adminBlazorWebsite.Data
Expand All @@ -10,6 +11,8 @@ public class ShortUrlEntity

public string Title { get; set; }

[Required]
[Url]
public string Url { get; set; }

public string ShortUrl { get; set; }
Expand All @@ -32,7 +35,7 @@ public string GetDisplayableUrl(){

var lenght = Url.ToString().Length;
if (lenght >= 50){
return string.Concat(Url.Substring(1,50), "...");
return string.Concat(Url.Substring(0,49), "...");
}
return Url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public string Vanity {
}

[Required]
[Url]
public string Url { get; set; }

}
Expand Down
121 changes: 50 additions & 71 deletions src/adminTools/adminBlazorWebsite/src/Pages/Urls.razor
Original file line number Diff line number Diff line change
Expand Up @@ -46,86 +46,65 @@ else
</tbody>
</table>
<p>
<!-- Add a new ShortUrl -->
<button class="btn btn-primary"
@onclick="CreateShortUrl">
Add New Url
</button>
</p>
<!-- Add a new ShortUrl -->
<button class="btn btn-primary"
@onclick="CreateShortUrl">
Add New Url
</button>
</p>
}

@if(ShowCreatePopup)
@if (ShowCreatePopup)
{
<div class="modal" tabindex="-1" style="display:block" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Short Url Request</h3>
<!-- Button to close the popup -->
<button type="button" class="close"
@onclick="ClosePopup">
<span aria-hidden="true">X</span>
</button>
</div>
<div class="modal-body">
<label>Title</label>
<input class="form-control" type="text"
placeholder="Title or description for this URL"
@bind="shortUrlRequest.Title" />
<br />
<label>The Url to redirect</label>
<input class="form-control" type="text"
placeholder="The Url to redirect"
@bind="shortUrlRequest.Url" />
<br />
<label>Vanity</label>
<input class="form-control" type="text"
placeholder="Vanity or the 'End' part of the Url"
@bind="shortUrlRequest.Vanity" />
<br />
<button class="btn btn-primary"
@onclick="SaveShortUrl">
Save
</button>
</div>
<Modal Title="Short Url Request" ClosePopup="ClosePopup">
<EditForm Model="shortUrlRequest" OnValidSubmit="SaveShortUrl">
<DataAnnotationsValidator />
<div>
<label for="title">Title</label>
<InputText id="title" class="form-control" placeholder="Title or description for this URL" @bind-Value="shortUrlRequest.Title" />
<ValidationMessage For="@(() => shortUrlRequest.Title)" />
</div>
</div>
</div>
<br />
<div>
<label for="url">The Url to redirect</label>
<InputText id="url" class="form-control" placeholder="The Url to redirect" @bind-Value="shortUrlRequest.Url" />
<ValidationMessage For="@(() => shortUrlRequest.Url)" />
</div>
<br />
<div>
<label for="vanity">Vanity</label>
<InputText id="vanity" class="form-control" placeholder="Vanity or the 'End' part of the Url" @bind-Value="shortUrlRequest.Vanity" />
<ValidationMessage For="@(() => shortUrlRequest.Vanity)" />
</div>
<button class="btn btn-primary" type="submit">
Save
</button>
</EditForm>
</Modal>
}


@if(ShowEditPopup)
@if (ShowEditPopup)
{
<div class="modal" tabindex="-1" style="display:block" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Edit Short Url</h3>
<!-- Button to close the popup -->
<button type="button" class="close"
@onclick="ClosePopup">
<span aria-hidden="true">X</span>
</button>
</div>
<div class="modal-body">
<label>Title</label>
<input class="form-control" type="text"
placeholder="Title or description for this URL"
@bind="editedUrl.Title" />
<br />
<label>The Url to redirect</label>
<input class="form-control" type="text"
placeholder="https://..."
@bind="editedUrl.Url" />
<br />
<button class="btn btn-primary"
@onclick="SaveUpdatedShortUrl">
Save
</button>
</div>
<Modal Title="Edit Short Url" ClosePopup="ClosePopup">
<EditForm Model="editedUrl" OnValidSubmit="SaveUpdatedShortUrl">
<DataAnnotationsValidator />
<div>
<label for="edit-title">Title</label>
<InputText id="edit-title" class="form-control" placeholder="Title or description for this URL" @bind-Value="editedUrl.Title" />
<ValidationMessage For="@(() => editedUrl.Title)" />
</div>
<br />
<div>
<label for="edit-url">The Url to redirect</label>
<InputText id="edit-url" class="form-control" placeholder="The Url to redirect" @bind-Value="editedUrl.Url" />
<ValidationMessage For="@(() => editedUrl.Url)" />
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">
Save
</button>
</EditForm>
</Modal>
}


Expand Down
32 changes: 32 additions & 0 deletions src/adminTools/adminBlazorWebsite/src/Shared/Modal.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="modal" tabindex="-1" style="display:block" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">@Title</h3>
<!-- Button to close the popup -->
<button type="button" class="close"
@onclick="ClosePopup">
<span aria-hidden="true">X</span>
</button>
</div>
<div class="modal-body">
@ChildContent
</div>
</div>
</div>
</div>

<div class="modal-backdrop show"></div>



@code {
[Parameter]
public string Title { get; set; }

[Parameter]
public EventCallback ClosePopup { get; set; }

[Parameter]
public RenderFragment ChildContent { get; set; }
}
12 changes: 6 additions & 6 deletions src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
</ItemGroup>

Expand Down
14 changes: 11 additions & 3 deletions src/shortenerTools/UrlShortener/UrlShortener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

namespace Cloud5mins.Function
{

public static class UrlShortener
{

[FunctionName("UrlShortener")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req,
Expand All @@ -53,7 +55,13 @@ public static async Task<HttpResponseMessage> Run(
{
return req.CreateResponse(HttpStatusCode.NotFound);
}


// Validates if input.url is a valid aboslute url, aka is a complete refrence to the resource, ex: http(s)://google.com
if (!Uri.IsWellFormedUriString(input.Url, UriKind.Absolute))
{
return req.CreateErrorResponse(HttpStatusCode.BadRequest, $"{input.Url} is not a valid absolute Url. The Url parameter must start with 'http://' or 'http://'.");
}

var result = new ShortResponse();
var config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
Expand All @@ -66,8 +74,8 @@ public static async Task<HttpResponseMessage> Run(
try
{
string longUrl = input.Url.Trim();
string vanity = input.Vanity.Trim();
string title = input.Title.Trim();
string vanity = string.IsNullOrWhiteSpace(input.Vanity) ? "" : input.Vanity.Trim();
string title = string.IsNullOrWhiteSpace(input.Title) ? "" : input.Title.Trim();

ShortUrlEntity newRow;

Expand Down
6 changes: 6 additions & 0 deletions src/shortenerTools/UrlUpdate/UrlUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public static async Task<HttpResponseMessage> Run(
return req.CreateResponse(HttpStatusCode.NotFound);
}

// Validates if input.url is a valid aboslute url, aka is a complete refrence to the resource, ex: http(s)://google.com
if (!Uri.IsWellFormedUriString(input.Url, UriKind.Absolute))
{
return req.CreateErrorResponse(HttpStatusCode.BadRequest, $"{input.Url} is not a valid absolute Url. The Url parameter must start with 'http://' or 'http://'.");
}

ShortUrlEntity result;
var config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
Expand Down
2 changes: 1 addition & 1 deletion src/shortenerTools/shortenerTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.7" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.5" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down

0 comments on commit 01dfbc3

Please sign in to comment.