dynamic rendering from REST call
This commit is contained in:
parent
9d20919f2c
commit
539221c456
@ -1,12 +1,11 @@
|
||||
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){
|
||||
|
||||
public Component(int type, string text){
|
||||
Type = type;
|
||||
Text = text;
|
||||
Chart = chart;
|
||||
}
|
||||
}
|
||||
3
src/PanoptesFrontend/Data/Schema.cs
Normal file
3
src/PanoptesFrontend/Data/Schema.cs
Normal file
@ -0,0 +1,3 @@
|
||||
public class Schema {
|
||||
public Component[] components {get; set;}
|
||||
}
|
||||
@ -14,16 +14,16 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@code {
|
||||
public List<Component> data;
|
||||
private Component[] data;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var response = await httpClient.GetAsync("http://localhost:8080");
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
data = JsonSerializer.Deserialize<List<Component>>(json);
|
||||
var response = await httpClient.GetStringAsync("http://localhost:8080/schema");
|
||||
var options = new JsonSerializerOptions {PropertyNameCaseInsensitive = true};
|
||||
var json = JsonSerializer.Deserialize<Schema>(response, options);
|
||||
data = json.components;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user