92 lines
2.3 KiB
C#
92 lines
2.3 KiB
C#
using MagMan.Core.Services;
|
|
using MagMan.Data.Admin.DbModels;
|
|
using MagMan.Data.Admin.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace MagMan.UI.Pages
|
|
{
|
|
[Authorize(Roles = "SuperAdmin, Admin")]
|
|
public partial class AdminArea: ComponentBase, IDisposable
|
|
{
|
|
#region Protected Enums
|
|
|
|
protected enum CtMode
|
|
{
|
|
Loading,
|
|
Company,
|
|
Users,
|
|
Machine,
|
|
AuthKeys
|
|
}
|
|
|
|
#endregion Protected Enums
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MTAdminService MTService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
AppMService.ShowSearch = false;
|
|
AppMService.ShowCustomers = true;
|
|
AppMService.PageName = "Admin Area";
|
|
AppMService.PageIcon = "fa-solid fa-building pr-2";
|
|
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
|
|
CustomerID = AppMService.CustomerID;
|
|
}
|
|
public void Dispose()
|
|
{
|
|
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
|
|
}
|
|
private async void AppMService_EA_CustomerSel()
|
|
{
|
|
var actMode = currMode;
|
|
currMode = CtMode.Loading;
|
|
CustomerID = AppMService.CustomerID;
|
|
await Task.Delay(50);
|
|
currMode = actMode;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private CtMode currMode = CtMode.Company;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int CustomerID { get; set; } = 0;
|
|
|
|
[Inject]
|
|
private NavigationManager NavMan { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string IsActive(CtMode modeReq)
|
|
{
|
|
string answ = currMode == modeReq ? "active" : "";
|
|
return answ;
|
|
}
|
|
|
|
private void SetMode(CtMode newMode)
|
|
{
|
|
currMode = newMode;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |