bleh...miac... logger api
This commit is contained in:
parent
fcd8de3330
commit
5fcab23479
|
|
@ -28,6 +28,7 @@ using DevExpress.Data.Filtering;
|
|||
using DevExpress.Data.Linq;
|
||||
using DevExpress.Data.Linq.Helpers;
|
||||
using TIAM.Database.DbSets.Drivers;
|
||||
using AyCode.Entities.Server.LogItems;
|
||||
|
||||
namespace TIAM.Database.DataLayers.Admins
|
||||
{
|
||||
|
|
@ -627,5 +628,11 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
#endregion
|
||||
|
||||
#region Logs
|
||||
|
||||
public Task<List<AcLogItem>> GetLogItemsAsync() => SessionAsync(ctx => ctx.LogItems.ToList());
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using AyCode.Entities.Server.LogItems;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.ModelBuilders.Companies;
|
||||
using TIAM.Database.ModelBuilders.Emails;
|
||||
using TIAM.Database.ModelBuilders.Products;
|
||||
|
|
@ -18,6 +19,7 @@ namespace TIAM.Database.DbContexts.Admins
|
|||
{
|
||||
public class AdminDbContext : DbContextBase, IAdminDbContext
|
||||
{
|
||||
public DbSet<AcLogItem> LogItems { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<Profile> Profiles { get; set; }
|
||||
public DbSet<Company> Companies { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
@page "/sysadmin/logs"
|
||||
@using BlazorAnimation
|
||||
@using TIAM.Entities.Users
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAM.Resources
|
||||
@using TIAM.Services
|
||||
@using TIAMSharedUI.Pages.Components
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Models.PageModels
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Consts
|
||||
@layout AdminLayout
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject IStringLocalizer<TIAMResources> Localizer
|
||||
@inject ISessionService SessionService
|
||||
|
||||
<PageTitle>User permissions</PageTitle>
|
||||
|
||||
<div class="text-center m-5">
|
||||
<h1>Drivers</h1>
|
||||
<h2 style="font-size:small">Manage drivers here!</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class=" col-12">
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card">
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
<div class="align-self-end pl-2 pb-2">
|
||||
<DxButton Text="Column Chooser"
|
||||
RenderStyle="ButtonRenderStyle.Secondary"
|
||||
IconCssClass="btn-column-chooser"
|
||||
Click="ColumnChooserButton_Click" />
|
||||
</div>
|
||||
|
||||
<LogViewerGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ContextId="TiamConstClient.TransferProductId" GetAllTag="SignalRTags.GetUserProductMappingsByProductId"></LogViewerGridComponent>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-6">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private LoggerClient<ManageUserProductMappings> _logger;
|
||||
//public UserModelDtoDetail UserModelDtoDetail = new();
|
||||
|
||||
|
||||
IGrid Grid { get; set; }
|
||||
//object? MasterGridData { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
void ColumnChooserButton_Click()
|
||||
{
|
||||
Grid.ShowColumnChooser();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
@using TIAM.Entities.Products
|
||||
@using TIAM.Entities.Transfers
|
||||
@using TIAM.Entities.Drivers
|
||||
@using TIAM.Entities.Users
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAM.Services
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using TIAM.Core.Loggers
|
||||
@using AyCode.Core.Loggers
|
||||
@using AyCode.Services.Loggers
|
||||
@using AyCode.Core
|
||||
@using AyCode.Core.Extensions
|
||||
@inject IServiceProviderDataService ServiceProviderDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient
|
||||
@inject IWizardProcessor WizardProcessor
|
||||
@inject IUserDataService UserDataService
|
||||
|
||||
|
||||
<LogViewerGrid Logger="_logger"
|
||||
@ref="_logViewerGrid"
|
||||
ContextIds="new [] {ContextId}"
|
||||
GetAllMessageTag="GetAllTag"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
PageSize="10"
|
||||
ValidationEnabled="false"
|
||||
CustomizeElement="Grid_CustomizeElement"
|
||||
CustomizeEditModel="CustomizeEditModel"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
|
||||
ShowFilterRow="true">
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
||||
@{
|
||||
var userEmailFieldName = $"{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
|
||||
}
|
||||
<DxGridDataColumn FieldName="@userEmailFieldName" Caption="User email" SortIndex="0" />
|
||||
<DxGridDataColumn FieldName="ProductId" Caption="ServiceId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
||||
@{
|
||||
var productNameFieldName = $"{nameof(UserProductMapping.Product)}.{nameof(Product.Name)}";
|
||||
}
|
||||
<DxGridDataColumn FieldName="@productNameFieldName" Caption="Service name" />
|
||||
<DxGridDataColumn FieldName="Permissions" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
@{
|
||||
<DxTabs>
|
||||
|
||||
<DxTabPage Text="Products">
|
||||
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Cars">
|
||||
<CarDetailGridComponent GetAllTag="SignalRTags.GetCarsForUserProductMapping" ContextId="((UserProductMapping)context.DataItem).Id" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
}
|
||||
</DetailRowTemplate>
|
||||
|
||||
<EditFormTemplate Context="UserEditFormContext">
|
||||
|
||||
|
||||
@{
|
||||
var transfer2 = (UserProductMapping)UserEditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
|
||||
<DxFormLayoutItem Caption="UserId" ColSpanLg="6" ColSpanMd="12">
|
||||
@transfer2.UserId
|
||||
@{
|
||||
var a = UserEditFormContext.GetEditor("UserId");
|
||||
}
|
||||
@* <DxButton Click="() => ShowPopup((UserProductMapping)UserEditFormContext.EditModel)" Context="ButtonContext">Select user</DxButton> *@
|
||||
<DxButton Click="@(async (MouseEventArgs e) => await ShowPopup((UserProductMapping)UserEditFormContext.EditModel))" Context="ButtonContext">Select user</DxButton>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
|
||||
@UserEditFormContext.GetEditor("Permissions")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
</LogViewerGrid>
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid ContextId { get; set; }
|
||||
[Parameter] public IProductRelation ParentData { get; set; } = null!;
|
||||
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
|
||||
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
|
||||
|
||||
private LoggerClient<UserProductMappingGridComponent> _logger;
|
||||
|
||||
private LogViewerGrid _logViewerGrid;
|
||||
|
||||
private UserProductMapping _tempProductMapping;
|
||||
|
||||
bool PopupVisible { get; set; }
|
||||
private DxMaskedInput<string> _emailInput;
|
||||
private DxButton _button1;
|
||||
private ElementReference _errorMessage;
|
||||
private string _errorCss = "display: none;";
|
||||
private List<UserModelDto> FoundUsers { get; set; } = new List<UserModelDto>();
|
||||
|
||||
|
||||
private string Email { get; set; } = "email@email.com";
|
||||
string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
|
||||
UserModelDto _chosenUser = null!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (!e.IsNew) return;
|
||||
|
||||
if (ContextId.IsNullOrEmpty())
|
||||
{
|
||||
_logger.Warning($"ContextId.IsNullOrEmpty()");
|
||||
return;
|
||||
}
|
||||
|
||||
var newUpm = (UserProductMapping)e.EditModel;
|
||||
newUpm.ProductId = ContextId;
|
||||
|
||||
var newProductMapping = new UserProductMapping
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
ProductId = (Guid)ContextId,
|
||||
Permissions = 2
|
||||
};
|
||||
|
||||
//e.EditModel = newProductMapping;
|
||||
}
|
||||
|
||||
async Task FindUser()
|
||||
{
|
||||
var userModelDto = await UserDataService.GetUserByEmailAsync(Email);
|
||||
if (userModelDto != null)
|
||||
{
|
||||
_chosenUser = userModelDto;
|
||||
FoundUsers.Add(_chosenUser);
|
||||
_emailInput.Enabled = false;
|
||||
_button1.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_emailInput.Value = "email@email.com";
|
||||
_errorCss = "display: block";
|
||||
}
|
||||
}
|
||||
|
||||
void CancelCreateClick()
|
||||
{
|
||||
PopupVisible = false;
|
||||
}
|
||||
|
||||
void SelectDriverPopupClosed()
|
||||
{
|
||||
//cancel clicked
|
||||
}
|
||||
|
||||
void SelectDriverPopupClosing(PopupClosingEventArgs args)
|
||||
{
|
||||
//myModel = new TransferWizardModel();
|
||||
|
||||
}
|
||||
|
||||
public Task SubmitForm(object result)
|
||||
{
|
||||
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ShowPopup(UserProductMapping emptyProductMapping)
|
||||
{
|
||||
_tempProductMapping = emptyProductMapping;
|
||||
PopupVisible = true;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task OnUserSelected(Guid userId)
|
||||
{
|
||||
// Logic after the user is selected
|
||||
await Task.Run(() => Console.WriteLine($"Selected User ID: {userId}"));
|
||||
}
|
||||
|
||||
private async Task OnRowClick(GridRowClickEventArgs e)
|
||||
{
|
||||
await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id"));
|
||||
}
|
||||
|
||||
private async Task SelectUser(Guid id)
|
||||
{
|
||||
PopupVisible = false;
|
||||
_tempProductMapping.UserId = id;
|
||||
|
||||
await OnUserSelected(id);
|
||||
}
|
||||
|
||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||
{
|
||||
if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1)
|
||||
{
|
||||
e.Style = "display: none";
|
||||
}
|
||||
// else if (e.ElementType == GridElementType.HeaderCell)
|
||||
// {
|
||||
// e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold";
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using AyCode.Entities.LogItems;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Services;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class LogViewerGrid : TiamGrid<LogitemViewerModel>
|
||||
{
|
||||
public LogViewerGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetAllUserProductMappings;
|
||||
AddMessageTag = SignalRTags.CreateUserProductMapping;
|
||||
UpdateMessageTag = SignalRTags.UpdateUserProductMapping;
|
||||
RemoveMessageTag = SignalRTags.DeleteUserProductMapping;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ using TIAMWebApp.Shared.Application.Utility;
|
|||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids
|
||||
{
|
||||
public class TiamGrid<TDataItem> : DxGrid where TDataItem : class, IId<Guid>
|
||||
public class TiamGrid<TDataItem> : DxGrid where TDataItem : class, IId<Guid>
|
||||
{
|
||||
protected bool IsFirstInitializeParameters;
|
||||
private SignalRDataSource<TDataItem> _dataSource = null!;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ using AyCode.Entities.Server.LogItems;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAMWebApp.Server.Services;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI;
|
||||
|
||||
namespace TIAMWebApp.Server.Controllers
|
||||
{
|
||||
|
|
@ -12,13 +14,14 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[ApiController]
|
||||
[EnableCors("_myAllowSpecificOrigins")]
|
||||
[Route("api/v1/[controller]")]
|
||||
public class LoggerApiController(LoggerToLoggerApiController logger) : ControllerBase
|
||||
public class LoggerApiController(LoggerToLoggerApiController logger, AdminDal _adminDal) : ControllerBase
|
||||
{
|
||||
|
||||
// = new TIAM.Core.Loggers.Logger<LoggerApiController>();
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.LoggerRouteName)]
|
||||
[Route(APIUrls.AddLogItemRouteName)]
|
||||
public async Task AddLogItem(AcLogItem? logItem)
|
||||
{
|
||||
try
|
||||
|
|
@ -44,5 +47,20 @@ namespace TIAMWebApp.Server.Controllers
|
|||
Console.WriteLine($@"ERROR!!! {nameof(LoggerApiController)}->AddLogItem; ex: {ex.Message}{AcEnv.NL}{AcEnv.NL}{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetAllLogItemsRouteName)]
|
||||
public async Task<List<LogitemViewerModel>> GetAllLogItems()
|
||||
{
|
||||
var result = await _adminDal.GetLogItemsAsync();
|
||||
List<LogitemViewerModel> returnList = new List<LogitemViewerModel>();
|
||||
foreach (var item in result)
|
||||
{
|
||||
returnList.Add(new LogitemViewerModel(Guid.NewGuid(), item, item.LogHeaderId));
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,11 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string MessageAPI = BaseUrlWithSlashAndVersion + "MessageAPI/";
|
||||
public const string PaymentAPI = BaseUrlWithSlashAndVersion + "PaymentAPI/";
|
||||
|
||||
public const string LoggerRouteName = "Logger";
|
||||
public const string Logger = LoggerApi + LoggerRouteName;
|
||||
public const string AddLogItemRouteName = "AddLogItem";
|
||||
public const string AddLogItem = LoggerApi + AddLogItemRouteName;
|
||||
|
||||
public const string GetAllLogItemsRouteName = "GetAllLogItems";
|
||||
public const string GetAllLogItems = LoggerApi + GetAllLogItemsRouteName;
|
||||
|
||||
//userdata
|
||||
public const string UserTestRouteName = "test1";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
using AyCode.Core.Interfaces;
|
||||
using AyCode.Entities.LogItems;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI
|
||||
{
|
||||
public class LogitemViewerModel : IId<Guid>
|
||||
{
|
||||
public AcLogItemClient AcLogItemClient { get; set; }
|
||||
|
||||
public int LogHeaderId { get; set; }
|
||||
public Guid Id { get ; set; }
|
||||
|
||||
public LogitemViewerModel(Guid id, AcLogItemClient logItemClient, int logHeaderID) {
|
||||
|
||||
Id = id;
|
||||
AcLogItemClient = logItemClient;
|
||||
LogHeaderId = logHeaderID;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue