| | 1 | | @inject Services.UserNotificationService userNotificationService |
| | 2 | | @inject Services.UserService userService |
| | 3 | |
|
| | 4 | | <AuthorizeView> |
| | 5 | | <Authorized> |
| | 6 | | <div class="navbar-item dropdown"> |
| 0 | 7 | | <a class="navbar-link dropdown-toggle icon @((ShowNotifications) ? "show" : null)" @onclick="() => ToggleNot |
| | 8 | | <i class="oi oi-bell"></i> |
| 0 | 9 | | @if (unreadNotificationsCount > 0) |
| 0 | 10 | | { |
| 0 | 11 | | <span class="badge">@unreadNotificationsCount</span> |
| 0 | 12 | | } |
| | 13 | |
|
| | 14 | | </a> |
| | 15 | | <div class="dropdown-menu media-list dropdown-menu-end @((ShowNotifications) ? "show" : null)" |
| | 16 | | style="@((ShowNotifications) ? NotificationStyle : null)"> |
| 0 | 17 | | <div class="dropdown-header">Benachrichtigungen (@totalNotificationsCount)</div> |
| | 18 | |
|
| | 19 | |
|
| 0 | 20 | | @if (notifications.Count > 0) |
| 0 | 21 | | { |
| | 22 | |
|
| 0 | 23 | | @foreach (var notification in notifications) |
| 0 | 24 | | { |
| | 25 | | <a href="javascript:;" class="dropdown-item media"> |
| | 26 | | <div class="media-left"> |
| | 27 | | <i class="oi oi-bug media-object bg-gray-500"></i> |
| | 28 | | </div> |
| | 29 | | <div class="media-body"> |
| 0 | 30 | | <h6 class="media-heading">@notification.Title</h6> |
| 0 | 31 | | <p>@notification.Text</p> |
| 0 | 32 | | <div class="text-muted fs-10px">@notification.Timestamp.ToString("dd.MM.yyyy HH:mm")</di |
| | 33 | | </div> |
| | 34 | | </a> |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | <div class="dropdown-footer text-center"> |
| | 38 | | <a href="javascript:;" class="text-decoration-none">Mehr anzeigen</a> |
| | 39 | | </div> |
| 0 | 40 | | } |
| | 41 | | else |
| 0 | 42 | | { |
| | 43 | | <div class="dropdown-footer text-center"> |
| | 44 | | <p>Es liegen keine Benachrichtigungen vor.</p> |
| | 45 | | </div> |
| 0 | 46 | | } |
| | 47 | |
|
| | 48 | | </div> |
| | 49 | | </div> |
| | 50 | |
|
| | 51 | |
|
| | 52 | |
|
| 0 | 53 | | <div class="navbar-item navbar-user dropdown" @onclick="() => ToggleUserMenu()"> |
| | 54 | | <a class="navbar-link dropdown-toggle d-flex @((ShowUserSubMenu) ? "show" : null)" |
| | 55 | | style="cursor: pointer;"> |
| 0 | 56 | | <span class="d-none d-md-inline">@userDisplayName</span> |
| | 57 | | <img src="https://www.profielactueel.nl/content/modules/catalog/1/3800/3759/10_xx_2_1.png" alt=""> |
| | 58 | | </a> |
| | 59 | | <div class="dropdown-menu dropdown-menu-end me-1 @((ShowUserSubMenu) ? "show" : null)" style="@((ShowUserSub |
| | 60 | | <a href="@($"/profile/{userName}")" class="dropdown-item">Mein Profil</a> |
| | 61 | |
|
| | 62 | | <a href="/myinbox" class="dropdown-item"><span class="badge bg-danger float-end rounded-pill">2</span> P |
| | 63 | | <a href="/myOrganizations" class="dropdown-item">Meine Organisationen</a> |
| | 64 | | <a href="/myconferences" class="dropdown-item">Meine Konferenzen</a> |
| | 65 | | <a href="/myresolutions" class="dropdown-item">Meine Resolutionen</a> |
| | 66 | | <a href="/myapplications" class="dropdown-item">Meine Bewerbungen</a> |
| 0 | 67 | | @if (context.User.IsInRole("Head-Admin") || context.User.IsInRole("Admin")) |
| 0 | 68 | | { |
| | 69 | | <div class="dropdown-divider"></div> |
| | 70 | | <a href="/admin/dashboard" class="dropdown-item text-danger">Admin Center</a> |
| 0 | 71 | | } |
| | 72 | | <div class="dropdown-divider"></div> |
| | 73 | | <a href="/Identity/Account/LogOut" class="dropdown-item">Log Out</a> |
| | 74 | | </div> |
| | 75 | | </div> |
| | 76 | | </Authorized> |
| | 77 | | </AuthorizeView> |
| | 78 | |
|
| | 79 | |
|
| | 80 | | @code { |
| 0 | 81 | | [CascadingParameter] public Task<AuthenticationState> AuthStateTask { get; set; } |
| | 82 | |
|
| 0 | 83 | | public bool ShowUserSubMenu { get; set; } |
| | 84 | |
|
| 0 | 85 | | private string SubMenuStyle = "position: absolute; inset: 0px auto auto 0px; margin: 0px; transform: translate(-20px |
| | 86 | |
|
| 0 | 87 | | public bool ShowNotifications { get; set; } |
| | 88 | |
|
| 0 | 89 | | private string NotificationStyle = "position: absolute; inset: 0px auto auto 0px; margin: 0px; transform: translate( |
| | 90 | |
|
| | 91 | | private List<MUNity.Schema.UserNotification.UserNotificationItem> notifications; |
| | 92 | |
|
| | 93 | | private int unreadNotificationsCount; |
| | 94 | |
|
| | 95 | | private int totalNotificationsCount; |
| | 96 | |
|
| | 97 | | private string userDisplayName; |
| | 98 | |
|
| | 99 | | private string userName; |
| | 100 | |
|
| | 101 | | private void ToggleUserMenu() |
| 0 | 102 | | { |
| 0 | 103 | | this.ShowNotifications = false; |
| 0 | 104 | | this.ShowUserSubMenu = !ShowUserSubMenu; |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | private void ToggleNotifications() |
| 0 | 108 | | { |
| 0 | 109 | | this.ShowUserSubMenu = false; |
| 0 | 110 | | this.ShowNotifications = !ShowNotifications; |
| 0 | 111 | | } |
| | 112 | |
|
| | 113 | | protected override async Task OnInitializedAsync() |
| 0 | 114 | | { |
| 0 | 115 | | await base.OnInitializedAsync(); |
| 0 | 116 | | var claim = (await AuthStateTask)?.User; |
| 0 | 117 | | if (claim != null) |
| 0 | 118 | | { |
| 0 | 119 | | this.userName = claim.Identity.Name; |
| 0 | 120 | | notifications = await userNotificationService.GetLastFiveIntrestingNotifications(claim); |
| 0 | 121 | | unreadNotificationsCount = await userNotificationService.GetCountOfUnreadNotifications(claim); |
| 0 | 122 | | totalNotificationsCount = await userNotificationService.GetTotalCountOfNotifications(claim); |
| 0 | 123 | | var userForeAndLastName = await userService.GetForeAndLastNameAsync(claim); |
| 0 | 124 | | if (string.IsNullOrEmpty(userForeAndLastName) || userForeAndLastName == "-") |
| 0 | 125 | | userDisplayName = claim.Identity?.Name ?? "-"; |
| | 126 | | else |
| | 127 | |
|
| 0 | 128 | | userDisplayName = userForeAndLastName; |
| | 129 | |
|
| 0 | 130 | | } |
| 0 | 131 | | } |
| | 132 | |
|
| | 133 | | } |