EmailMessages improvements, fixes, etc...

This commit is contained in:
Loretta 2024-08-15 18:45:36 +02:00
parent 9af295d5ba
commit bb9d576a05
7 changed files with 344 additions and 292 deletions

View File

@ -614,7 +614,7 @@ namespace TIAM.Database.Test
var userId = Guid.Parse(userIdUserProductMappingIdString[0]);
var userProductMappingId = Guid.Parse(userIdUserProductMappingIdString[1]);
var emailMessages = await Dal.GetEmailMessagesAsync(userId, userProductMappingId);
var emailMessages = await Dal.GetEmailMessagesByUserIdOrUpmId(userId, userProductMappingId);
Assert.IsNotNull(emailMessages);

View File

@ -318,10 +318,28 @@ namespace TIAM.Database.DataLayers.Admins
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(userId, userProductMappingId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesByUserIdOrUpmId(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessagesByUserIdOrUpmId<EmailMessage, EmailRecipient>(userId, userProductMappingId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(contextId, userId, userProductMappingId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetAllEmailMessagesAsync() => SessionAsync(ctx => ctx.GetAllEmailMessages<EmailMessage, EmailRecipient>().OrderByDescending(x => x.Created).ToList());
/// <summary>
///
/// </summary>
/// <param name="driverId">UserProductMappingId</param>
/// <returns></returns>
public Task<List<EmailMessage>> GetTransfersMessagesByDriverIdAsync(Guid driverId) => SessionAsync(ctx =>
{
//TODO: Az upm.UserId elvben nem kell, csak amíg ne fix a db! semmilyen gondot nem okoz... - J.
var upm = ctx.GetUserProductMappingById(driverId);
if (upm == null) return [];
//return ctx.GetEmailMessages<EmailMessage, EmailRecipient>(driverId) //TODO: jövőben elég lesz a driverId is és mehet vissza ez a sor! - J.
return ctx.GetEmailMessagesByUserIdOrUpmId<EmailMessage, EmailRecipient>(upm.UserId, driverId)
.Where(emailMessage => ctx.TransferToDrivers.Any(transferToDriver => transferToDriver.TransferId == emailMessage.ContextId && transferToDriver.UserProductMappingId == driverId))
.OrderByDescending(x => x.Created)
.ToList();
});
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage));

View File

@ -75,6 +75,10 @@ public class SignalRTags : AcSignalRTags
public const int GetMessagesByContextId = 60;
public const int GetAllMessages = 61;
/// <summary>
/// UserPropductMappingId
/// </summary>
public const int GetTransfersMessagesByDriverId = 62;
public const int CreateMessage = 63;
public const int UpdateMessage = 64;
public const int DeleteMessage = 65;

View File

@ -52,213 +52,214 @@
</FooterContentTemplate>
</DxPopup>
@if (isLoading)
@if (_isLoading)
{
<div class="text-center m-5">
<DxWaitIndicator Visible="true"
CssClass="m-auto"
AnimationType="WaitIndicatorAnimationType.Spin" />
</div>
}
else if (!string.IsNullOrEmpty(errorMessage))
else if (!string.IsNullOrEmpty(_errorMessage))
{
<div class="alert alert-danger">@errorMessage</div>
<div class="alert alert-danger">@_errorMessage</div>
}
else
{
<div class="container mt-4">
<DxTabs>
<DxTabPage Text="Details">
<div class="container mt-4">
<DxTabs>
<DxTabPage Text="Details">
@if (!editMode)
{
<section>
<div class="container py-4">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-10 col-lg-8 col-xl-6">
<div class="card" style="border-radius: 16px;">
<div class="card-header py-3 px-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<span class="fw-bold text-body">Transfer identifier: @transfer.Id</span>
<p class="text-muted mb-0">@transfer.ContactPhone</p>
@if (!_editMode)
{
<section>
<div class="container py-4">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-10 col-lg-8 col-xl-6">
<div class="card" style="border-radius: 16px;">
<div class="card-header py-3 px-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<span class="fw-bold text-body">Transfer identifier: @_transfer.Id</span>
<p class="text-muted mb-0">@_transfer.ContactPhone</p>
</div>
</div>
</div>
</div>
</div>
<div class="card-body p-4">
<div class="mb-4 pb-2">
<div class="mb-3">
<h4 class="fw-bold">Passenger: @transfer.FullName</h4>
<h4 class="fw-bold">E-mail address: @transfer.ContactEmail</h4>
<h5 class="text-muted">From: @transfer.FromAddress</h5>
<h5 class="text-muted">To: @transfer.ToAddress</h5>
<h5>@transfer.Appointment.ToString("MMMM dd, yyyy")</h5>
<h5 class="mb-3 text-muted">@transfer.Appointment.ToString("hh:mm tt")</h5>
<p>Passengers: @transfer.PassengerCount</p>
<p>Luggage: @transfer.LuggageCount</p>
<p>Flight number (optional): @transfer.FlightNumber</p>
<hr />
<h3>License plate: POX-382</h3>
<p class="text-muted">Car looks: Silver, Toyota, Prius</p>
<hr />
<p class="text-muted">Status on: <span class="text-body">@DateTime.Now.ToString("hh:mm tt"), @DateTime.Today.ToString("MMMM dd, yyyy")</span></p>
<div class="card-body p-4">
<div class="mb-4 pb-2">
<div class="mb-3">
<h4 class="fw-bold">Passenger: @_transfer.FullName</h4>
<h4 class="fw-bold">E-mail address: @_transfer.ContactEmail</h4>
<h5 class="text-muted">From: @_transfer.FromAddress</h5>
<h5 class="text-muted">To: @_transfer.ToAddress</h5>
<h5>@_transfer.Appointment.ToString("MMMM dd, yyyy")</h5>
<h5 class="mb-3 text-muted">@_transfer.Appointment.ToString("hh:mm tt")</h5>
<p>Passengers: @_transfer.PassengerCount</p>
<p>Luggage: @_transfer.LuggageCount</p>
<p>Flight number (optional): @_transfer.FlightNumber</p>
<hr />
<h3>License plate: POX-382</h3>
<p class="text-muted">Car looks: Silver, Toyota, Prius</p>
<hr />
<p class="text-muted">Status on: <span class="text-body">@DateTime.Now.ToString("hh:mm tt"), @DateTime.Today.ToString("MMMM dd, yyyy")</span></p>
</div>
</div>
<div class="d-flex justify-content-between align-items-center">
<h4>EUR @_transfer.Price <span class="small text-muted"> </span></h4>
</div>
</div>
<div class="card-footer p-4">
<div class="d-flex justify-content-between align-items-center">
<h5 class="fw-normal mb-0"><a href="#!" class="text-decoration-none">Contact driver</a></h5>
<div class="vr"></div>
<h5 class="fw-normal mb-0"><a href="#!" class="text-decoration-none">Cancel</a></h5>
<div class="vr"></div>
<DxButton RenderStyle="ButtonRenderStyle.Primary" Click="Pay">Pay</DxButton>
<div class="vr"></div>
<h5 class="fw-normal mb-0"><a class="btn btn-secondary" @onclick="SetEditMode">Modify</a></h5>
</div>
</div>
</div>
<div class="d-flex justify-content-between align-items-center">
<h4>EUR @transfer.Price <span class="small text-muted"> </span></h4>
</div>
</div>
<div class="card-footer p-4">
<div class="d-flex justify-content-between align-items-center">
<h5 class="fw-normal mb-0"><a href="#!" class="text-decoration-none">Contact driver</a></h5>
<div class="vr"></div>
<h5 class="fw-normal mb-0"><a href="#!" class="text-decoration-none">Cancel</a></h5>
<div class="vr"></div>
<DxButton RenderStyle="ButtonRenderStyle.Primary" Click="Pay">Pay</DxButton>
<div class="vr"></div>
<h5 class="fw-normal mb-0"><a class="btn btn-secondary" @onclick="SetEditMode">Modify</a></h5>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</section>
}
}
else
{
else
{
<section>
<div class="container py-1">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-10 col-lg-8 col-xl-6">
<DxFormLayout>
<div class="card card-admin card-stepper" style="border-radius: 16px;">
<div class="card-header py-2 px-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<span class="fw-bold text-body">Transfer identifier: @transfer.Id</span>
<p class="text-muted">
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field dxbl-col-12" Caption="Contact Phone">
<DxTextBox @bind-Text="transfer.ContactPhone" />
</DxFormLayoutItem>
</p>
<section>
<div class="container py-1">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-10 col-lg-8 col-xl-6">
<DxFormLayout>
<div class="card card-admin card-stepper" style="border-radius: 16px;">
<div class="card-header py-2 px-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<span class="fw-bold text-body">Transfer identifier: @_transfer.Id</span>
<p class="text-muted">
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field dxbl-col-12" Caption="Contact Phone">
<DxTextBox @bind-Text="_transfer.ContactPhone" />
</DxFormLayoutItem>
</p>
</div>
<div>
<h6 class="mb-0"> </h6>
</div>
</div>
</div>
<div>
<h6 class="mb-0"> </h6>
<div class="card-body p-4">
<div class="d-flex flex-row mb-4 pb-2">
<div class="flex-fill">
<DxFormLayoutItem ColSpanLg="6" CssClass="form-field" Caption="First Name">
<DxTextBox @bind-Text="_transfer.FirstName" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="6" CssClass="form-field" Caption="Last Name">
<DxTextBox @bind-Text="_transfer.LastName" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Contact Email">
<DxTextBox @bind-Text="_transfer.ContactEmail" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="From Address">
<DxTextBox @bind-Text="_transfer.FromAddress" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="To Address">
<DxTextBox @bind-Text="_transfer.ToAddress" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Appointment">
<DxDateEdit TimeSectionVisible="true" @bind-Date="_transfer.Appointment" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Passenger Count">
<DxSpinEdit @bind-Value="_transfer.PassengerCount" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Luggage Count">
<DxSpinEdit @bind-Value="_transfer.LuggageCount" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Flight Number">
<DxTextBox @bind-Text="_transfer.FlightNumber" />
</DxFormLayoutItem>
<hr />
<h4>License plate: POX-382</h4>
<p class="text-muted">Car looks: Silver, Toyota, Prius</p>
<hr />
<p class="text-muted">Status on: <span class="text-body">@DateTime.Now.TimeOfDay, @DateTime.Today.Date</span></p>
</div>
</div>
<!--ul id="progressbar-1" class="mx-0 mt-0 mb-5 px-0 pt-0 pb-4">
<li class="step0 active" id="step1">
<span style="margin-left: 22px; margin-top: 12px;">PLACED</span>
</li>
<li class="step0 active text-center" id="step2"><span>WAITING FOR PICK UP</span></li>
<li class="step0 text-muted text-end" id="step3">
<span style="margin-right: 22px;">ARRIVED</span>
</li>
</ul-->
<div class="d-flex flex-row mb-4 pb-2">
<h4> EUR @_transfer.Price <span class="small text-muted"> via (COD) </span></h4>
</div>
<div class="d-flex flex-row mb-4 pb-2">
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Comment">
<DxMemo @bind-Text="_transfer.Comment" />
</DxFormLayoutItem>
</div>
</div>
<div class="card-footer p-4">
<div class="d-flex justify-content-between">
<DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton>
</div>
</div>
</div>
</div>
<div class="card-body p-4">
<div class="d-flex flex-row mb-4 pb-2">
<div class="flex-fill">
<DxFormLayoutItem ColSpanLg="6" CssClass="form-field" Caption="First Name">
<DxTextBox @bind-Text="transfer.FirstName" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="6" CssClass="form-field" Caption="Last Name">
<DxTextBox @bind-Text="transfer.LastName" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Contact Email">
<DxTextBox @bind-Text="transfer.ContactEmail" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="From Address">
<DxTextBox @bind-Text="transfer.FromAddress" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="To Address">
<DxTextBox @bind-Text="transfer.ToAddress" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Appointment">
<DxDateEdit TimeSectionVisible="true" @bind-Date="transfer.Appointment" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Passenger Count">
<DxSpinEdit @bind-Value="transfer.PassengerCount" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Luggage Count">
<DxSpinEdit @bind-Value="transfer.LuggageCount" />
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Flight Number">
<DxTextBox @bind-Text="transfer.FlightNumber" />
</DxFormLayoutItem>
<hr />
<h4>License plate: POX-382</h4>
<p class="text-muted">Car looks: Silver, Toyota, Prius</p>
<hr />
<p class="text-muted">Status on: <span class="text-body">@DateTime.Now.TimeOfDay, @DateTime.Today.Date</span></p>
</div>
</div>
<!--ul id="progressbar-1" class="mx-0 mt-0 mb-5 px-0 pt-0 pb-4">
<li class="step0 active" id="step1">
<span style="margin-left: 22px; margin-top: 12px;">PLACED</span>
</li>
<li class="step0 active text-center" id="step2"><span>WAITING FOR PICK UP</span></li>
<li class="step0 text-muted text-end" id="step3">
<span style="margin-right: 22px;">ARRIVED</span>
</li>
</ul-->
<div class="d-flex flex-row mb-4 pb-2">
<h4> EUR @transfer.Price <span class="small text-muted"> via (COD) </span></h4>
</div>
<div class="d-flex flex-row mb-4 pb-2">
<DxFormLayoutItem ColSpanLg="12" CssClass="form-field" Caption="Comment">
<DxMemo @bind-Text="transfer.Comment" />
</DxFormLayoutItem>
</div>
</div>
<div class="card-footer p-4">
<div class="d-flex justify-content-between">
<DxButton Click="@((e) => UpdateTransferEventHandler(e, true))">Save Changes</DxButton>
</div>
</div>
</DxFormLayout>
</div>
</DxFormLayout>
</div>
</div>
</div>
</div>
</section>
}
</section>
}
</DxTabPage>
<DxTabPage Text="Messages">
<MessageDetailGridComponent ContextId="transferId" IsSenderEmailVisible="false" IsSubjectVisible="false"></MessageDetailGridComponent>
<DxButton Click="() => SendMail(transfer)" Text="Send a message" RenderStyle="ButtonRenderStyle.Primary" />
</DxTabPage>
</DxTabs>
</DxTabPage>
<DxTabPage Text="Messages">
<div style="margin-top: 10px; margin-bottom: 10px;">
<DxButton Click="() => SendMail(_transfer)" Text="Send a message" RenderStyle="ButtonRenderStyle.Primary" />
</div>
<MessageDetailGridComponent ContextId="transferId" IsSenderEmailVisible="false" IsMessageTextVisible="false"></MessageDetailGridComponent>
</DxTabPage>
</DxTabs>
</div>
}
@code {
[Parameter]
public Guid transferId { get; set; } = Guid.Empty;
[Parameter] public Guid transferId { get; set; } = Guid.Empty;
private Transfer transfer = new Transfer();
private bool isLoading = true;
private string errorMessage = string.Empty;
private LoggerClient<EditTransfers> _logger;
private Transfer _transfer = new Transfer();
private bool _isLoading = true;
private string _errorMessage = string.Empty;
private LoggerClient<EditTransfers> _logger = null!;
private MessageWizardModel _messageWizardModel = new();
private bool _popupVisible;
public List<string> IgnoreList =
[
"ReceiverEmailAddress",
@ -270,8 +271,8 @@ else
"ContextId",
];
List<string> StatusTypes = new List<string>();
private bool editMode = false;
private bool _editMode = false;
private readonly List<string> _statusTypes = [];
void SendMail(Transfer item)
{
@ -331,27 +332,28 @@ else
private async Task Pay()
{
if (transfer != null)
if (_transfer != null)
{
string paymentId = "";
if(transfer.PaymentId!=null)
var paymentId = "";
if (_transfer.PaymentId != null)
{
//if we have already
paymentId = transfer.PaymentId;
paymentId = _transfer.PaymentId;
}
else
{
//if we have no paymentId yet
paymentId = await SumUpService.CreatePaymentAsync(transfer);
transfer.PaymentId = paymentId;
paymentId = await SumUpService.CreatePaymentAsync(_transfer);
_transfer.PaymentId = paymentId;
//and save it to Db
var resultTransfer = await UpdateTransfer(false);
if (resultTransfer.PaymentId != null)
{
_logger.Debug("Added paymentId to Db: "+ resultTransfer.PaymentId);
_logger.Debug("Added paymentId to Db: " + resultTransfer.PaymentId);
}
}
string checkoutUrl = "sumuppayment/" + paymentId;
var checkoutUrl = "sumuppayment/" + paymentId;
Console.WriteLine($"Payment Link: {paymentId}");
navigationManager.NavigateTo(checkoutUrl);
}
@ -360,15 +362,15 @@ else
protected override async Task OnInitializedAsync()
{
foreach (var t in Enum.GetValues(typeof(TransferStatusType)).OfType<TransferStatusType>().ToList())
StatusTypes.Add(t.ToString());
_statusTypes.Add(t.ToString());
_logger = new LoggerClient<EditTransfers>(LogWriters.ToArray());
_logger.Info($"parameter: {transferId.ToString()}");
await LoadTransfer();
if(transfer.UserId.IsNullOrEmpty())
if (_transfer.UserId.IsNullOrEmpty())
{
await UserDataService.SetEmailConfirmed(transfer.UserId);
await UserDataService.SetEmailConfirmed(_transfer.UserId);
}
}
@ -380,7 +382,7 @@ else
private void SetEditMode()
{
editMode = true;
_editMode = true;
}
private async Task LoadTransfer()
@ -391,19 +393,20 @@ else
if (response != null)
{
transfer = response;
_transfer = response;
}
else
{
errorMessage = $"Error loading transfer: {transfer.Id}";
_errorMessage = $"Error loading transfer: {_transfer.Id}";
}
}
catch (Exception ex)
{
errorMessage = $"Exception: {ex.Message}";
_errorMessage = $"Exception: {ex.Message}";
}
isLoading = false;
_isLoading = false;
}
private async Task UpdateTransferEventHandler(MouseEventArgs e, bool shouldRedirect = false)
@ -413,25 +416,26 @@ else
navManager.NavigateTo("/mytransfers"); // Redirect to a list or another page after successful update
}
private async Task<Transfer> UpdateTransfer(bool shouldRedirect = false)
private async Task<Transfer?> UpdateTransfer(bool shouldRedirect = false)
{
try
{
var responseTransfer = await transferDataService.UpdateTransferAsync(transfer);
var responseTransfer = await transferDataService.UpdateTransferAsync(_transfer);
if (responseTransfer != null)
{
{
return responseTransfer;
}
else
{
errorMessage = $"Error updating transfer: {transfer.Id}";
_errorMessage = $"Error updating transfer: {_transfer.Id}";
return null;
}
}
catch (Exception ex)
{
errorMessage = $"Exception: {ex.Message}";
_errorMessage = $"Exception: {ex.Message}";
return null;
}
}
}

View File

@ -71,98 +71,105 @@
<div class="row">
<div class=" col-12">
<DxTabs>
<DxTabPage Text="Upcoming">
<DxAccordion ExpandMode="ExpandMode"
ExpandCollapseAction="ExpandCollapseAction"
AnimationType="LayoutAnimationType.Slide">
<Items>
@foreach (var (transfer, i) in Upcoming)
{
<DxAccordionItem CssClass="@GetCustomColor(transfer.TransferStatusType)" Text=@($"{transfer.Appointment} - {transfer.FromAddress}") Expanded=@(i == 0)>
<ContentTemplate>
<div class="py-3 px-3">
<TransferCardComponent DataChanged="RefreshComponent" Context="@transfer" />
</div>
</ContentTemplate>
</DxAccordionItem>
}
</Items>
</DxAccordion>
</DxTabPage>
<DxTabPage Text="Problems">
<DxAccordion ExpandMode="ExpandMode"
ExpandCollapseAction="ExpandCollapseAction"
AnimationType="LayoutAnimationType.Slide">
<Items>
@foreach (var (transfer, i) in Problems)
{
<DxAccordionItem CssClass="@GetCustomColor(transfer.TransferStatusType)" Text=@($"{transfer.Appointment} - {transfer.FromAddress}") Expanded=@(i == 0)>
<ContentTemplate>
<div class="py-3 px-3">
<TransferCardComponent DataChanged="RefreshComponent" Context="@transfer" />
</div>
</ContentTemplate>
</DxAccordionItem>
}
</Items>
</DxAccordion>
</DxTabPage>
<DxTabPage Text="Calendar">
<div class="d-flex flex-column mb-4 pb-2">
<DxScheduler @bind-StartDate="@StartDate"
DataStorage="@_dataStorage"
CssClass="w-100">
<DxSchedulerTimelineView Duration="@TimeSpan.FromHours(48)" CellMinWidth="80">
<Scales>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Day" UnitCount="1"></DxSchedulerTimeScale>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Hour" UnitCount="2"></DxSchedulerTimeScale>
</Scales>
</DxSchedulerTimelineView>
<DxSchedulerWeekView ShowWorkTimeOnly="false"></DxSchedulerWeekView>
<DxSchedulerDayView DayCount="1" ShowWorkTimeOnly="false"></DxSchedulerDayView>
</DxScheduler>
</div>
</DxTabPage>
<DxTabs>
<DxTabPage Text="Upcoming">
<DxAccordion ExpandMode="ExpandMode"
ExpandCollapseAction="ExpandCollapseAction"
AnimationType="LayoutAnimationType.Slide">
<Items>
@foreach (var (transfer, i) in Upcoming)
{
<DxTabPage Text="History">
<div class="d-flex flex-column mb-4 pb-2">
<TransferDetailGrid @ref="_gridTransfer"
Logger="_logger"
GetAllMessageTag="SignalRTags.GetTransfersByUserProductMappingId"
SignalRClient="AdminSignalRClient"
ContextIds="new object[] {driverId}"
CustomizeElement="Grid_CustomizeElement"
ShowGroupPanel="true"
CustomGroup="Grid_CustomGroup"
CustomizeGroupValueDisplayText="Grid_CustomizeGroupValueDisplayText"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
AllowSelectRowByClick="false"
PageSize="13"
ShowFilterRow="true">
<DxAccordionItem CssClass="@GetCustomColor(transfer.TransferStatusType)" Text=@($"{transfer.Appointment} - {transfer.FromAddress}") Expanded=@(i == 0)>
<ContentTemplate>
<div class="py-3 px-3">
<TransferCardComponent DataChanged="RefreshComponent" Context="@transfer" />
</div>
</ContentTemplate>
</DxAccordionItem>
}
</Items>
</DxAccordion>
</DxTabPage>
<DxTabPage Text="Problems">
<DxAccordion ExpandMode="ExpandMode"
ExpandCollapseAction="ExpandCollapseAction"
AnimationType="LayoutAnimationType.Slide">
<Items>
@foreach (var (transfer, i) in Problems)
{
<Columns>
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="Appointment" SortOrder="GridColumnSortOrder.Descending" GroupIndex="0" GroupInterval="GridColumnGroupInterval.Custom" DisplayFormat="g" Width="125" />
<DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70" />
<DxGridDataColumn FieldName="FromAddress" />
<DxGridDataColumn FieldName="ToAddress" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="125" Visible="false" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns>
</TransferDetailGrid>
</div>
</DxTabPage>
<DxAccordionItem CssClass="@GetCustomColor(transfer.TransferStatusType)" Text=@($"{transfer.Appointment} - {transfer.FromAddress}") Expanded=@(i == 0)>
<ContentTemplate>
<div class="py-3 px-3">
<TransferCardComponent DataChanged="RefreshComponent" Context="@transfer" />
</div>
</ContentTemplate>
</DxAccordionItem>
}
</Items>
</DxAccordion>
</DxTabPage>
<DxTabPage Text="Calendar">
<div class="d-flex flex-column mb-4 pb-2">
<DxScheduler @bind-StartDate="@StartDate"
DataStorage="@_dataStorage"
CssClass="w-100">
<DxSchedulerTimelineView Duration="@TimeSpan.FromHours(48)" CellMinWidth="80">
<Scales>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Day" UnitCount="1"></DxSchedulerTimeScale>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Hour" UnitCount="2"></DxSchedulerTimeScale>
</Scales>
</DxSchedulerTimelineView>
<DxSchedulerWeekView ShowWorkTimeOnly="false"></DxSchedulerWeekView>
<DxSchedulerDayView DayCount="1" ShowWorkTimeOnly="false"></DxSchedulerDayView>
</DxScheduler>
</div>
</DxTabPage>
<DxTabPage Text="History">
<div class="d-flex flex-column mb-4 pb-2">
<TransferDetailGrid @ref="_gridTransfer"
Logger="_logger"
GetAllMessageTag="SignalRTags.GetTransfersByUserProductMappingId"
SignalRClient="AdminSignalRClient"
ContextIds="new object[] {driverId}"
CustomizeElement="Grid_CustomizeElement"
ShowGroupPanel="true"
CustomGroup="Grid_CustomGroup"
CustomizeGroupValueDisplayText="Grid_CustomizeGroupValueDisplayText"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
AllowSelectRowByClick="false"
PageSize="13"
ShowFilterRow="true">
<Columns>
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="Appointment" SortOrder="GridColumnSortOrder.Descending" GroupIndex="0" GroupInterval="GridColumnGroupInterval.Custom" DisplayFormat="g" Width="125" />
<DxGridDataColumn FieldName="OrderId" Caption="Order" SortIndex="1" SortOrder="GridColumnSortOrder.Descending" Width="70" />
<DxGridDataColumn FieldName="FromAddress" />
<DxGridDataColumn FieldName="ToAddress" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="125" Visible="false" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns>
</TransferDetailGrid>
</div>
</DxTabPage>
<DxTabPage Text="Messages">
<div class="d-flex flex-column mb-4 pb-2">
@* TODO: Megírni az GetMessagesByDriverId() endpoint-ot! - J. *@
<MessageDetailGridComponent ContextId="driverId" GetAllMessageTag="SignalRTags.GetTransfersMessagesByDriverId" IsSenderEmailVisible="false" IsMessageTextVisible="false"></MessageDetailGridComponent>
</div>
</DxTabPage>
</DxTabs>
</DxTabs>
</div>
<div class=" col-12 col-xl-6">
@ -276,13 +283,13 @@
{
if (e.FieldName == "Appointment")
{
string displayText = ((DateTime)e.Value).Date.ToString();
string displayText = ((DateTime)e.Value).Date.ToString();
e.DisplayText = displayText;
}
}
private void RefreshComponent()
{
StateHasChanged();
@ -355,7 +362,7 @@
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
}
string GetCustomColor(TransferStatusType transferStatusType)
{

View File

@ -18,6 +18,7 @@
@using TIAM.Entities.Emails
@using AyCode.Blazor.Components.Services
@using AyCode.Core.Extensions
@using TIAM.Services
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient;
@ -25,22 +26,24 @@
<MessageDetailGrid @ref="_messageGrid"
Logger="_logger"
SignalRClient="AdminSignalRClient"
GetAllMessageTag="GetAllMessageTag"
ContextIds="@(ContextId.IsNullOrEmpty() ? throw new InvalidDataException($"ContextId.IsNullOrEmpty(); ContextId: {ContextId}") : [ContextId.Value])"
CustomizeElement="CustomizeElement">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" DeleteButtonVisible="AcDomain.IsDeveloperVersion" EditButtonVisible="AcDomain.IsDeveloperVersion" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridCommandColumn Width="135" MinWidth="135" Visible="AcDomain.IsDeveloperVersion" DeleteButtonVisible="AcDomain.IsDeveloperVersion" EditButtonVisible="AcDomain.IsDeveloperVersion" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="ContextId" Width="80px" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
<DxGridDataColumn FieldName="EmailAddress" Width="100px" Visible="@IsSenderEmailVisible" />
<DxGridDataColumn FieldName="Subject" Visible=@IsSubjectVisible />
<DxGridDataColumn FieldName="Text">
<DxGridDataColumn FieldName="Created" Caption="Received" DisplayFormat="g" Width="130" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="EmailAddress" Caption="Sender" Width="200px" Visible="@IsSenderEmailVisible" />
<DxGridDataColumn FieldName="Subject" />
<DxGridDataColumn FieldName="Text" Visible="@IsMessageTextVisible">
<CellDisplayTemplate Context="displayTextContext">
<text>@System.Text.RegularExpressions.Regex.Replace((displayTextContext.Value as string)!, "<(.|\n)*?>", string.Empty)</text>
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="IsReaded" Caption="Readed" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="130" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="IsReaded" Caption="Readed" Visible="@IsSenderEmailVisible" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns>
<DetailRowTemplate>
@{
@ -61,9 +64,10 @@
@code {
[Parameter] public Guid? ContextId { get; set; }
//[Parameter] public IEmailMessageRelation ParentData { get; set; } = null!;
[Parameter] public bool IsSubjectVisible { get; set; } = true;
[Parameter] public bool IsMessageTextVisible { get; set; } = true;
[Parameter] public bool IsSenderEmailVisible { get; set; } = true;
[Parameter] public int GetAllMessageTag { get; set; } = SignalRTags.GetMessagesByContextId;
private MessageGrid _messageGrid = null!;
private LoggerClient<MessageDetailGridComponent> _logger = null!;

View File

@ -73,6 +73,21 @@ namespace TIAMWebApp.Server.Controllers
}
}
/// <summary>
///
/// </summary>
/// <param name="driverId">UserPropductMappingId</param>
/// <returns></returns>
[NonAction]
[ApiExplorerSettings(IgnoreApi = true)]
[SignalR(SignalRTags.GetTransfersMessagesByDriverId)]
public async Task<List<EmailMessage>> GetTransfersMessagesByDriverId(Guid driverId)
{
_logger.Info($@"GetAllMessagesByDriverId called; driverId: {driverId}");
return await _adminDal.GetTransfersMessagesByDriverIdAsync(driverId);
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetMessagesByContextIdRouteName + "/{contextId}")]