| | 1 | | @using Syki.Front.Features.Academic.CreateNotification |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Academic |
| | 4 | |
|
| | 5 | | @page "/academic/notifications" |
| | 6 | | @attribute [Authorize(Roles = "Academic")] |
| | 7 | |
|
| | 8 | | <SykiPageTitle Title="Notificações" /> |
| | 9 | |
|
| | 10 | | <MudContainer Class="my-4 px-4"> |
| | 11 | | <SykiPageHeader Icon="@Icons.Material.Filled.Notifications" Title="Notificações" ButtonText="Nova Notificação" OnCli |
| | 12 | | <SykiPageAlert Text="Aqui você pode escolher quais usuários serão notificados e acompanhar o status de visualização |
| | 13 | | <MudContainer Class="px-0 mb-4"> |
| | 14 | | <MudDataGrid |
| | 15 | | T="NotificationOut" |
| | 16 | | Class="pa-4" |
| | 17 | | Items="@_notifications" |
| | 18 | | QuickFilter="@_quickFilter" |
| | 19 | | Dense="true" |
| | 20 | | Hover="true" |
| | 21 | | ReadOnly="true" |
| | 22 | | Loading="@_loading" |
| | 23 | | RowsPerPage="10" |
| | 24 | | FooterClass="d-flex" |
| | 25 | | > |
| | 26 | | <ToolBarContent> |
| | 27 | | <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por título ou descrição" / |
| | 28 | | </ToolBarContent> |
| | 29 | | <Columns> |
| | 30 | | <PropertyColumn Property="x => x.Title" Title="Título" /> |
| | 31 | | <PropertyColumn Property="x => x.Description" Title="Descrição" /> |
| | 32 | | <PropertyColumn Property="x => x.CreatedAt.ToLocalTime().Format()" Title="Criada em" /> |
| | 33 | | <PropertyColumn Property="x => x.Target.GetDescription()" Title="Audiência" /> |
| | 34 | | <PropertyColumn Property="x => x.Views" Title="Visualizações" /> |
| | 35 | | </Columns> |
| | 36 | | <NoRecordsContent> |
| | 37 | | @(GetNotFoundMessage()) |
| | 38 | | </NoRecordsContent> |
| | 39 | | <PagerContent> |
| | 40 | | <SykiDataGridPager T="NotificationOut"/> |
| | 41 | | </PagerContent> |
| | 42 | | </MudDataGrid> |
| | 43 | | </MudContainer> |
| | 44 | | </MudContainer> |
| | 45 | |
|
| | 46 | | @inject IDialogService DialogService |
| | 47 | | @inject GetNotificationsClient GetNotificationsClient |
| | 48 | | @inject IBrowserViewportService BrowserViewportService |
| | 49 | |
|
| | 50 | | @code |
| | 51 | | { |
| | 52 | | private bool _loading; |
| | 53 | | private string _searchString; |
| 0 | 54 | | private List<NotificationOut> _notifications = []; |
| | 55 | |
|
| | 56 | | protected override async Task OnInitializedAsync() |
| | 57 | | { |
| 0 | 58 | | _loading = true; |
| 0 | 59 | | _notifications = await GetNotificationsClient.Get(); |
| 0 | 60 | | _loading = false; |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | private async Task OpenDialog() |
| | 64 | | { |
| 0 | 65 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| 0 | 66 | | var options = new DialogOptions { |
| 0 | 67 | | MaxWidth = MaxWidth.Small, |
| 0 | 68 | | FullWidth = true, |
| 0 | 69 | | FullScreen = breakpoint == Breakpoint.Xs, |
| 0 | 70 | | }; |
| 0 | 71 | | var dialog = await DialogService.ShowAsync<CreateNotificationDialog>("", options); |
| | 72 | |
|
| 0 | 73 | | var result = await dialog.Result; |
| | 74 | |
|
| 0 | 75 | | if (result!.Canceled) return; |
| | 76 | |
|
| 0 | 77 | | await OnInitializedAsync(); |
| 0 | 78 | | } |
| | 79 | |
|
| 0 | 80 | | private Func<NotificationOut, bool> _quickFilter => x => _searchString.IsIn(x.Title, x.Description); |
| | 81 | |
|
| | 82 | | private string GetNotFoundMessage() |
| | 83 | | { |
| 0 | 84 | | return (_searchString.IsEmpty()) ? "Não existem notificações cadastradas ainda." : "Nenhuma notificação encontra |
| | 85 | | } |
| | 86 | | } |