From d49198f650ac6bb1ea777661aa7e837efa5ca22d Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Sat, 23 May 2020 17:19:07 +0200 Subject: [PATCH 01/15] Added VS solution file Updated NuGet packages Changed target framework for shortenerTools to netcoreapp3.1 --- AzUrlShortener.sln | 31 ++++++++++++++++++++++++ src/shortenerTools/shortenerTools.csproj | 14 +++++------ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 AzUrlShortener.sln diff --git a/AzUrlShortener.sln b/AzUrlShortener.sln new file mode 100644 index 00000000..287123ef --- /dev/null +++ b/AzUrlShortener.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30122.103 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "shortenerTools", "src\shortenerTools\shortenerTools.csproj", "{F2DDB6A9-0522-44D0-A34D-8DBB63B9BCA7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminBlazorWebsite", "src\adminTools\adminBlazorWebsite\src\adminBlazorWebsite.csproj", "{C0F1FBEA-E94D-4D65-9DD4-FA3089547354}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F2DDB6A9-0522-44D0-A34D-8DBB63B9BCA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2DDB6A9-0522-44D0-A34D-8DBB63B9BCA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2DDB6A9-0522-44D0-A34D-8DBB63B9BCA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2DDB6A9-0522-44D0-A34D-8DBB63B9BCA7}.Release|Any CPU.Build.0 = Release|Any CPU + {C0F1FBEA-E94D-4D65-9DD4-FA3089547354}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0F1FBEA-E94D-4D65-9DD4-FA3089547354}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0F1FBEA-E94D-4D65-9DD4-FA3089547354}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0F1FBEA-E94D-4D65-9DD4-FA3089547354}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {08EEDDBA-DEEE-4573-8A3E-CCB57D35BDCD} + EndGlobalSection +EndGlobal diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 8bbb24b1..9ab2f416 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -1,13 +1,13 @@ - + - netcoreapp2.2 + netcoreapp3.1 v3 - + - - + + @@ -16,9 +16,9 @@ PreserveNewest - + Always Always - + \ No newline at end of file From 75a1728698911f2bd8a30063439e1c36f2430c91 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Mon, 25 May 2020 09:53:50 +0200 Subject: [PATCH 02/15] Add solution folders for docs and deployment files --- AzUrlShortener.sln | 18 ++++++++++++++++++ .../adminBlazorWebsite/src/appsettings.json | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/AzUrlShortener.sln b/AzUrlShortener.sln index 287123ef..18c8136d 100644 --- a/AzUrlShortener.sln +++ b/AzUrlShortener.sln @@ -7,6 +7,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "shortenerTools", "src\short EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminBlazorWebsite", "src\adminTools\adminBlazorWebsite\src\adminBlazorWebsite.csproj", "{C0F1FBEA-E94D-4D65-9DD4-FA3089547354}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Deployment", "Deployment", "{91EC9638-F1E4-4939-837B-206A6E94B7BD}" + ProjectSection(SolutionItems) = preProject + deployment\azureDeploy.json = deployment\azureDeploy.json + deployment\azureDeploy.params.json = deployment\azureDeploy.params.json + deployment\debug.azcli = deployment\debug.azcli + deployment\debugARM.json = deployment\debugARM.json + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{029E1EDF-80F2-40D5-9C76-4C5371D6AB94}" + ProjectSection(SolutionItems) = preProject + azFunctions-deployment.md = azFunctions-deployment.md + CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md + CONTRIBUTING.md = CONTRIBUTING.md + how-it-works.md = how-it-works.md + post-deployment-configuration.md = post-deployment-configuration.md + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/adminTools/adminBlazorWebsite/src/appsettings.json b/src/adminTools/adminBlazorWebsite/src/appsettings.json index 9c68e467..0863798d 100644 --- a/src/adminTools/adminBlazorWebsite/src/appsettings.json +++ b/src/adminTools/adminBlazorWebsite/src/appsettings.json @@ -10,8 +10,8 @@ } }, "AllowedHosts": "*", - "azFunctionUrl" :"http://....../api/UrlList", - "code":"http://..../api/UrlShortener", + "azFunctionUrl": "http://localhost:7071/api/UrlList", + "code": "http://localhost:7071/api/UrlShortener", "defaultAdminEMail": "admin@cloud5mins.com", "defaultAdminPW": "_STRONG_PASSWORD_" } From 62c158480e49964f79f0d19d5ba0e783e0be3e28 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 25 May 2020 13:57:35 +0000 Subject: [PATCH 03/15] Bump Microsoft.Azure.Cosmos.Table in /src/shortenerTools Bumps Microsoft.Azure.Cosmos.Table from 1.0.6 to 1.0.7. Signed-off-by: dependabot-preview[bot] --- src/shortenerTools/shortenerTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 8bbb24b1..2555e935 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -4,7 +4,7 @@ v3 - + From 8b9999388e54554c2639bdb3e5b6997c4e35f195 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 25 May 2020 13:57:55 +0000 Subject: [PATCH 04/15] Bump Microsoft.NET.Sdk.Functions in /src/shortenerTools Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.3 to 3.0.7. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits/3.0.7) Signed-off-by: dependabot-preview[bot] --- src/shortenerTools/shortenerTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 8bbb24b1..45a45b15 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -6,7 +6,7 @@ - + From d21bf7b0cfc5ef423ac80c5b092edc305bda1e14 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 25 May 2020 13:58:19 +0000 Subject: [PATCH 05/15] Bump Microsoft.Extensions.Configuration in /src/shortenerTools Bumps [Microsoft.Extensions.Configuration](https://github.com/aspnet/Extensions) from 3.1.2 to 3.1.4. - [Release notes](https://github.com/aspnet/Extensions/releases) - [Commits](https://github.com/aspnet/Extensions/compare/v3.1.2...v3.1.4) Signed-off-by: dependabot-preview[bot] --- src/shortenerTools/shortenerTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 8bbb24b1..6f7aacda 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -7,7 +7,7 @@ - + From 964cdcbcf7553ecd7f7ee21aecc84d1833cd1fe2 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 26 May 2020 20:59:11 +0200 Subject: [PATCH 06/15] Revert appsettings.json and NuGet updates --- .../adminBlazorWebsite/src/appsettings.json | 4 ++-- src/shortenerTools/shortenerTools.csproj | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/adminTools/adminBlazorWebsite/src/appsettings.json b/src/adminTools/adminBlazorWebsite/src/appsettings.json index 0863798d..9f74f57c 100644 --- a/src/adminTools/adminBlazorWebsite/src/appsettings.json +++ b/src/adminTools/adminBlazorWebsite/src/appsettings.json @@ -10,8 +10,8 @@ } }, "AllowedHosts": "*", - "azFunctionUrl": "http://localhost:7071/api/UrlList", - "code": "http://localhost:7071/api/UrlShortener", + "azFunctionUrl": "http://....../api/UrlList", + "code": "http://....../api/UrlShortener", "defaultAdminEMail": "admin@cloud5mins.com", "defaultAdminPW": "_STRONG_PASSWORD_" } diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 9ab2f416..1ec874db 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -1,13 +1,13 @@  - netcoreapp3.1 + netcoreapp2.2 v3 - + - - + + @@ -16,9 +16,9 @@ PreserveNewest - + Always Always - + \ No newline at end of file From a5c945a8604ab864be10e31dc2864c73f66ee31b Mon Sep 17 00:00:00 2001 From: kmm7 Date: Tue, 26 May 2020 20:44:16 +0100 Subject: [PATCH 07/15] Feature/soft delete (#2) * Fix spelling in comment * Fix the spelling error "Bellow" to "Below" * IsArchived bit flag introduced. Archive button added to the frontend Co-authored-by: Frank Boucher <2404846+FBoucher@users.noreply.github.com> Co-authored-by: Bernard Vander Beken Co-authored-by: IronManion <36028632+IronManion@users.noreply.github.com> Co-authored-by: Anth Co-authored-by: Anth --- .vscode/launch.json | 7 ++ .vscode/settings.json | 24 +++---- azFunctions-deployment.md | 2 +- .../src/Data/ShortUrlEntity.cs | 5 +- .../src/Data/UrlShortenerService.cs | 22 ++++++ .../adminBlazorWebsite/src/Pages/Urls.razor | 18 +++-- src/shortenerTools/.vscode/settings.json | 24 +++---- src/shortenerTools/Domain/ShortResponse.cs | 3 +- src/shortenerTools/Domain/ShortUrlEntity.cs | 21 ++++-- .../Domain/StorageTableHelper.cs | 14 +++- src/shortenerTools/UrlArchive/UrlArchive.cs | 72 +++++++++++++++++++ src/shortenerTools/UrlList/UrlList.cs | 2 + .../UrlShortener/UrlShortener.cs | 2 +- 13 files changed, 173 insertions(+), 43 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 src/shortenerTools/UrlArchive/UrlArchive.cs diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..5c7247b4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 22aa3c11..10e122f6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,21 +1,21 @@ { "workbench.colorCustomizations": { - "activityBar.background": "#1f6fd0", - "activityBar.activeBackground": "#1f6fd0", - "activityBar.activeBorder": "#ee90bb", + "activityBar.background": "#404040", + "activityBar.activeBackground": "#404040", + "activityBar.activeBorder": "#000000", "activityBar.foreground": "#e7e7e7", "activityBar.inactiveForeground": "#e7e7e799", - "activityBarBadge.background": "#ee90bb", - "activityBarBadge.foreground": "#15202b", - "titleBar.activeBackground": "#1857a4", - "titleBar.inactiveBackground": "#1857a499", + "activityBarBadge.background": "#000000", + "activityBarBadge.foreground": "#e7e7e7", + "titleBar.activeBackground": "#272727", + "titleBar.inactiveBackground": "#27272799", "titleBar.activeForeground": "#e7e7e7", "titleBar.inactiveForeground": "#e7e7e799", - "statusBar.background": "#1857a4", - "statusBarItem.hoverBackground": "#1f6fd0", + "statusBar.background": "#272727", + "statusBarItem.hoverBackground": "#404040", "statusBar.foreground": "#e7e7e7", - "statusBar.border": "#1857a4", - "titleBar.border": "#1857a4" + "statusBar.border": "#272727", + "titleBar.border": "#272727" }, - "peacock.color": "#1857a4" + "peacock.color": "#272727" } \ No newline at end of file diff --git a/azFunctions-deployment.md b/azFunctions-deployment.md index 4363aa21..4aa904a7 100644 --- a/azFunctions-deployment.md +++ b/azFunctions-deployment.md @@ -1,6 +1,6 @@ # Deployment Details -This page describes step by step how to deploy the Azure URL Shortener. To learn more about how the deployment was built see the section [bellow](#how-the-deployment-works) +This page describes step by step how to deploy the Azure URL Shortener. To learn more about how the deployment was built see the section [below](#how-the-deployment-works) ## Deployment with the `Deploy to Azure` Button diff --git a/src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs b/src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs index 3da4fcc6..21261a38 100644 --- a/src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs +++ b/src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs @@ -5,6 +5,7 @@ namespace adminBlazorWebsite.Data public class ShortUrlEntity { public string PartitionKey { get; set; } + public string RowKey { get; set; } public string Title { get; set; } @@ -12,11 +13,13 @@ public class ShortUrlEntity 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){ + public static ShortUrlEntity GetEntity(string longUrl, string endUrl) + { return new ShortUrlEntity { PartitionKey = endUrl.First().ToString(), diff --git a/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs b/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs index 394485f1..7ac81af9 100644 --- a/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs +++ b/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs @@ -109,6 +109,28 @@ public async Task UpdateShortUrl(ShortUrlEntity editedUrl) } } + public async Task ArchiveShortUrl(ShortUrlEntity archivedUrl) + { + var url = GetFunctionUrl("UrlArchive"); + + CancellationToken cancellationToken; + + using (var client = new HttpClient()) + using (var request = new HttpRequestMessage(HttpMethod.Delete, url)) + using (var httpContent = CreateHttpContent(archivedUrl)) + { + request.Content = httpContent; + + using (var response = await client + .SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) + .ConfigureAwait(false)) + { + var resultList = response.Content.ReadAsStringAsync().Result; + return JsonConvert.DeserializeObject(resultList); + } + } + } + private static StringContent CreateHttpContent(object content) { diff --git a/src/adminTools/adminBlazorWebsite/src/Pages/Urls.razor b/src/adminTools/adminBlazorWebsite/src/Pages/Urls.razor index c109691e..8da2ee18 100644 --- a/src/adminTools/adminBlazorWebsite/src/Pages/Urls.razor +++ b/src/adminTools/adminBlazorWebsite/src/Pages/Urls.razor @@ -40,6 +40,7 @@ else @url.Clicks + } @@ -109,13 +110,13 @@ else