mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 04:50:55 +00:00
55 lines
1.8 KiB
Plaintext
55 lines
1.8 KiB
Plaintext
@inject NavigationManager NavigationManager
|
|
@using CartriX.Shared.DTOs.Location
|
|
@using CartriX.Shared.DTOs.Printer
|
|
@using CartriX.Shared.Models
|
|
@using Newtonsoft.Json
|
|
|
|
|
|
<RadzenSidebar @bind-Expanded="sideBarExpanded">
|
|
<RadzenPanelMenu>
|
|
<RadzenPanelMenuItem Text="Добавить принтер" Icon="Add" Click="@(() => NavigationManager.NavigateTo("/PrinterAdd"))" />
|
|
@if (locations == null)
|
|
{
|
|
<RadzenPanelMenuItem Text="..." />
|
|
}
|
|
else
|
|
{
|
|
@foreach (LocationDtoNameAndPrinters location in locations)
|
|
{
|
|
<RadzenPanelMenuItem Text="@(location.name)" Icon="Label">
|
|
@foreach (PrinterDtoWithNameAndId dto in location.printers)
|
|
{
|
|
<RadzenPanelMenuItem Text="@(dto.name)" Icon="Print" Click="@(() => NavigationManager.NavigateTo($"/PrinterPage/{dto.id}"))" />
|
|
}
|
|
</RadzenPanelMenuItem>
|
|
}
|
|
<RadzenPanelMenuItem Text="Картриджи" Icon="inventory_2" Click="@(() => NavigationManager.NavigateTo("/Cartridges"))"/>
|
|
}
|
|
</RadzenPanelMenu>
|
|
</RadzenSidebar>
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
[EditorRequired]
|
|
public bool sideBarExpanded { get; set; }
|
|
|
|
List<LocationDtoNameAndPrinters>? locations = null;
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
HttpClient client = new HttpClient();
|
|
|
|
var response = await client.GetAsync("http://localhost:5197/api/Location/GetAll");
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
locations = JsonConvert.DeserializeObject<List<LocationDtoNameAndPrinters>>(content)!;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Error: {ex.Message}");
|
|
}
|
|
}
|
|
} |