| | 1 | | @using Syki.Front.Features.Academic.CreateWebhookSubscription |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Pages.Academic |
| | 4 | |
|
| | 5 | | @page "/academic/webhooks" |
| | 6 | | @attribute [Authorize(Roles = "Academic")] |
| | 7 | |
|
| | 8 | | <SykiPageTitle Title="Webhooks" /> |
| | 9 | |
|
| | 10 | | <MudContainer Class="my-4 px-4"> |
| | 11 | | <SykiPageHeader Icon="@Icons.Material.Filled.Webhook" Title="Webhooks" ButtonText="Novo Webhook" OnClick="@OpenDrawe |
| | 12 | | <SykiPageAlert Text="Configure webhooks para receber notificações quando determinados eventos acontecerem no sistema |
| | 13 | | <MudContainer Class="px-0 mb-4"> |
| | 14 | | <MudDataGrid |
| | 15 | | T="GetWebhooksOut" |
| | 16 | | Class="pa-4" |
| | 17 | | Items="@_webhooks" |
| | 18 | | Dense="true" |
| | 19 | | Hover="true" |
| | 20 | | ReadOnly="true" |
| | 21 | | Loading="@_loading" |
| | 22 | | RowsPerPage="10" |
| | 23 | | FooterClass="d-flex" |
| | 24 | | > |
| | 25 | | <Columns> |
| | 26 | | <PropertyColumn Property="x => x.Name" Title="Nome" /> |
| | 27 | | <PropertyColumn Property="x => x.Url" Title="Url" /> |
| | 28 | | <PropertyColumn Property="x => x.CallsCount.ToThousandSeparated()" Title="Chamadas" /> |
| | 29 | | <PropertyColumn Property="x => x.CreatedAt.ToLocalTime().Format()" Title="Criado em" /> |
| | 30 | |
|
| | 31 | | <TemplateColumn> |
| | 32 | | <CellTemplate> |
| | 33 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" Href="@($"/academic |
| | 34 | | </CellTemplate> |
| | 35 | | </TemplateColumn> |
| | 36 | | </Columns> |
| | 37 | | <NoRecordsContent> |
| 0 | 38 | | @(GetNotFoundMessage()) |
| | 39 | | </NoRecordsContent> |
| | 40 | | <PagerContent> |
| | 41 | | <SykiDataGridPager T="GetWebhooksOut"/> |
| | 42 | | </PagerContent> |
| | 43 | | </MudDataGrid> |
| | 44 | | </MudContainer> |
| | 45 | | </MudContainer> |
| | 46 | |
|
| 0 | 47 | | <CreateWebhookSubscriptionDrawer @ref="@_drawer" AfterSubmit="@LoadData" /> |
| 0 | 48 | |
|
| 0 | 49 | | @inject NavigationManager Nav |
| 0 | 50 | | @inject IDialogService DialogService |
| 0 | 51 | | @inject GetWebhooksClient GetWebhooksClient |
| 0 | 52 | |
|
| | 53 | | @code |
| | 54 | | { |
| | 55 | | private bool _loading; |
| | 56 | | private string _searchString; |
| 0 | 57 | | private List<GetWebhooksOut> _webhooks = []; |
| | 58 | | private CreateWebhookSubscriptionDrawer _drawer = default!; |
| | 59 | |
|
| | 60 | | protected override async Task OnInitializedAsync() |
| | 61 | | { |
| 0 | 62 | | await LoadData(); |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | private async Task LoadData() |
| | 66 | | { |
| 0 | 67 | | _loading = true; |
| 0 | 68 | | _webhooks = await GetWebhooksClient.Get(); |
| 0 | 69 | | _loading = false; |
| 0 | 70 | | } |
| | 71 | |
|
| | 72 | | private async Task OpenDrawer() |
| | 73 | | { |
| 0 | 74 | | await _drawer.Open(); |
| 0 | 75 | | } |
| | 76 | |
|
| | 77 | | private string GetNotFoundMessage() |
| | 78 | | { |
| 0 | 79 | | return (_searchString.IsEmpty()) ? "Não existem webhooks cadastrados ainda." : "Nenhum webhook encontrado."; |
| | 80 | | } |
| | 81 | | } |