123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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 Console = HyperCube.Utils.AdvConsole;
- namespace HyperCube.Shared
- {
- public partial class Sidebar : ComponentBase
- {
- [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()
- {
- }
- 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;
- }
- }
- }
|