From e7f13973cb8ac0a746f6b3f3d7beb1530c22dbb9 Mon Sep 17 00:00:00 2001 From: Gianluigi Liguori Date: Mon, 4 Nov 2024 11:21:42 +0100 Subject: [PATCH] Rename Layout Folder and remove Redirect On Error --- .../{Shared => Layout}/LoginDisplay.razor | 56 +++--- src/Savings.SPA/Layout/MainLayout.razor | 13 ++ .../{Shared => Layout}/MainLayout.razor.css | 162 ++++++++--------- .../{Shared => Layout}/NavMenu.razor | 164 +++++++++--------- .../{Shared => Layout}/NavMenu.razor.css | 136 +++++++-------- .../{Shared => Layout}/RedirectToLogin.razor | 42 ++--- src/Savings.SPA/Shared/MainLayout.razor | 28 --- 7 files changed, 293 insertions(+), 308 deletions(-) rename src/Savings.SPA/{Shared => Layout}/LoginDisplay.razor (96%) create mode 100644 src/Savings.SPA/Layout/MainLayout.razor rename src/Savings.SPA/{Shared => Layout}/MainLayout.razor.css (94%) rename src/Savings.SPA/{Shared => Layout}/NavMenu.razor (97%) rename src/Savings.SPA/{Shared => Layout}/NavMenu.razor.css (94%) rename src/Savings.SPA/{Shared => Layout}/RedirectToLogin.razor (97%) delete mode 100644 src/Savings.SPA/Shared/MainLayout.razor diff --git a/src/Savings.SPA/Shared/LoginDisplay.razor b/src/Savings.SPA/Layout/LoginDisplay.razor similarity index 96% rename from src/Savings.SPA/Shared/LoginDisplay.razor rename to src/Savings.SPA/Layout/LoginDisplay.razor index e3b4163..aceefa1 100644 --- a/src/Savings.SPA/Shared/LoginDisplay.razor +++ b/src/Savings.SPA/Layout/LoginDisplay.razor @@ -1,28 +1,28 @@ -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication -@using Microsoft.Extensions.Options; -@inject NavigationManager Navigation - -@inject IOptionsSnapshot> Options - - - - - - - - - - -@code { - public void BeginLogOut() - { - Navigation.NavigateToLogout(Options.Get( - Microsoft.Extensions.Options.Options.DefaultName) - .AuthenticationPaths.LogOutPath); - } -} +@using Microsoft.AspNetCore.Components.WebAssembly.Authentication +@using Microsoft.Extensions.Options; +@inject NavigationManager Navigation + +@inject IOptionsSnapshot> Options + + + + + + + + + + +@code { + public void BeginLogOut() + { + Navigation.NavigateToLogout(Options.Get( + Microsoft.Extensions.Options.Options.DefaultName) + .AuthenticationPaths.LogOutPath); + } +} diff --git a/src/Savings.SPA/Layout/MainLayout.razor b/src/Savings.SPA/Layout/MainLayout.razor new file mode 100644 index 0000000..096659d --- /dev/null +++ b/src/Savings.SPA/Layout/MainLayout.razor @@ -0,0 +1,13 @@ +@inherits LayoutComponentBase + + +
+ +
+
+ @Body +
+
+
diff --git a/src/Savings.SPA/Shared/MainLayout.razor.css b/src/Savings.SPA/Layout/MainLayout.razor.css similarity index 94% rename from src/Savings.SPA/Shared/MainLayout.razor.css rename to src/Savings.SPA/Layout/MainLayout.razor.css index c7ac763..c865427 100644 --- a/src/Savings.SPA/Shared/MainLayout.razor.css +++ b/src/Savings.SPA/Layout/MainLayout.razor.css @@ -1,81 +1,81 @@ -.page { - position: relative; - display: flex; - flex-direction: column; -} - -main { - flex: 1; -} - -.sidebar { - background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); -} - -.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 ::deep .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - text-decoration: none; - } - - .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { - text-decoration: underline; - } - - .top-row ::deep 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 ::deep a, .top-row ::deep .btn-link { - margin-left: 0; - } -} - -@media (min-width: 641px) { - .page { - flex-direction: row; - } - - .sidebar { - width: 250px; - height: 100vh; - position: sticky; - top: 0; - } - - .top-row { - position: sticky; - top: 0; - z-index: 1; - } - - .top-row.auth ::deep a:first-child { - flex: 1; - text-align: right; - width: 0; - } - - .top-row, article { - padding-left: 2rem !important; - padding-right: 1.5rem !important; - } -} +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.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 ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; + } + + .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { + text-decoration: underline; + } + + .top-row ::deep 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 ::deep a, .top-row ::deep .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .top-row.auth ::deep a:first-child { + flex: 1; + text-align: right; + width: 0; + } + + .top-row, article { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/src/Savings.SPA/Shared/NavMenu.razor b/src/Savings.SPA/Layout/NavMenu.razor similarity index 97% rename from src/Savings.SPA/Shared/NavMenu.razor rename to src/Savings.SPA/Layout/NavMenu.razor index 57689e6..20f8d80 100644 --- a/src/Savings.SPA/Shared/NavMenu.razor +++ b/src/Savings.SPA/Layout/NavMenu.razor @@ -1,82 +1,82 @@ -@using Microsoft.Extensions.Configuration -@using Savings.SPA.Services; -@inject IConfiguration Configuration -@inject IJSRuntime JS -@inject ISavingsApi _api; - - - - - -@code { - - private bool collapseNavMenu = true; - - private string NavMenuCssClass => collapseNavMenu ? "collapse" : string.Empty; - - private void ToggleNavMenu() - { - collapseNavMenu = !collapseNavMenu; - } - - private async Task DownloadFileFromStream() - { - var fileStream = await _api.GetBackup(); - var fileName = "Savings.db"; - - using var streamRef = new DotNetStreamReference(stream: fileStream); - - await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef); - } - -} +@using Microsoft.Extensions.Configuration +@using Savings.SPA.Services; +@inject IConfiguration Configuration +@inject IJSRuntime JS +@inject ISavingsApi _api; + + + + + +@code { + + private bool collapseNavMenu = true; + + private string NavMenuCssClass => collapseNavMenu ? "collapse" : string.Empty; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } + + private async Task DownloadFileFromStream() + { + var fileStream = await _api.GetBackup(); + var fileName = "Savings.db"; + + using var streamRef = new DotNetStreamReference(stream: fileStream); + + await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef); + } + +} diff --git a/src/Savings.SPA/Shared/NavMenu.razor.css b/src/Savings.SPA/Layout/NavMenu.razor.css similarity index 94% rename from src/Savings.SPA/Shared/NavMenu.razor.css rename to src/Savings.SPA/Layout/NavMenu.razor.css index 77a8500..604b7a1 100644 --- a/src/Savings.SPA/Shared/NavMenu.razor.css +++ b/src/Savings.SPA/Layout/NavMenu.razor.css @@ -1,68 +1,68 @@ -.navbar-toggler { - background-color: rgba(255, 255, 255, 0.1); -} - -.top-row { - height: 3.5rem; - background-color: rgba(0,0,0,0.4); -} - -.navbar-brand { - font-size: 1.1rem; -} - -.oi { - width: 2rem; - font-size: 1.1rem; - vertical-align: text-top; - top: -2px; -} - -.nav-item { - font-size: 0.9rem; - padding-bottom: 0.5rem; -} - - .nav-item:first-of-type { - padding-top: 1rem; - } - - .nav-item:last-of-type { - padding-bottom: 1rem; - } - - .nav-item ::deep a { - color: #d7d7d7; - border-radius: 4px; - height: 3rem; - display: flex; - align-items: center; - line-height: 3rem; - } - -.nav-item ::deep a.active { - background-color: rgba(255,255,255,0.25); - color: white; -} - -.nav-item ::deep a:hover { - background-color: rgba(255,255,255,0.1); - color: white; -} - -@media (min-width: 641px) { - .navbar-toggler { - display: none; - } - - .collapse { - /* Never collapse the sidebar for wide screens */ - display: block; - } - - .nav-scrollable { - /* Allow sidebar to scroll for tall menus */ - height: calc(100vh - 3.5rem); - overflow-y: auto; - } -} +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.nav-item { + font-size: 0.9rem; + padding-bottom: 0.5rem; +} + + .nav-item:first-of-type { + padding-top: 1rem; + } + + .nav-item:last-of-type { + padding-bottom: 1rem; + } + + .nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; + } + +.nav-item ::deep a.active { + background-color: rgba(255,255,255,0.25); + color: white; +} + +.nav-item ::deep a:hover { + background-color: rgba(255,255,255,0.1); + color: white; +} + +@media (min-width: 641px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } + + .nav-scrollable { + /* Allow sidebar to scroll for tall menus */ + height: calc(100vh - 3.5rem); + overflow-y: auto; + } +} diff --git a/src/Savings.SPA/Shared/RedirectToLogin.razor b/src/Savings.SPA/Layout/RedirectToLogin.razor similarity index 97% rename from src/Savings.SPA/Shared/RedirectToLogin.razor rename to src/Savings.SPA/Layout/RedirectToLogin.razor index ea96897..1e49788 100644 --- a/src/Savings.SPA/Shared/RedirectToLogin.razor +++ b/src/Savings.SPA/Layout/RedirectToLogin.razor @@ -1,22 +1,22 @@ -@inject NavigationManager Navigation -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication -@using Microsoft.Extensions.Options -@inject IOptionsSnapshot> Options - -@code { - protected override void OnInitialized() - { - - var requestOptions = new InteractiveRequestOptions() - { - Interaction = InteractionType.SignIn, - ReturnUrl = Navigation.Uri, - }; - - requestOptions.TryAddAdditionalParameter("prompt", "select_account"); - - Navigation.NavigateToLogin(Options.Get( - Microsoft.Extensions.Options.Options.DefaultName) - .AuthenticationPaths.LogInPath, requestOptions); - } +@inject NavigationManager Navigation +@using Microsoft.AspNetCore.Components.WebAssembly.Authentication +@using Microsoft.Extensions.Options +@inject IOptionsSnapshot> Options + +@code { + protected override void OnInitialized() + { + + var requestOptions = new InteractiveRequestOptions() + { + Interaction = InteractionType.SignIn, + ReturnUrl = Navigation.Uri, + }; + + requestOptions.TryAddAdditionalParameter("prompt", "select_account"); + + Navigation.NavigateToLogin(Options.Get( + Microsoft.Extensions.Options.Options.DefaultName) + .AuthenticationPaths.LogInPath, requestOptions); + } } \ No newline at end of file diff --git a/src/Savings.SPA/Shared/MainLayout.razor b/src/Savings.SPA/Shared/MainLayout.razor deleted file mode 100644 index f7d6c84..0000000 --- a/src/Savings.SPA/Shared/MainLayout.razor +++ /dev/null @@ -1,28 +0,0 @@ -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication; -@inherits LayoutComponentBase -@inject IJSRuntime JS - - -
- -
-
- - - @Body - - - @{ - //Capture when the access token can't be retrieved (i.e. refresh token is expired after 1d) and perform an interactive redirect - if (ex is AccessTokenNotAvailableException) - { - ((AccessTokenNotAvailableException)ex).Redirect(); - } - } - - -
-
-