inizio aggancio data con menu

This commit is contained in:
zaccaria.majid
2023-02-07 16:54:57 +01:00
parent 624e4139ab
commit adf75a1cc9
11 changed files with 307 additions and 44 deletions
+42 -26
View File
@@ -26,39 +26,55 @@
@foreach (var item in NavMenuLinks)
{
<div>
@if (item.hasChildren)
@if (hasChild(item.GRUPPO))
{
<div class="navLinkItem" @onclick="()=>doShowChildren(item.Title)">
@if (!isComp)
{
<h5 class=""><i class="@item.Icon px-2"></i>@item.Title</h5>
}
else
{
<i class="@item.Icon"></i>
}
</div>
@foreach (var link in item.linkChildren)
if (item.NUMERO == 0)
{
@if (!isComp)
{
<div class="linkChildren" id="@item.Title">
<h6 class="navLinkChildrenText">@link</h6>
</div>
}
}
}
else
{
<a href="@item.Title" style="text-decoration: none; color: #000;">
<div class="navLinkItem">
<div class="@isActive(item.GRUPPO)" @onclick="()=>doShowChildren(item.GRUPPO)">
@if (!isComp)
{
<h5 class=""><i class="@item.Icon px-2"></i>@item.Title</h5>
<i class="@item.DESCRIZIONE"></i>
<h5>@item.NOME</h5>
@if (item.GRUPPO == currChildOpen)
{
<i class="fa-solid fa-chevron-up"></i>
}
else
{
<i class="fa-solid fa-chevron-down"></i>
}
}
else
{
<i class="@item.Icon"></i>
<i class="@item.DESCRIZIONE"></i>
}
</div>
}
<div class="linkChildren" id="@item.GRUPPO">
@foreach (var link in NavMenuLinksChild)
{
@if (!isComp)
{
<div class="text-center p-1">
<a class="navLinkChildrenText" href="@link.URL">@link.NOME</a>
</div>
}
}
</div>
}
else
{
<a href="@item.URL" style="text-decoration: none; color: #000;">
<div class="navLinkItem">
@if (!isComp)
{
<i class="@item.DESCRIZIONE"></i>
<h5>@item.NOME</h5>
}
else
{
<i class="@item.DESCRIZIONE"></i>
}
</div>
</a>
+66 -3
View File
@@ -14,33 +14,96 @@ using Microsoft.JSInterop;
using StockMan.CORE;
using StockMan.CORE.Shared;
using StockMan.CORE.Data;
using StockMan.Data.DbModels;
using Microsoft.Extensions.Hosting;
namespace StockMan.CORE.Components
{
public partial class NewNavMenu
{
[Parameter]
public List<LinkMan> NavMenuLinks { get; set;} = new List<LinkMan>();
public List<PermessiModel>? NavMenuLinks { get; set; } = null;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected bool isComp = false;
protected bool isChildOpen = false;
public List<PermessiModel> NavMenuLinksChild { get; set; } = new List<PermessiModel>();
protected int currChildOpen { get; set; } = 0;
protected void compress()
{
JSRuntime.InvokeVoidAsync("closeNav");
isComp = true;
}
protected void doShowChildren(string id)
protected void doShowChildren(int id)
{
JSRuntime.InvokeVoidAsync("doShowChildren", id);
if (currChildOpen != 0)
{
JSRuntime.InvokeVoidAsync("doHideChildren", currChildOpen);
}
else
{
currChildOpen = id;
}
isChildOpen = !isChildOpen;
NavMenuLinksChild.Clear();
if (NavMenuLinks != null)
{
var lista = NavMenuLinks.Where(x => x.GRUPPO == id).ToList();
if (lista.Count != 1)
{
foreach (var item in lista)
{
if (item.NUMERO != 0)
{
NavMenuLinksChild.Add(item);
}
}
}
}
if (!isChildOpen)
{
JSRuntime.InvokeVoidAsync("doShowChildren", id);
}
else
{
JSRuntime.InvokeVoidAsync("doHideChildren", id);
currChildOpen= 0;
}
}
protected string isActive(int gruppo)
{
string answ = "navLinkItem";
if (gruppo == currChildOpen)
{
answ = "navLinkItemActive";
}
return answ;
}
protected void deCompress()
{
JSRuntime.InvokeVoidAsync("openNav");
JSRuntime.InvokeVoidAsync("showMenuBtn");
isComp = false;
}
protected bool hasChild(int group)
{
bool hasIt = false;
if (NavMenuLinks != null)
{
var lista = NavMenuLinks.Where(x => x.GRUPPO == group).ToList();
if (lista.Count != 1)
{
hasIt = true;
}
}
return hasIt;
}
}
}
+48 -2
View File
@@ -55,18 +55,64 @@
transition: 0.25s;
}
.linkChildren {
align-content: center;
height: 0%;
align-content: start;
display: none;
height: 0%;
transition: 1s;
}
.linkChildren div {
background-color: rgba(179, 157, 219, 0.2);
transition: background-color 200ms ease-out 100ms;
}
.linkChildren div:hover {
background-color: #7e57c2;
}
.linkChildren div:hover a {
color: #fff;
}
.navLinkItem {
text-decoration: none;
padding: 1rem;
border-radius: 1rem;
transition: background-color 300ms ease-out 100ms;
display: flex;
width: 100%;
justify-content: space-between;
}
.navLinkItemActive {
text-decoration: none;
padding: 1rem;
transition: background-color 300ms ease-out 100ms;
display: flex;
width: 100%;
border-radius: 1rem 1rem 0 0;
background-color: #8e44ad;
justify-content: space-between;
color: #fff;
}
.navLinkItem:hover {
background-color: rgba(179, 157, 219, 0.2);
color: #7e57c2;
}
.navLinkChildrenText {
text-decoration: none;
color: #000;
}
.navLinkItem i,
.navLinkItemActive i {
width: 25%;
text-align: center;
display: flex;
justify-content: center;
align-content: center;
flex-wrap: wrap;
font-size: 1rem;
}
.navLinkItem h5,
.navLinkItemActive h5 {
width: 75%;
text-align: center;
display: flex;
flex-wrap: wrap;
align-content: center;
}
+54 -4
View File
@@ -45,7 +45,6 @@
}
.links .navItem {
//margin-right: 50%;
}
@@ -70,20 +69,71 @@
.linkChildren {
align-content: center;
height: 0%;
align-content: start;
display: none;
height: 0%;
transition: 1s;
}
.linkChildren div {
background-color: rgba(179, 157, 219, 0.2);
transition: background-color 200ms ease-out 100ms;
}
.linkChildren div:hover {
background-color: rgb(126, 87, 194);
a {
color: #fff;
}
}
.navLinkItem {
text-decoration: none;
padding: 1rem;
border-radius: 1rem;
transition: background-color 300ms ease-out 100ms
transition: background-color 300ms ease-out 100ms;
display: flex;
width: 100%;
justify-content: space-between;
}
.navLinkItemActive {
text-decoration: none;
padding: 1rem;
transition: background-color 300ms ease-out 100ms;
display: flex;
width: 100%;
border-radius: 1rem 1rem 0 0;
background-color: rgb(142, 68, 173);
justify-content: space-between;
color: #fff;
}
.navLinkItem:hover {
background-color: rgba(179, 157, 219, 0.2);
color: rgb(126, 87, 194);
}
.navLinkChildrenText {
text-decoration: none;
color: #000;
}
.navLinkItem i, .navLinkItemActive i {
width: 25%;
text-align: center;
display: flex;
justify-content: center;
align-content: center;
flex-wrap: wrap;
font-size: 1rem;
}
.navLinkItem h5, .navLinkItemActive h5 {
width: 75%;
text-align: center;
display: flex;
flex-wrap: wrap;
align-content: center;
}
+1 -1
View File
@@ -1 +1 @@
.navMenu{background-color:#f00;height:100%;width:100%;margin:.8rem .8rem .8rem .8rem;padding:1rem;width:18rem;height:97vh;position:sticky;border-radius:1.5rem;background-color:#f0f0f0;box-shadow:3px 3px 10px 0 #d1d1d1;transition:.35s;}#myBtn{transition:.25s;border:0;background:none;}.title{text-align:center;display:flex;justify-content:space-between;transition:1s;}.icon{margin-top:.5rem;padding:.8rem;background-color:#d9d9d9;border-radius:50%;}.title h4{margin-top:.7rem;}.links{align-content:center;text-align:center;display:grid;height:100%;}.decoration{text-decoration:none;}.bot{position:absolute;bottom:1rem;}.navLinkIcon{padding:0;margin:0;}.navLinkIcon,.navLinkText{width:50%;transition:.25s;}.linkChildren{align-content:center;height:0%;display:none;transition:1s;}.navLinkItem{text-decoration:none;padding:1rem;border-radius:1rem;transition:background-color 300ms ease-out 100ms;}.navLinkItem:hover{background-color:rgba(179,157,219,.2);color:#7e57c2;}
.navMenu{background-color:#f00;height:100%;width:100%;margin:.8rem .8rem .8rem .8rem;padding:1rem;width:18rem;height:97vh;position:sticky;border-radius:1.5rem;background-color:#f0f0f0;box-shadow:3px 3px 10px 0 #d1d1d1;transition:.35s;}#myBtn{transition:.25s;border:0;background:none;}.title{text-align:center;display:flex;justify-content:space-between;transition:1s;}.icon{margin-top:.5rem;padding:.8rem;background-color:#d9d9d9;border-radius:50%;}.title h4{margin-top:.7rem;}.links{align-content:center;text-align:center;display:grid;height:100%;}.decoration{text-decoration:none;}.bot{position:absolute;bottom:1rem;}.navLinkIcon{padding:0;margin:0;}.navLinkIcon,.navLinkText{width:50%;transition:.25s;}.linkChildren{align-content:start;display:none;height:0%;transition:1s;}.linkChildren div{background-color:rgba(179,157,219,.2);transition:background-color 200ms ease-out 100ms;}.linkChildren div:hover{background-color:#7e57c2;}.linkChildren div:hover a{color:#fff;}.navLinkItem{text-decoration:none;padding:1rem;border-radius:1rem;transition:background-color 300ms ease-out 100ms;display:flex;width:100%;justify-content:space-between;}.navLinkItemActive{text-decoration:none;padding:1rem;transition:background-color 300ms ease-out 100ms;display:flex;width:100%;border-radius:1rem 1rem 0 0;background-color:#8e44ad;justify-content:space-between;color:#fff;}.navLinkItem:hover{background-color:rgba(179,157,219,.2);color:#7e57c2;}.navLinkChildrenText{text-decoration:none;color:#000;}.navLinkItem i,.navLinkItemActive i{width:25%;text-align:center;display:flex;justify-content:center;align-content:center;flex-wrap:wrap;font-size:1rem;}.navLinkItem h5,.navLinkItemActive h5{width:75%;text-align:center;display:flex;flex-wrap:wrap;align-content:center;}
+43
View File
@@ -108,6 +108,48 @@ namespace StockMan.CORE.Data
return dbResult;
}
/// <summary>
/// Lista Permessi
/// </summary>
/// <returns></returns>
public async Task<List<PermessiModel>> PermessiGetAll()
{
string source = "DB";
List<PermessiModel>? dbResult = new List<PermessiModel>();
string currKey = $"{rKeyPermessi}:All";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<PermessiModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<PermessiModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.PermessiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
if (dbResult == null)
{
dbResult = new List<PermessiModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"PermessiGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Lista Famiglie Articoli da ricerca
/// </summary>
@@ -217,6 +259,7 @@ namespace StockMan.CORE.Data
private const string rKeyLocType = $"{redisBaseAddr}:Cache:LocType";
private const string rKeyMovType = $"{redisBaseAddr}:Cache:MovType";
private const string rKeyOperator = $"{redisBaseAddr}:Cache:Operator";
private const string rKeyPermessi = $"{redisBaseAddr}:Cache:Permessi";
private static IConfiguration _configuration = null!;
private static ILogger<StockDataService> _logger = null!;
private static StoManController dbController = null!;
+7 -7
View File
@@ -1,4 +1,6 @@
using StockMan.CORE.Data;
using Microsoft.AspNetCore.Components;
using StockMan.CORE.Data;
using StockMan.Data.DbModels;
using System.Net;
namespace StockMan.CORE.Shared
@@ -6,8 +8,10 @@ namespace StockMan.CORE.Shared
public partial class MainLayout
{
#region Protected Properties
[Inject]
protected StockDataService SDService { get; set; } = null!;
protected List<LinkMan> navMenuLinks { get; set; } = new List<LinkMan>();
protected List<PermessiModel>? navMenuLinks { get; set; } = null;
#endregion Protected Properties
@@ -16,11 +20,7 @@ namespace StockMan.CORE.Shared
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
navMenuLinks.Clear();
navMenuLinks.Add(new LinkMan() { Title = "Articolo", Icon = "fa-solid fa-box", hasChildren = true, linkChildren = new List<string>() { "Anagrafica articoli", "Famiglia articoli" } });
navMenuLinks.Add(new LinkMan() { Title = "Magazzino", Icon = "fa-solid fa-boxes-stacked" });
navMenuLinks.Add(new LinkMan() { Title = "Anagrafiche", Icon = "fa-solid fa-clipboard-list" });
navMenuLinks.Add(new LinkMan() { Title = "Admin", Icon = "fa-solid fa-id-card-clip" });
navMenuLinks = await SDService.PermessiGetAll();
}
#endregion Protected Methods
+6 -1
View File
@@ -9,5 +9,10 @@ function closeNav() {
function doShowChildren(id) {
document.getElementById(id).style.display = "block";
document.getElementsByClassName("linkChildren").style.height = "100%";
console.log(id);
}
function doHideChildren(id) {
document.getElementById(id).style.display = "none";
console.log(id);
}
@@ -18,6 +18,23 @@ namespace StockMan.Data.Controllers
#region Public Methods
/// <summary>
/// Lista Permessi
/// </summary>
/// <returns></returns>
public List<PermessiModel> PermessiGetAll()
{
List<PermessiModel> dbResult = new List<PermessiModel>();
using (StockManContext localDbCtx = new StockManContext(_configuration))
{
dbResult = localDbCtx
.DbSetPermessi
.OrderBy(x => x.GRUPPO)
.ToList();
}
return dbResult;
}
/// <summary>
/// Lista Contatori
/// </summary>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace StockMan.Data.DbModels
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
[Table("Permessi")]
public partial class PermessiModel
{
[Key]
public string COD_PERMESSO { get; set; } = null!;
public string URL { get; set; } = null!;
public int GRUPPO { get; set; } = 0;
public int NUMERO { get; set; } = 0;
public string NOME { get; set; } = null!;
public string DESCRIZIONE { get; set; } = null!;
}
}
+1
View File
@@ -41,6 +41,7 @@ namespace StockMan.Data
public virtual DbSet<LocationModel> DbSetLocation { get; set; } = null!;
public virtual DbSet<MovTypeModel> DbSetMovType { get; set; } = null!;
public virtual DbSet<OperatorModel> DbSetOperator { get; set; } = null!;
public virtual DbSet<PermessiModel> DbSetPermessi { get; set; } = null!;
//public virtual DbSet<VItemFlux2Save> DbSetVItemFlux2Save { get; set; } = null!;
//public virtual DbSet<VItemFluxByLoc2Save> DbSetVItemFluxByLoc2Save { get; set; } = null!;
//public virtual DbSet<VItemStockAct> DbSetVItemStockAct { get; set; } = null!;