Skip to content

Commit 3a54ead

Browse files
authored
Update Submit UI with 0 based chart and info box for submissions
1 parent 1645007 commit 3a54ead

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

Jellyfin.HardwareVisualizer/Client/Pages/HardwareSurveyChartsPage.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
<PageTitle>Jellyfin Hardware Survey</PageTitle>
66

7+
@if(Submission != Guid.Empty)
8+
{
9+
<div>
10+
<p>Your submission was received and is currently been processed. Please check in a few Minutes and reload the website.</p>
11+
</div>
12+
}
13+
714
<div class="d-inline-flex p-2 flex-row">
815
@foreach (var selectedDevice in this.DataSelectorService.SelectedDevices)
916
{

Jellyfin.HardwareVisualizer/Client/Pages/HardwareSurveyChartsPage.razor.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
using ChartJs.Blazor.BarChart;
2+
using ChartJs.Blazor.BarChart.Axes;
23
using ChartJs.Blazor.Common;
4+
using ChartJs.Blazor.Common.Axes;
5+
using ChartJs.Blazor.Common.Axes.Ticks;
36
using ChartJs.Blazor.Common.Enums;
7+
using ChartJs.Blazor.LineChart;
48
using Jellyfin.HardwareVisualizer.Client.Service;
59
using Jellyfin.HardwareVisualizer.Client.Service.ResLoaded;
610
using Jellyfin.HardwareVisualizer.Shared.Models;
@@ -21,6 +25,10 @@ public partial class HardwareSurveyChartsPage
2125
[SupplyParameterFromQuery(Name = "device")]
2226
[Parameter]
2327
public string[]? SelectedDevices { get; set; }
28+
29+
[SupplyParameterFromQuery(Name = "submission")]
30+
[Parameter]
31+
public Guid Submission { get; set; }
2432

2533
public Guid SelectedDevice { get; set; }
2634

@@ -45,7 +53,7 @@ await ResourceLoaderService.AddResource(
4553
new ScriptLinkResource("_content/ChartJs.Blazor.Fork/ChartJsBlazorInterop.js"));
4654

4755
var usageChart = new BarConfig(_horizontalChart);
48-
56+
4957
usageChart.Options = new BarOptions
5058
{
5159
Responsive = true,
@@ -58,6 +66,16 @@ await ResourceLoaderService.AddResource(
5866
{
5967
Display = true,
6068
Position = Position.Top
69+
},
70+
Scales = new BarScales
71+
{
72+
XAxes = new List<CartesianAxis>(){
73+
new BarLinearCartesianAxis (){
74+
Ticks = new LinearCartesianTicks(){
75+
BeginAtZero = true
76+
}
77+
}
78+
}
6179
}
6280
};
6381

@@ -137,7 +155,7 @@ private void DataSelectorService_DeviceAdded(object? sender, RenderDeviceViewMod
137155
_usageChart.Data.Datasets.Add(new BarDataset<int>(values, _horizontalChart)
138156
{
139157
Label = renderDeviceViewModel.Name,
140-
BackgroundColor = ChartBackgroundColors[i % ChartBackgroundColors.Length]
158+
BackgroundColor = ChartBackgroundColors[i % ChartBackgroundColors.Length],
141159
});
142160
}
143161

Jellyfin.HardwareVisualizer/Client/Pages/SubmitSurveyResultPage.razor.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,42 @@ protected override async Task OnInitializedAsync()
5252

5353
public async Task SubmitResults()
5454
{
55-
var textModel = await this._editor.GetModel();
56-
var value = await textModel.GetValue(EndOfLinePreference.TextDefined, false);
57-
ValidateSubmission(value);
58-
if (!IsSchemaValid)
55+
string value;
56+
try
57+
{
58+
var textModel = await this._editor.GetModel();
59+
value = await textModel.GetValue(EndOfLinePreference.TextDefined, false);
60+
}
61+
catch (Exception ex)
5962
{
63+
ValidationErrors.Add(new Error()
64+
{
65+
Column = 0,
66+
Line = 0,
67+
Message = $"Could not get text from editor. Please try again: {ex.Message}",
68+
Path = ""
69+
});
70+
Console.WriteLine(ex);
71+
return;
72+
}
73+
try
74+
{
75+
ValidateSubmission(value);
76+
if (!IsSchemaValid)
77+
{
78+
return;
79+
}
80+
}
81+
catch (Exception ex)
82+
{
83+
ValidationErrors.Add(new Error()
84+
{
85+
Column = 0,
86+
Line = 0,
87+
Message = $"Could not validate submission. Please try again: {ex.Message}",
88+
Path = ""
89+
});
90+
Console.WriteLine(ex);
6091
return;
6192
}
6293

@@ -75,6 +106,16 @@ public async Task SubmitResults()
75106
Message = f
76107
})));
77108
}
109+
else if (postAsync.StatusCode == HttpStatusCode.GatewayTimeout)
110+
{
111+
ValidationErrors.Add(new Error()
112+
{
113+
Column = 0,
114+
Line = 0,
115+
Message = $"You are currently rate limited. Please try again in {postAsync.StatusMessage}",
116+
Path = ""
117+
});
118+
}
78119
}
79120

80121
private async Task OnEditorInitialized()

0 commit comments

Comments
 (0)