133 lines
4.9 KiB
Plaintext
133 lines
4.9 KiB
Plaintext
@using MP.MONO.Core
|
|
@using Newtonsoft.Json
|
|
|
|
@page "/Info"
|
|
|
|
@inject NavigationManager NavManager
|
|
|
|
<PageTitle>Machine Info</PageTitle>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<h2>Machine Info <button class="btn btn-primary" @onclick="() => ShowAll()">Expand All <i class="bi bi-caret-down-square"></i></button></h2>
|
|
</div>
|
|
<div class="col-6 text-end">
|
|
@if (!licOk)
|
|
{
|
|
<button class="btn btn-warning" @onclick="() => ToggleKeyMan()"><i class="bi bi-key"></i> Key Management</button>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
@if (showKeyMan)
|
|
{
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<h4>Gestione Licenza</h4>
|
|
</div>
|
|
<div class="col-4 text-center">
|
|
<a target="_blank" href="Download?fileName=@fileName" class="btn btn-block btn-warning"><span class="bi bi-file-earmark-arrow-down-fill"></span> Download Fingerprint File</a>
|
|
</div>
|
|
<div class="col-4">
|
|
<div class="input-group mb-3">
|
|
<input type="text" class="form-control" placeholder="license key" aria-label="license key" @bind-value="@licVal">
|
|
<button class="btn btn-outline-success" type="button" @onclick="() => SaveLic()">Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<DisplayInfo ParamName="CPU Info" currInfo="@cpuInfo" btnType="btn-primary" showSection="@showCpu"></DisplayInfo>
|
|
</div>
|
|
<div class="col-4">
|
|
<DisplayInfo ParamName="RAM Info" currInfo="@ramInfo" btnType="btn-primary mb-1" showSection="@showRam"></DisplayInfo>
|
|
<DisplayInfo ParamName="NET Info" currInfo="@netInfo" btnType="btn-primary" showSection="@showNet"></DisplayInfo>
|
|
</div>
|
|
<div class="col-4">
|
|
<DisplayInfo ParamName="OS Info" currInfo="@osInfo" btnType="btn-primary mb-1" showSection="@showOs"></DisplayInfo>
|
|
<DisplayInfo ParamName="BIOS Info" currInfo="@biosInfo" btnType="btn-primary" showSection="@showBios"></DisplayInfo>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private Dictionary<string, string> biosInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> cpuInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> netInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> osInfo = new Dictionary<string, string>();
|
|
private Dictionary<string, string> ramInfo = new Dictionary<string, string>();
|
|
|
|
private bool showBios = false;
|
|
private bool showCpu = false;
|
|
private bool showNet = false;
|
|
private bool showOs = false;
|
|
private bool showRam = false;
|
|
private bool showKeyMan = false;
|
|
|
|
private bool licOk = false;
|
|
|
|
private string licVal { get; set; } = "";
|
|
private string fileName { get; set; } = "InfoData.json";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
biosInfo = await MachineInfo.GetInfo("BIOS");
|
|
cpuInfo = await MachineInfo.GetInfo("CPU");
|
|
netInfo = await MachineInfo.GetInfo("NET");
|
|
osInfo = await MachineInfo.GetInfo("OS");
|
|
ramInfo = await MachineInfo.GetInfo("RAM");
|
|
// check licenze
|
|
licOk = await MachineDataValidator.testCurrInfo();
|
|
}
|
|
|
|
private void ShowAll()
|
|
{
|
|
showBios = true;
|
|
showCpu = true;
|
|
showNet = true;
|
|
showOs = true;
|
|
showRam = true;
|
|
}
|
|
|
|
private void ToggleKeyMan()
|
|
{
|
|
showKeyMan = !showKeyMan;
|
|
// salvo su disco...
|
|
saveInfoData();
|
|
}
|
|
|
|
private void saveInfoData()
|
|
{
|
|
var fullData = biosInfo.Concat(cpuInfo).Concat(netInfo).Concat(osInfo).Concat(ramInfo).GroupBy(ele => ele.Key).OrderBy(x => x.Key).ToDictionary(ele => ele.Key, ele => ele.First().Value);
|
|
string filePath = Path.Combine(baseDir, "temp", "InfoData.json");
|
|
File.WriteAllText(filePath, JsonConvert.SerializeObject(fullData, Formatting.Indented));
|
|
}
|
|
private string baseDir = $"{Directory.GetCurrentDirectory()}";
|
|
|
|
private async Task SaveLic()
|
|
{
|
|
//se ho un valore x la licenza...
|
|
if (!string.IsNullOrEmpty(licVal))
|
|
{
|
|
string filePath = Path.Combine(baseDir, "Conf", "lic.file");
|
|
File.WriteAllText(filePath, licVal);
|
|
}
|
|
|
|
// check licenze
|
|
licOk = await MachineDataValidator.testCurrInfo();
|
|
// se ok --> rivado ad home!
|
|
if (licOk)
|
|
{
|
|
await Task.Delay(1);
|
|
// rimando alla home
|
|
NavManager.NavigateTo("/", true);
|
|
}
|
|
}
|
|
}
|