mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 13:00:55 +00:00
Сделал диалоговое окно добавления принтера
This commit is contained in:
1 parent
17e4794160
commit
88f53c793e
78 files changed
+854
-60572
No files matched your search
@@ -0,0 +1,125 @@
|
||||
@using CartriX.Shared.DTOs.Printer
|
||||
|
||||
<RadzenStack Gap="16px">
|
||||
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
|
||||
<RadzenLabel Text="IP Адрес принтера:" />
|
||||
<RadzenTextBox Placeholder="123.255.255.255" Style="flex: 1; min-width: 200px;" @bind-Value="printerIpOrHostname" />
|
||||
</RadzenStack>
|
||||
<RadzenButton Text="Опросить" Icon="content_paste_search" BusyText="Опрашиваем" IsBusy="processingQueryToPrinter" Click="@(() => OnQueryPrinter())" />
|
||||
<RadzenTable>
|
||||
<RadzenTableHeader>
|
||||
<RadzenTableHeaderRow>
|
||||
<RadzenTableHeaderCell ColSpan="2">
|
||||
Результат запроса принтера
|
||||
</RadzenTableHeaderCell>
|
||||
</RadzenTableHeaderRow>
|
||||
</RadzenTableHeader>
|
||||
<RadzenTableBody>
|
||||
<RadzenTableRow>
|
||||
<RadzenTableCell>Имя хоста</RadzenTableCell>
|
||||
<RadzenTableCell>
|
||||
@if (processingQueryToPrinter)
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.Wave" Style="width: 100%;" />
|
||||
}
|
||||
else if (queryPrinterToAdd is not null)
|
||||
{
|
||||
@queryPrinterToAdd.hostname;
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
|
||||
}
|
||||
</RadzenTableCell>
|
||||
</RadzenTableRow>
|
||||
<RadzenTableRow>
|
||||
<RadzenTableCell>IP Адрес</RadzenTableCell>
|
||||
<RadzenTableCell>
|
||||
@if (processingQueryToPrinter)
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.Wave" Style="width: 100%;" />
|
||||
}
|
||||
else if (queryPrinterToAdd is not null)
|
||||
{
|
||||
@queryPrinterToAdd.ipAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
|
||||
}
|
||||
</RadzenTableCell>
|
||||
</RadzenTableRow>
|
||||
<RadzenTableRow>
|
||||
<RadzenTableCell>Модель принтера</RadzenTableCell>
|
||||
<RadzenTableCell>
|
||||
@if (processingQueryToPrinter)
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.Wave" Style="width: 100%;" />
|
||||
}
|
||||
else if (queryPrinterToAdd is not null)
|
||||
{
|
||||
@queryPrinterToAdd.model;
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
|
||||
}
|
||||
</RadzenTableCell>
|
||||
</RadzenTableRow>
|
||||
<RadzenTableRow>
|
||||
<RadzenTableCell>Местоположение</RadzenTableCell>
|
||||
<RadzenTableCell>
|
||||
@if (processingQueryToPrinter)
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.Wave" Style="width: 100%;" />
|
||||
}
|
||||
else if (queryPrinterToAdd is not null)
|
||||
{
|
||||
@queryPrinterToAdd.location;
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenSkeleton Animation="SkeletonAnimation.None" Style="width: 100%;" />
|
||||
}
|
||||
</RadzenTableCell>
|
||||
</RadzenTableRow>
|
||||
</RadzenTableBody>
|
||||
</RadzenTable>
|
||||
<RadzenStack>
|
||||
<RadzenButton Text="Добавить" Disabled="true" />
|
||||
</RadzenStack>
|
||||
|
||||
</RadzenStack>
|
||||
|
||||
@code {
|
||||
private string printerIpOrHostname = "";
|
||||
private bool processingQueryToPrinter = false;
|
||||
|
||||
QueryPrinterToAdd queryPrinterToAdd = null!;
|
||||
|
||||
private async Task OnQueryPrinter()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(printerIpOrHostname))
|
||||
return;
|
||||
|
||||
processingQueryToPrinter = true;
|
||||
try
|
||||
{
|
||||
HttpClient client = new();
|
||||
var response = await client.GetAsync($"http://localhost:5197/api/Printer/GetSNMP/{printerIpOrHostname}");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = JsonConvert.DeserializeObject<QueryPrinterToAdd>(await response.Content.ReadAsStringAsync());
|
||||
queryPrinterToAdd = result!;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
processingQueryToPrinter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user