73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
@page "/database"
|
|
@using Ministreliy.Models
|
|
@using Newtonsoft.Json
|
|
@using System.Text
|
|
@inject IJSRuntime JS
|
|
@inject NavigationManager NavManager
|
|
|
|
<PageTitle>База данных</PageTitle>
|
|
|
|
<div>
|
|
<div class="row justify-content-between">
|
|
<div class="col-10">
|
|
<ul class="nav nav-tabs">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" aria-current="page" href="database">Сводные данные</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="database/type">Типы устройств</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="database/device">Устройства</a>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
<div class="col-2">
|
|
@* <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addtype">
|
|
Добавить тип
|
|
</button>
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#deltype">
|
|
Удалить тип
|
|
</button> *@
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@if (listDeviceTypes.Count == 0 || listDeviceItems.Count == 0)
|
|
{
|
|
<p>@messageStatus</p>
|
|
}
|
|
|
|
|
|
@code {
|
|
public static List<DeviceType>? listDeviceTypes = new();
|
|
public static List<DeviceItem>? listDeviceItems = new();
|
|
public static HttpClient httpClient = new();
|
|
|
|
string? messageStatus = "Получаю данные...";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
httpClient.BaseAddress = new Uri("http://localhost:5262/api/");
|
|
var devicetype = await httpClient.GetAsync("Device/GetTypes");
|
|
var deviceitem = await httpClient.GetAsync("Device/GetDevices");
|
|
listDeviceTypes = JsonConvert.DeserializeObject<List<DeviceType>>(await devicetype.Content.ReadAsStringAsync());
|
|
listDeviceItems = JsonConvert.DeserializeObject<List<DeviceItem>>(await deviceitem.Content.ReadAsStringAsync());
|
|
messageStatus = string.Empty;
|
|
if (listDeviceTypes.Count == 0)
|
|
{
|
|
messageStatus += $"нет типов устройств\r\n";
|
|
}
|
|
if (listDeviceItems.Count == 0)
|
|
{
|
|
messageStatus += $"нет устройств\r\n";
|
|
}
|
|
DataStore.ListDeviceTypesStore = listDeviceTypes;
|
|
DataStore.ListDeviceItemsStore = listDeviceItems;
|
|
}
|
|
}
|