schema generation from request - not working

This commit is contained in:
gaz8860 Gary 2023-04-05 19:21:21 +01:00
parent 0036cbbcea
commit 9d20919f2c
15 changed files with 48 additions and 30 deletions

View File

@ -0,0 +1,12 @@
public class Component {
public int Type {get; set;}
public string Text {get; set;}
public List<Stats> Chart {get; set;}
public Component(int type, string text="", List<Stats> chart = null){
Type = type;
Text = text;
Chart = chart;
}
}

View File

@ -1,6 +0,0 @@
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public string Email { get; set; }
}

View File

@ -0,0 +1,4 @@
public class Stats {
String Label {get; set;}
Int64 Value {get; set;}
}

View File

@ -1,14 +0,0 @@
<div class="card">
<div class="card-header">
@Data.Name
</div>
<div class="card-body">
<p>Age: @Data.Age</p>
<p>Email: @Data.Email</p>
</div>
</div>
@code {
[Parameter]
public Person Data { get; set; }
}

View File

@ -0,0 +1,10 @@
<div class="card">
<div class="card-body">
<p>@Data.Text</p>
</div>
</div>
@code {
[Parameter]
public Component Data { get; set; }
}

View File

@ -1,25 +1,29 @@
@page "/people"
@page "/test"
@using System.Net.Http.Json
@using System.Text.Json
@inject HttpClient httpClient
@if (people != null)
@if (data != null)
{
@foreach (var person in people)
{
<PersonCard Data="@person" />
@foreach (var component in data) {
switch (component.Type) {
case 0:
<TestCard Data="@component" />
break;
}
}
}
@code {
private List<Person> people;
public List<Component> data;
protected override async Task OnInitializedAsync()
{
var response = await httpClient.GetAsync("http://localhost:8080");
var json = await response.Content.ReadAsStringAsync();
people = JsonSerializer.Deserialize<List<Person>>(json);
data = JsonSerializer.Deserialize<List<Component>>(json);
}
}

View File

@ -31,8 +31,8 @@ build_metadata.AdditionalFiles.CssScope =
build_metadata.AdditionalFiles.TargetPath = UGFnZXNcSW5kZXgucmF6b3I=
build_metadata.AdditionalFiles.CssScope =
[C:/Users/user/Documents/Panoptes/2023-ca400-murphg62-byrnm257/src/PanoptesFrontend/Pages/PersonCard.razor]
build_metadata.AdditionalFiles.TargetPath = UGFnZXNcUGVyc29uQ2FyZC5yYXpvcg==
[C:/Users/user/Documents/Panoptes/2023-ca400-murphg62-byrnm257/src/PanoptesFrontend/Pages/TestCard.razor]
build_metadata.AdditionalFiles.TargetPath = UGFnZXNcVGVzdENhcmQucmF6b3I=
build_metadata.AdditionalFiles.CssScope =
[C:/Users/user/Documents/Panoptes/2023-ca400-murphg62-byrnm257/src/PanoptesFrontend/Pages/TestRequest.razor]

View File

@ -1 +1 @@
280f506f1a47e4ea08b5e9891f5fe3ce43a1a5db
84500de425a5aa9d6b1d6919ac86ff6fd49c4373

View File

@ -2,3 +2,11 @@
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0