diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index d0bfd422..6fd06ba4 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -70,6 +70,7 @@ namespace TIAM.Database.DataLayers.Admins #endregion Transfer #region TransferDestination + public List? GetTransferDestinations() => Session(ctx=>ctx.GetTransferDestinations().ToList()); public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx=>ctx.GetTransferDestinationById(transferDestinationId)); public Task GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx=>ctx.GetTransferDestinationById(transferDestinationId)); public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson()); diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransferDestinations.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransferDestinations.razor index 3d69efcf..cf7cda0c 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransferDestinations.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransferDestinations.razor @@ -1,6 +1,7 @@ -@page "/user/destinations" +@page "/sysadmin/destinations" @using BlazorAnimation @using TIAM.Resources +@using TIAM.Services @using TIAMSharedUI.Shared @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using AyCode.Services.Loggers @@ -27,66 +28,7 @@ IconCssClass="btn-column-chooser" Click="ColumnChooserButton_Click" /> - - - - - - - - @{ - var keyField = context.Value; - @context.Value - } - - - - - - - - - - - - - - @{ - var transfer = (TransferDestinationWizardModel)EditFormContext.EditModel; - } - - - @EditFormContext.GetEditor("Name") - - - @EditFormContext.GetEditor("Description") - - - @EditFormContext.GetEditor("AddressString") - - - @EditFormContext.GetEditor("PriceType") - - - @EditFormContext.GetEditor("Price") - - - - - - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor index fbb47ebb..62716782 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor @@ -2,6 +2,7 @@ @using BlazorAnimation @using TIAM.Models.Dtos.Users @using TIAM.Resources +@using TIAM.Services @using TIAMSharedUI.Pages.Components @using TIAMSharedUI.Shared @using TIAMWebApp.Shared.Application.Interfaces @@ -108,7 +109,7 @@ - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor index 382e0c43..6ec7d586 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor @@ -49,6 +49,9 @@ + + + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationGridComponent.razor new file mode 100644 index 00000000..6eb2ce13 --- /dev/null +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationGridComponent.razor @@ -0,0 +1,127 @@ +@using TIAM.Entities.Transfers +@using TIAM.Entities.Drivers +@using TIAM.Models.Dtos.Users +@using TIAM.Resources +@using TIAMSharedUI.Shared.Components.Grids +@using TIAMWebApp.Shared.Application.Interfaces +@using TIAMWebApp.Shared.Application.Utility +@using TIAM.Core.Loggers +@using AyCode.Core.Loggers +@using AyCode.Services.Loggers +@using TIAMWebApp.Shared.Application.Services +@using AyCode.Core.Enums +@using AyCode.Core.Extensions +@using AyCode.Core +@inject IUserDataService UserDataService +@inject IEnumerable LogWriters +@inject AdminSignalRClient AdminSignalRClient; +@inject IStringLocalizer localizer + + + + + + + + + @{ + var keyField = context.Value; + @context.Value + } + + + + + + + + + + + + + + + + @{ + var transfer = (TransferDestination)EditFormContext.EditModel; + } + + + @EditFormContext.GetEditor("Name") + + + @EditFormContext.GetEditor("Description") + + + @EditFormContext.GetEditor("AddressString") + + + @EditFormContext.GetEditor("Price") + + + @EditFormContext.GetEditor("Price2") + + + @EditFormContext.GetEditor("Price3") + + + @EditFormContext.GetEditor("ProductCommis") + + + @EditFormContext.GetEditor("ExtraPrice") + + + + + + + +@code { + [Parameter] public bool KeyboardNavigationEnabled { get; set; } + [Parameter] public Guid? ContextId { get; set; } + [Parameter] public int GetAllTag { get; set; } + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; + + private TransferDestinationGrid _transferToDriversGrid = null!; + private LoggerClient _logger = null!; + + protected override void OnInitialized() + { + _logger = new LoggerClient(LogWriters.ToArray()); + + } + + private void DataItemChanged(GridDataItemChangedEventArgs args) + { + + } + + private void DataItemSaving(GridEditModelSavingEventArgs obj) + { + _logger.Debug($"DataItemSaving"); + } + + private void DataItemDeleting(GridDataItemDeletingEventArgs obj) + { + _logger.Debug($"DataItemDeleting"); + } + + void CustomizeEditModel(GridCustomizeEditModelEventArgs e) + { + if (!e.IsNew) return; + + + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor new file mode 100644 index 00000000..a618c137 --- /dev/null +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor @@ -0,0 +1,146 @@ +@using TIAM.Entities.Products +@using TIAM.Entities.ServiceProviders +@using TIAM.Entities.Transfers +@using TIAM.Entities.Drivers +@using TIAM.Entities.Users +@using TIAM.Models.Dtos.Users +@using TIAMWebApp.Shared.Application.Interfaces +@using TIAMWebApp.Shared.Application.Services +@using TIAMWebApp.Shared.Application.Utility +@using AyCode.Services.Loggers +@using TIAM.Core.Loggers +@using AyCode.Core +@using TIAMSharedUI.Shared.Components.Grids +@inject IServiceProviderDataService ServiceProviderDataService +@inject IEnumerable LogWriters +@inject AdminSignalRClient AdminSignalRClient; + + + + + + + + + + + + + + + + + + + + + + + + + @{ + var serviceProvider = (Company)EditFormContext.EditModel; + } + + + @EditFormContext.GetEditor("Price") + + + @EditFormContext.GetEditor("Price2") + + + @EditFormContext.GetEditor("Price3") + + + + @EditFormContext.GetEditor("ProductCommis") + + + + + + + + + +@code { + [Parameter] public bool KeyboardNavigationEnabled { get; set; } + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; + [Parameter] public Guid? ContextId { get; set; } + [Parameter] public Guid[]? ContextIds { get; set; } = new Guid[0]; + [Parameter] public int GetAllTag { get; set; } + + private LoggerClient _logger = null!; + + protected override async Task OnInitializedAsync() + { + _logger = new LoggerClient(LogWriters.ToArray()); + + // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract + //_detailGridData = UserModelDtoDetail.ServiceProviders ?? []; + //_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync(); + + //_logger.Info($"DetailGridData: {_detailGridData.Count}"); + } + + protected override void OnParametersSet() + { + if(ContextId.HasValue) + { + ContextIds = new Guid[1]; + ContextIds[0] = (Guid)ContextId!; + + } + base.OnParametersSet(); + } + + // void CustomizeEditModel(GridCustomizeEditModelEventArgs e) + // { + // if (!e.IsNew) return; + + // var newProductMapping = new UserProductMapping + // { + // ProductId = Guid.NewGuid(), + // UserId = UserModelDtoDetail.Id, + // Permissions = 1 + // }; + + // e.EditModel = newProductMapping; + // } + + // async Task EditModelSaving(GridEditModelSavingEventArgs e) + // { + // if (e.IsNew) + // //add new orderData to orderData array + // _logger.Info("New orderData added"); + // else + // _logger.Info("orderData updated"); + + // await UpdateDataAsync(); + // } + + // async Task DataItemDeleting(GridDataItemDeletingEventArgs e) + // { + // //remove orderData from orderData array + // _logger.Info("orderData deleted"); + // //await UpdateDataAsync(); + // } + + // async Task UpdateDataAsync() + // { + // //refresh grid + // _logger.Info("orderData grid refreshed"); + // } + +} \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor index 7f2dcf88..e0e851f7 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor @@ -68,9 +68,10 @@ @code { [Parameter] public bool KeyboardNavigationEnabled { get; set; } - + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter] public Guid? ContextId { get; set; } + private Guid[] ContextIds = new Guid[0]; private LoggerClient _logger = null!; protected override void OnInitialized() @@ -79,4 +80,54 @@ base.OnInitialized(); } + + protected override void OnParametersSet() + { + if(ContextId.HasValue) + { + ContextIds = new Guid[1]; + ContextIds[0] = (Guid)ContextId!; + + } + base.OnParametersSet(); + } + + // void CustomizeEditModel(GridCustomizeEditModelEventArgs e) + // { + // if (!e.IsNew) return; + + // var newProductMapping = new UserProductMapping + // { + // ProductId = Guid.NewGuid(), + // UserId = UserModelDtoDetail.Id, + // Permissions = 1 + // }; + + // e.EditModel = newProductMapping; + // } + + // async Task EditModelSaving(GridEditModelSavingEventArgs e) + // { + // if (e.IsNew) + // //add new orderData to orderData array + // _logger.Info("New orderData added"); + // else + // _logger.Info("orderData updated"); + + // await UpdateDataAsync(); + // } + + // async Task DataItemDeleting(GridDataItemDeletingEventArgs e) + // { + // //remove orderData from orderData array + // _logger.Info("orderData deleted"); + // //await UpdateDataAsync(); + // } + + // async Task UpdateDataAsync() + // { + // //refresh grid + // _logger.Info("orderData grid refreshed"); + // } + } \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/TransferDestinationDetailGrid.cs b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationDetailGrid.cs new file mode 100644 index 00000000..806a7a9a --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationDetailGrid.cs @@ -0,0 +1,30 @@ +using Microsoft.AspNetCore.Components; +using TIAM.Entities.Profiles; +using TIAM.Services; + +namespace TIAMSharedUI.Shared.Components.Grids; + +public class TransferDestinationDetailGrid : TransferDestinationGrid +{ + public TransferDestinationDetailGrid() : base() + { + GetAllMessageTag = SignalRTags.GetAllTransferDestinations; + AddMessageTag = SignalRTags.CreateTransferDestination; + UpdateMessageTag = SignalRTags.UpdateTransferDestination; + RemoveMessageTag = SignalRTags.RemoveTransferDestination; + } + + protected override Task SetParametersAsyncCore(ParameterView parameters) + { + if (!IsFirstInitializeParameters) + { + //ShowFilterRow = true; + //ShowGroupPanel = true; + //AllowSort = false; + + //etc... + } + + return base.SetParametersAsyncCore(parameters); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/TransferDestinationGrid.cs b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationGrid.cs new file mode 100644 index 00000000..9bd75531 --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationGrid.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Components; +using TIAM.Entities.Profiles; +using TIAM.Entities.Transfers; +using TIAM.Services; + + +namespace TIAMSharedUI.Shared.Components.Grids; + +public class TransferDestinationGrid : TiamGrid +{ + public TransferDestinationGrid() : base() + { + GetAllMessageTag = SignalRTags.GetAllTransferDestinations; + AddMessageTag = SignalRTags.CreateTransferDestination; + UpdateMessageTag = SignalRTags.UpdateTransferDestination; + RemoveMessageTag = SignalRTags.RemoveTransferDestination; + } + + protected override Task SetParametersAsyncCore(ParameterView parameters) + { + if (!IsFirstInitializeParameters) + { + //ShowFilterRow = true; + //ShowGroupPanel = true; + //AllowSort = false; + + //etc... + } + + return base.SetParametersAsyncCore(parameters); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/TransferDestinationToProductDetailGrid.cs b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationToProductDetailGrid.cs new file mode 100644 index 00000000..f0136ac6 --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/TransferDestinationToProductDetailGrid.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Components; +using TIAM.Entities.Products; +using TIAM.Entities.Transfers; +using TIAM.Services; + +namespace TIAMSharedUI.Shared.Components.Grids; + +public class TransferDestinationToProductDetailGrid : TransferDestinationToProductGrid +{ + public TransferDestinationToProductDetailGrid() : base() + { + GetAllMessageTag = SignalRTags.GetAllTransferDestinationToProducts; + AddMessageTag = SignalRTags.CreateTransferDestinationToProduct; + UpdateMessageTag = SignalRTags.UpdateTransferDestinationToProduct; + RemoveMessageTag = SignalRTags.RemoveTransferDestinationToProduct; + } + + protected override Task SetParametersAsyncCore(ParameterView parameters) + { + if (!IsFirstInitializeParameters) + { + //ShowFilterRow = true; + //ShowGroupPanel = true; + //AllowSort = false; + + //etc... + } + + return base.SetParametersAsyncCore(parameters); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Users/AdminNavMenu.razor b/TIAMSharedUI/Shared/Users/AdminNavMenu.razor index 5c7c4d1e..fbfacfd6 100644 --- a/TIAMSharedUI/Shared/Users/AdminNavMenu.razor +++ b/TIAMSharedUI/Shared/Users/AdminNavMenu.razor @@ -17,6 +17,7 @@ + @@ -25,7 +26,6 @@ - diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index a9cabb51..88363119 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -20,6 +20,7 @@ using TIAMWebApp.Server.Services; using TIAMWebApp.Shared.Application.Models.ClientSide; using AyCode.Core.Extensions; using TIAM.Entities.Users; +using TIAMSharedUI.Shared.Components.Grids; namespace TIAMWebApp.Server.Controllers { @@ -48,9 +49,10 @@ namespace TIAMWebApp.Server.Controllers [AllowAnonymous] [HttpGet] [Route(APIUrls.GetTransferDestinationsRouteName)] - public async Task> GetTransferDestinations() + [SignalR(SignalRTags.GetAllTransferDestinations)] + public List GetTransferDestinations() { - return await _adminDal.Context.TransferDestinations.ToListAsync(); + return _adminDal.GetTransferDestinations(); } //[Authorize]