+
doShowChildren(item.GRUPPO)">
@if (!isComp)
{
-
@item.Title
+
+ @item.NOME
+ @if (item.GRUPPO == currChildOpen)
+ {
+
+ }
+ else
+ {
+
+ }
+
}
else
{
-
+
+ }
+
+ }
+
+ @foreach (var link in NavMenuLinksChild)
+ {
+ @if (!isComp)
+ {
+
+ }
+ }
+
+ }
+ else
+ {
+
+
+ @if (!isComp)
+ {
+
+
@item.NOME
+ }
+ else
+ {
+
}
diff --git a/StockMan.CORE/Components/NewNavMenu.razor.cs b/StockMan.CORE/Components/NewNavMenu.razor.cs
index e055633..fd93c39 100644
--- a/StockMan.CORE/Components/NewNavMenu.razor.cs
+++ b/StockMan.CORE/Components/NewNavMenu.razor.cs
@@ -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
NavMenuLinks { get; set;} = new List();
+ public List? NavMenuLinks { get; set; } = null;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected bool isComp = false;
+ protected bool isChildOpen = false;
+ public List NavMenuLinksChild { get; set; } = new List();
+
+ 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;
+ }
}
}
\ No newline at end of file
diff --git a/StockMan.CORE/Components/NewNavMenu.razor.css b/StockMan.CORE/Components/NewNavMenu.razor.css
index c70fa27..cba9294 100644
--- a/StockMan.CORE/Components/NewNavMenu.razor.css
+++ b/StockMan.CORE/Components/NewNavMenu.razor.css
@@ -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;
}
\ No newline at end of file
diff --git a/StockMan.CORE/Components/NewNavMenu.razor.less b/StockMan.CORE/Components/NewNavMenu.razor.less
index 0e45626..cd9a5ea 100644
--- a/StockMan.CORE/Components/NewNavMenu.razor.less
+++ b/StockMan.CORE/Components/NewNavMenu.razor.less
@@ -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;
+}
diff --git a/StockMan.CORE/Components/NewNavMenu.razor.min.css b/StockMan.CORE/Components/NewNavMenu.razor.min.css
index 488c6ed..5daac3a 100644
--- a/StockMan.CORE/Components/NewNavMenu.razor.min.css
+++ b/StockMan.CORE/Components/NewNavMenu.razor.min.css
@@ -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;}
\ No newline at end of file
+.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;}
\ No newline at end of file
diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs
index 7e1177d..ab66902 100644
--- a/StockMan.CORE/Data/StockDataService.cs
+++ b/StockMan.CORE/Data/StockDataService.cs
@@ -108,6 +108,48 @@ namespace StockMan.CORE.Data
return dbResult;
}
+
+ ///
+ /// Lista Permessi
+ ///
+ ///
+ public async Task> PermessiGetAll()
+ {
+ string source = "DB";
+ List? dbResult = new List();
+ 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>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
+ }
+ else
+ {
+ dbResult = dbController.PermessiGetAll();
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, LongCache);
+ }
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"PermessiGetAll | {source} in: {ts.TotalMilliseconds} ms");
+ return dbResult;
+ }
+
///
/// Lista Famiglie Articoli da ricerca
///
@@ -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 _logger = null!;
private static StoManController dbController = null!;
diff --git a/StockMan.CORE/Shared/MainLayout.razor.cs b/StockMan.CORE/Shared/MainLayout.razor.cs
index 2d31150..82eaab6 100644
--- a/StockMan.CORE/Shared/MainLayout.razor.cs
+++ b/StockMan.CORE/Shared/MainLayout.razor.cs
@@ -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 navMenuLinks { get; set; } = new List();
+ protected List? 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() { "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
diff --git a/StockMan.CORE/wwwroot/lib/menuCompression.js b/StockMan.CORE/wwwroot/lib/menuCompression.js
index 8b8cc6c..faf0742 100644
--- a/StockMan.CORE/wwwroot/lib/menuCompression.js
+++ b/StockMan.CORE/wwwroot/lib/menuCompression.js
@@ -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);
}
\ No newline at end of file
diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs
index c6ccaef..398404d 100644
--- a/StockMan.Data/Controllers/StoManController.cs
+++ b/StockMan.Data/Controllers/StoManController.cs
@@ -18,6 +18,23 @@ namespace StockMan.Data.Controllers
#region Public Methods
+ ///
+ /// Lista Permessi
+ ///
+ ///
+ public List PermessiGetAll()
+ {
+ List dbResult = new List();
+ using (StockManContext localDbCtx = new StockManContext(_configuration))
+ {
+ dbResult = localDbCtx
+ .DbSetPermessi
+ .OrderBy(x => x.GRUPPO)
+ .ToList();
+ }
+ return dbResult;
+ }
+
///
/// Lista Contatori
///
diff --git a/StockMan.Data/DbModels/PermessiModel.cs b/StockMan.Data/DbModels/PermessiModel.cs
new file mode 100644
index 0000000..95d1ea3
--- /dev/null
+++ b/StockMan.Data/DbModels/PermessiModel.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace StockMan.Data.DbModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ [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!;
+ }
+}
diff --git a/StockMan.Data/StockManContext.cs b/StockMan.Data/StockManContext.cs
index 6000702..f342046 100644
--- a/StockMan.Data/StockManContext.cs
+++ b/StockMan.Data/StockManContext.cs
@@ -41,6 +41,7 @@ namespace StockMan.Data
public virtual DbSet DbSetLocation { get; set; } = null!;
public virtual DbSet DbSetMovType { get; set; } = null!;
public virtual DbSet DbSetOperator { get; set; } = null!;
+ public virtual DbSet DbSetPermessi { get; set; } = null!;
//public virtual DbSet DbSetVItemFlux2Save { get; set; } = null!;
//public virtual DbSet DbSetVItemFluxByLoc2Save { get; set; } = null!;
//public virtual DbSet DbSetVItemStockAct { get; set; } = null!;