< Summary - Syki

Information
Class: Syki.Front.Pages.Adm.AdmCommandPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Adm/AdmCommandPage.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 58
Coverable lines: 58
Total lines: 347
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 24
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%210%
.ctor()100%210%
GetProcessedAtIconColor()0%620%
GetIdentedData()0%620%
OnParametersSetAsync()100%210%
GetRetriesNotFoundMessage()100%210%
GetSubcommandsNotFoundMessage()100%210%
GetBatchesNotFoundMessage()100%210%
GoToDetails(...)100%210%
GoToEvent(...)100%210%
GoToBatch(...)100%210%
Reprocess()100%210%

File(s)

/home/runner/work/syki/syki/Front/Pages/Adm/AdmCommandPage.razor

#LineLine coverage
 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/commands/{id:guid}"
 8@attribute [Authorize(Roles = "Adm")]
 9
 10<SykiPageTitle Title="Comandos" />
 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.Task" Class="mb-1" Size="Size.Large"/>
 019                        <MudText Typo="Typo.h5" Class="mt-1" Style="font-weight: bold">@($"Comando - {_data.Description}
 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                    >
 031                        @_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="Duração (ms)" Conten
 48            </MudItem>
 49            <MudItem xs="12" sm="12" md="12" lg="12">
 50                <InfoCard Icon="@Icons.Material.Filled.DataObject" Color="@Colors.Blue.Darken1" Title="Dados" Content="@
 51            </MudItem>
 052            @if (_data.Error.HasValue())
 53            {
 54                <MudItem xs="12" sm="12" md="12" lg="12">
 55                    <InfoCard Icon="@Icons.Material.Filled.Error" Color="@Colors.Red.Darken1" Title="Erro" Content="@_da
 56                </MudItem>
 57            }
 058            @if (_data.EventId != null)
 59            {
 60                <MudItem xs="12" sm="12" md="12" lg="12">
 61                    <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem">
 062                        <MudLink OnClick="@(() => GoToEvent(_data.EventId.Value))" Color="Color.Primary">Este comando fo
 63                    </InfoCard>
 64                </MudItem>
 65            }
 066            @if (_data.ParentId != null)
 67            {
 68                <MudItem xs="12" sm="12" md="12" lg="12">
 69                    <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem">
 070                        <MudLink OnClick="@(() => GoToDetails(_data.ParentId.Value))" Color="Color.Primary">Este comando
 71                    </InfoCard>
 72                </MudItem>
 73            }
 074            @if (_data.OriginalId != null)
 75            {
 76                <MudItem xs="12" sm="12" md="12" lg="12">
 77                    <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem">
 078                        <MudLink OnClick="@(() => GoToDetails(_data.OriginalId.Value))" Color="Color.Primary">Este coman
 79                    </InfoCard>
 80                </MudItem>
 81            }
 082            @if (_data.SourceBatchId != null)
 83            {
 84                <MudItem xs="12" sm="12" md="12" lg="12">
 85                    <InfoCard Icon="@Icons.Material.Filled.TripOrigin" Color="@Colors.Orange.Darken1" Title="Origem">
 086                        <MudLink OnClick="@(() => GoToBatch(_data.SourceBatchId.Value))" Color="Color.Primary">Este coma
 87                    </InfoCard>
 88                </MudItem>
 89            }
 090            @if (_data.BatchId != null)
 91            {
 92                <MudItem xs="12" sm="12" md="12" lg="12">
 93                    <InfoCard Icon="@Icons.Material.Filled.BorderOuter" Color="@Colors.Green.Darken1" Title="Lote">
 094                        <MudLink OnClick="@(() => GoToBatch(_data.BatchId.Value))" Color="Color.Primary">Este comando pe
 95                    </InfoCard>
 96                </MudItem>
 97            }
 98        </MudGrid>
 99    </MudContainer>
 100
 0101    @if (_data.OriginalId == null && _data.Status == CommandStatus.Error)
 102    {
 103        <style>
 104            .mud-table-toolbar {
 105                height: auto;
 106            }
 107        </style>
 108        <MudContainer Class="px-0 my-4">
 109            <MudTable
 110                Class="mb-4"
 111                Dense="true"
 112                Hover="true"
 113                T="CommandOut"
 114                RowsPerPage="10"
 115                Loading="@_loading"
 116                Items="@_data.Retries"
 117                Breakpoint="Breakpoint.Sm"
 118            >
 119                <ToolBarContent>
 120                    <MudStack Row="true" AlignItems="AlignItems.Center" Class="my-4 ml-1 mr-2" Style="width: 100%">
 121                        <MudItem xs="12" sm="8" md="8" lg="8">
 122                            <MudStack Row="true" AlignItems="AlignItems.Center">
 123                                <MudIcon Icon="@Icons.Material.Filled.Task" Class="mb-1" Size="Size.Medium"/>
 124                                <MudText Typo="Typo.h6" Style="font-weight: bold">Reprocessamentos</MudText>
 125                            </MudStack>
 126                        </MudItem>
 127                        <MudItem xs="12" sm="4" md="4" lg="4" Class="d-flex justify-end">
 128                            <MudButton
 129                                OnClick="@Reprocess"
 130                                Size="Size.Medium"
 131                                Color="Color.Primary"
 132                                IconSize="Size.Medium"
 133                                Variant="Variant.Filled"
 134                                Disabled="@_disableButton"
 135                                StartIcon="@Icons.Material.Outlined.Autorenew"
 136                            >
 137                                Reprocessar
 138                            </MudButton>
 139                        </MudItem>
 140                    </MudStack>
 141                </ToolBarContent>
 142
 143                <HeaderContent>
 144                    <MudTh>Tipo</MudTh>
 145                    <MudTh>Criação</MudTh>
 146                    <MudTh>Processamento</MudTh>
 147                    <MudTh>Duração (ms)</MudTh>
 148                    <MudTh></MudTh>
 149                </HeaderContent>
 150                <RowTemplate>
 151                    <MudTd DataLabel="Tipo">
 152                        <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
 153                            <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Smal
 0154                            <MudText Typo="Typo.body2">@context.Description</MudText>
 155                        </MudStack>
 156                    </MudTd>
 0157                    <MudTd DataLabel="Criação">@context.CreatedAt.ToMinuteString()</MudTd>
 0158                    <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd>
 0159                    <MudTd DataLabel="Duração (ms)">@context.Duration.ToThousandSeparated()</MudTd>
 160                    <MudTd>
 0161                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => Go
 162                    </MudTd>
 163                </RowTemplate>
 164                <NoRecordsContent>
 0165                    @(GetRetriesNotFoundMessage())
 166                </NoRecordsContent>
 167            </MudTable>
 168        </MudContainer>
 169    }
 170
 0171    @if (_data.Subcommands.Count > 0)
 172    {
 173        <style>
 174            .mud-table-toolbar {
 175                height: auto;
 176            }
 177        </style>
 178        <MudContainer Class="px-0 my-4">
 179            <MudTable
 180                Class="mb-4"
 181                Dense="true"
 182                Hover="true"
 183                T="CommandOut"
 184                RowsPerPage="10"
 185                Loading="@_loading"
 186                Items="@_data.Subcommands"
 187                Breakpoint="Breakpoint.Sm"
 188            >
 189                <ToolBarContent>
 190                    <MudStack Row="true" AlignItems="AlignItems.Center" Class="mt-2">
 191                        <MudIcon Icon="@Icons.Material.Filled.SubdirectoryArrowRight" Class="mb-1" Size="Size.Medium"/>
 192                        <MudText Typo="Typo.h6" Style="font-weight: bold">Subcomandos</MudText>
 193                    </MudStack>
 194                </ToolBarContent>
 195
 196                <HeaderContent>
 197                    <MudTh>Tipo</MudTh>
 198                    <MudTh>Criação</MudTh>
 199                    <MudTh>Processamento</MudTh>
 200                    <MudTh>Duração (ms)</MudTh>
 201                    <MudTh></MudTh>
 202                </HeaderContent>
 203                <RowTemplate>
 204                    <MudTd DataLabel="Tipo">
 205                        <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
 206                            <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Smal
 0207                            <MudText Typo="Typo.body2">@context.Description</MudText>
 208                        </MudStack>
 209                    </MudTd>
 0210                    <MudTd DataLabel="Criação">@context.CreatedAt.ToMinuteString()</MudTd>
 0211                    <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd>
 0212                    <MudTd DataLabel="Duração (ms)">@context.Duration.ToThousandSeparated()</MudTd>
 213                    <MudTd>
 0214                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => Go
 215                    </MudTd>
 216                </RowTemplate>
 217                <NoRecordsContent>
 0218                    @(GetSubcommandsNotFoundMessage())
 219                </NoRecordsContent>
 220            </MudTable>
 221        </MudContainer>
 222    }
 223
 0224    @if (_data.Batches.Count > 0)
 225    {
 226        <style>
 227            .mud-table-toolbar {
 228                height: auto;
 229            }
 230        </style>
 231        <MudContainer Class="px-0 my-4">
 232            <MudTable
 233                Class="mb-4"
 234                Dense="true"
 235                Hover="true"
 236                T="BatchOut"
 237                RowsPerPage="10"
 238                Loading="@_loading"
 239                Items="@_data.Batches"
 240                Breakpoint="Breakpoint.Sm"
 241            >
 242                <ToolBarContent>
 243                    <MudStack Row="true" AlignItems="AlignItems.Center" Class="mt-2">
 244                        <MudIcon Icon="@Icons.Material.Filled.SubdirectoryArrowRight" Class="mb-1" Size="Size.Medium"/>
 245                        <MudText Typo="Typo.h6" Style="font-weight: bold">Lotes</MudText>
 246                    </MudStack>
 247                </ToolBarContent>
 248
 249                <HeaderContent>
 250                    <MudTh>Tipo</MudTh>
 251                    <MudTh>Criação</MudTh>
 252                    <MudTh>Processamento</MudTh>
 253                    <MudTh>Comandos</MudTh>
 254                    <MudTh></MudTh>
 255                </HeaderContent>
 256                <RowTemplate>
 257                    <MudTd DataLabel="Tipo">
 258                        <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
 259                            <MudIcon Icon="@context.Status.GetIcon()" Color="@context.Status.GetColor()" Size="Size.Smal
 0260                            <MudText Typo="Typo.body2">@context.Type.GetDescription()</MudText>
 261                        </MudStack>
 262                    </MudTd>
 0263                    <MudTd DataLabel="Criação">@context.CreatedAt.ToMinuteString()</MudTd>
 0264                    <MudTd DataLabel="Processamento">@context.ProcessedAt.ToMinuteString()</MudTd>
 0265                    <MudTd DataLabel="Comandos">@context.Size.ToThousandSeparated()</MudTd>
 266                    <MudTd>
 0267                        <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.RemoveRedEye" OnClick="@(() => Go
 268                    </MudTd>
 269                </RowTemplate>
 270                <NoRecordsContent>
 0271                    @(GetBatchesNotFoundMessage())
 272                </NoRecordsContent>
 273            </MudTable>
 274        </MudContainer>
 275    }
 276</MudContainer>
 277
 278@inject NavigationManager Nav
 279@inject GetCommandClient GetCommandClient
 280@inject ReprocessCommandClient ReprocessCommandClient
 281
 282@code
 283{
 284  [Parameter]
 0285  public Guid Id { get; set; }
 286
 287    private bool _loading;
 288    private bool _disableButton;
 0289    private CommandOut _data = new();
 290
 291    private string GetProcessedAtIconColor()
 292    {
 0293        return _data.ProcessedAt == null ? Colors.BlueGray.Lighten4 : Colors.Green.Darken1;
 294    }
 295
 296    private string GetIdentedData()
 297    {
 0298        return _data.Data.HasValue() ? JValue.Parse(_data.Data).ToString(Formatting.Indented) : "";
 299    }
 300
 301    protected override async Task OnParametersSetAsync()
 302    {
 0303        _loading = true;
 0304        _data = await GetCommandClient.Get(Id);
 0305        _loading = false;
 0306    }
 307
 308    private string GetRetriesNotFoundMessage()
 309    {
 0310        return "Este comando não possui reprocessamentos.";
 311    }
 312
 313    private string GetSubcommandsNotFoundMessage()
 314    {
 0315        return "Este comando não possui subcomandos.";
 316    }
 317
 318    private string GetBatchesNotFoundMessage()
 319    {
 0320        return "Este comando não possui lotes.";
 321    }
 322
 323    private void GoToDetails(Guid id)
 324    {
 0325        Nav.NavigateTo($"adm/commands/{id}");
 0326    }
 327
 328    private void GoToEvent(Guid id)
 329    {
 0330        Nav.NavigateTo($"adm/events/{id}");
 0331    }
 332
 333    private void GoToBatch(Guid id)
 334    {
 0335        Nav.NavigateTo($"adm/batches/{id}");
 0336    }
 337
 338    private async Task Reprocess()
 339    {
 0340        _disableButton = true;
 0341        await ReprocessCommandClient.Reprocess(Id);
 0342        _loading = true;
 0343        _data = await GetCommandClient.Get(Id);
 0344        _loading = false;
 0345        _disableButton = false;
 0346    }
 347}