2024-01-12 08:30:42 +00:00
|
|
|
@using UI_SequentMicrosystems.Services
|
|
|
|
|
|
|
|
@inject PointsService _PointsService
|
|
|
|
@inject IJSRuntime _JSRuntime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row text-center">
|
2024-01-12 22:22:40 +00:00
|
|
|
<div class="col-xs-12 col-md-2 align-self-center">
|
2024-01-12 08:30:42 +00:00
|
|
|
<button class="btn btn-dark text-white no-border" @onclick="(() => _PointsService.SavePoint())">Save Point (@_PointsService.GetPointsCount())</button>
|
|
|
|
</div>
|
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
<div class="col-xs-12 col-md row">
|
|
|
|
|
|
|
|
<div class="col-6 col-xl-4 align-self-center">
|
|
|
|
<input type="number" step="1" class="form-control form-control-sm bg-dark text-white no-border" value="@(_PointsService.GetTimerInterval())" @onchange="((x) =>
|
|
|
|
{
|
|
|
|
PointTimerChange(x.Value.ToString());
|
|
|
|
})">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-6 col-xl-6 text-start align-self-center">
|
|
|
|
<div class="form-check form-switch">
|
|
|
|
@if (TimerEnabled)
|
|
|
|
{
|
|
|
|
<input class="form-check-input align-self-center" type="checkbox" role="switch" id="SavePointsSwitch" @onclick="(() =>
|
|
|
|
{
|
|
|
|
TimerEnabled = false;
|
|
|
|
_PointsService.StopTimer();
|
|
|
|
})" checked>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input class="form-check-input align-self-center" type="checkbox" role="switch" id="SavePointsSwitch" @onclick="(() =>
|
|
|
|
{
|
|
|
|
TimerEnabled = true;
|
|
|
|
_PointsService.StartTimer();
|
|
|
|
})">
|
|
|
|
}
|
|
|
|
|
|
|
|
<label class="form-check-label" for="SavePointsSwitch">Auto Saving</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-xs-12 col-sm-5 row">
|
|
|
|
<div class="col-5 col-md-5 align-self-center">
|
2024-01-12 08:30:42 +00:00
|
|
|
<button class="btn btn-dark text-white no-border" @onclick="(() => DownloadFile())">Export as CSV</button>
|
|
|
|
</div>
|
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
<div class="col-7 col-md-7 text-start align-self-center">
|
2024-01-12 08:30:42 +00:00
|
|
|
<div class="form-check form-switch">
|
|
|
|
@if (RecalculateValues)
|
|
|
|
{
|
2024-01-12 22:22:40 +00:00
|
|
|
<input class="form-check-input" type="checkbox" role="switch" id="RecalculatePointSwitch" @onclick="(() =>
|
2024-01-12 08:30:42 +00:00
|
|
|
{
|
|
|
|
RecalculateValues = false;
|
|
|
|
})" checked>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-12 22:22:40 +00:00
|
|
|
<input class="form-check-input" type="checkbox" role="switch" id="RecalculatePointSwitch" @onclick="(() => RecalculateValues = true)">
|
2024-01-12 08:30:42 +00:00
|
|
|
}
|
2024-01-12 22:22:40 +00:00
|
|
|
<label class="form-check-label" for="RecalculatePointSwitch">Recalculate Values?</label>
|
2024-01-12 08:30:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
private bool RecalculateValues = false;
|
2024-01-12 22:22:40 +00:00
|
|
|
private bool TimerEnabled = false;
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
{
|
|
|
|
TimerEnabled = _PointsService.GetTImerStatus();
|
|
|
|
_PointsService.EventUpdateTopBar += UpdateView;
|
2024-01-12 08:30:42 +00:00
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
}
|
2024-01-12 08:30:42 +00:00
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Start downloading CSV file with points
|
|
|
|
/// </summary>
|
2024-01-12 08:30:42 +00:00
|
|
|
private async void DownloadFile()
|
|
|
|
{
|
|
|
|
// Název souboru
|
|
|
|
string fileName = "TESDevice1.csv";
|
|
|
|
|
|
|
|
// Vytvoření a spuštění odkazu ke stažení
|
|
|
|
await _JSRuntime.InvokeVoidAsync("DownloadFile", fileName, await _PointsService.CreatePointsFileLines(RecalculateValues));
|
|
|
|
}
|
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Timer Time Change
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="time"></param>
|
|
|
|
private void PointTimerChange(string? time)
|
|
|
|
{
|
|
|
|
if (time == null || time == "") { return; }
|
2024-01-12 08:30:42 +00:00
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
time = time.Replace(".", ",");
|
|
|
|
_PointsService.SetTimerInterval(int.Parse(time));
|
|
|
|
}
|
2024-01-12 08:30:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-12 22:22:40 +00:00
|
|
|
public async Task UpdateView(object? o, bool b)
|
|
|
|
{
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
{
|
|
|
|
StateHasChanged();
|
|
|
|
});
|
|
|
|
}
|
2024-01-12 08:30:42 +00:00
|
|
|
}
|