89 lines
2.2 KiB
Plaintext
89 lines
2.2 KiB
Plaintext
@using GWMS.Data
|
|
@using GWMS.UI.Data
|
|
@using GWMS.UI.Components
|
|
|
|
@inject GWMSDataService DataService
|
|
@inject MessageService AppMService
|
|
@inject IJSRuntime JSRuntime
|
|
|
|
@if (!DbAllOk)
|
|
{
|
|
<div class="row">
|
|
<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">
|
|
<i class="fas fa-database"></i> Init Main DB
|
|
</Button>
|
|
</div>
|
|
}
|
|
else if (!DbIdentity)
|
|
{
|
|
<div class="col-3">
|
|
<Button id="btnReset" class="btn btn-warning btn-block" Clicked="initIdent">
|
|
<i class="fas fa-user-shield"></i> Init Ident DB
|
|
</Button>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
|
|
[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;
|
|
|
|
reportProcess();
|
|
await DbAdmin.migrateDbMain();
|
|
await ReloadData();
|
|
reportChange();
|
|
}
|
|
|
|
protected async Task initIdent()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione servizi Identity?"))
|
|
return;
|
|
|
|
reportProcess();
|
|
await DbAdmin.migrateDbIdentity();
|
|
await ReloadData();
|
|
reportChange();
|
|
}
|
|
|
|
protected bool DbUserOk { get; set; } = false;
|
|
protected bool DbIdentity { get; set; } = false;
|
|
protected bool DbAllOk { get; set; } = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
var resultIden = await Health.Checks.DbIdentity(DbConfig.DATABASE_NAME);
|
|
DbIdentity = (resultIden.Status == HealthStatus.Healthy);
|
|
DbAllOk = (DbIdentity);
|
|
}
|
|
|
|
private void reportChange()
|
|
{
|
|
evRefresh.InvokeAsync(1);
|
|
}
|
|
|
|
private void reportProcess()
|
|
{
|
|
evProcessing.InvokeAsync(1);
|
|
}
|
|
|
|
} |