From 0401a6c9e755e777736339e421e5253992f5daf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:55:13 +0000 Subject: [PATCH 01/54] Bump HtmlSanitizer from 8.0.692 to 8.0.723 in /web Bumps [HtmlSanitizer](https://github.com/mganss/HtmlSanitizer) from 8.0.692 to 8.0.723. - [Release notes](https://github.com/mganss/HtmlSanitizer/releases) - [Commits](https://github.com/mganss/HtmlSanitizer/compare/v8.0.692...v8.0.723) --- updated-dependencies: - dependency-name: HtmlSanitizer dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- web/Viper.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/Viper.csproj b/web/Viper.csproj index 63fc56c..78acaf5 100644 --- a/web/Viper.csproj +++ b/web/Viper.csproj @@ -13,7 +13,7 @@ - + From 7a42f9b7de317bab092103c451460a09128e3154 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 23 Oct 2023 14:46:17 -0700 Subject: [PATCH 02/54] Trying alternate location for credentials --- web/Program.cs | 15 ++++++++++----- web/appsettings.Development.json | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/web/Program.cs b/web/Program.cs index ae20071..bbc72ab 100644 --- a/web/Program.cs +++ b/web/Program.cs @@ -45,12 +45,17 @@ try { // AWS Configurations - builder.Configuration.AddSystemsManager("/" + builder.Environment.EnvironmentName, new AWSOptions + AWSOptions awsOptions = new() { - Region = RegionEndpoint.USWest1 - }).AddSystemsManager("/Shared", new AWSOptions { - Region = RegionEndpoint.USWest1 - }); + Region = RegionEndpoint.USWest1 + }; + if(builder.Environment.EnvironmentName == "Test") + { + awsOptions.ProfilesLocation = "P:\\viper.net"; + } + builder.Configuration + .AddSystemsManager("/" + builder.Environment.EnvironmentName, awsOptions) + .AddSystemsManager("/Shared", awsOptions); } catch (Exception ex) { diff --git a/web/appsettings.Development.json b/web/appsettings.Development.json index cdda7d9..bb67fd7 100644 --- a/web/appsettings.Development.json +++ b/web/appsettings.Development.json @@ -2,8 +2,8 @@ "DetailedErrors": true, "Logging": { "LogLevel": { - "Default": "Warning", - "System": "Warning", + "Default": "Debug", + "System": "Debug", "Microsoft.EntityFrameworkCore.ChangeTracking": "Warning" } }, From 3a724d04c0e3fc1e51f3c8dc8ef5bf236255f9d3 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 23 Oct 2023 14:46:58 -0700 Subject: [PATCH 03/54] Removing duplicate function --- web/Areas/RAPS/Controllers/PermissionsController.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/web/Areas/RAPS/Controllers/PermissionsController.cs b/web/Areas/RAPS/Controllers/PermissionsController.cs index 9323067..858fb8c 100644 --- a/web/Areas/RAPS/Controllers/PermissionsController.cs +++ b/web/Areas/RAPS/Controllers/PermissionsController.cs @@ -34,14 +34,6 @@ public PermissionsController(RAPSContext context) _auditService = new RAPSAuditService(context); } - private static Expression> FilterToInstance(string instance) - { - return r => - instance.ToUpper() == "VIPER" - ? !r.Permission.ToUpper().StartsWith("VMACS.") && !r.Permission.ToUpper().StartsWith("VIPERFORMS") - : r.Permission.StartsWith("VMACS."); - } - // GET: Permissions [HttpGet] [Permission(Allow = "RAPS.Admin,RAPS.ViewPermissions")] @@ -53,7 +45,7 @@ public async Task>> GetTblPermissions(st } return await _context.TblPermissions .Include(p => p.TblMemberPermissions) - .Where(FilterToInstance(instance)) + .Where(RAPSSecurityService.FilterPermissionsToInstance(instance)) .OrderBy(p => p.Permission) .ToListAsync(); } From fc62011e8d9cd6fc97a32d47e235cf66ce9476e9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 23 Oct 2023 15:05:02 -0700 Subject: [PATCH 04/54] Another attempt at using shared credentials file --- web/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/Program.cs b/web/Program.cs index bbc72ab..17dd3c2 100644 --- a/web/Program.cs +++ b/web/Program.cs @@ -51,7 +51,8 @@ }; if(builder.Environment.EnvironmentName == "Test") { - awsOptions.ProfilesLocation = "P:\\viper.net"; + awsOptions.ProfilesLocation = "P:\\viper.net\\awscredentials"; + awsOptions.Profile = "default"; } builder.Configuration .AddSystemsManager("/" + builder.Environment.EnvironmentName, awsOptions) From 241a5036804e556586faaa40694ec7a9af877cf0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 23 Oct 2023 15:19:06 -0700 Subject: [PATCH 05/54] Setting aws creds location in config --- web/Program.cs | 3 +++ web/appsettings.Test.json | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/web/Program.cs b/web/Program.cs index 17dd3c2..3ac7a56 100644 --- a/web/Program.cs +++ b/web/Program.cs @@ -49,11 +49,14 @@ { Region = RegionEndpoint.USWest1 }; + + /* if(builder.Environment.EnvironmentName == "Test") { awsOptions.ProfilesLocation = "P:\\viper.net\\awscredentials"; awsOptions.Profile = "default"; } + */ builder.Configuration .AddSystemsManager("/" + builder.Environment.EnvironmentName, awsOptions) .AddSystemsManager("/Shared", awsOptions); diff --git a/web/appsettings.Test.json b/web/appsettings.Test.json index fea0534..0daea6a 100644 --- a/web/appsettings.Test.json +++ b/web/appsettings.Test.json @@ -14,5 +14,9 @@ }, "Cas": { "CasBaseUrl": "https://ssodev.ucdavis.edu/cas/" + }, + "AWS": { + "ProfilesLocation": "P:\\viper.net\\awscredentials", + "Profile": "default" } } \ No newline at end of file From 61e8fa20b58eee64d099c7ab6f3d80eb6da17c52 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 23 Oct 2023 15:28:22 -0700 Subject: [PATCH 06/54] Explicitly setting values --- web/Program.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/web/Program.cs b/web/Program.cs index 3ac7a56..b68b502 100644 --- a/web/Program.cs +++ b/web/Program.cs @@ -49,14 +49,11 @@ { Region = RegionEndpoint.USWest1 }; - - /* if(builder.Environment.EnvironmentName == "Test") { - awsOptions.ProfilesLocation = "P:\\viper.net\\awscredentials"; - awsOptions.Profile = "default"; + awsOptions.ProfilesLocation = builder.Configuration.GetValue("AWS:ProfilesLocation"); + awsOptions.Profile = builder.Configuration.GetValue("AWS:ProfilesLocation"); } - */ builder.Configuration .AddSystemsManager("/" + builder.Environment.EnvironmentName, awsOptions) .AddSystemsManager("/Shared", awsOptions); From b67eb822d7f41ace95bca3994760cf037a7876ab Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 25 Oct 2023 14:21:45 -0700 Subject: [PATCH 07/54] Fixing profile name --- web/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/Program.cs b/web/Program.cs index b68b502..4a9b81d 100644 --- a/web/Program.cs +++ b/web/Program.cs @@ -52,7 +52,7 @@ if(builder.Environment.EnvironmentName == "Test") { awsOptions.ProfilesLocation = builder.Configuration.GetValue("AWS:ProfilesLocation"); - awsOptions.Profile = builder.Configuration.GetValue("AWS:ProfilesLocation"); + awsOptions.Profile = builder.Configuration.GetValue("AWS:Profile"); } builder.Configuration .AddSystemsManager("/" + builder.Environment.EnvironmentName, awsOptions) From 2536341f337227373215872cac0e2fc01152cd60 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 1 Nov 2023 10:58:05 -0700 Subject: [PATCH 08/54] Using internal links for top nav. Adding dev/test css files. Using non-primary colors for top nav. --- .../Shared/Components/MainNav/Default.cshtml | 36 +++++++++---------- web/Views/Shared/_VIPERLayout.cshtml | 24 +++++-------- web/wwwroot/css/site-Development.css | 1 + web/wwwroot/css/site-Test.css | 1 + web/wwwroot/css/site.css | 9 +++++ 5 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 web/wwwroot/css/site-Development.css create mode 100644 web/wwwroot/css/site-Test.css diff --git a/web/Views/Shared/Components/MainNav/Default.cshtml b/web/Views/Shared/Components/MainNav/Default.cshtml index 006f9d2..7f1dc2f 100644 --- a/web/Views/Shared/Components/MainNav/Default.cshtml +++ b/web/Views/Shared/Components/MainNav/Default.cshtml @@ -4,8 +4,8 @@ RAPSContext? rapsContext = (RAPSContext?)Context.RequestServices.GetService(typeof(RAPSContext)); IUserHelper UserHelper = new UserHelper(); } - - + + VIPER 1.0 @@ -14,92 +14,92 @@ @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Accreditation")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.admin")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Analytics")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.CATS")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Curriculum")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Development")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Facilities")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Faculty")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Fiscal")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.IDCards.Apply")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Personnel")) { - + } - + @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Research")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Schedule")) { - + } @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Students")) { - + } - + diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 5f1936e..3df10eb 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -12,6 +12,12 @@ @ViewData["Title"] - VIPER(2.0) + @if (HttpHelper.Environment?.EnvironmentName != "Production") + { + + + + } @RenderSection("Styles", required: false) @@ -19,9 +25,9 @@ - + - + @await Component.InvokeAsync("MiniNav", new { @@ -279,20 +285,6 @@ } } }).use(Quasar).mount('body'); - - @if (HttpHelper.Environment?.EnvironmentName == "Development") - { - - Quasar.setCssVar('primary', '#092'); - - } - else if (HttpHelper.Environment?.EnvironmentName == "Test") - { - - Quasar.setCssVar('primary', '#d66902'); - - } - @await RenderSectionAsync("FinalScripts", required: false) diff --git a/web/wwwroot/css/site-Development.css b/web/wwwroot/css/site-Development.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/web/wwwroot/css/site-Development.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/wwwroot/css/site-Test.css b/web/wwwroot/css/site-Test.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/web/wwwroot/css/site-Test.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/wwwroot/css/site.css b/web/wwwroot/css/site.css index 418fa22..ab46e64 100644 --- a/web/wwwroot/css/site.css +++ b/web/wwwroot/css/site.css @@ -21,6 +21,15 @@ body { margin-bottom: 60px; } +/*Top nav/header styles*/ +#mainLayoutHeader { + background-color: #022851; +} + +#mainLayoutHeaderTabs { + background-color: #033266; +} + .sticky-header-table { /* height or max-height is important */ height: 600px; From 9a2b7bd1dcb41747b443b8a6dccd173f753aad86 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 1 Nov 2023 11:28:30 -0700 Subject: [PATCH 09/54] Increasing size of VIPER and handling test/development notice differently. --- web/Views/Shared/_VIPERLayout.cshtml | 28 ++++++++++++++-------------- web/wwwroot/css/site.css | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 3df10eb..9a13ffe 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -25,9 +25,9 @@ - + - + @await Component.InvokeAsync("MiniNav", new { @@ -38,18 +38,18 @@ - @if (HttpHelper.Environment?.EnvironmentName == "Development") - { - - } - else if (HttpHelper.Environment?.EnvironmentName == "Test") - { - - } - else - { - - } + + VIPER 2.0 + @if (HttpHelper.Environment?.EnvironmentName == "Development") + { + - Development + } + else if (HttpHelper.Environment?.EnvironmentName == "Test") + { + - Test + } + + @if (UserHelper.IsEmulating()) { diff --git a/web/wwwroot/css/site.css b/web/wwwroot/css/site.css index ab46e64..2a2d5fa 100644 --- a/web/wwwroot/css/site.css +++ b/web/wwwroot/css/site.css @@ -24,10 +24,25 @@ body { /*Top nav/header styles*/ #mainLayoutHeader { background-color: #022851; + /*background-color: white;*/ +} + +#mainLayoutViper { + font-family: Proxima Nova; + font-size: 1.6em; + font-weight: normal; + vertical-align: bottom; +} + +#mainLayoutViperMode { + margin-left: .6em; + margin-top: .2em; + vertical-align: bottom; + color: red; } #mainLayoutHeaderTabs { - background-color: #033266; + background-color: #1D4776; } .sticky-header-table { From f75a127bbe187c2a95edfe01738ec2c1678a3582 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 1 Nov 2023 11:55:51 -0700 Subject: [PATCH 10/54] Using UCD brand colors --- web/Views/Shared/_VIPERLayout.cshtml | 19 ++++++++++++++++--- web/wwwroot/css/site.css | 18 ++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 9a13ffe..2ac2a92 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -42,11 +42,11 @@ VIPER 2.0 @if (HttpHelper.Environment?.EnvironmentName == "Development") { - - Development + Development } else if (HttpHelper.Environment?.EnvironmentName == "Test") { - - Test + Test } @@ -284,7 +284,20 @@ vueUnmountedActions.shift().call(this); } } - }).use(Quasar).mount('body'); + }).use(Quasar, { + config: { + brand: { + primary: '#022851', + secondary: '#00B2E3', + accent: '#C6007E', + dark: '#191919', + positive: '#3DAE2B', + negative: '#F93549', + info: '#00C4B3', + warning: '#FFCD00' + } + } + }).mount('body'); @await RenderSectionAsync("FinalScripts", required: false) diff --git a/web/wwwroot/css/site.css b/web/wwwroot/css/site.css index 2a2d5fa..8f05a6f 100644 --- a/web/wwwroot/css/site.css +++ b/web/wwwroot/css/site.css @@ -1,5 +1,7 @@ html { font-size: 14px; + position: relative; + min-height: 100%; } @media (min-width: 768px) { @@ -8,19 +10,14 @@ html { } } -.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { - box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; -} - -html { - position: relative; - min-height: 100%; -} - body { margin-bottom: 60px; } +.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { + box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; +} + /*Top nav/header styles*/ #mainLayoutHeader { background-color: #022851; @@ -32,6 +29,7 @@ body { font-size: 1.6em; font-weight: normal; vertical-align: bottom; + margin-left: .6em; } #mainLayoutViperMode { @@ -72,7 +70,7 @@ body { } /* this is when the loading indicator appears */ -&.q-table--loading thead tr:last-child th { +.q-table--loading thead tr:last-child th { /* height of all previous header rows */ top: 48px; } From d4f65237949dc73398b67576a9572ddca772af30 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 1 Nov 2023 12:41:57 -0700 Subject: [PATCH 11/54] Fixing display of search and hiding on non-dev enviroments until it does something --- web/Views/Shared/_VIPERLayout.cshtml | 32 ++++++++++------------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 2ac2a92..524c506 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -57,9 +57,16 @@ } - - - + + @*Don't show the search until it does something*@ + @if (HttpHelper.Environment?.EnvironmentName == "Development") + { + + + + } @await Component.InvokeAsync("ProfilePic", new { @@ -81,18 +88,8 @@ ) - - @@ -288,6 +277,7 @@ config: { brand: { primary: '#022851', + //primary: '#1976d2', secondary: '#00B2E3', accent: '#C6007E', dark: '#191919', From b96cbaa48876c0aa2ea2e6f04239b57468db8227 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 1 Nov 2023 14:03:49 -0700 Subject: [PATCH 12/54] Replacing breadcrumb footers with links. Replace q-route-tab with q-btn. Making login button flat. --- .../Shared/Components/MainNav/Default.cshtml | 151 ++++++------------ .../Components/ProfilePic/Default.cshtml | 2 +- web/Views/Shared/_VIPERLayout.cshtml | 33 ++-- web/wwwroot/css/site.css | 11 +- 4 files changed, 82 insertions(+), 115 deletions(-) diff --git a/web/Views/Shared/Components/MainNav/Default.cshtml b/web/Views/Shared/Components/MainNav/Default.cshtml index 7f1dc2f..bfa12f5 100644 --- a/web/Views/Shared/Components/MainNav/Default.cshtml +++ b/web/Views/Shared/Components/MainNav/Default.cshtml @@ -3,108 +3,53 @@ @{ RAPSContext? rapsContext = (RAPSContext?)Context.RequestServices.GetService(typeof(RAPSContext)); IUserHelper UserHelper = new UserHelper(); -} - - - - VIPER 1.0 - - - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Accreditation")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.admin")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Analytics")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.CATS")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Curriculum")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Development")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Facilities")) - { - - - } + //I want to iterate over a list of links to show instead of copying/pasting the link + //[href, label, permission, tooltip?] + List tabLinks = new List + { + new string[] { "/", "1.0", "SVMSecure", "VIPER 1.0" }, + new string[] { "/Accreditation/default.cfm", "Accreditation", "SVMSecure.Accreditation" }, + new string[] { "/Admin/default.cfm", "Admin", "SVMSecure.admin" }, + new string[] { "/Analytics/default.cfm", "Analytics", "SVMSecure.Analytics" }, + new string[] { "/cats/default.cfm", "Computing", "SVMSecure.CATS" }, + new string[] { "/curriculum/default.cfm", "Curriculum", "SVMSecure.Curriculum" }, + new string[] { "/Development/default.cfm", "Development", "SVMSecure.Development" }, + new string[] { "/facilities/default.cfm", "Facilities", "SVMSecure.Facilities" }, + new string[] { "/faculty/default.cfm", "Faculty", "SVMSecure.Faculty" }, + new string[] { "/fiscal/default.cfm", "Fiscal", "SVMSecure.Fiscal" }, + new string[] { "/IDCards/default.cfm", "IDCards", "SVMSecure.IDCards.Apply" }, + new string[] { "/personnel/default.cfm", "Personnel", "SVMSecure.Personnel" }, + new string[] { "/policy/default.cfm", "Policies", "SVMSecure" }, + new string[] { "/research/default.cfm", "Research", "SVMSecure.Research" }, + new string[] { "/schedule/default.cfm", "Schedule", "SVMSecure.Schedule" }, + new string[] { "/students/default.cfm", "Students", "SVMSecure.Students" }, + new string[] { "/Hospital/default.cfm", "VMTH", "SVMSecure" }, + new string[] { "https://ucdsvm.knowledgeowl.com/help", "", "", "Help" } + }; - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Faculty")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Fiscal")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.IDCards.Apply")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Personnel")) - { - - - } - - - - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Research")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Schedule")) - { - - - } - - @if (UserHelper.HasPermission(rapsContext, Model, "SVMSecure.Students")) - { - - - } +} - - - - - - Help - - - - \ No newline at end of file +
+ + @{int i = 0;} + @foreach (string[] tabLink in tabLinks) + { + if (tabLink[0] == "https://ucdsvm.knowledgeowl.com/help") + { + + Help + + + } + else if (tabLink[2] == "" || UserHelper.HasPermission(rapsContext, Model, tabLink[2])) { + + @if(tabLink.Length >= 4 && tabLink[3] != "") + { + @tabLink[3] + } + + + } + } + +
\ No newline at end of file diff --git a/web/Views/Shared/Components/ProfilePic/Default.cshtml b/web/Views/Shared/Components/ProfilePic/Default.cshtml index 22fa3f2..a10378e 100644 --- a/web/Views/Shared/Components/ProfilePic/Default.cshtml +++ b/web/Views/Shared/Components/ProfilePic/Default.cshtml @@ -23,7 +23,7 @@ } else { - + Login diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 524c506..ffd327d 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -132,17 +132,30 @@ -
- -
+
From 14996dfc512e80d2e846aa3fb0c38b97d09c4487 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 2 Nov 2023 14:13:12 -0700 Subject: [PATCH 14/54] left nav enhancements. top nav selected tab. getting home page nav from cms. --- web/Areas/CMS/Data/LeftNavMenu.cs | 81 +++++++++++++++++++ web/Areas/RAPS/Controllers/RAPSController.cs | 4 +- web/Classes/AreaController.cs | 4 +- web/Classes/NavMenu.cs | 20 +++++ web/Classes/NavMenuItem.cs | 17 +++- web/Controllers/HomeController.cs | 10 +-- .../Shared/Components/MainNav/Default.cshtml | 30 ++----- .../Shared/Components/MainNav/MainNav.cs | 36 +++++++++ web/Views/Shared/_VIPERLayout.cshtml | 19 +++-- web/wwwroot/css/site.css | 38 ++++++++- 10 files changed, 211 insertions(+), 48 deletions(-) create mode 100644 web/Areas/CMS/Data/LeftNavMenu.cs create mode 100644 web/Classes/NavMenu.cs diff --git a/web/Areas/CMS/Data/LeftNavMenu.cs b/web/Areas/CMS/Data/LeftNavMenu.cs new file mode 100644 index 0000000..0056db2 --- /dev/null +++ b/web/Areas/CMS/Data/LeftNavMenu.cs @@ -0,0 +1,81 @@ +using Microsoft.EntityFrameworkCore; +using Viper.Areas.CMS.Models; +using Viper.Classes; +using Viper.Classes.SQLContext; +using Viper.Models.VIPER; + +namespace Viper.Areas.CMS.Data +{ + public class LeftNavMenu + { + private readonly VIPERContext? _viperContext; + private readonly RAPSContext? _rapsContext; + + public IUserHelper UserHelper; + + public LeftNavMenu() + { + this._viperContext = (VIPERContext?)HttpHelper.HttpContext?.RequestServices.GetService(typeof(VIPERContext)); + this._rapsContext = (RAPSContext?)HttpHelper.HttpContext?.RequestServices.GetService(typeof(RAPSContext)); + UserHelper = new UserHelper(); + } + + /// + /// Get one or more left nav + /// + /// The primary key of the menu + /// Friendly name of the menu + /// System + /// ViperSectionPath + /// Page + /// If true, filter items based on the permission of the logged in user. Should be set to false for CMS management functions. + /// List of menus matching the arguments + public IEnumerable? GetLeftNavMenus(int? leftNavMenuId = null, string? friendlyName = null, string? system = null, + string? viperSectionPath = null, string? page = null, bool filterItemsByPermissions=true) + { + var menus = _viperContext?.LeftNavMenus + .Include(m => m.LeftNavItems + .OrderBy(i => i.DisplayOrder)) + .ThenInclude(i => i.LeftNavItemToPermissions) + .Where(m => leftNavMenuId == null || m.LeftNavMenuId == leftNavMenuId) + .Where(m => string.IsNullOrEmpty(friendlyName) || m.FriendlyName == friendlyName) + .Where(m => string.IsNullOrEmpty(system) || m.System == system) + .Where(m => string.IsNullOrEmpty(viperSectionPath) || m.ViperSectionPath == viperSectionPath) + .Where(m => string.IsNullOrEmpty(page) || m.Page == page) + .ToList(); + if(menus == null) + { + return null; + } + + var currentUser = UserHelper.GetCurrentUser(); + List cmsMenus = new(); + foreach(var m in menus) + { + //by default, filter items based on user permissions + List items = new(); + foreach(var item in m.LeftNavItems) + { + bool includeItem = !filterItemsByPermissions; + if(filterItemsByPermissions) + { + foreach (var p in item.LeftNavItemToPermissions) + { + if (UserHelper.HasPermission(_rapsContext, currentUser, p.Permission)) + { + includeItem = true; + break; + } + } + } + if(includeItem) + { + items.Add(new(item)); + } + } + cmsMenus.Add(new(m.MenuHeaderText, items)); + } + return cmsMenus; + } + } +} diff --git a/web/Areas/RAPS/Controllers/RAPSController.cs b/web/Areas/RAPS/Controllers/RAPSController.cs index 11b5715..09ddcb0 100644 --- a/web/Areas/RAPS/Controllers/RAPSController.cs +++ b/web/Areas/RAPS/Controllers/RAPSController.cs @@ -65,7 +65,7 @@ public async Task Index(string? instance) } [Route("/[area]/{instance}/[action]")] - public async Task>> Nav(int? roleId, int? permissionId, string? memberId, string instance = "VIPER") + public async Task> Nav(int? roleId, int? permissionId, string? memberId, string instance = "VIPER") { TblRole? selectedRole = (roleId != null) ? await _RAPSContext.TblRoles.FindAsync(roleId) : null; TblPermission? selectedPermission = (permissionId != null) ? await _RAPSContext.TblPermissions.FindAsync(permissionId) : null; @@ -159,7 +159,7 @@ public async Task>> Nav(int? roleId, int? nav.Add(new NavMenuItem() { MenuItemText = "Export to VMACS", MenuItemURL = "ExportToVMACS" }); nav.Add(new NavMenuItem() { MenuItemText = "Update Role Views", MenuItemURL = "RoleViewUpdate" }); } - return nav; + return new NavMenu("RAPS", nav); } diff --git a/web/Classes/AreaController.cs b/web/Classes/AreaController.cs index 52a6c7f..e655730 100644 --- a/web/Classes/AreaController.cs +++ b/web/Classes/AreaController.cs @@ -5,10 +5,10 @@ namespace Viper.Classes public class AreaController : Controller { public AreaController() { } - public async Task>> Nav() + public async Task> Nav() { //TODO: get a default nav? - return await Task.Run(() => new List()); + return await Task.Run(() => new NavMenu("", new List())); } //TODO: Handle 403 and 500 errors here? diff --git a/web/Classes/NavMenu.cs b/web/Classes/NavMenu.cs new file mode 100644 index 0000000..b7d09a4 --- /dev/null +++ b/web/Classes/NavMenu.cs @@ -0,0 +1,20 @@ +namespace Viper.Classes +{ + public class NavMenu + { + public string? MenuHeaderText { get; set; } + public List? MenuItems { get; set; } + + + public NavMenu() + { + + } + + public NavMenu(string? menuHeaderText = null, List? menuItems = null) + { + MenuHeaderText = menuHeaderText; + MenuItems = menuItems; + } + } +} diff --git a/web/Classes/NavMenuItem.cs b/web/Classes/NavMenuItem.cs index 2aaed84..1601350 100644 --- a/web/Classes/NavMenuItem.cs +++ b/web/Classes/NavMenuItem.cs @@ -1,4 +1,6 @@ -namespace Viper.Classes +using Viper.Models.VIPER; + +namespace Viper.Classes { public class NavMenuItem { @@ -6,5 +8,18 @@ public class NavMenuItem public string MenuItemURL { get; set; } = ""; public bool IsHeader { get; set; } = false; public int DisplayOrder { get; set; } = 0; + + public NavMenuItem() + { + + } + + public NavMenuItem(LeftNavItem leftNavItem) + { + MenuItemText = leftNavItem.MenuItemText; + IsHeader = leftNavItem.IsHeader; + DisplayOrder = (int)(leftNavItem.DisplayOrder != null ? leftNavItem.DisplayOrder : 0); + MenuItemURL = leftNavItem.Url; + } } } diff --git a/web/Controllers/HomeController.cs b/web/Controllers/HomeController.cs index d8ef9a6..f3c5236 100644 --- a/web/Controllers/HomeController.cs +++ b/web/Controllers/HomeController.cs @@ -20,6 +20,7 @@ using Amazon.SimpleSystemsManagement.Model; using Viper.Classes.SQLContext; using Viper.Models.RAPS; +using Viper.Areas.CMS.Data; namespace Viper.Controllers { @@ -52,13 +53,10 @@ public IActionResult Index() } [Route("nav")] -#pragma warning disable IDE0060 // Remove unused parameter - public ActionResult> Nav(int? roleId, int? permissionId, string? memberId, string instance = "VIPER") -#pragma warning restore IDE0060 // Remove unused parameter + public ActionResult Nav() { - //TODO Populate homepage navigation - var nav = new List(); - return nav; + var menu = new LeftNavMenu().GetLeftNavMenus(friendlyName: "viper-home")?.FirstOrDefault(); + return menu ?? new NavMenu("", new List()); } /// diff --git a/web/Views/Shared/Components/MainNav/Default.cshtml b/web/Views/Shared/Components/MainNav/Default.cshtml index bfa12f5..fa7453d 100644 --- a/web/Views/Shared/Components/MainNav/Default.cshtml +++ b/web/Views/Shared/Components/MainNav/Default.cshtml @@ -3,30 +3,7 @@ @{ RAPSContext? rapsContext = (RAPSContext?)Context.RequestServices.GetService(typeof(RAPSContext)); IUserHelper UserHelper = new UserHelper(); - //I want to iterate over a list of links to show instead of copying/pasting the link - //[href, label, permission, tooltip?] - List tabLinks = new List - { - new string[] { "/", "1.0", "SVMSecure", "VIPER 1.0" }, - new string[] { "/Accreditation/default.cfm", "Accreditation", "SVMSecure.Accreditation" }, - new string[] { "/Admin/default.cfm", "Admin", "SVMSecure.admin" }, - new string[] { "/Analytics/default.cfm", "Analytics", "SVMSecure.Analytics" }, - new string[] { "/cats/default.cfm", "Computing", "SVMSecure.CATS" }, - new string[] { "/curriculum/default.cfm", "Curriculum", "SVMSecure.Curriculum" }, - new string[] { "/Development/default.cfm", "Development", "SVMSecure.Development" }, - new string[] { "/facilities/default.cfm", "Facilities", "SVMSecure.Facilities" }, - new string[] { "/faculty/default.cfm", "Faculty", "SVMSecure.Faculty" }, - new string[] { "/fiscal/default.cfm", "Fiscal", "SVMSecure.Fiscal" }, - new string[] { "/IDCards/default.cfm", "IDCards", "SVMSecure.IDCards.Apply" }, - new string[] { "/personnel/default.cfm", "Personnel", "SVMSecure.Personnel" }, - new string[] { "/policy/default.cfm", "Policies", "SVMSecure" }, - new string[] { "/research/default.cfm", "Research", "SVMSecure.Research" }, - new string[] { "/schedule/default.cfm", "Schedule", "SVMSecure.Schedule" }, - new string[] { "/students/default.cfm", "Students", "SVMSecure.Students" }, - new string[] { "/Hospital/default.cfm", "VMTH", "SVMSecure" }, - new string[] { "https://ucdsvm.knowledgeowl.com/help", "", "", "Help" } - }; - + List tabLinks = (List)ViewData["tabLinks"] ?? new List(); }
@@ -42,7 +19,10 @@ } else if (tabLink[2] == "" || UserHelper.HasPermission(rapsContext, Model, tabLink[2])) { - + @if(tabLink.Length >= 4 && tabLink[3] != "") { @tabLink[3] diff --git a/web/Views/Shared/Components/MainNav/MainNav.cs b/web/Views/Shared/Components/MainNav/MainNav.cs index 343f32d..750f9d0 100644 --- a/web/Views/Shared/Components/MainNav/MainNav.cs +++ b/web/Views/Shared/Components/MainNav/MainNav.cs @@ -15,6 +15,42 @@ public MainNavViewComponent() public async Task InvokeAsync(AaudUser user) { ViewData["OldViperURL"] = oldViperURL; + //I want to iterate over a list of links to show instead of copying/pasting the link + //[href, label, permission, tooltip?] + ViewData["tabLinks"] = new List + { + new string[] { "/", "1.0", "SVMSecure", "VIPER 1.0" }, + new string[] { "~/", "VIPER Home", "SVMSecure" }, + new string[] { "/Accreditation/default.cfm", "Accreditation", "SVMSecure.Accreditation" }, + new string[] { "/Admin/default.cfm", "Admin", "SVMSecure.admin" }, + new string[] { "/Analytics/default.cfm", "Analytics", "SVMSecure.Analytics" }, + new string[] { "/cats/default.cfm", "Computing", "SVMSecure.CATS" }, + new string[] { "/curriculum/default.cfm", "Curriculum", "SVMSecure.Curriculum" }, + new string[] { "/Development/default.cfm", "Development", "SVMSecure.Development" }, + new string[] { "/facilities/default.cfm", "Facilities", "SVMSecure.Facilities" }, + new string[] { "/faculty/default.cfm", "Faculty", "SVMSecure.Faculty" }, + new string[] { "/fiscal/default.cfm", "Fiscal", "SVMSecure.Fiscal" }, + new string[] { "/IDCards/default.cfm", "IDCards", "SVMSecure.IDCards.Apply" }, + new string[] { "/personnel/default.cfm", "Personnel", "SVMSecure.Personnel" }, + new string[] { "/policy/default.cfm", "Policies", "SVMSecure" }, + new string[] { "/research/default.cfm", "Research", "SVMSecure.Research" }, + new string[] { "/schedule/default.cfm", "Schedule", "SVMSecure.Schedule" }, + new string[] { "/students/default.cfm", "Students", "SVMSecure.Students" }, + new string[] { "/Hospital/default.cfm", "VMTH", "SVMSecure" }, + new string[] { "https://ucdsvm.knowledgeowl.com/help", "", "", "Help" } + }; + var path = HttpContext.Request.Path.Value; + var area = (path ?? "/").ToLower().Split("/"); + switch(area.Length >= 1 ? area[1] : area[0]) + { + case "raps": + ViewData["SelectedTopNav"] = "Computing"; + break; + default: + ViewData["SelectedTopNav"] = "VIPER Home"; + break; + } + return await Task.Run(() => View("Default", user)); } diff --git a/web/Views/Shared/_VIPERLayout.cshtml b/web/Views/Shared/_VIPERLayout.cshtml index 878dd55..66efdf9 100644 --- a/web/Views/Shared/_VIPERLayout.cshtml +++ b/web/Views/Shared/_VIPERLayout.cshtml @@ -89,9 +89,10 @@ - +