mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
Более менее сделал страничку с принтером
This commit is contained in:
1 parent
286beabf89
commit
9a486a57b4
9 files changed
+103
-32
No files matched your search
@@ -4,53 +4,114 @@
|
||||
@inject IJSRuntime JS
|
||||
@using System.Net
|
||||
|
||||
<style>
|
||||
.rz-fabmenu {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
<RadzenStack>
|
||||
@@media (max-width: 800px) {
|
||||
.desktopActionPanel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</RadzenStack>
|
||||
.rz-fabmenu {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@if (printer.StatusId == 1)
|
||||
|
||||
<RadzenFabMenu class="phoneFab" Icon="more_horiz">
|
||||
<RadzenFabMenuItem Text="Заменить картридж" />
|
||||
<RadzenFabMenuItem Text="Веб конфигурация" />
|
||||
</RadzenFabMenu>
|
||||
|
||||
|
||||
@if (dataIsLoading)
|
||||
{
|
||||
<RadzenStack>
|
||||
<h1>Получаем информацию...</h1>
|
||||
</RadzenStack>
|
||||
}
|
||||
else if (printer is null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (pingIsActive)
|
||||
{
|
||||
<h1>Пингуем...</h1>
|
||||
}
|
||||
else
|
||||
{
|
||||
<RadzenStack Orientation="Orientation.Vertical">
|
||||
<RadzenCard>
|
||||
<RadzenStack Orientation="Orientation.Horizontal">
|
||||
@if (printer.Model.PicturePath is null)
|
||||
{
|
||||
<img src="/media/product_empty.jpg" width="200" />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
<RadzenStack>
|
||||
<RadzenText Text="@printer.Model.Name" TextStyle="TextStyle.DisplayH4"/>
|
||||
<img alt="@printer.Model.Manufacturer.Name" />
|
||||
|
||||
<RadzenText/>
|
||||
<RadzenText/>
|
||||
<RadzenText/>
|
||||
<RadzenText/>
|
||||
</RadzenStack>
|
||||
|
||||
</RadzenStack>
|
||||
</RadzenCard>
|
||||
<RadzenCard class="desktopActionPanel">
|
||||
<RadzenStack Orientation="Orientation.Horizontal">
|
||||
<RadzenButton Text="Заменить картридж" Click="ChangeCartridgeClick" />
|
||||
<RadzenButton Text="Веб конфигурация" Click="WebConfigurationClick" />
|
||||
</RadzenStack>
|
||||
</RadzenCard>
|
||||
</RadzenStack>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
<RadzenStack Orientation="Orientation.Vertical">
|
||||
<RadzenCard style="height: 200px;">
|
||||
|
||||
</RadzenCard>
|
||||
<RadzenCard>
|
||||
<RadzenStack Orientation="Orientation.Horizontal">
|
||||
<RadzenButton Text="Заменить картридж" Click="ChangeCartridgeClick" />
|
||||
<RadzenButton Text="Веб конфигурация" Click="WebConfigurationClick" />
|
||||
</RadzenStack>
|
||||
</RadzenCard>
|
||||
</RadzenStack>
|
||||
|
||||
@code {
|
||||
//bool dataIsLoading;
|
||||
bool dataIsLoading;
|
||||
bool pingIsActive;
|
||||
[Parameter] public int PrinterId { get; set; }
|
||||
private Models.Printer.PrinterItem printer = default!;
|
||||
private Models.Printer.PrinterItem? printer = default!;
|
||||
|
||||
protected async override Task OnInitializedAsync()
|
||||
{
|
||||
// dataIsLoading = true;
|
||||
dataIsLoading = true;
|
||||
await GetPrinterInfo();
|
||||
//dataIsLoading = false;
|
||||
dataIsLoading = false;
|
||||
StateHasChanged();
|
||||
await PingPrinter();
|
||||
}
|
||||
|
||||
|
||||
async Task GetPrinterInfo()
|
||||
{
|
||||
var responce = await http.GetAsync(ApiRoutes.Printer.Item(PrinterId));
|
||||
var json = await responce.Content.ReadAsStringAsync();
|
||||
printer = JsonConvert.DeserializeObject<Models.Printer.PrinterItem>(json)!;
|
||||
}
|
||||
async Task PingPrinter()
|
||||
{
|
||||
pingIsActive = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
var responce = await http.GetFromJsonAsync<bool>(ApiRoutes.Network.Ping(printer!.IpAddressOrHostname!));
|
||||
Console.WriteLine(responce);
|
||||
bool pingIsSuccessful = (bool)responce;
|
||||
int SetStatusId = (pingIsSuccessful) ? 1 : 2;
|
||||
await http.PatchAsJsonAsync(ApiRoutes.Printer.ChangeStatus(PrinterId), SetStatusId);
|
||||
await GetPrinterInfo();
|
||||
pingIsActive = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
async Task ChangeCartridgeClick()
|
||||
{
|
||||
NavigationManager.NavigateTo($"/printer/{PrinterId}/cartridgereplace");
|
||||
@@ -59,7 +120,7 @@ else
|
||||
{
|
||||
string features = "width=1280,height=720,resizable=no,scrollbars=yes";
|
||||
|
||||
if (IPAddress.TryParse(printer.IpAddressOrHostname, out IPAddress? address))
|
||||
if (IPAddress.TryParse(printer!.IpAddressOrHostname, out IPAddress? address))
|
||||
{
|
||||
await JS.InvokeVoidAsync("open", $"http://{address.ToString()}", "_blank", features);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user