First main page test prepared
This commit is contained in:
parent
906f2d6034
commit
4fe9bc7d87
7 changed files with 143 additions and 69 deletions
|
@ -5,10 +5,6 @@
|
|||
</div>
|
||||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
@Body
|
||||
</article>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="">TestingRoom_NN_Kajk_UI</a>
|
||||
<a class="navbar-brand" href="">NN - Kajk</a>
|
||||
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
@ -11,12 +11,12 @@
|
|||
<nav class="nav flex-column">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
|
||||
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Control
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="counter">
|
||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
||||
<NavLink class="nav-link" href="variables">
|
||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Variables
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
12
Models/VariablePostModel.cs
Normal file
12
Models/VariablePostModel.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace TestingRoom_NN_Kajk_UI.Models
|
||||
{
|
||||
public class VariablePostModel
|
||||
{
|
||||
public string data { get; set; }
|
||||
|
||||
[JsonPropertyName("default")]
|
||||
public bool Isdefault { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
@page "/counter"
|
||||
@page "/variables"
|
||||
|
||||
<PageTitle>Counter</PageTitle>
|
||||
|
||||
|
|
125
Pages/Home.razor
125
Pages/Home.razor
|
@ -1,7 +1,126 @@
|
|||
@page "/"
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
@using TestingRoom_NN_Kajk_UI.Models
|
||||
@inject HttpClient HttpClient
|
||||
|
||||
<h1>Hello, world!</h1>
|
||||
<PageTitle>Control</PageTitle>
|
||||
|
||||
Welcome to your new app.
|
||||
<div class="row align-content-center text-center align-items-center">
|
||||
<div class="col-sm-12 col-xl-6 col-xxl-4">
|
||||
<h2><b>Otáčky: @RPM_Actual RPM</b></h2>
|
||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="@RPM_Actual" aria-valuemin="0" aria-valuemax="@RPM_Max">
|
||||
<div class="progress-bar" style="width: @($"{Math.Round((RPM_Actual / RPM_Max), 2) * 100}%")"></div>
|
||||
</div>
|
||||
<h3/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-xl-6 col-xxl-4">
|
||||
<div class="align-content-center">
|
||||
<h4><b>Žádané otáčky:</b></h4>
|
||||
<div class="input-group mb-3">
|
||||
<input class="form-control text-center" type="number" min="0" max="@RPM_Max" value="@RPM_Requested" @onchange="(x) => SetRPMRequested(int.Parse(x.Value.ToString()))" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(-1)">-1</button>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(+1)">+1</button>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(-10)">-10</button>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(+10)">+10</button>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(-100)">-100</button>
|
||||
<button class="btn btn-primary" @onclick="() => AddRPMRequested(100)">+100</button>
|
||||
</div>
|
||||
|
||||
<h6/>
|
||||
|
||||
<div>
|
||||
@foreach (int i in RPM_Presets)
|
||||
{
|
||||
<button class="btn btn-primary" @onclick="() => SetRPMRequested(i)">@i RPM</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<h3/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@code{
|
||||
string RPM_Actual_Variable_Name = "actual_rpm";
|
||||
string RPM_Requested_Variable_Name = "requested_rpm";
|
||||
string RPM_Max_Variable_Name = "max_rpm";
|
||||
|
||||
float RPM_Actual = 0;
|
||||
float RPM_Max = 1900;
|
||||
float RPM_Requested = 0;
|
||||
List<int> RPM_Presets = new() { 0, 1500, 1800 };
|
||||
|
||||
private System.Timers.Timer RPM_Actual_Timer = new System.Timers.Timer(500); //actual RPM reader timer
|
||||
private System.Timers.Timer RPM_Requested_Timer = new System.Timers.Timer(5000); //requested RPM reader timer
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
//actual RPM request timer
|
||||
RPM_Actual_Timer.AutoReset = true;
|
||||
RPM_Actual_Timer.Elapsed += RequestActualRPM;
|
||||
RPM_Actual_Timer.Start();
|
||||
|
||||
//requested RPM request timer
|
||||
RPM_Requested_Timer.AutoReset = true;
|
||||
RPM_Requested_Timer.Elapsed += RequestRequestedRPM;
|
||||
RPM_Requested_Timer.Start();
|
||||
}
|
||||
|
||||
private void SetRPMRequested(int rpm)
|
||||
{
|
||||
RPM_Requested_Timer.Stop();
|
||||
RPM_Requested = rpm;
|
||||
SetRPMRequested();
|
||||
RPM_Requested_Timer.Start();
|
||||
}
|
||||
|
||||
private void AddRPMRequested(int add)
|
||||
{
|
||||
RPM_Requested_Timer.Stop();
|
||||
RPM_Requested += add;
|
||||
|
||||
if (RPM_Requested < 0)
|
||||
RPM_Requested = 0;
|
||||
if (RPM_Requested > RPM_Max)
|
||||
RPM_Requested = RPM_Max;
|
||||
|
||||
SetRPMRequested();
|
||||
RPM_Requested_Timer.Start();
|
||||
}
|
||||
|
||||
private async void RequestActualRPM(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
//RPM_Actual = float.Parse(await HttpClient.GetStringAsync($"/api/variables/{RPM_Actual_Variable_Name}"));
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void RequestRequestedRPM(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
//RPM_Requested = int.Parse(await HttpClient.GetStringAsync($"/api/variables/{RPM_Requested_Variable_Name}"));
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async void SetRPMRequested()
|
||||
{
|
||||
//await HttpClient.PostAsJsonAsync($"/api/variables/{RPM_Requested_Variable_Name}", new VariablePostModel { data = RPM_Requested.ToString(), Isdefault = false });
|
||||
}
|
||||
|
||||
private async void GetRPMMax()
|
||||
{
|
||||
//RPM_Max = int.Parse(await HttpClient.GetStringAsync($"/api/variables/{RPM_Requested_Variable_Name}"));
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
@page "/weather"
|
||||
@inject HttpClient Http
|
||||
|
||||
<PageTitle>Weather</PageTitle>
|
||||
|
||||
<h1>Weather</h1>
|
||||
|
||||
<p>This component demonstrates fetching data from the server.</p>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th aria-label="Temperature in Celsius">Temp. (C)</th>
|
||||
<th aria-label="Temperature in Farenheit">Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[]? forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
|
||||
}
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public string? Summary { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
}
|
|
@ -16,4 +16,8 @@
|
|||
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Add table
Reference in a new issue