Fix gestione init DB!
This commit is contained in:
@@ -11,42 +11,22 @@
|
||||
<div class="row h3">
|
||||
@if (!(DbUserOk && DbIdentity))
|
||||
{
|
||||
<div class="col-3 text-right">
|
||||
<b>App Setup</b>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button class="btn btn-block btn-warning" @onclick="() => toggleSetup()">
|
||||
<i class="fas fa-wrench pr-2" aria-hidden="true"></i> DB Setup
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-3 mb-3">
|
||||
<i class="fas fa-question-circle"></i>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
@if (ShowSetup)
|
||||
{
|
||||
<MigrationManager />
|
||||
}
|
||||
<MigrationManager evRefresh="()=> Done()" evProcessing="()=> Processing()" />
|
||||
</div>
|
||||
}
|
||||
@if (!DbLogOk)
|
||||
else if (!DbLogOk)
|
||||
{
|
||||
<div class="col-3 text-right">
|
||||
<b>Sim Data</b>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button class="btn btn-block btn-danger" @onclick="() => toggleSim()">
|
||||
<i class="fas fa-wrench pr-2" aria-hidden="true"></i> Setup SIMULAZIONE
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<i class="fas fa-question-circle"></i>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
@if (ShowSim)
|
||||
{
|
||||
<SetupSim />
|
||||
}
|
||||
<SetupSim evRefresh="()=> Done()" evProcessing="()=> Processing()" />
|
||||
</div>
|
||||
}
|
||||
@if (processRunning)
|
||||
{
|
||||
<div class="col-12 text-center">
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:75%"></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -59,14 +39,25 @@
|
||||
protected bool DbLogOk { get; set; } = false;
|
||||
protected bool DbAllOk { get; set; } = false;
|
||||
protected bool DbIdentity { get; set; } = false;
|
||||
protected bool ShowSim { get; set; } = false;
|
||||
protected bool ShowSetup { get; set; } = false;
|
||||
protected bool processRunning { get; set; } = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
processRunning = false;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task Processing()
|
||||
{
|
||||
processRunning = true;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task Done()
|
||||
{
|
||||
processRunning = false;
|
||||
await ReloadData();
|
||||
}
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
var resultUser = await Health.Checks.DbUserApp(DbConfig.DATABASE_NAME);
|
||||
@@ -78,14 +69,4 @@
|
||||
DbAllOk = (DbUserOk && DbLogOk && DbIdentity);
|
||||
}
|
||||
|
||||
protected async void toggleSim()
|
||||
{
|
||||
ShowSim = !ShowSim;
|
||||
await ReloadData();
|
||||
}
|
||||
protected async void toggleSetup()
|
||||
{
|
||||
ShowSetup = !ShowSetup;
|
||||
await ReloadData();
|
||||
}
|
||||
}
|
||||
@@ -9,47 +9,44 @@
|
||||
@if (!DbAllOk)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<h4>DB Init</h4>
|
||||
<div class="col-3 text-right">
|
||||
<h3>DB Init</h3>
|
||||
</div>
|
||||
@if (!DbUserOk)
|
||||
{
|
||||
<div class="col-3">
|
||||
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="initDb">
|
||||
<span class="oi oi-reload"></span> Init Main DB
|
||||
<i class="fas fa-database"></i> Init Main DB
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
@if (!DbIdentity)
|
||||
else if (!DbIdentity)
|
||||
{
|
||||
<div class="col-3">
|
||||
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="initIdent">
|
||||
<span class="oi oi-reload"></span> Init Ident DB
|
||||
<Button id="btnReset" class="btn btn-warning btn-block" Clicked="initIdent">
|
||||
<i class="fas fa-user-shield"></i> Init Ident DB
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
@if (processRunning)
|
||||
{
|
||||
<div class="offset-3 col-6">
|
||||
<i class="fas fa-circle-notch fa-spin fa-5x"></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
protected bool processRunning { get; set; } = false;
|
||||
[Parameter]
|
||||
public EventCallback<int> evRefresh { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<int> evProcessing { get; set; }
|
||||
|
||||
protected async Task initDb()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione DB?"))
|
||||
return;
|
||||
|
||||
processRunning = true;
|
||||
reportProcess();
|
||||
await DbAdmin.migrateDbMain();
|
||||
await ReloadData();
|
||||
processRunning = false;
|
||||
reportChange();
|
||||
}
|
||||
|
||||
protected async Task initIdent()
|
||||
@@ -57,10 +54,10 @@
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione servizi Identity?"))
|
||||
return;
|
||||
|
||||
processRunning = true;
|
||||
reportProcess();
|
||||
await DbAdmin.migrateDbIdentity();
|
||||
await ReloadData();
|
||||
processRunning = false;
|
||||
reportChange();
|
||||
}
|
||||
|
||||
protected bool DbUserOk { get; set; } = false;
|
||||
@@ -81,4 +78,14 @@
|
||||
DbAllOk = (DbUserOk && DbIdentity);
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
evRefresh.InvokeAsync(1);
|
||||
}
|
||||
|
||||
private void reportProcess()
|
||||
{
|
||||
evProcessing.InvokeAsync(1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,56 +5,73 @@
|
||||
@inject MessageService AppMService
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="p-2">
|
||||
<h4>Simulazione</h4>
|
||||
<div class="row">
|
||||
<div class="col-3 text-right">
|
||||
<h3>Simulazione</h3>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">giorni</span>
|
||||
<div class="col-9">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">giorni</span>
|
||||
</div>
|
||||
<input @bind-value="@numDays" @bind-value:event="oninput" type="number" class="form-control" title="Giorni" />
|
||||
</div>
|
||||
</div>
|
||||
<input @bind-value="@numDays" @bind-value:event="oninput" type="number" class="form-control" title="Giorni" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">step</span>
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">step</span>
|
||||
</div>
|
||||
<input @bind-value="@stepMin" @bind-value:event="oninput" type="number" class="form-control" title="Step sim (minuti)" />
|
||||
</div>
|
||||
</div>
|
||||
<input @bind-value="@stepMin" @bind-value:event="oninput" type="number" class="form-control" title="Step sim (minuti)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">cons orario max</span>
|
||||
<div class="p-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">cons orario max</span>
|
||||
</div>
|
||||
<input @bind-value="@maxHourRate" @bind-value:event="oninput" type="number" class="form-control" title="Consumo massimo orario" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="resetDB">
|
||||
<span class="oi oi-reload"></span> Regen DB Data
|
||||
</Button>
|
||||
</div>
|
||||
<input @bind-value="@maxHourRate" @bind-value:event="oninput" type="number" class="form-control" title="Consumo massimo orario" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="resetDB">
|
||||
<span class="oi oi-reload"></span> Regen DB Data
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> evRefresh { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<int> evProcessing { get; set; }
|
||||
|
||||
protected int numDays { get; set; } = 7;
|
||||
protected int stepMin { get; set; } = 30;
|
||||
protected int maxHourRate { get; set; } = 800;
|
||||
|
||||
protected bool processRunning { get; set; } = false;
|
||||
|
||||
protected async Task resetDB()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler risimulare l'intero set di dati?"))
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler risimulare il set di dati di Log?"))
|
||||
return;
|
||||
|
||||
processRunning = true;
|
||||
reportProcess();
|
||||
DataService.RegenDB(numDays, stepMin, maxHourRate);
|
||||
processRunning = false;
|
||||
reportChange();
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
evRefresh.InvokeAsync(1);
|
||||
}
|
||||
|
||||
private void reportProcess()
|
||||
{
|
||||
evProcessing.InvokeAsync(1);
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,6 @@
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user