Attempt to improve responsiveness of dashboard

dhcp-server
Pat Hartl 2023-08-28 18:55:15 -05:00
parent 1def1ce0e8
commit 6399f1750c
4 changed files with 69 additions and 50 deletions

View File

@ -3,7 +3,9 @@
@using AntDesign.Charts;
@using System.Collections.Concurrent;
<Area @ref="Chart" Config="Config" />
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
@ -11,6 +13,7 @@
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
Dictionary<string, double[]> Data = new Dictionary<string, double[]>();
@ -39,7 +42,9 @@
}
};
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
@ -52,14 +57,14 @@
await RefreshData();
};
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}

View File

@ -3,7 +3,9 @@
@using AntDesign.Charts;
@using System.Collections.Concurrent;
<Area @ref="Chart" Config="Config" />
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
@ -11,6 +13,7 @@
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
Dictionary<string, double[]> Data = new Dictionary<string, double[]>();
@ -39,7 +42,9 @@
}
};
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
@ -52,14 +57,13 @@
await RefreshData();
};
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}

View File

@ -2,13 +2,16 @@
@using LANCommander.Extensions;
@using AntDesign.Charts;
<Area @ref="Chart" Config="Config" />
<Spin Spinning="Loading">
<Area @ref="Chart" Config="Config" />
</Spin>
@code {
[Parameter] public int TimerHistory { get; set; }
[Parameter] public int TimerInterval { get; set; }
IChartComponent? Chart;
System.Timers.Timer Timer;
bool Loading = true;
double[] Data;
@ -42,7 +45,9 @@
}
};
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (Timer == null)
{
@ -55,14 +60,13 @@
await RefreshData();
};
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Chart.UpdateChart(Config, null, null, JsConfig);
Timer.Start();
Loading = false;
StateHasChanged();
}
}

View File

@ -1,16 +1,20 @@
@using AntDesign.Charts
@using ByteSizeLib
<Pie Data="Data" Config="Config" JsConfig="@JsConfig" />
<Spin Spinning="Loading">
<Pie Data="Data" Config="Config" JsConfig="@JsConfig" />
</Spin>
@code {
object[] Data;
bool Loading = true;
string JsConfig = @"{
meta: {
value: {
alias: 'Data Usage',
formatter: (v) => humanFileSize(v, true)
formatter: (v) => Uploader.GetHumanFileSize(v, true, 1)
}
},
label: {
@ -58,6 +62,8 @@
}
};
Loading = false;
StateHasChanged();
}
}