Pagina cartellino QR Operatori

This commit is contained in:
Samuele Locatelli
2021-09-20 16:24:12 +02:00
parent d4b8116fc1
commit 521edc8f91
7 changed files with 218 additions and 80 deletions
+60
View File
@@ -0,0 +1,60 @@
@using MP.AppAuth.Models
@inject IJSRuntime JSRuntime
<div class="card">
<div class="card-header py-2 font-weight-bold">
<div class="row">
<div class="col-4 col-md-4">
<img src="img/LogoBlu.svg" class="img-fluid" width="32" /> EgalWare
</div>
<div class="col-8 text-right">
<h3 class="py-0 mb-0">@CardMessage</h3>
</div>
</div>
</div>
<div class="card-body px-3">
<div class="row">
<div class="col-6 col-md-4">
@*<img src="@Url.Action("QR", new { valore = @ViewBag.BaseUrl + "MatrOpr=" + @item.MatrOpr + "&UserAuthKey=" + item.authKey })" alt="Image 12345" class="img-fluid" />*@
<div id="qrCodeImg_@(CurrItem.MatrOpr)"></div>
</div>
<div class="col-6 col-md-8">
<h2><b>@CurrItem.Cognome</b> @CurrItem.Nome</h2>
matr: @CurrItem.MatrOpr
</div>
</div>
</div>
<div class="card-footer text-muted">
Card login MAPO-TAB
</div>
</div>
@code {
[Parameter]
public AnagraficaOperatori CurrItem { get; set; }
[Parameter]
public string CardMessage { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{CurrItem.MatrOpr}", rawCode);
}
protected string BaseUrl = "http://IIS01/";
protected string rawCode
{
get
{
string answ = "";
if (CurrItem != null)
{
answ = $"{BaseUrl}&MatrOpr={CurrItem.MatrOpr}&UserAuthKey={CurrItem.AuthKey}";
}
return answ;
}
}
}
+28
View File
@@ -0,0 +1,28 @@
@page "/UserQr"
@using MP.Land.Data
@using MP.Land.Components
<div class="card">
<div class="card-body">
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
@foreach (var item in ListRecords)
{
<div class="col-6 my-2 userCard">
<UserCard CurrItem="@item"></UserCard>
</div>
}
</div>
}
</div>
</div>
+102
View File
@@ -0,0 +1,102 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration;
using MP.AppAuth.Models;
using MP.Land.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Land.Pages
{
public partial class UserQr
{
#region Private Fields
private List<AnagraficaOperatori> ListRecords;
#endregion Private Fields
#region Protected Fields
protected string CardMessage = "User Card";
protected int totalCount = 0;
#endregion Protected Fields
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; }
private bool isLoading { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected AppAuthService DataService { get; set; }
#endregion Protected Properties
#region Protected Methods
protected bool authOk(UpdMan currItem)
{
bool answ = !string.IsNullOrEmpty(currItem.LicenseKey) && Convert.ToBoolean(currItem.IsAuth);
return answ;
}
protected string fullUrl(string relUrl)
{
return $"{Configuration["BaseUrl"]}{relUrl}";
}
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.PageName = "User Card";
AppMService.PageIcon = "fas fa-qrcode pr-2";
//AppMService.EA_SearchUpdated += OnSeachUpdated;
//AppMService.EA_FilterUpdated += OnFilterUpdated;
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
isLoading = true;
//MacList = await DataService.MacchineGetAll();
await ReloadData();
}
protected async Task ReloadData()
{
isLoading = true;
// importante altrimenti NON mostra update UI
await Task.Delay(1);
ListRecords = await DataService.AnagOperList();
totalCount = ListRecords.Count();
await Task.Delay(1);
}
protected MarkupString traduci(string lemma)
{
MarkupString answ;
//string rawHtml = "<li>primo</li><li>secondo</li>";
string rawHtml = DataService.Traduci(lemma, "IT");
answ = new MarkupString(rawHtml);
// cerco nella cache Redis
return answ;
}
#endregion Protected Methods
}
}