notification
This commit is contained in:
parent
34a58f76ce
commit
2a8b267934
|
|
@ -10,7 +10,7 @@ public static class FruitBankConstClient
|
|||
public static string BaseUrl = "https://localhost:59579"; //FrutiBank nop
|
||||
|
||||
#if RELEASE
|
||||
//public static string BaseUrl = "https://shop.fruitbank.hu"; //FrutiBank nop
|
||||
// public static string BaseUrl = "https://shop.fruitbank.hu"; //FrutiBank nop
|
||||
#endif
|
||||
|
||||
//public static string BaseUrl = "http://10.0.2.2:59579"; //FrutiBank (android) nop
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
<style>
|
||||
.order-notification-toast {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.order-notification-toast .message {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.order-notification-toast .order-info {
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.order-notification-toast .label {
|
||||
color: #666;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.order-notification-toast .order-number {
|
||||
font-weight: bold;
|
||||
color: #0066cc;
|
||||
}
|
||||
|
||||
.order-notification-toast .date {
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="order-notification-toast">
|
||||
<div class="message">@Message</div>
|
||||
@if (!string.IsNullOrEmpty(OrderNumber))
|
||||
{
|
||||
<div class="order-info">
|
||||
<span class="label">Rendelés:</span>
|
||||
<span class="order-number">#@OrderNumber</span>
|
||||
</div>
|
||||
}
|
||||
@if (DateOfReceipt.HasValue)
|
||||
{
|
||||
<div class="order-info">
|
||||
<span class="label">Átvétel:</span>
|
||||
<span class="date">@DateOfReceipt.Value.ToString("yyyy-MM-dd HH:mm")</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public string Message { get; set; } = string.Empty;
|
||||
[Parameter] public string? OrderNumber { get; set; }
|
||||
[Parameter] public DateTime? DateOfReceipt { get; set; }
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
<div class="sidebar">
|
||||
<NavMenu @ref="_navMenu" />
|
||||
</div>
|
||||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
@if (LoggedInModel.IsLoggedIn)
|
||||
|
|
@ -13,13 +12,11 @@
|
|||
<div style="float: left; text-align: left;" class="col-md-8">
|
||||
<b>@($"{LoggedInModel.CustomerDto!.FullName} [{string.Join(", ", LoggedInModel.CustomerRoles.Where(x => x.SystemName.Contains("Measuring")).Select(x => x.Name))}]")</b>
|
||||
</div>
|
||||
|
||||
<div style="float: right; text-align: right;" class="col-md-4">
|
||||
<DxButton Text="Kijelentkezés" Click="OnLogoutClick" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
<DxToastProvider Name="Positioning"
|
||||
MaxToastCount="199"
|
||||
|
|
@ -31,7 +28,6 @@
|
|||
RenderStyle="ToastRenderStyle.Info"
|
||||
ShowCloseButton="true">
|
||||
</DxToastProvider>
|
||||
|
||||
<CascadingValue Value="RefreshMainLayoutEventCallback">
|
||||
@Body
|
||||
</CascadingValue>
|
||||
|
|
@ -39,6 +35,29 @@
|
|||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Custom Toast for Order Notifications -->
|
||||
<DxToast @ref="orderNotificationToast"
|
||||
Title="@toastTitle"
|
||||
ProviderName="Positioning">
|
||||
<div class="order-notification-toast">
|
||||
<div class="message">@toastMessage</div>
|
||||
@if (!string.IsNullOrEmpty(toastOrderNumber))
|
||||
{
|
||||
<div class="order-info">
|
||||
<span class="label">Rendelés:</span>
|
||||
<span class="order-number">#@toastOrderNumber</span>
|
||||
</div>
|
||||
}
|
||||
@if (toastDateOfReceipt.HasValue)
|
||||
{
|
||||
<div class="order-info">
|
||||
<span class="label">Átvétel:</span>
|
||||
<span class="date">@toastDateOfReceipt.Value.ToString("yyyy-MM-dd HH:mm")</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</DxToast>
|
||||
|
||||
<div id="blazor-error-ui" data-nosnippet>
|
||||
An unhandled error has occurred.
|
||||
<a href="." class="reload">Reload</a>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace FruitBankHybrid.Shared.Layout;
|
|||
public partial class MainLayout : LayoutComponentBase
|
||||
{
|
||||
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
|
||||
[Inject] public required NavigationManager NavManager{ get; set; }
|
||||
[Inject] public required NavigationManager NavManager { get; set; }
|
||||
[Inject] public required LoggedInModel LoggedInModel { get; set; }
|
||||
[Inject] IToastNotificationService ToastService { get; set; }
|
||||
[Inject] public required FruitBankSignalRClient FruitBankSignalRClient { get; set; }
|
||||
|
|
@ -28,14 +28,19 @@ public partial class MainLayout : LayoutComponentBase
|
|||
private NavMenu _navMenu = null!;
|
||||
private LoggerClient _logger = null!;
|
||||
|
||||
// Toast fields
|
||||
private DxToast orderNotificationToast;
|
||||
private string toastTitle = "Értesítő!";
|
||||
private string toastMessage = "";
|
||||
private string? toastOrderNumber;
|
||||
private DateTime? toastDateOfReceipt;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<MainLayout>(LogWriters.ToArray());
|
||||
_logger.Info("OnInitializedAsync");
|
||||
|
||||
var loginUri = NavManager.ToAbsoluteUri("/Login").ToString();
|
||||
|
||||
FruitBankSignalRClient.OnMessageReceived += SignalRClientOnMessageReceived;
|
||||
FruitBankSignalRClient.OnMessageReceived += SignalRClientOnMessageReceived;
|
||||
|
||||
if (!LoggedInModel.IsLoggedIn && NavManager.Uri != loginUri)
|
||||
{
|
||||
|
|
@ -57,35 +62,30 @@ public partial class MainLayout : LayoutComponentBase
|
|||
var orderDto = notificationMessage.Content;
|
||||
if ((orderDto?.HasMeasuringAccess(LoggedInModel.CustomerDto!.Id, LoggedInModel.IsRevisor) ?? LoggedInModel.IsRevisor) || orderDto?.MeasurementOwnerId == 0)
|
||||
{
|
||||
var messageText = $"{notificationMessage.Message}";
|
||||
if (orderDto != null)
|
||||
{
|
||||
messageText += $" Rendelés: #{orderDto.CustomOrderNumber}. Átvétel: {orderDto.DateOfReceipt}";
|
||||
}
|
||||
toastMessage = notificationMessage.Message;
|
||||
toastOrderNumber = orderDto?.CustomOrderNumber;
|
||||
toastDateOfReceipt = orderDto?.DateOfReceipt;
|
||||
|
||||
_logger.Debug($"NotificationMessage received. {messageText}");
|
||||
_logger.Debug($"NotificationMessage received. {toastMessage}");
|
||||
|
||||
ToastService.ShowToast(new ToastOptions
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
ProviderName = "Positioning",
|
||||
Title = "Értesítő!",
|
||||
Text = messageText,
|
||||
orderNotificationToast?.Show();
|
||||
StateHasChanged();
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnLogoutClick()
|
||||
{
|
||||
LoggedInModel.LogOut();
|
||||
|
||||
RefreshMainLayout();
|
||||
NavManager.NavigateTo("/Login");
|
||||
}
|
||||
|
||||
|
||||
public void RefreshMainLayout()
|
||||
{
|
||||
_navMenu.RefreshNavMenu();
|
||||
|
|
|
|||
|
|
@ -103,4 +103,35 @@ h1:focus {
|
|||
/*.alt-item {
|
||||
--dxbl-grid-row-bg: var(--DS-color-surface-neutral-subdued-rest);
|
||||
}*/
|
||||
/*endregion: DSGrids*/
|
||||
/*endregion: DSGrids*/
|
||||
|
||||
|
||||
|
||||
.order-notification-toast {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.order-notification-toast .message {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.order-notification-toast .order-info {
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.order-notification-toast .label {
|
||||
color: #666;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.order-notification-toast .order-number {
|
||||
font-weight: bold;
|
||||
color: #0066cc;
|
||||
}
|
||||
|
||||
.order-notification-toast .date {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ Global
|
|||
{85ADEDE3-C271-47DF-B273-2EDB32792CEF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{85ADEDE3-C271-47DF-B273-2EDB32792CEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85ADEDE3-C271-47DF-B273-2EDB32792CEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{85ADEDE3-C271-47DF-B273-2EDB32792CEF}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{899988C3-8F36-4B19-A1DE-1D1D85F114D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{899988C3-8F36-4B19-A1DE-1D1D85F114D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{899988C3-8F36-4B19-A1DE-1D1D85F114D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
|
|||
Loading…
Reference in New Issue