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..92056412 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.foreground": "#e7e7e7", - "activityBar.inactiveForeground": "#e7e7e799", - "activityBarBadge.background": "#ee90bb", - "activityBarBadge.foreground": "#15202b", - "titleBar.activeBackground": "#1857a4", - "titleBar.inactiveBackground": "#1857a499", + "activityBar.background": "#3399ff", + "activityBar.activeBackground": "#3399ff", + "activityBar.activeBorder": "#bf0060", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#bf0060", + "activityBarBadge.foreground": "#e7e7e7", + "titleBar.activeBackground": "#007fff", + "titleBar.inactiveBackground": "#007fff99", "titleBar.activeForeground": "#e7e7e7", "titleBar.inactiveForeground": "#e7e7e799", - "statusBar.background": "#1857a4", - "statusBarItem.hoverBackground": "#1f6fd0", + "statusBar.background": "#007fff", + "statusBarItem.hoverBackground": "#3399ff", "statusBar.foreground": "#e7e7e7", - "statusBar.border": "#1857a4", - "titleBar.border": "#1857a4" + "statusBar.border": "#007fff", + "titleBar.border": "#007fff" }, - "peacock.color": "#1857a4" + "peacock.color": "#272727" } \ No newline at end of file diff --git a/AzUrlShortener.sln b/AzUrlShortener.sln new file mode 100644 index 00000000..18c8136d --- /dev/null +++ b/AzUrlShortener.sln @@ -0,0 +1,49 @@ + +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 +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 + 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/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs b/src/adminTools/adminBlazorWebsite/src/Data/ShortUrlEntity.cs index 3da4fcc6..0d88ecc6 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(), @@ -29,7 +32,7 @@ public string GetDisplayableUrl(){ var lenght = Url.ToString().Length; if (lenght >= 50){ - return Url.Substring(1,50); + return string.Concat(Url.Substring(1,50), "..."); } return Url; } 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