From f3b19a271a9c17052d620522f681f0d6e9e97eda Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Mon, 18 Dec 2023 14:30:04 -0600 Subject: [PATCH 01/15] ### IMPORTANT NOTES With the release of v4.0.0, the Azure Naming Tool has been upgraded to a .NET 8 Blazor Web App. This requires an update to the hosting environment, as well as a BACKUP & RESTORE of your configuration. Review the v3.4.0 Migration Guide for details. [View the Azure Naming Tool v3.4 Migration Guide](https://github.com/mspnp/AzureNamingTool/wiki/v3.4.0-MigrationGuide) ### FEATURES - Updated project to .NET 8 - Updated project to Blazor Web App - Added new site setting for enabling/disabling Instructions page for non-admin users - Added new site setting for enabling/disabling Generated Names Log page for non-admin users - Added new site settings for enabling/disabling Latest News for all users ### CONTRIBUTORS - [mwiedemeyer](https://github.com/mwiedemeyer) --- .gitignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9b3808a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/src/bin/Debug/net8.0/settings +/src/obj +/src/Properties/PublishProfiles +/src/Properties/ServiceDependencies/azurenamingtool-dev - Zip Deploy +/src/.vs +/src/bin/Debug/net8.0 From 36e5b0f9e63d54972c275718f042dd33837ef65d Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Mon, 18 Dec 2023 14:30:14 -0600 Subject: [PATCH 02/15] ### IMPORTANT NOTES With the release of v4.0.0, the Azure Naming Tool has been upgraded to a .NET 8 Blazor Web App. This requires an update to the hosting environment, as well as a BACKUP & RESTORE of your configuration. Review the v3.4.0 Migration Guide for details. [View the Azure Naming Tool v3.4 Migration Guide](https://github.com/mspnp/AzureNamingTool/wiki/v3.4.0-MigrationGuide) ### FEATURES - Updated project to .NET 8 - Updated project to Blazor Web App - Added new site setting for enabling/disabling Instructions page for non-admin users - Added new site setting for enabling/disabling Generated Names Log page for non-admin users - Added new site settings for enabling/disabling Latest News for all users ### CONTRIBUTORS - [mwiedemeyer](https://github.com/mwiedemeyer) --- src/.dockerignore | 7 +- src/.gitattributes | 63 --- src/.gitignore | 367 ------------------ src/App.razor | 23 -- src/AzureNamingTool.csproj | 80 +--- src/AzureNamingTool.csproj.user | 10 + src/AzureNamingTool.sln | 14 +- .../_Host.cshtml => Components/App.razor} | 91 +++-- .../General}/AnchorNavigation.razor | 0 .../General}/ExternalContent.razor | 0 .../General}/LatestNews.razor | 0 .../General}/NavMenu.razor | 23 +- .../General}/NavMenu.razor.css | 0 .../AdminConfigurationInstructions.razor | 19 + .../Instructions/AdminLogInstructions.razor | 0 .../AdminPasswordInstructions.razor | 0 .../ConfigurationInstructions.razor | 0 .../Instructions/GenerateInstructions.razor | 0 .../GeneratedNamesLogInstructions.razor | 0 .../Instructions/ReferenceInstructions.razor | 0 .../Layout}/MainLayout.razor | 11 +- src/Components/Layout/MainLayout.razor.css | 97 +++++ src/Components/Layout/NavMenu.razor | 230 +++++++++++ src/Components/Layout/NavMenu.razor.css | 62 +++ .../Modals/AddModal.razor | 0 .../Modals/ConfirmationModal.razor | 2 +- .../Modals/EditModal.razor | 0 .../Modals/InformationModal.razor | 4 +- .../Modals/MultiTypeSelectModal.razor | 0 .../Modals/PasswordModal.razor | 2 +- .../Modals/WorkingModal.razor | 0 src/{ => Components}/Pages/Admin.razor | 90 +++++ src/{ => Components}/Pages/AdminLog.razor | 0 .../Pages/Configuration.razor | 2 +- src/Components/Pages/Error.razor | 36 ++ src/{ => Components}/Pages/Generate.razor | 4 +- .../Pages/GeneratedNamesLog.razor | 8 +- src/{ => Components}/Pages/Index.razor | 33 +- src/{ => Components}/Pages/Instructions.razor | 31 +- src/{ => Components}/Pages/Reference.razor | 0 src/Components/Routes.razor | 16 + src/{ => Components}/_Imports.razor | 8 +- src/Dockerfile | 19 +- src/Helpers/GeneralHelper.cs | 4 +- src/Helpers/ModalHelper.cs | 2 +- src/Models/ConfigurationData.cs | 31 +- src/Models/SiteConfiguration.cs | 3 + src/Models/StateContainer.cs | 12 +- src/Pages/Error.cshtml | 42 -- src/Pages/Error.cshtml.cs | 27 -- src/Pages/_Layout.cshtml | 44 --- src/Program.cs | 73 ++-- src/Properties/launchSettings.json | 34 +- src/Services/AdminLogService.cs | 2 +- src/Services/ImportExportService.cs | 15 + src/Shared/MainLayout.razor.css | 72 ---- src/appsettings.Development.json | 4 +- src/appsettings.json | 10 +- src/programsettings.json | 2 +- src/repository/appsettings.json | 3 + src/wwwroot/app.css | 178 +++++++++ src/wwwroot/favicon.png | Bin 0 -> 1148 bytes 62 files changed, 1032 insertions(+), 878 deletions(-) delete mode 100644 src/.gitattributes delete mode 100644 src/.gitignore delete mode 100644 src/App.razor create mode 100644 src/AzureNamingTool.csproj.user rename src/{Pages/_Host.cshtml => Components/App.razor} (56%) rename src/{Shared/Components => Components/General}/AnchorNavigation.razor (100%) rename src/{Shared/Components => Components/General}/ExternalContent.razor (100%) rename src/{Shared/Components => Components/General}/LatestNews.razor (100%) rename src/{Shared/Components => Components/General}/NavMenu.razor (92%) rename src/{Shared/Components => Components/General}/NavMenu.razor.css (100%) rename src/{Shared => Components}/Instructions/AdminConfigurationInstructions.razor (88%) rename src/{Shared => Components}/Instructions/AdminLogInstructions.razor (100%) rename src/{Shared => Components}/Instructions/AdminPasswordInstructions.razor (100%) rename src/{Shared => Components}/Instructions/ConfigurationInstructions.razor (100%) rename src/{Shared => Components}/Instructions/GenerateInstructions.razor (100%) rename src/{Shared => Components}/Instructions/GeneratedNamesLogInstructions.razor (100%) rename src/{Shared => Components}/Instructions/ReferenceInstructions.razor (100%) rename src/{Shared => Components/Layout}/MainLayout.razor (96%) create mode 100644 src/Components/Layout/MainLayout.razor.css create mode 100644 src/Components/Layout/NavMenu.razor create mode 100644 src/Components/Layout/NavMenu.razor.css rename src/{Shared => Components}/Modals/AddModal.razor (100%) rename src/{Shared => Components}/Modals/ConfirmationModal.razor (97%) rename src/{Shared => Components}/Modals/EditModal.razor (100%) rename src/{Shared => Components}/Modals/InformationModal.razor (97%) rename src/{Shared => Components}/Modals/MultiTypeSelectModal.razor (100%) rename src/{Shared => Components}/Modals/PasswordModal.razor (98%) rename src/{Shared => Components}/Modals/WorkingModal.razor (100%) rename src/{ => Components}/Pages/Admin.razor (90%) rename src/{ => Components}/Pages/AdminLog.razor (100%) rename src/{ => Components}/Pages/Configuration.razor (99%) create mode 100644 src/Components/Pages/Error.razor rename src/{ => Components}/Pages/Generate.razor (99%) rename src/{ => Components}/Pages/GeneratedNamesLog.razor (97%) rename src/{ => Components}/Pages/Index.razor (82%) rename src/{ => Components}/Pages/Instructions.razor (83%) rename src/{ => Components}/Pages/Reference.razor (100%) create mode 100644 src/Components/Routes.razor rename src/{ => Components}/_Imports.razor (77%) delete mode 100644 src/Pages/Error.cshtml delete mode 100644 src/Pages/Error.cshtml.cs delete mode 100644 src/Pages/_Layout.cshtml delete mode 100644 src/Shared/MainLayout.razor.css create mode 100644 src/wwwroot/app.css create mode 100644 src/wwwroot/favicon.png diff --git a/src/.dockerignore b/src/.dockerignore index 3729ff0c..fe1152bd 100644 --- a/src/.dockerignore +++ b/src/.dockerignore @@ -22,4 +22,9 @@ **/secrets.dev.yaml **/values.dev.yaml LICENSE -README.md \ No newline at end of file +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/src/.gitattributes b/src/.gitattributes deleted file mode 100644 index 1ff0c423..00000000 --- a/src/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 2dde792d..00000000 --- a/src/.gitignore +++ /dev/null @@ -1,367 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# 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 -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# 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 -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - -# Settings files -settings/* -!settings/blank.txt \ No newline at end of file diff --git a/src/App.razor b/src/App.razor deleted file mode 100644 index 344f424f..00000000 --- a/src/App.razor +++ /dev/null @@ -1,23 +0,0 @@ -@using AzureNamingTool.Models; - - - - - - - - - - Not found - - -

Whoa, it looks like that page went and r-u-n-n-o-f-t! Try again!

-
-
-
-
-
-@code { - [Parameter] - public IdentityProviderDetails? identityProviderDetails { get; set; } -} diff --git a/src/AzureNamingTool.csproj b/src/AzureNamingTool.csproj index 0b58776c..8261c253 100644 --- a/src/AzureNamingTool.csproj +++ b/src/AzureNamingTool.csproj @@ -1,82 +1,25 @@ - + - 3.3.0 - net7.0 + net8.0 enable enable - 8d243b16-78f2-4542-8f36-682411560b1a + 4.0.0 + true + eca63fb9-b7f9-454f-910b-5088ae877085 Linux . - true - - - - 1591;1701;1702 - - - - 1591;1701;1702 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Always - - - Never - + + + + @@ -85,9 +28,4 @@ - - - - - diff --git a/src/AzureNamingTool.csproj.user b/src/AzureNamingTool.csproj.user new file mode 100644 index 00000000..838fbf22 --- /dev/null +++ b/src/AzureNamingTool.csproj.user @@ -0,0 +1,10 @@ + + + + https + C:\Projects\v3.4.0\AzureNamingTool\Properties\PublishProfiles\azurenamingtool-dev - Zip Deploy.pubxml + + + ProjectDebugger + + \ No newline at end of file diff --git a/src/AzureNamingTool.sln b/src/AzureNamingTool.sln index df78ab4b..c26d8f0e 100644 --- a/src/AzureNamingTool.sln +++ b/src/AzureNamingTool.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.0.32112.339 +VisualStudioVersion = 17.8.34322.80 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureNamingTool", "AzureNamingTool.csproj", "{611DC036-F19A-4198-A63E-9163B545F59A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureNamingTool", "AzureNamingTool.csproj", "{B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {611DC036-F19A-4198-A63E-9163B545F59A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {611DC036-F19A-4198-A63E-9163B545F59A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {611DC036-F19A-4198-A63E-9163B545F59A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {611DC036-F19A-4198-A63E-9163B545F59A}.Release|Any CPU.Build.0 = Release|Any CPU + {B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8C98E701-BDC5-4F6F-9F85-7BEC01C00E51} + SolutionGuid = {903E93DC-11BB-4512-A444-F59A4BE2EEF8} EndGlobalSection EndGlobal diff --git a/src/Pages/_Host.cshtml b/src/Components/App.razor similarity index 56% rename from src/Pages/_Host.cshtml rename to src/Components/App.razor index 6787beed..f241777a 100644 --- a/src/Pages/_Host.cshtml +++ b/src/Components/App.razor @@ -1,27 +1,25 @@ -@page "/" -@namespace AzureNamingTool.Pages -@using AzureNamingTool.Helpers; -@using AzureNamingTool.Models; +@using AzureNamingTool.Helpers +@using AzureNamingTool.Models @inject StateContainer state -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@inject IHttpContextAccessor httpContextAccessor; @{ - Layout = "_Layout"; + //Layout = "_Layout"; // Verify the site configration files are present ConfigurationHelper.VerifyConfiguration(state); ConfigurationHelper.VerifySecurity(state); var identityProviderDetails = new IdentityProviderDetails(); - // Check if there is an HttpContext object - if (GeneralHelper.IsNotNull(this.HttpContext)) + //Check if there is an HttpContext object + if (GeneralHelper.IsNotNull(httpContextAccessor)) { - if (GeneralHelper.IsNotNull(this.HttpContext.Request.Headers)) + if (GeneralHelper.IsNotNull(httpContextAccessor.HttpContext!.Request.Headers)) { // Get the Identity provider, if using Azure App Service Authentication - if (this.HttpContext.Request.Headers.ContainsKey("X-MS-CLIENT-PRINCIPAL-IDP")) + if (httpContextAccessor.HttpContext.Request.Headers.ContainsKey("X-MS-CLIENT-PRINCIPAL-IDP")) { // Set the identity provider - identityProviderDetails.CurrentIdentityProvider = this.HttpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-IDP"]!; + identityProviderDetails.CurrentIdentityProvider = httpContextAccessor.HttpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-IDP"]!; } } @@ -30,16 +28,16 @@ { string headername = ConfigurationHelper.GetAppSetting("IdentityHeaderName", true); // Check if the IdentityHeaderName header is present - if(GeneralHelper.IsNotNull(this.HttpContext)) + if (GeneralHelper.IsNotNull(httpContextAccessor.HttpContext)) { - if(GeneralHelper.IsNotNull(this.HttpContext.Request)) + if (GeneralHelper.IsNotNull(httpContextAccessor.HttpContext.Request)) { - if (GeneralHelper.IsNotNull(this.HttpContext.Request.Headers)) + if (GeneralHelper.IsNotNull(httpContextAccessor.HttpContext.Request.Headers)) { - if (this.HttpContext.Request.Headers.ContainsKey(headername)) + if (httpContextAccessor.HttpContext.Request.Headers.ContainsKey(headername)) { // Set the current user - identityProviderDetails.CurrentUser = this.HttpContext.Request.Headers[headername]!; + identityProviderDetails.CurrentUser = httpContextAccessor.HttpContext.Request.Headers[headername]!; } } } @@ -47,11 +45,27 @@ } } } - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file + + function addPopovers() { + $("#dropdownMenu").on("show.bs.dropdown", function () { + // For difference between offset and position: http://stackoverflow.com/a/3202038/44852 + var dropdownButtonPosition = $(this).position(); + var dropdownButtonOffset = $(this).offset(); + var dropdownButtonHeight = $(this).height(); + var dropdownMenu = $(this).find(".dropdown-menu:first"); + var dropdownMenuHeight = dropdownMenu.height(); + var scrollToTop = $(document).scrollTop(); + + // It seems there are some numbers that don't get included so I am using some tolerance for + // more accurate result. + var heightTolerance = 17; + + // I figured that window.innerHeight works more accurate on Chrome + // but it is not available on Internet Explorer. So I am using $(window).height() + // method where window.innerHeight is not available. + var visibleWindowHeight = window.innerHeight || $(window).height(); + + var totalHeightDropdownOccupies = dropdownMenuHeight + + dropdownButtonOffset.top + dropdownButtonHeight + heightTolerance - scrollToTop; + + // If there is enough height for dropdown to fully appear, then show it under the dropdown button, + // otherwise show it above dropdown button. + var dropdownMenuTopLocation = totalHeightDropdownOccupies < visibleWindowHeight + ? dropdownButtonPosition.top + dropdownButtonHeight + : dropdownButtonPosition.top - dropdownMenuHeight - dropdownButtonHeight + heightTolerance; + + dropdownMenu.css("left", dropdownButtonPosition.left) + .css("top", dropdownMenuTopLocation); + }); + } + diff --git a/src/Shared/Components/AnchorNavigation.razor b/src/Components/General/AnchorNavigation.razor similarity index 100% rename from src/Shared/Components/AnchorNavigation.razor rename to src/Components/General/AnchorNavigation.razor diff --git a/src/Shared/Components/ExternalContent.razor b/src/Components/General/ExternalContent.razor similarity index 100% rename from src/Shared/Components/ExternalContent.razor rename to src/Components/General/ExternalContent.razor diff --git a/src/Shared/Components/LatestNews.razor b/src/Components/General/LatestNews.razor similarity index 100% rename from src/Shared/Components/LatestNews.razor rename to src/Components/General/LatestNews.razor diff --git a/src/Shared/Components/NavMenu.razor b/src/Components/General/NavMenu.razor similarity index 92% rename from src/Shared/Components/NavMenu.razor rename to src/Components/General/NavMenu.razor index be81f064..5da4ba12 100644 --- a/src/Shared/Components/NavMenu.razor +++ b/src/Components/General/NavMenu.razor @@ -127,7 +127,7 @@ } - @if ((PageType.ToString() == "AzureNamingTool.Pages.Index") && (connected)) + @if ((PageType.ToString() == "AzureNamingTool.Pages.Index") && (connected) && !Convert.ToBoolean(config.LatestNewsEnabled)) {
diff --git a/src/Shared/Modals/WorkingModal.razor b/src/Components/Modals/WorkingModal.razor similarity index 100% rename from src/Shared/Modals/WorkingModal.razor rename to src/Components/Modals/WorkingModal.razor diff --git a/src/Pages/Admin.razor b/src/Components/Pages/Admin.razor similarity index 90% rename from src/Pages/Admin.razor rename to src/Components/Pages/Admin.razor index c9a89a35..8a97240b 100644 --- a/src/Pages/Admin.razor +++ b/src/Components/Pages/Admin.razor @@ -413,6 +413,69 @@ +
+ +
+
+

+ Enable/Disable the Instructions page for non-admin users. (Documentation links will still be visible.) +

+
+
+ + Enable +
+
+
+
+ +
+
+

+ Enable/Disable the Generated Names Log page for non-admin users. +

+
+
+ + Enable +
+
+
+
+ +
+
+

+ Enable/Disable the Latest News for all users. +

+
+
+ + Enable +
+
+
Azure Cloud Adoption Framework which adheres to a few rules and allows the complete customization of your naming convention. While most of the customizations can be made in your web browser, this tool also includes an API.

- For guidance on the API, review your swagger page at: @(NavigationManager.Uri)swagger/index.html + For guidance on the API, review your swagger page at: swagger/index.html

Admin

The Admin page is used to configure the Azure Naming Tool. This page is only accessible by Admin users.

-

Instructions

-

- The Instructions page provides documentation for the site pages. Each page of the site contains a documentation link (top right) that will open contextual instructions for the current page. + @if (Convert.ToBoolean(config.InstructionsEnabled) || admin) + { +

Instructions

+

+ The Instructions page provides documentation for the site pages. Each page of the site contains a documentation link (top right) that will open contextual instructions for the current page.

+ }

Configuration

The Configuration page provides all the data points that make up your naming convention. There are 8 standard components that may be used to name each Azure resource. The data within each of those components can be completely customized, except for the resource types. For the resource types, only the short name, optional, and excluded values may be updated. A delimiter may be selected to separate each component in your resource names. However, the delimiter will be included in a resource name if that character is allowed. The tool also supports the ability to define custom components. This allows administratos to create new components for the naming convention. Your configuration may be exported under the Global Configuration header. We recommend doing that after defining your naming convention as a backup. @*Lastly, use the Policy export feature to create an Azure Policy Definition. That can be applied to your Azure environment to enforce your naming convention.*@ @@ -44,15 +47,22 @@

The Generate page provides a drop-down menu to select an Azure resource type. Once a resource is selected, the naming component options are provided. Read-only components cannot be changed, like the value for a resource type. Optional components, if unselected, will be null and not shown in the output. Required components do not allow a null value and will require a selection from the menu.

-

Generated Names Log

-

- The Generated Names Log contains a record of all names generated in the Azure Naming Tool. This includes the date, user, generated name, resource type, and components selected. This log can be exported to a .csv file. + @if (Convert.ToBoolean(config.GeneratedNamesLogEnabled) || admin) + { +

Generated Names Log

+

+ The Generated Names Log contains a record of all names generated in the Azure Naming Tool. This includes the date, user, generated name, resource type, and components selected. This log can be exported to a .csv file.

-

-

+ } + }
@code { @@ -61,6 +71,7 @@ [CascadingParameter] public IModalService? Modal { get; set; } private bool admin; + private SiteConfiguration config = ConfigurationHelper.GetConfigurationData(); private string appversion = ConfigurationHelper.GetAssemblyVersion(); private string updateurl = "https://github.com/mspnp/AzureNamingTool/wiki/Updating"; diff --git a/src/Pages/Instructions.razor b/src/Components/Pages/Instructions.razor similarity index 83% rename from src/Pages/Instructions.razor rename to src/Components/Pages/Instructions.razor index 658cd7e2..955b1168 100644 --- a/src/Pages/Instructions.razor +++ b/src/Components/Pages/Instructions.razor @@ -1,10 +1,12 @@ @page "/instructions" +@using AzureNamingTool.Components.Instructions @using AzureNamingTool.Helpers @using AzureNamingTool.Models -@using AzureNamingTool.Shared.Components -@using AzureNamingTool.Shared.Instructions +@using AzureNamingTool.Components.General @inject StateContainer state @inject ProtectedSessionStorage session +@inject IToastService toastService +@inject NavigationManager NavigationManager
@@ -32,16 +34,16 @@
-
-
+
+
- Admin Log - -
-
- -
-
+ Admin Log + +
+
+
+ +
}
@@ -89,8 +91,8 @@ @code { [CascadingParameter] protected ThemeInfo? theme { get; set; } - private bool admin = false; + private SiteConfiguration config = ConfigurationHelper.GetConfigurationData(); protected override async Task OnAfterRenderAsync(bool firstRender) { @@ -98,6 +100,11 @@ { var result = await session.GetAsync("admin"); admin = (bool)result.Value; + if (!Convert.ToBoolean(config.InstructionsEnabled) && !admin) + { + toastService.ShowWarning("The Instructions page is disabled in the site settings."); + NavigationManager.NavigateTo("/"); + } StateHasChanged(); } } diff --git a/src/Pages/Reference.razor b/src/Components/Pages/Reference.razor similarity index 100% rename from src/Pages/Reference.razor rename to src/Components/Pages/Reference.razor diff --git a/src/Components/Routes.razor b/src/Components/Routes.razor new file mode 100644 index 00000000..074e87df --- /dev/null +++ b/src/Components/Routes.razor @@ -0,0 +1,16 @@ +@using AzureNamingTool.Models + + + + + + + + + + + +@code { + [Parameter] + public IdentityProviderDetails? identityProviderDetails { get; set; } +} \ No newline at end of file diff --git a/src/_Imports.razor b/src/Components/_Imports.razor similarity index 77% rename from src/_Imports.razor rename to src/Components/_Imports.razor index 8bcd3380..2708462b 100644 --- a/src/_Imports.razor +++ b/src/Components/_Imports.razor @@ -1,15 +1,15 @@ @using System.Net.Http -@using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components.Authorization +@using System.Net.Http.Json @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop @using AzureNamingTool -@using AzureNamingTool.Shared +@using AzureNamingTool.Components @using Blazored.Toast @using Blazored.Toast.Services @using Blazored.Modal @using Blazored.Modal.Services -@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; \ No newline at end of file +@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; diff --git a/src/Dockerfile b/src/Dockerfile index 4663c624..2c408507 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,20 +1,23 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app WORKDIR /app -EXPOSE 80 -EXPOSE 443 +EXPOSE 8080 +EXPOSE 8081 -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["AzureNamingTool.csproj", "."] -RUN dotnet restore "./AzureNamingTool.csproj" +RUN dotnet restore "./././AzureNamingTool.csproj" COPY . . WORKDIR "/src/." -RUN dotnet build "AzureNamingTool.csproj" -c Release -o /app/build +RUN dotnet build "./AzureNamingTool.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish -RUN dotnet publish "AzureNamingTool.csproj" -c Release -o /app/publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./AzureNamingTool.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app diff --git a/src/Helpers/GeneralHelper.cs b/src/Helpers/GeneralHelper.cs index 9e0cbe80..73907568 100644 --- a/src/Helpers/GeneralHelper.cs +++ b/src/Helpers/GeneralHelper.cs @@ -1,7 +1,7 @@ using AzureNamingTool.Models; -using AzureNamingTool.Pages; +using AzureNamingTool.Components.Pages; using AzureNamingTool.Services; -using AzureNamingTool.Shared; +using AzureNamingTool.Components; using Blazored.Modal; using Blazored.Modal.Services; using System; diff --git a/src/Helpers/ModalHelper.cs b/src/Helpers/ModalHelper.cs index bd51e93f..3c5215ed 100644 --- a/src/Helpers/ModalHelper.cs +++ b/src/Helpers/ModalHelper.cs @@ -1,6 +1,6 @@ using AzureNamingTool.Models; using AzureNamingTool.Services; -using AzureNamingTool.Shared.Modals; +using AzureNamingTool.Components.Modals; using Blazored.Modal; using Blazored.Modal.Services; diff --git a/src/Models/ConfigurationData.cs b/src/Models/ConfigurationData.cs index fc3e75dd..d1f9ce34 100644 --- a/src/Models/ConfigurationData.cs +++ b/src/Models/ConfigurationData.cs @@ -1,24 +1,24 @@ using AzureNamingTool.Models; -using AzureNamingTool.Pages; +using AzureNamingTool.Components.Pages; using System.Collections.Generic; namespace AzureNamingTool.Models { public class ConfigurationData { - public List ResourceComponents { get; set; } = new(); - public List ResourceDelimiters { get; set; } = new(); - public List ResourceEnvironments { get; set; } = new(); - public List ResourceLocations { get; set; } = new(); - public List ResourceOrgs { get; set; } = new(); - public List ResourceProjAppSvcs { get; set; } = new(); - public List ResourceTypes { get; set; } = new(); - public List ResourceUnitDepts { get; set; } = new(); - public List ResourceFunctions { get; set; } = new(); - public List CustomComponents { get; set; } = new(); - public List GeneratedNames { get; set; } = new(); - public List? AdminLogs { get; set; } = new(); - public List AdminUsers { get; set; } = new(); + public List ResourceComponents { get; set; } = []; + public List ResourceDelimiters { get; set; } = []; + public List ResourceEnvironments { get; set; } = []; + public List ResourceLocations { get; set; } = []; + public List ResourceOrgs { get; set; } = []; + public List ResourceProjAppSvcs { get; set; } = []; + public List ResourceTypes { get; set; } = []; + public List ResourceUnitDepts { get; set; } = []; + public List ResourceFunctions { get; set; } = []; + public List CustomComponents { get; set; } = []; + public List GeneratedNames { get; set; } = []; + public List? AdminLogs { get; set; } = []; + public List AdminUsers { get; set; } = []; public string? SALTKey { get; set; } public string? AdminPassword { get; set; } @@ -31,5 +31,8 @@ public class ConfigurationData public string? IdentityHeaderName { get; set; } public string? ResourceTypeEditingAllowed { get; set; } = "False"; public string? AutoIncrementResourceInstance { get; set; } = "False"; + public string? InstructionsEnabled { get; set; } = "True"; + public string? GeneratedNamesLogEnabled { get; set; } = "True"; + public string? LatestNewsEnabled { get; set; } = "True"; } } diff --git a/src/Models/SiteConfiguration.cs b/src/Models/SiteConfiguration.cs index 4344692d..48b5d70b 100644 --- a/src/Models/SiteConfiguration.cs +++ b/src/Models/SiteConfiguration.cs @@ -15,5 +15,8 @@ public class SiteConfiguration public string? IdentityHeaderName { get; set; } public string? ResourceTypeEditingAllowed { get; set; } = "False"; public string? AutoIncrementResourceInstance { get; set; } = "False"; + public string? InstructionsEnabled { get; set; } = "True"; + public string? GeneratedNamesLogEnabled { get; set; } = "True"; + public string? LatestNewsEnabled { get; set; } = "True"; } } diff --git a/src/Models/StateContainer.cs b/src/Models/StateContainer.cs index db9c259c..fe7af555 100644 --- a/src/Models/StateContainer.cs +++ b/src/Models/StateContainer.cs @@ -6,7 +6,7 @@ public class StateContainer private bool? _admin; private bool? _password; private string _apptheme = String.Empty; - private bool? _newsenabled; + private bool? _latestnewsenabled; public bool _reloadnav; public bool? _configurationdatasynced; @@ -74,19 +74,19 @@ public void SetAppTheme(string value) NotifyStateChanged(); } - public bool NewsEnabled + public bool LatestNewsEnabled { - get => _newsenabled ?? true; + get => _latestnewsenabled ?? true; set { - _newsenabled = value; + _latestnewsenabled = value; NotifyStateChanged(); } } - public void SetNewsEnabled(bool newsenabled) + public void SetLatestNewsEnabled(bool latestnewsenabled) { - _newsenabled = newsenabled; + _latestnewsenabled = latestnewsenabled; NotifyStateChanged(); } diff --git a/src/Pages/Error.cshtml b/src/Pages/Error.cshtml deleted file mode 100644 index 3f799b5d..00000000 --- a/src/Pages/Error.cshtml +++ /dev/null @@ -1,42 +0,0 @@ -@page -@model AzureNamingTool.Pages.ErrorModel - - - - - - - - Error - - - - - -
-
-

Error.

-

An error occurred while processing your request.

- - @if (Model.ShowRequestId) - { -

- Request ID: @Model.RequestId -

- } - -

Development Mode

-

- Swapping to the Development environment displays detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

-
-
- - - diff --git a/src/Pages/Error.cshtml.cs b/src/Pages/Error.cshtml.cs deleted file mode 100644 index 05d7b96f..00000000 --- a/src/Pages/Error.cshtml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using System.Diagnostics; - -namespace AzureNamingTool.Pages -{ - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - [IgnoreAntiforgeryToken] - public class ErrorModel : PageModel - { - public string RequestId { get; set; } = String.Empty; - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) - { - _logger = logger; - } - - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} \ No newline at end of file diff --git a/src/Pages/_Layout.cshtml b/src/Pages/_Layout.cshtml deleted file mode 100644 index 011b2c95..00000000 --- a/src/Pages/_Layout.cshtml +++ /dev/null @@ -1,44 +0,0 @@ -@using AzureNamingTool.Models; -@using Microsoft.AspNetCore.Components.Web -@using AzureNamingTool.Helpers -@inject StateContainer state -@namespace AzureNamingTool.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - - - - - - - - - - - - - - - - @RenderBody() - -
- - An error has occurred. This application may no longer respond until reloaded. - - - An unhandled exception has occurred. See browser dev tools for details. - - Reload - 🗙 -
- - - - - - diff --git a/src/Program.cs b/src/Program.cs index dff78406..1d39668c 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,26 +1,30 @@ using AzureNamingTool.Attributes; +using AzureNamingTool.Components; +using AzureNamingTool.Helpers; +using AzureNamingTool.Models; using BlazorDownloadFile; +using Blazored.Modal; using Blazored.Toast; using Microsoft.OpenApi.Models; -using Blazored.Modal; using System.Reflection; -using AzureNamingTool.Models; -using AzureNamingTool.Helpers; var builder = WebApplication.CreateBuilder(args); // Add services to the container. -builder.Services.AddMvcCore().AddApiExplorer(); -builder.Services.AddRazorPages(); +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents().AddHubOptions(options => + { + options.ClientTimeoutInterval = TimeSpan.FromSeconds(30); + options.EnableDetailedErrors = false; + options.HandshakeTimeout = TimeSpan.FromSeconds(15); + options.KeepAliveInterval = TimeSpan.FromSeconds(15); + options.MaximumParallelInvocationsPerClient = 1; + options.MaximumReceiveMessageSize = 102400000; + options.StreamBufferCapacity = 10; + }); + + builder.Services.AddHealthChecks(); -if (builder.Environment.IsDevelopment()) -{ - builder.Services.AddServerSideBlazor().AddCircuitOptions(x => x.DetailedErrors = true).AddHubOptions(x => x.MaximumReceiveMessageSize = 102400000); -} -else -{ - builder.Services.AddServerSideBlazor().AddHubOptions(x => x.MaximumReceiveMessageSize = 102400000); -} builder.Services.AddBlazorDownloadFile(); builder.Services.AddBlazoredToast(); builder.Services.AddBlazoredModal(); @@ -28,6 +32,7 @@ builder.Services.AddSingleton(); +builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(c => { c.OperationFilter(); @@ -42,36 +47,23 @@ c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); }); -builder.Services.AddCors(options => -{ - options.AddDefaultPolicy( - builder => - { - builder.WithOrigins("http://localhost:44332") - .AllowAnyHeader() - .AllowAnyMethod(); - }); -}); - +// Add services to the container. +//builder.Services.AddMvcCore().AddApiExplorer(); +builder.Services.AddBlazorDownloadFile(); +builder.Services.AddBlazoredToast(); +builder.Services.AddBlazoredModal(); builder.Services.AddMemoryCache(); +builder.Services.AddMvcCore().AddApiExplorer(); + var app = builder.Build(); app.MapHealthChecks("/healthcheck/ping"); // Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) +if (!app.Environment.IsDevelopment()) { - app.UseDeveloperExceptionPage(); - app.UseCors(x => x - .AllowAnyMethod() - .AllowAnyHeader() - .SetIsOriginAllowed(origin => true) // allow any origin - .AllowCredentials()); // allow credentials -} -else -{ - app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseExceptionHandler("/Error", createScopeForErrors: true); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } @@ -81,14 +73,11 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); +app.UseAntiforgery(); -app.UseRouting(); +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); -//app.UseAuthentication(); -//app.UseAuthorization(); app.MapControllers(); -app.MapBlazorHub(); -app.MapFallbackToPage("/_Host"); - app.Run(); diff --git a/src/Properties/launchSettings.json b/src/Properties/launchSettings.json index a22b73c5..10bb4cb6 100644 --- a/src/Properties/launchSettings.json +++ b/src/Properties/launchSettings.json @@ -1,19 +1,49 @@ { "profiles": { - "AzureNamingTool": { + "http": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:51656;http://localhost:51657" + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5222" + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7184;http://localhost:5222" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } }, "Docker": { "commandName": "Docker", "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, "publishAllPorts": true, "useSSL": true } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:60381", + "sslPort": 44346 + } } } \ No newline at end of file diff --git a/src/Services/AdminLogService.cs b/src/Services/AdminLogService.cs index cc3f9852..629db9ac 100644 --- a/src/Services/AdminLogService.cs +++ b/src/Services/AdminLogService.cs @@ -1,6 +1,6 @@ using AzureNamingTool.Helpers; using AzureNamingTool.Models; -using AzureNamingTool.Pages; +using AzureNamingTool.Components.Pages; using System.Text.Json; namespace AzureNamingTool.Services diff --git a/src/Services/ImportExportService.cs b/src/Services/ImportExportService.cs index 5a634d9c..6fb6c032 100644 --- a/src/Services/ImportExportService.cs +++ b/src/Services/ImportExportService.cs @@ -110,6 +110,9 @@ public static async Task ExportConfig(bool includeadmin = false configdata.GenerationWebhook = config.GenerationWebhook; configdata.ResourceTypeEditingAllowed = config.ResourceTypeEditingAllowed; configdata.AutoIncrementResourceInstance = config.AutoIncrementResourceInstance; + configdata.InstructionsEnabled = config.InstructionsEnabled; + configdata.GeneratedNamesLogEnabled = config.GeneratedNamesLogEnabled; + configdata.LatestNewsEnabled = config.LatestNewsEnabled; // Get the security settings if (includeadmin) @@ -200,6 +203,18 @@ public static async Task PostConfig(ConfigurationData configdat { config.AutoIncrementResourceInstance = configdata.AutoIncrementResourceInstance; } + if (GeneralHelper.IsNotNull(configdata.InstructionsEnabled)) + { + config.InstructionsEnabled = configdata.InstructionsEnabled; + } + if (GeneralHelper.IsNotNull(configdata.GeneratedNamesLogEnabled)) + { + config.GeneratedNamesLogEnabled = configdata.GeneratedNamesLogEnabled; + } + if (GeneralHelper.IsNotNull(configdata.LatestNewsEnabled)) + { + config.LatestNewsEnabled = configdata.LatestNewsEnabled; + } var jsonWriteOptions = new JsonSerializerOptions() { WriteIndented = true diff --git a/src/Shared/MainLayout.razor.css b/src/Shared/MainLayout.razor.css deleted file mode 100644 index 492171e5..00000000 --- a/src/Shared/MainLayout.razor.css +++ /dev/null @@ -1,72 +0,0 @@ -.page { - position: relative; - display: flex; - flex-direction: column; -} - -main { - flex: 1; -} - -.sidebar { - /*background-image: linear-gradient(180deg, rgb(27, 110, 194) 0%, #0d6efd 70%);*/ - background-color: #004494; -} - -.top-row { - background-color: #f7f7f7; - border-bottom: 1px solid #d6d5d5; - justify-content: flex-end; - height: 3.5rem; - display: flex; - align-items: center; -} - - .top-row ::deep a, .top-row .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - } - - .top-row a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } - -@media (max-width: 640.98px) { - .top-row:not(.auth) { - display: none; - } - - .top-row.auth { - justify-content: space-between; - } - - .top-row a, .top-row .btn-link { - margin-left: 0; - } -} - -@media (min-width: 641px) { - .page { - flex-direction: row; - } - - .sidebar { - width: 250px; - min-height: 100vh; - position: sticky; - top: 0; - /*z-index: 9999;*/ - } - - .top-row { - position: sticky; - top: 0; - z-index: 1; - } - - .top-row, article { - /*padding-left: 2rem !important; - padding-right: 1.5rem !important;*/ - } -} diff --git a/src/appsettings.Development.json b/src/appsettings.Development.json index 770d3e93..f8063ef1 100644 --- a/src/appsettings.Development.json +++ b/src/appsettings.Development.json @@ -1,9 +1,9 @@ { - "DetailedErrors": true, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } - } + }, + "DetailedErrors": true } diff --git a/src/appsettings.json b/src/appsettings.json index ed8b1c30..10f68b8c 100644 --- a/src/appsettings.json +++ b/src/appsettings.json @@ -1,15 +1,9 @@ { - "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-AzNamingTool-70EEEBD8-2ADB-4EC9-8BEF-04B30513736D;Trusted_Connection=True;MultipleActiveResultSets=true" - }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*", - "SALTKey": "", - "AdminPassword": "", - "APIKey": "" -} \ No newline at end of file + "AllowedHosts": "*" +} diff --git a/src/programsettings.json b/src/programsettings.json index 60443f7b..6ed0448b 100644 --- a/src/programsettings.json +++ b/src/programsettings.json @@ -1,5 +1,5 @@ { "FeedbackURL": "https://forms.office.com/r/M2EZLg6zKq", "latestNewsEnabled": "false", - "toolVersion":"3.3.0" + "toolVersion":"4.0.0" } diff --git a/src/repository/appsettings.json b/src/repository/appsettings.json index 5cf718e4..9236bab0 100644 --- a/src/repository/appsettings.json +++ b/src/repository/appsettings.json @@ -19,5 +19,8 @@ "ConnectivityCheckEnabled": "true", "ResourceTypeEditingAllowed": "false", "AutoIncrementResourceInstance": "false", + "LatestNewsEnabled": "True", + "GeneratedNamesLogEnabled": "True", + "InstructionsEnabled": "True", "IdentityHeaderName": "X-MS-CLIENT-PRINCIPAL-NAME" } \ No newline at end of file diff --git a/src/wwwroot/app.css b/src/wwwroot/app.css new file mode 100644 index 00000000..d6689573 --- /dev/null +++ b/src/wwwroot/app.css @@ -0,0 +1,178 @@ +@import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); + +html, body { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; +} + +h1:focus { + outline: none; +} + +a, .btn-link { + color: #6a5eff; +} + +.btn-primary { + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; +} + +.content { + padding-top: 1.1rem; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid red; +} + +.validation-message { + color: red; +} + +.warning-message { + color: red; + font-weight: bold; +} + +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; + } + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.blazored-toast-container{ + z-index:99999 !important; +} + +#btnScrollToTop { + position: fixed; /* Fixed/sticky position */ + bottom: 20px; /* Place the button at the bottom of the page */ + right: 30px; /* Place the button 30px from the right */ + z-index: 99; /* Make sure it does not overlap */ +} + +.text-white, .link-light, .nav-link, .nav-item { + color: #ffffff !important; +} + +.text-dark, .link-dark { + color: #000000 !important; +} + + +.nav-item a.active, .nav-item a:hover, .nav-link a.active, .nav-link a:hover { + background-color: rgba(0,0,0,0.15) !important; + color: white; +} + +.bg-navcolor { + background-color: #004494; +} + +.bg-dark{ + background: #000000 !important; +} + +/* The switch - the box around the slider */ +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + + /* Hide default HTML checkbox */ + .switch input { + opacity: 0; + width: 0; + height: 0; + } + +/* The slider */ +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + + .slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; + } + +input:checked + .slider { + background-color: #4C4E52; +} + +input:focus + .slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + + .slider.round:before { + border-radius: 50%; + } + +.disabled-text { + color: #A9A9A9; +} + +.btn-dummy { + pointer-events: none; + cursor: not-allowed; +} + +.blazored-toast-message { + hyphens:none !important; +} \ No newline at end of file diff --git a/src/wwwroot/favicon.png b/src/wwwroot/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8422b59695935d180d11d5dbe99653e711097819 GIT binary patch literal 1148 zcmV-?1cUpDP)9h26h2-Cs%i*@Moc3?#6qJID|D#|3|2Hn7gTIYEkr|%Xjp);YgvFmB&0#2E2b=| zkVr)lMv9=KqwN&%obTp-$<51T%rx*NCwceh-E+=&e(oLO`@Z~7gybJ#U|^tB2Pai} zRN@5%1qsZ1e@R(XC8n~)nU1S0QdzEYlWPdUpH{wJ2Pd4V8kI3BM=)sG^IkUXF2-j{ zrPTYA6sxpQ`Q1c6mtar~gG~#;lt=s^6_OccmRd>o{*=>)KS=lM zZ!)iG|8G0-9s3VLm`bsa6e ze*TlRxAjXtm^F8V`M1%s5d@tYS>&+_ga#xKGb|!oUBx3uc@mj1%=MaH4GR0tPBG_& z9OZE;->dO@`Q)nr<%dHAsEZRKl zedN6+3+uGHejJp;Q==pskSAcRcyh@6mjm2z-uG;s%dM-u0*u##7OxI7wwyCGpS?4U zBFAr(%GBv5j$jS@@t@iI8?ZqE36I^4t+P^J9D^ELbS5KMtZ z{Qn#JnSd$15nJ$ggkF%I4yUQC+BjDF^}AtB7w348EL>7#sAsLWs}ndp8^DsAcOIL9 zTOO!!0!k2`9BLk25)NeZp7ev>I1Mn={cWI3Yhx2Q#DnAo4IphoV~R^c0x&nw*MoIV zPthX?{6{u}sMS(MxD*dmd5rU(YazQE59b|TsB5Tm)I4a!VaN@HYOR)DwH1U5y(E)z zQqQU*B%MwtRQ$%x&;1p%ANmc|PkoFJZ%<-uq%PX&C!c-7ypis=eP+FCeuv+B@h#{4 zGx1m0PjS~FJt}3mdt4c!lel`1;4W|03kcZRG+DzkTy|7-F~eDsV2Tx!73dM0H0CTh zl)F-YUkE1zEzEW(;JXc|KR5{ox%YTh{$%F$a36JP6Nb<0%#NbSh$dMYF-{ z1_x(Vx)}fs?5_|!5xBTWiiIQHG<%)*e=45Fhjw_tlnmlixq;mUdC$R8v#j( zhQ$9YR-o%i5Uc`S?6EC51!bTRK=Xkyb<18FkCKnS2;o*qlij1YA@-nRpq#OMTX&RbL<^2q@0qja!uIvI;j$6>~k@IMwD42=8$$!+R^@5o6HX(*n~ Date: Mon, 18 Dec 2023 14:31:30 -0600 Subject: [PATCH 03/15] - Removed publish profiles --- src/AzureNamingTool.csproj | 4 ++++ src/AzureNamingTool.csproj.user | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AzureNamingTool.csproj b/src/AzureNamingTool.csproj index 8261c253..76a5a14b 100644 --- a/src/AzureNamingTool.csproj +++ b/src/AzureNamingTool.csproj @@ -28,4 +28,8 @@ + + + + diff --git a/src/AzureNamingTool.csproj.user b/src/AzureNamingTool.csproj.user index 838fbf22..73821ccb 100644 --- a/src/AzureNamingTool.csproj.user +++ b/src/AzureNamingTool.csproj.user @@ -2,7 +2,7 @@ https - C:\Projects\v3.4.0\AzureNamingTool\Properties\PublishProfiles\azurenamingtool-dev - Zip Deploy.pubxml + C:\Projects\AzureNamingTool\.github\workflows\codeql.yml ProjectDebugger From d7262e2ff1b540591d4de0729598c03f194f655d Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Mon, 18 Dec 2023 14:43:35 -0600 Subject: [PATCH 04/15] - Added 404 page/routing --- src/AzureNamingTool.sln | 2 +- .../Instructions/AdminConfigurationInstructions.razor | 2 +- src/Components/Pages/404.razor | 6 ++++++ src/Program.cs | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/Components/Pages/404.razor diff --git a/src/AzureNamingTool.sln b/src/AzureNamingTool.sln index c26d8f0e..140a7e60 100644 --- a/src/AzureNamingTool.sln +++ b/src/AzureNamingTool.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34322.80 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureNamingTool", "AzureNamingTool.csproj", "{B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureNamingTool", "AzureNamingTool.csproj", "{B9EC3E06-9B4D-4CA0-ABBD-E4115384B730}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Components/Instructions/AdminConfigurationInstructions.razor b/src/Components/Instructions/AdminConfigurationInstructions.razor index 8a4d975e..c5865bbe 100644 --- a/src/Components/Instructions/AdminConfigurationInstructions.razor +++ b/src/Components/Instructions/AdminConfigurationInstructions.razor @@ -118,7 +118,7 @@
  • Latest News

    - If enabled, the Latest News component will be enabled for all users. This setting will apply to all users. + If enabled, the Latest News component will be displayed in the navigation menu. This setting will apply to all users.

  • diff --git a/src/Components/Pages/404.razor b/src/Components/Pages/404.razor new file mode 100644 index 00000000..03c7bc48 --- /dev/null +++ b/src/Components/Pages/404.razor @@ -0,0 +1,6 @@ +@page "/404" + +

    Whoa, it looks like that page went and r-u-n-n-o-f-t! Try again!

    +@code { + +} \ No newline at end of file diff --git a/src/Program.cs b/src/Program.cs index 1d39668c..1cbfff20 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -78,6 +78,7 @@ app.MapRazorComponents() .AddInteractiveServerRenderMode(); +app.UseStatusCodePagesWithRedirects("/404"); app.MapControllers(); app.Run(); From eef053bcb06222405355372e944e040582fcb9fa Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Mon, 18 Dec 2023 14:44:40 -0600 Subject: [PATCH 05/15] - Updated 404 page text --- src/Components/Pages/404.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Pages/404.razor b/src/Components/Pages/404.razor index 03c7bc48..1819a823 100644 --- a/src/Components/Pages/404.razor +++ b/src/Components/Pages/404.razor @@ -1,6 +1,6 @@ @page "/404" -

    Whoa, it looks like that page went and r-u-n-n-o-f-t! Try again!

    +

    Whoa, it looks like that page doesn't exist! Please check the URL and try again!

    @code { } \ No newline at end of file From 9ed0b9e1e369371547fdd039505ea162062b34d5 Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Mon, 18 Dec 2023 14:52:07 -0600 Subject: [PATCH 06/15] - Updated gitignore file --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9b3808a9..3f4985b7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,8 @@ # This .gitignore file was automatically created by Microsoft(R) Visual Studio. ################################################################################ -/src/bin/Debug/net8.0/settings /src/obj /src/Properties/PublishProfiles /src/Properties/ServiceDependencies/azurenamingtool-dev - Zip Deploy /src/.vs -/src/bin/Debug/net8.0 +/src/bin From 66b4eef62d918d1414a3ca7d205859d8efee771b Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 19 Dec 2023 07:36:42 -0600 Subject: [PATCH 07/15] - Updated Index page styling/formatting --- src/Components/Pages/Index.razor | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Components/Pages/Index.razor b/src/Components/Pages/Index.razor index 7f121aa5..f90fa3d0 100644 --- a/src/Components/Pages/Index.razor +++ b/src/Components/Pages/Index.razor @@ -32,7 +32,7 @@

    Instructions

    The Instructions page provides documentation for the site pages. Each page of the site contains a documentation link (top right) that will open contextual instructions for the current page. -

    +

    }

    Configuration

    @@ -52,16 +52,15 @@

    Generated Names Log

    The Generated Names Log contains a record of all names generated in the Azure Naming Tool. This includes the date, user, generated name, resource type, and components selected. This log can be exported to a .csv file. -

    +

    } @if (Convert.ToBoolean(config.InstructionsEnabled) || admin) {

    -

    - } + View Instructions + +

    }
  • @@ -79,7 +78,11 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { var resultAdmin = await session.GetAsync("admin"); - admin = (bool)resultAdmin.Value; + if (admin != (bool)resultAdmin.Value) + { + admin = (bool)resultAdmin.Value; + StateHasChanged(); + } // Determine if the version notification has been dismissed var resultNotification = await session.GetAsync("versionnotification"); bool notificationshown = resultNotification.Success ? resultNotification.Value : false; From 7c20d5016c3060d15e6c94e78c065124f5a42c9e Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 19 Dec 2023 07:48:55 -0600 Subject: [PATCH 08/15] - Updated Index page messaging --- src/Components/Pages/Index.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Pages/Index.razor b/src/Components/Pages/Index.razor index f90fa3d0..4e336058 100644 --- a/src/Components/Pages/Index.razor +++ b/src/Components/Pages/Index.razor @@ -36,7 +36,7 @@ }

    Configuration

    - The Configuration page provides all the data points that make up your naming convention. There are 8 standard components that may be used to name each Azure resource. The data within each of those components can be completely customized, except for the resource types. For the resource types, only the short name, optional, and excluded values may be updated. A delimiter may be selected to separate each component in your resource names. However, the delimiter will be included in a resource name if that character is allowed. The tool also supports the ability to define custom components. This allows administratos to create new components for the naming convention. Your configuration may be exported under the Global Configuration header. We recommend doing that after defining your naming convention as a backup. @*Lastly, use the Policy export feature to create an Azure Policy Definition. That can be applied to your Azure environment to enforce your naming convention.*@ + The Configuration page provides all the data points that make up your naming convention. There are 8 standard components that may be used to name each Azure resource. The data within each of those components can be completely customized, except for the resource types. For the resource types, only the short name, optional, and excluded values may be updated. A delimiter may be selected to separate each component in your resource names. However, the delimiter will be included in a resource name if that character is allowed. The tool also supports the ability to define custom components. This allows administrators to create new components for the naming convention. Your configuration may be exported under the Global Configuration header. We recommend doing that after defining your naming convention as a backup. @*Lastly, use the Policy export feature to create an Azure Policy Definition. That can be applied to your Azure environment to enforce your naming convention.*@

    Reference

    From c0656d7f2e41310dd63e77a181575e36df52bfae Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 26 Dec 2023 10:26:12 -0600 Subject: [PATCH 09/15] - Added Site Settings Reset functionality to Admin page --- src/Components/Pages/Admin.razor | 59 +++++++++++++++++++++++++++++++- src/Models/ConfigurationData.cs | 2 +- src/Models/SiteConfiguration.cs | 2 +- src/repository/appsettings.json | 2 +- 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/Components/Pages/Admin.razor b/src/Components/Pages/Admin.razor index 8a97240b..3b8cae52 100644 --- a/src/Components/Pages/Admin.razor +++ b/src/Components/Pages/Admin.razor @@ -1,10 +1,12 @@ @page "/admin" +@using AzureNamingTool.Components.Modals @using AzureNamingTool.Helpers; @using AzureNamingTool.Models; @using System.Runtime.Caching; @using AzureNamingTool.Services; @using Blazored.Toast.Configuration; @using Microsoft.AspNetCore.Html +@using Microsoft.AspNetCore.WebUtilities @using Microsoft.Extensions.Logging @using System.Reflection; @inject IJSRuntime JsRuntime @@ -524,6 +526,23 @@ +
    + +
    +
    +

    + This will reset all site settings to the default values. This cannot be undone! +

    +
    +
    + +
    +
    +
    } @@ -614,11 +633,27 @@ state.AppTheme = theme.ThemeStyle; StateHasChanged(); + + var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("reset", out var _reset)) + { + if (Convert.ToBoolean(_reset)) + { + toastService.ShowSuccess("The site settings have been reset!"); + } + } + } } private async void AdminFormAction(string action, int id = 0) { + var workingmodaloptions = new ModalOptions() + { + HideCloseButton = true, + UseCustomLayout = true + }; + var workingmodal = Modal.Show("Working", workingmodaloptions); message = new ResponseMessage(); message.Header = "INFORMATION"; message.Type = MessageTypesEnum.INFORMATION; @@ -896,6 +931,28 @@ displaymessage = false; } break; + + case "resetsitesettings": + confirm = await ModalHelper.ShowConfirmationModal(Modal!, "ATTENTION", "
    This will reset the site settings.
    Are you sure?
    ", "bg-danger", theme); + if (confirm) + { + // Create new default configuration + SiteConfiguration resetconfig = new(); + ConfigurationHelper.SetAppSetting("AutoIncrementResourceInstance", resetconfig.AutoIncrementResourceInstance!, false); + ConfigurationHelper.SetAppSetting("DuplicateNamesAllowed", resetconfig.DuplicateNamesAllowed!, false); + ConfigurationHelper.SetAppSetting("ResourceTypeEditingAllowed", resetconfig.ResourceTypeEditingAllowed!, false); + ConfigurationHelper.SetAppSetting("InstructionsEnabled", resetconfig.InstructionsEnabled!, false); + ConfigurationHelper.SetAppSetting("GeneratedNamesLogEnabled", resetconfig.GeneratedNamesLogEnabled!, false); + ConfigurationHelper.SetAppSetting("LatestNewsEnabled", resetconfig.LatestNewsEnabled!, false); + ConfigurationHelper.SetAppSetting("ConnectivityCheckEnabled", resetconfig.ConnectivityCheckEnabled!, false); + ConfigurationHelper.SetAppSetting("GenerationWebhook", String.Empty, true); + NavigationManager.NavigateTo("/admin?reset=true", true); + } + else + { + displaymessage = false; + } + break; } config = ConfigurationHelper.GetConfigurationData(); @@ -923,11 +980,11 @@ } } - servicesData = await ServicesHelper.LoadServicesData(servicesData, admin); state.SetNavReload(true); StateHasChanged(); + workingmodal.Close(); if (redirect) { if (admin) diff --git a/src/Models/ConfigurationData.cs b/src/Models/ConfigurationData.cs index d1f9ce34..72ddc8aa 100644 --- a/src/Models/ConfigurationData.cs +++ b/src/Models/ConfigurationData.cs @@ -33,6 +33,6 @@ public class ConfigurationData public string? AutoIncrementResourceInstance { get; set; } = "False"; public string? InstructionsEnabled { get; set; } = "True"; public string? GeneratedNamesLogEnabled { get; set; } = "True"; - public string? LatestNewsEnabled { get; set; } = "True"; + public string? LatestNewsEnabled { get; set; } = "False"; } } diff --git a/src/Models/SiteConfiguration.cs b/src/Models/SiteConfiguration.cs index 48b5d70b..f2d61a8f 100644 --- a/src/Models/SiteConfiguration.cs +++ b/src/Models/SiteConfiguration.cs @@ -17,6 +17,6 @@ public class SiteConfiguration public string? AutoIncrementResourceInstance { get; set; } = "False"; public string? InstructionsEnabled { get; set; } = "True"; public string? GeneratedNamesLogEnabled { get; set; } = "True"; - public string? LatestNewsEnabled { get; set; } = "True"; + public string? LatestNewsEnabled { get; set; } = "False"; } } diff --git a/src/repository/appsettings.json b/src/repository/appsettings.json index 9236bab0..27680641 100644 --- a/src/repository/appsettings.json +++ b/src/repository/appsettings.json @@ -19,7 +19,7 @@ "ConnectivityCheckEnabled": "true", "ResourceTypeEditingAllowed": "false", "AutoIncrementResourceInstance": "false", - "LatestNewsEnabled": "True", + "LatestNewsEnabled": "False", "GeneratedNamesLogEnabled": "True", "InstructionsEnabled": "True", "IdentityHeaderName": "X-MS-CLIENT-PRINCIPAL-NAME" From 26fc3e10ab40cfdd65bdcd645b5548ec9d3dbf75 Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 26 Dec 2023 10:44:14 -0600 Subject: [PATCH 10/15] Update deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml --- .../deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml b/.github/workflows/deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml index 12dda2d1..8c881ccd 100644 --- a/.github/workflows/deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml +++ b/.github/workflows/deploy-azure-naming-tool-to-azure-webapps-dotnet-core.yml @@ -21,7 +21,7 @@ name: Azure Naming Tool - Build and deploy to an Azure Web App env: AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root - DOTNET_VERSION: '7.0.x' # set this to the .NET Core version to use + DOTNET_VERSION: '8.0.x' # set this to the .NET Core version to use on: push: From 41b15155fc96f7a236fd4bcb3743b02340e876ec Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 26 Dec 2023 13:40:10 -0600 Subject: [PATCH 11/15] Update Dockerfile --- src/Dockerfile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Dockerfile b/src/Dockerfile index 2c408507..d2def0bf 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,25 +1,22 @@ -#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -USER app WORKDIR /app -EXPOSE 8080 -EXPOSE 8081 +EXPOSE 80 +EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["AzureNamingTool.csproj", "."] -RUN dotnet restore "./././AzureNamingTool.csproj" +RUN dotnet restore "./AzureNamingTool.csproj" COPY . . WORKDIR "/src/." -RUN dotnet build "./AzureNamingTool.csproj" -c $BUILD_CONFIGURATION -o /app/build +RUN dotnet build "AzureNamingTool.csproj" -c Release -o /app/build FROM build AS publish -ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./AzureNamingTool.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "AzureNamingTool.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "AzureNamingTool.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "AzureNamingTool.dll"] From 6a7637f49e8dcacaa9e9a6359e876bf2d3124682 Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 2 Jan 2024 11:27:25 -0600 Subject: [PATCH 12/15] 2024-01-02 BryanSoltis - v4.0.0 ### BUG FIXES - Fixed #64 - Updated auto-increment process to properly set instance/number of digits --- src/Services/ResourceNamingRequestService.cs | 32 +++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Services/ResourceNamingRequestService.cs b/src/Services/ResourceNamingRequestService.cs index 6223b89c..84844382 100644 --- a/src/Services/ResourceNamingRequestService.cs +++ b/src/Services/ResourceNamingRequestService.cs @@ -786,31 +786,33 @@ public static async Task RequestName(ResourceNameRequest r // Check if the request contains Resource Instance is a selected componoent if (!String.IsNullOrEmpty(GeneralHelper.GetPropertyValue(request, "ResourceInstance")?.ToString())) { - // CHeck if the name should be auto-incremented + // Check if the name should be auto-incremented if (Convert.ToBoolean(ConfigurationHelper.GetAppSetting("AutoIncrementResourceInstance"))) { // Check if there was a ResourceInstance value supplied if (GeneralHelper.IsNotNull(GeneralHelper.GetPropertyValue(request, "ResourceInstance"))) { // Attempt to auto-increement the instance + // Set the original name value + string originalname = name; // Get the instance value string originalinstance = GeneralHelper.GetPropertyValue(request, "ResourceInstance")?.ToString() ?? ""; - // Increase the instance by 1 - string newinstance = (Convert.ToInt32(originalinstance) + 1).ToString(); - // Make sure the instance pattern matches the entered values (leading zeros) - while (newinstance.Length < originalinstance.Length) + // Determine the next instance value + string newinstance = String.Empty; + int i = 1; + while (await ConfigurationHelper.CheckIfGeneratedNameExists(name)) { - newinstance = "0" + newinstance; - } - // Update the generated name with the new instance - string newname = name.Replace(originalinstance, newinstance); - // Check to make sure the new name is unique - while (await ConfigurationHelper.CheckIfGeneratedNameExists(newname)) - { - newinstance = (Convert.ToInt32(newinstance) + 1).ToString(); - newname = name.Replace(originalinstance, newinstance); + newinstance = (Convert.ToInt32(originalinstance) + i).ToString(); + // Make sure the instance pattern matches the entered values (leading zeros) + while (newinstance.Length < originalinstance.Length) + { + newinstance = "0" + newinstance; + } + // Replace the new instance in the original name + name = originalname.Replace(originalinstance, newinstance); + // Increase the counter + i += 1; } - name = newname; sbMessage.Append("The resource instance has been auto-incremented to the next value."); sbMessage.Append(Environment.NewLine); } From 905b5af98b3c20c510d4094468c43ca34c97bc5a Mon Sep 17 00:00:00 2001 From: Bryan Soltis Date: Tue, 9 Jan 2024 12:20:33 -0600 Subject: [PATCH 13/15] - Updated sidebar color to fill visible window --- src/Components/Layout/NavMenu.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Layout/NavMenu.razor b/src/Components/Layout/NavMenu.razor index ff4d0544..3c67a7db 100644 --- a/src/Components/Layout/NavMenu.razor +++ b/src/Components/Layout/NavMenu.razor @@ -17,7 +17,7 @@ -
    +