Files
CartriX/CartriX.Web/Pages/PrintersPage.razor
T
2026-05-22 01:21:04 +09:00

84 lines
4.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@page "/Printers"
@inject NavigationManager navigationManager
@inject HttpClient httpClient
@inject DialogService DialogService
<RadzenMenu>
<RadzenMenuItem Text="Добавить принтер" Icon="Add" Click="@(() => ShowInlineDialog())"/>
<RadzenMenuItem Icon="move_item" Text="Переместить принтер" Disabled="true" />
<RadzenMenuItem Icon="delete" Text="Удалить принтер" Disabled="true" />
</RadzenMenu>
<RadzenDataGrid Data="locations" TItem="DTOs.Location.List" GridLines="DataGridGridLines.Horizontal">
<Columns>
<RadzenDataGridColumn Title="Расположения" Property="name" Resizable="true" Width="350px" />
<RadzenDataGridColumn Title="Количество устройств" Property="countPrinters" Resizable="true"/>
</Columns>
<Template Context="location">
<RadzenDataGrid Data="location.printers">
<Columns>
<RadzenDataGridColumn Width="200px" Title="Название принетра" Property="name"/>
<RadzenDataGridColumn Width="200px" Title="IP Адрес" Property="ipAddressOrHostname" />
<RadzenDataGridColumn Width="200px" Title="Модель" Property="modelName" />
<RadzenDataGridColumn Title="Статус">
<Template Context="printer">
@switch (printer.statusId)
{
case 1:
<RadzenBadge IsPill="true" BadgeStyle="BadgeStyle.Success">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="4px" Style="margin-top: 4px; margin-bottom: 4px;">
<RadzenIcon Icon="check_circle" /> Активный
</RadzenStack>
</RadzenBadge>
return;
case 2:
<RadzenBadge IsPill="true" BadgeStyle="BadgeStyle.Base">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="4px" Style="margin-top: 4px; margin-bottom: 4px;">
<RadzenIcon Icon="circle_circle" /> Недоступен
</RadzenStack>
</RadzenBadge>
return;
case 3:
<RadzenBadge IsPill="true" BadgeStyle="BadgeStyle.Info">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="4px" Style="margin-top: 4px; margin-bottom: 4px;">
<RadzenIcon Icon="change_circle" /> В ремонте
</RadzenStack>
</RadzenBadge>
return;
}
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn Width="52px">
<Template Context="printer">
<RadzenButton Icon="info" ButtonStyle="ButtonStyle.Info" ButtonType="ButtonType.Button" Variant="Variant.Flat" Click="() => OpenPrinterPage(printer.id)" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</Template>
</RadzenDataGrid>
@code {
List<DTOs.Location.List> locations = null!;
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
var response = await httpClient.GetAsync(ApiRoutes.Location.List);
locations = JsonConvert.DeserializeObject<List<DTOs.Location.List>>(await response.Content.ReadAsStringAsync())!;
}
async Task ShowInlineDialog()
{
var result = await DialogService.OpenAsync<AddPrinterDialog.AddPrinterDialog>(
options: new DialogOptions() { Width = "768"},
title: "Добавление принтера для отслеживания");
}
void OpenPrinterPage(int id)
{
navigationManager.NavigateTo($"/Printer/{id}");
}
}