Merge branch 'routing' into 'master'

Routing for modules

See merge request murphg62/2023-ca400-murphg62-byrnm257!16
This commit is contained in:
gaz8860 Gary 2023-05-06 19:31:49 +00:00
commit e44c7001a4
4 changed files with 59 additions and 30 deletions

View File

@ -39,6 +39,8 @@
public string SelectedChartType {get; set;}
[Parameter]
public int ChartId {get; set;}
[Parameter]
public string module {get; set;}
protected override void OnAfterRender(bool firstRender)
{
@ -53,8 +55,7 @@
private async Task UpdateChartSeries()
{
string module = "localhost:8080";
var response = await httpService.GetAsync<GraphComponent>($"http://localhost:10000/{module}/{ChartId}");
var response = await httpService.GetAsync<GraphComponent>($"http://localhost:10000/component/{module}/{ChartId}");
StatsList = response.Stats;
await chart.UpdateSeriesAsync(true);
await InvokeAsync(() => StateHasChanged());

View File

@ -25,6 +25,8 @@
public List<Dictionary<string, object>> data { get; set; }
[Parameter]
public int TableId {get; set;}
[Parameter]
public string module {get; set;}
public IDictionary<string, Type> columns { get; set; }
public string GetColumnPropertyExpression(string name, Type type)
@ -63,9 +65,7 @@
private async Task Update()
{
string module = "localhost:8080";
var response = await httpService.GetAsync<TableComponent>($"http://localhost:10000/{module}/{TableId}");
var response = await httpService.GetAsync<TableComponent>($"http://localhost:10000/component/{module}/{TableId}");
if (response.Data != null)
{

View File

@ -1,4 +1,4 @@
@page "/test"
@page "/module/{moduleId}"
@using System.Net;
@using PanoptesFrontend.Data
@ -8,48 +8,76 @@
@inject IHttpService httpService
@inject IJSRuntime JSRuntime
@if (tables != null | graphs != null)
@if (tables != null || graphs != null)
{
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
@foreach (var component in tables)
<div class="row">
@if (graphs != null)
{
<div class="card mb-3">
<div class="card-body">
<DynamicTable data="@component.Data" TableId="@component.Id"/>
@for (int i = 0; i < graphs.Length; i += 2)
{
<div class="col-md-12">
<div class="row">
@if (i < graphs.Length)
{
<div class="col-md-6">
<div class="card mb-3">
<div class="card-body">
<DynamicChart StatsList="@graphs[i].Stats"
SelectedChartType="@graphs[i].Graph"
ChartTitle="@graphs[i].Title"
ChartId="@graphs[i].Id"
module="@moduleId"/>
</div>
</div>
</div>
}
@if (i + 1 < graphs.Length)
{
<div class="col-md-6">
<div class="card mb-3">
<div class="card-body">
<DynamicChart StatsList="@graphs[i + 1].Stats"
SelectedChartType="@graphs[i + 1].Graph"
ChartTitle="@graphs[i + 1].Title"
ChartId="@graphs[i + 1].Id"
module="@moduleId"/>
</div>
</div>
</div>
}
</div>
</div>
</div>
}
}
</div>
<div class="col-md-6">
@foreach (var component in graphs)
@if (tables != null)
{
<div class="card mb-3">
<div class="card-body">
<DynamicChart StatsList="@component.Stats"
SelectedChartType="@component.Graph"
ChartTitle="@component.Title"
ChartId="@component.Id"/>
</div>
<div class="col-md-12">
@foreach (var table in tables)
{
<div class="card mb-3">
<div class="card-body">
<DynamicTable data="@table.Data" TableId="@table.Id" module="@moduleId"/>
</div>
</div>
}
</div>
}
</div>
</div>
</div>
}
@code {
private TableComponent[] tables;
private GraphComponent[] graphs;
private string module = "localhost:8080";
[Parameter]
public string moduleId { get; set; }
protected async override Task OnInitializedAsync()
{
var schema = await httpService.GetAsync<Schema>($"http://localhost:10000/{module}/schema");
var schema = await httpService.GetAsync<Schema>("http://localhost:10000/" + moduleId + "/schema");
tables = schema.tables;
graphs = schema.graphs;
}

View File

@ -18,7 +18,7 @@
{
@foreach (var module in response){
<div class="nav-item px-3">
<NavLink class="nav-link" href=@module.Name Match="NavLinkMatch.All">
<NavLink class="nav-link" href=@($"/module/{module.Name}") Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> @module.Name
</NavLink>
</div>