Browse Source

return to home button on top logo

ganahrhr 3 years ago
parent
commit
d7b434a2cd
2 changed files with 114 additions and 109 deletions
  1. 4 4
      Shared/Sidebar.razor
  2. 110 105
      Shared/Sidebar.razor.cs

+ 4 - 4
Shared/Sidebar.razor

@@ -5,10 +5,10 @@
 <AuthorizeView>
     <Authorized>
         <nav class="nav">
-            <div class="top-href">
-                <div class="top-href__logo">
-                    <img src="img/logo.svg" alt="">
-                </div>
+            <div class="top-href">                
+                <div class="top-href__logo" style="cursor:pointer" title="Вернуться на главную" @onclick="@LogoClick">
+                    <img src="img/logo.svg" alt="">                
+                </div>                
                 <a style="cursor:pointer" title="Личные данные" @onclick="@ProfileClick">
                     <img src="img/user.svg" alt="">
                 </a>

+ 110 - 105
Shared/Sidebar.razor.cs

@@ -1,111 +1,116 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.Components.Authorization;
-using Microsoft.AspNetCore.Identity;
-using HyperCube.Pages;
-using HyperCube.Models;
-using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
-
-namespace HyperCube.Shared
-{
-    public partial class Sidebar : ComponentBase
-    {
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using Microsoft.AspNetCore.Identity;
+using HyperCube.Pages;
+using HyperCube.Models;
+using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
+
+namespace HyperCube.Shared
+{
+    public partial class Sidebar : ComponentBase
+    {
+        [Inject]
+        ProtectedSessionStorage storage { get; set; }
+        [Inject]
+        NavigationManager NavigationManager { get; set; }
         [Inject]
-        ProtectedSessionStorage storage { get; set; }
-        [Inject]
-        NavigationManager NavigationManager { get; set; }
-        [Inject]
-        AuthenticationStateProvider AuthenticationStateProvider { get; set; }
-        [Inject]
-        UserManager<IdentityUser> UserManager { get; set; }
-
-        ModalProfile modalProfile { get; set; }
-        ModalFiles modalFiles { get; set; }
-        ModalCompetency modalCompetency { get; set; }
-        ModalRating modalRating { get; set; }
-        ModalRules modalRules { get; set; }
-        ModalAssets modalAssets { get; set; }
-        ModalInfo modalError404 { get; set; }
-        ModalLoading modalLoading { get; set; }
-
-        AccountModel _currentAccount;        
-
-        protected override async Task OnInitializedAsync()
-        {            
+        AuthenticationStateProvider AuthenticationStateProvider { get; set; }
+        [Inject]
+        UserManager<IdentityUser> UserManager { get; set; }
+
+        ModalProfile modalProfile { get; set; }
+        ModalFiles modalFiles { get; set; }
+        ModalCompetency modalCompetency { get; set; }
+        ModalRating modalRating { get; set; }
+        ModalRules modalRules { get; set; }
+        ModalAssets modalAssets { get; set; }
+        ModalInfo modalError404 { get; set; }
+        ModalLoading modalLoading { get; set; }
+
+        AccountModel _currentAccount;        
+
+        protected override async Task OnInitializedAsync()
+        {            
             var acc = await GetCurrentAcc();
             Console.WriteLine($"sidebar myFlag set1 {acc.Name}");
             //AppData.CurrentAccount = acc;
             await storage.SetAsync("acc", acc.Email);
 
-            var myFlag = await storage.GetAsync<string>("acc");
-            Console.WriteLine($"sidebar myFlag set {myFlag.Value}");
-            await storage.SetAsync("completed", true);
-        }
-
-        async Task ProfileClick()
-        {
-            //AccountModel account = new() { Name = "[SomeUserName]", UUID = "[SomeUserID]" };
-            AccountModel account = await GetCurrentAcc();
-
-            account.LoadRoles();
-            modalProfile.Open(account);
-        }
-
-        void FilesClick()
-        {
-            modalFiles.Open();
-        }
-
-        void CompetencyClick()
-        {
-            modalCompetency.Open();
-        }
-
-        void RatingClick()
-        {
-            modalRating.Open();
-        }
-
-        void RulesClick()
-        {
-            modalRules.Open();
-        }
-
-        void AssetsClick()
-        {            
-            modalAssets.Open();
-        }
-
-        void ExitClick()
-        {            
-            NavigationManager.NavigateTo("Identity/Account/Logout", true);
-        }
-
-        void ErrorClick()
-        {
-            modalError404.Open();            
-        }
-
-        async Task<AccountModel> GetCurrentAcc()
-        {
-            if (_currentAccount == null)
-            {
-                var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
-                var user = authState.User;
-
-                if (user.Identity.IsAuthenticated)
-                {
-                    ///tmp
-                    Dictionary<string, AccountModel> accounts = await MySQLConnector.Instance().SQLSelectASPUsers();
-
-                    var currentUser = await UserManager.GetUserAsync(user);
-                    if (accounts.ContainsKey(currentUser.Id))
-                        _currentAccount = accounts[currentUser.Id];
-                }
-            }
-            return _currentAccount;
-        }
-    }
-}
+            var myFlag = await storage.GetAsync<string>("acc");
+            Console.WriteLine($"sidebar myFlag set {myFlag.Value}");
+            await storage.SetAsync("completed", true);
+        }
+
+        void LogoClick()
+        {
+            NavigationManager.NavigateTo("");
+        }
+
+        async Task ProfileClick()
+        {
+            //AccountModel account = new() { Name = "[SomeUserName]", UUID = "[SomeUserID]" };
+            AccountModel account = await GetCurrentAcc();
+
+            account.LoadRoles();
+            modalProfile.Open(account);
+        }
+
+        void FilesClick()
+        {
+            modalFiles.Open();
+        }
+
+        void CompetencyClick()
+        {
+            modalCompetency.Open();
+        }
+
+        void RatingClick()
+        {
+            modalRating.Open();
+        }
+
+        void RulesClick()
+        {
+            modalRules.Open();
+        }
+
+        void AssetsClick()
+        {            
+            modalAssets.Open();
+        }
+
+        void ExitClick()
+        {            
+            NavigationManager.NavigateTo("Identity/Account/Logout", true);
+        }
+
+        void ErrorClick()
+        {
+            modalError404.Open();            
+        }
+
+        async Task<AccountModel> GetCurrentAcc()
+        {
+            if (_currentAccount == null)
+            {
+                var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
+                var user = authState.User;
+
+                if (user.Identity.IsAuthenticated)
+                {
+                    ///tmp
+                    Dictionary<string, AccountModel> accounts = await MySQLConnector.Instance().SQLSelectASPUsers();
+
+                    var currentUser = await UserManager.GetUserAsync(user);
+                    if (accounts.ContainsKey(currentUser.Id))
+                        _currentAccount = accounts[currentUser.Id];
+                }
+            }
+            return _currentAccount;
+        }
+    }
+}