forked from itsecd/cloud-development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataCard.razor
More file actions
74 lines (70 loc) · 3.1 KB
/
DataCard.razor
File metadata and controls
74 lines (70 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@inject IConfiguration Configuration
@inject HttpClient Client
<CardDeck>
<Card>
<CardHeader>
<Heading Size="HeadingSize.Is5"><Blazorise.Icons.FontAwesome.Icon Name="IconName.Table" /> Характеристики текущего объекта</Heading>
</CardHeader>
<CardBody>
<Table Bordered >
<TableHeader ThemeContrast="ThemeContrast.Light">
<TableRow>
<TableHeaderCell>#</TableHeaderCell>
<TableHeaderCell>Характеристика</TableHeaderCell>
<TableHeaderCell>Значение</TableHeaderCell>
</TableRow>
</TableHeader>
<TableBody>
@if(Value is null)
{
<TableRow>
<TableRowCell>1</TableRowCell>
<TableRowCell>нет данных</TableRowCell>
<TableRowCell>нет данных</TableRowCell>
</TableRow>
}
else
{
var array = Value.ToArray();
foreach (var property in array)
{
<TableRow>
<TableRowCell>@(Array.IndexOf(array, property)+1)</TableRowCell>
<TableRowCell>@property.Key</TableRowCell>
<TableRowCell>@property.Value?.ToString()</TableRowCell>
</TableRow>
}
}
</TableBody>
</Table>
</CardBody>
</Card>
<Card Margin="Margin.Is3.OnY">
<CardHeader>
<Heading Size="HeadingSize.Is5"><Blazorise.Icons.FontAwesome.Icon Name="IconName.Send" /> Запросить новый объект</Heading>
</CardHeader>
<CardBody>
<Row>
<Column ColumnSize="ColumnSize.Is4">
<Text>Идентификатор нового объекта:</Text>
</Column>
<Column ColumnSize="ColumnSize.Is4">
<NumericEdit TValue="int" @bind-Value="@Id"/>
</Column>
<Column ColumnSize="ColumnSize.Is4">
<Button Clicked=RequestNewData Color="Color.Primary">Запросить данные <Blazorise.Icons.FontAwesome.Icon Name="IconName.ArrowRight" /></Button>
</Column>
</Row>
</CardBody>
</Card>
</CardDeck>
@code {
private JsonObject? Value { get; set; }
private int Id { get; set; }
private async Task RequestNewData()
{
var baseAddress = Configuration["BaseAddress"] ?? throw new KeyNotFoundException("Конфигурация клиента не содержит параметра BaseAddress");
Value = await Client.GetFromJsonAsync<JsonObject>($"{baseAddress}?id={Id}", new JsonSerializerOptions { });
StateHasChanged();
}
}