| | 1 | | @using Newtonsoft.Json |
| | 2 | | @using Newtonsoft.Json.Linq |
| | 3 | | @using Syki.Front.Features.Adm.GetCommandsSummary |
| | 4 | |
|
| | 5 | | @namespace Syki.Front.Pages.Adm |
| | 6 | |
|
| | 7 | | @page "/adm/batches/{id:guid}" |
| | 8 | | @attribute [Authorize(Roles = "Adm")] |
| | 9 | |
|
| | 10 | | <SykiPageTitle Title="Lotes" /> |
| | 11 | |
|
| | 12 | | <MudContainer Class="my-4 px-4"> |
| | 13 | | <MudCard> |
| | 14 | | <MudCardContent> |
| | 15 | | <MudGrid> |
| | 16 | | <MudItem xs="12" sm="8" md="8" lg="8"> |
| | 17 | | <MudStack Row="true" AlignItems="AlignItems.Center"> |
| | 18 | | <MudIcon Icon="@Icons.Material.Filled.BorderOuter" Class="mb-1" Size="Size.Large"/> |
| 0 | 19 | | <MudText Typo="Typo.h5" Class="mt-1" Style="font-weight: bold">@($"Lote - {_data.Type.GetDescrip |
| | 20 | | </MudStack> |
| | 21 | | </MudItem> |
| | 22 | | <MudItem xs="12" sm="4" md="4" lg="4" Class="d-flex justify-end"> |
| | 23 | | <MudChip |
| | 24 | | T="string" |
| | 25 | | Class="px-5 ma-0" |
| | 26 | | Size="Size.Large" |
| | 27 | | Icon="@_data.Status.GetIcon()" |
| | 28 | | Color="@_data.Status.GetColor()" |
| | 29 | | IconColor="Color.Default" |
| | 30 | | > |
| 0 | 31 | | @_data.Status.GetDescription() |
| | 32 | | </MudChip> |
| | 33 | | </MudItem> |
| | 34 | | </MudGrid> |
| | 35 | | </MudCardContent> |
| | 36 | | </MudCard> |
| | 37 | |
|
| | 38 | | <MudContainer Class="px-0 my-4"> |
| | 39 | | <MudGrid Spacing="2"> |
| | 40 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | 41 | | <InfoCard Icon="@Icons.Material.Filled.AccessTime" Color="@Colors.BlueGray.Lighten4" Title="Criação" Con |
| | 42 | | </MudItem> |
| | 43 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | 44 | | <InfoCard Icon="@Icons.Material.Filled.AccessTimeFilled" Color="@GetProcessedAtIconColor()" Title="Proce |
| | 45 | | </MudItem> |
| | 46 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | 47 | | <InfoCard Icon="@Icons.Material.Filled.Timer" Color="@Colors.Indigo.Darken1" Title="Comandos" Content="@ |
| | 48 | | </MudItem> |
| 0 | 49 | | @if (_data.EventId != null) |
| | 50 | | { |
| | 51 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | 52 | | <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem"> |
| 0 | 53 | | <MudLink OnClick="@(() => GoToEvent(_data.EventId.Value))" Color="Color.Primary">Este lote foi o |
| | 54 | | </InfoCard> |
| | 55 | | </MudItem> |
| | 56 | | } |
| 0 | 57 | | @if (_data.SourceCommandId != null) |
| | 58 | | { |
| | 59 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | 60 | | <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem"> |
| 0 | 61 | | <MudLink OnClick="@(() => GoToCommand(_data.SourceCommandId.Value))" Color="Color.Primary">Este |
| | 62 | | </InfoCard> |
| | 63 | | </MudItem> |
| | 64 | | } |
| 0 | 65 | | @if (_data.NextCommandId != null) |
| | 66 | | { |
| | 67 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | 68 | | <InfoCard Icon="@Icons.Material.Filled.NextPlan" Color="@Colors.Teal.Darken1" Title="Próximo comando |
| 0 | 69 | | <MudLink OnClick="@(() => GoToDetails(_data.NextCommandId.Value))" Color="Color.Primary">Este lo |
| | 70 | | </InfoCard> |
| | 71 | | </MudItem> |
| | 72 | | } |
| | 73 | | </MudGrid> |
| | 74 | | </MudContainer> |
| | 75 | |
|
| 0 | 76 | | @if (_data.Commands.Count > 0) |
| | 77 | | { |
| | 78 | | <style> |
| | 79 | | .mud-table-toolbar { |
| | 80 | | height: auto; |
| | 81 | | } |
| | 82 | | </style> |
| | 83 | | <MudContainer Class="px-0 my-4"> |
| | 84 | | <MudTable |
| | 85 | | Class="mb-4" |
| | 86 | | Dense="true" |
| | 87 | | Hover="true" |
| | 88 | | T="CommandOut" |
| | 89 | | RowsPerPage="10" |
| | 90 | | Loading="@_loading" |
| | 91 | | Items="@_data.Commands" |
| | 92 | | Breakpoint="Breakpoint.Sm" |
| | 93 | | > |
| | 94 | | <ToolBarContent> |
| | 95 | | <MudStack Row="true" AlignItems="AlignItems.Center" Class="mt-2"> |
| | 96 | | <MudIcon Icon="@Icons.Material.Filled.SubdirectoryArrowRight" Class="mb-1" Size="Size.Medium"/> |
| | 97 | | <MudText Typo="Typo.h6" Style="font-weight: bold">Comandos</MudText> |
| | 98 | | </MudStack> |
| | 99 | | </ToolBarContent> |
| | 100 | |
|
| | 101 | | <HeaderContent> |
| | 102 | | <MudTh>Tipo</MudTh> |
| | 103 | | <MudTh>Criação</MudTh> |
| | 104 | | <MudTh>Processamento</MudTh> |
| | 105 | | <MudTh>Duração (ms)</MudTh> |
| | 106 | | <MudTh></MudTh> |
| | 107 | | </HeaderContent> |
| | 108 | | <RowTemplate> |
| | 109 | | <MudTd DataLabel="Tipo"> |
| | 110 | | <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1"> |
| | 111 | | <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Smal |
| 0 | 112 | | <MudText Typo="Typo.body2">@context.Description</MudText> |
| | 113 | | </MudStack> |
| | 114 | | </MudTd> |
| 0 | 115 | | <MudTd DataLabel="Criação">@context.CreatedAt.ToMinuteString()</MudTd> |
| 0 | 116 | | <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd> |
| 0 | 117 | | <MudTd DataLabel="Duração (ms)">@context.Duration.ToThousandSeparated()</MudTd> |
| | 118 | | <MudTd> |
| 0 | 119 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => Go |
| | 120 | | </MudTd> |
| | 121 | | </RowTemplate> |
| | 122 | | <NoRecordsContent> |
| 0 | 123 | | @(GetSubcommandsNotFoundMessage()) |
| | 124 | | </NoRecordsContent> |
| | 125 | | </MudTable> |
| | 126 | | </MudContainer> |
| | 127 | | } |
| | 128 | | </MudContainer> |
| | 129 | |
|
| | 130 | | @inject NavigationManager Nav |
| | 131 | | @inject GetBatchClient GetBatchClient |
| | 132 | | @inject ReprocessCommandClient ReprocessCommandClient |
| | 133 | |
|
| | 134 | | @code |
| | 135 | | { |
| | 136 | | [Parameter] |
| 0 | 137 | | public Guid Id { get; set; } |
| | 138 | |
|
| | 139 | | private bool _loading; |
| 0 | 140 | | private BatchOut _data = new(); |
| | 141 | |
|
| | 142 | | private string GetProcessedAtIconColor() |
| | 143 | | { |
| 0 | 144 | | return _data.ProcessedAt == null ? Colors.BlueGray.Lighten4 : Colors.Green.Darken1; |
| | 145 | | } |
| | 146 | |
|
| | 147 | | protected override async Task OnInitializedAsync() |
| | 148 | | { |
| 0 | 149 | | _loading = true; |
| 0 | 150 | | _data = await GetBatchClient.Get(Id); |
| 0 | 151 | | _loading = false; |
| 0 | 152 | | } |
| | 153 | |
|
| | 154 | | private string GetSubcommandsNotFoundMessage() |
| | 155 | | { |
| 0 | 156 | | return "Este lote não possui comandos."; |
| | 157 | | } |
| | 158 | |
|
| | 159 | | private void GoToDetails(Guid id) |
| | 160 | | { |
| 0 | 161 | | Nav.NavigateTo($"adm/commands/{id}"); |
| 0 | 162 | | } |
| | 163 | |
|
| | 164 | | private void GoToEvent(Guid id) |
| | 165 | | { |
| 0 | 166 | | Nav.NavigateTo($"adm/events/{id}"); |
| 0 | 167 | | } |
| | 168 | |
|
| | 169 | | private void GoToCommand(Guid id) |
| | 170 | | { |
| 0 | 171 | | Nav.NavigateTo($"adm/commands/{id}"); |
| 0 | 172 | | } |
| | 173 | | } |