This commit is contained in:
mmrbnjd
2024-06-24 17:33:26 +03:30
parent a1d265bf7f
commit 4631d8f159
4 changed files with 52 additions and 4 deletions

View File

@@ -0,0 +1,11 @@
@using Shared.DTOs
<h3>Notifications</h3>
<h3>@items.Count()</h3>
<Alert Color="AlertColor.Warning" Dismissable="true"> <strong>Holy guacamole!</strong> You should check in on some of those fields below. </Alert>
@code {
[Parameter] public List<AlertDTO> items { get; set; }
}

View File

@@ -7,6 +7,7 @@
@inject NavigationManager nav
@inject localService localserv;
@inject Fixedvalues fv;
<Modal @ref="modal" />
<HeadContent>
<link rel="canonical" href="#">
<!-- Favicon -->
@@ -165,6 +166,11 @@
</ul>
</li>
<!--/ User -->
<li class="nav-item lh-1 me-3 f-ir">
<Button Type="ButtonType.Button" @onclick="ShowNotifications" Color="ButtonColor.None">
<Badge Color="BadgeColor.Danger"><Icon Name="IconName.MegaphoneFill" /> @dashBoard?.Notifications.Count()</Badge>
</Button>
</li>
</ul>
</div>
</nav>
@@ -206,6 +212,7 @@
</div>
@code {
private Modal modal = default!;
public DashBoardDTO? dashBoard { get; set; }
protected override async Task OnInitializedAsync()
{
@@ -217,6 +224,15 @@
}
}
@functions {
public async Task ShowNotifications()
{
var parameters = new Dictionary<string, object>();
parameters.Add("items", dashBoard?.Notifications);
await modal.ShowAsync<Front.CUSComponent.Notifications>(title: "اطلاعیه ها", parameters: parameters);
}
private async Task Logout()
{
_hc.DefaultRequestHeaders.Clear();

View File

@@ -7,9 +7,12 @@
@layout PanelLayout
@inject HttpClientController hc;
@inject Fixedvalues fv;
<PageTitle>کاربری</PageTitle>
<Toasts class="p-3" Messages="messages" AutoHide="true" Delay="4000" Placement="ToastsPlacement.TopRight" />
<div class="row">
<div class="col-lg-6 mb-3 order-0">
<div class="card">
<div class="d-flex align-items-end row">
@@ -402,14 +405,21 @@
@code {
List<ToastMessage> messages = new List<ToastMessage>();
private Modal modal = default!;
private void ShowMessage(ToastType toastType, string Message) => messages.Add(CreateToastMessage(toastType, Message));
public DashBoardDTO? dashBoard { get; set; }
protected override async Task OnInitializedAsync()
{
if (!await localserv.OnlineUser())
nav.NavigateTo("/");
dashBoard = await fv.GetDashBoard();
if (dashBoard != null)
foreach (var war in dashBoard.Warning)
ShowMessage((ToastType)Enum.Parse(typeof(ToastType), war.Status.ToString()), war.Message);
//var rsp = await hc.Get("User/GetDashBoard");
// if (rsp.IsSuccessStatusCode)
// {
@@ -418,3 +428,12 @@
await base.OnInitializedAsync();
}
}
@functions {
private ToastMessage CreateToastMessage(ToastType toastType, string Message)
=> new ToastMessage
{
Type = toastType,
Message = Message,
};
}