Skip to content

Commit 0bb6059

Browse files
authored
Merge pull request #586 from TechnologyEnhancedLearning/RC
Merge Arizona release to master
2 parents 9e9fb49 + 666871b commit 0bb6059

File tree

51 files changed

+1046
-35
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1046
-35
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Controllers/UserGroupController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public async Task<IActionResult> AddUsersToUserGroup(int userGroupId, string use
257257
var vr = await this.userGroupService.AddUsersToUserGroup(userGroupId, userIdList);
258258
if (vr.IsValid)
259259
{
260+
this.ClearUserCachedPermissions(userIdList);
260261
return this.Json(new
261262
{
262263
success = true,
@@ -527,5 +528,16 @@ public async Task<IActionResult> UserGroupCatalogues(int id)
527528

528529
return this.PartialView("_UserGroupCatalogues", catalogues);
529530
}
531+
532+
private void ClearUserCachedPermissions(string userIdList)
533+
{
534+
if (!string.IsNullOrWhiteSpace(userIdList))
535+
{
536+
foreach (var userId in userIdList.Split(","))
537+
{
538+
_ = Task.Run(async () => { await this.userService.ClearUserCachedPermissions(int.Parse(userId)); });
539+
}
540+
}
541+
}
530542
}
531543
}

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
9090
<PackageReference Include="IdentityModel" Version="4.4.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.38" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />

LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ public class FindwiseSettings
1414
/// Gets or sets the CatalogueSearchPageSize.
1515
/// </summary>
1616
public int CatalogueSearchPageSize { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets the AllCatalogueSearchPageSize.
20+
/// </summary>
21+
public int AllCatalogueSearchPageSize { get; set; }
1722
}
1823
}

LearningHub.Nhs.WebUI/Configuration/Settings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,10 @@ public Settings()
245245
/// Gets or sets the MediaKindSettings.
246246
/// </summary>
247247
public MediaKindSettings MediaKindSettings { get; set; } = new MediaKindSettings();
248+
249+
/// <summary>
250+
/// Gets or sets AllCataloguePageSize.
251+
/// </summary>
252+
public int AllCataloguePageSize { get; set; }
248253
}
249254
}

LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public async Task<IActionResult> Index(int pageIndex = 1, string term = null)
123123
BookmarkId = t.BookmarkId,
124124
NodeId = int.Parse(t.Id),
125125
BadgeUrl = t.BadgeUrl,
126+
Providers = t.Providers,
126127
}).ToList();
127128
}
128129
else
@@ -551,5 +552,70 @@ public async Task<IActionResult> RequestPreviewAccess(CatalogueRequestAccessView
551552
return this.View("RequestPreviewAccess", viewModel);
552553
}
553554
}
555+
556+
/// <summary>
557+
/// Get all catelogues, filter and pagination based on alphabets.
558+
/// </summary>
559+
/// <param name="filterChar">filterChar.</param>
560+
/// <returns>rk.</returns>
561+
[Route("/allcatalogue")]
562+
[Route("/allcatalogue/{filterChar}")]
563+
public async Task<IActionResult> GetAllCatalogue(string filterChar = "a")
564+
{
565+
var pageSize = this.settings.AllCataloguePageSize;
566+
var catalogues = await this.catalogueService.GetAllCatalogueAsync(filterChar, pageSize);
567+
return this.View("allcatalogue", catalogues);
568+
}
569+
570+
/// <summary>
571+
/// AllCatalogues Search.
572+
/// </summary>
573+
/// <param name="pageIndex">pageIndex.</param>
574+
/// <param name="term">Search term.</param>
575+
/// <returns>IActionResult.</returns>
576+
[Route("/allcataloguesearch")]
577+
public async Task<IActionResult> GetAllCatalogueSearch(int pageIndex = 1, string term = null)
578+
{
579+
var catalogues = new AllCatalogueSearchResponseViewModel();
580+
var searchString = term?.Trim() ?? string.Empty;
581+
var allCatalogueSearchPageSize = this.settings.FindwiseSettings.AllCatalogueSearchPageSize;
582+
583+
if (!string.IsNullOrWhiteSpace(term))
584+
{
585+
var termCatalogues = await this.searchService.GetAllCatalogueSearchResultAsync(
586+
new AllCatalogueSearchRequestModel
587+
{
588+
SearchText = searchString,
589+
PageIndex = pageIndex - 1,
590+
PageSize = allCatalogueSearchPageSize,
591+
});
592+
593+
catalogues.TotalCount = termCatalogues.TotalHits;
594+
catalogues.Catalogues = termCatalogues.DocumentModel.Select(t => new AllCatalogueViewModel
595+
{
596+
Url = t.Url,
597+
Name = t.Name,
598+
CardImageUrl = t.CardImageUrl,
599+
BannerUrl = t.BannerUrl,
600+
Description = t.Description,
601+
RestrictedAccess = t.RestrictedAccess,
602+
HasAccess = t.HasAccess,
603+
IsBookmarked = t.IsBookmarked,
604+
BookmarkId = t.BookmarkId,
605+
NodeId = int.Parse(t.Id),
606+
BadgeUrl = t.BadgeUrl,
607+
Providers = t.Providers,
608+
}).ToList();
609+
}
610+
else
611+
{
612+
catalogues.TotalCount = 0;
613+
catalogues.Catalogues = new List<AllCatalogueViewModel>();
614+
}
615+
616+
this.ViewBag.PageIndex = pageIndex;
617+
this.ViewBag.PageSize = allCatalogueSearchPageSize;
618+
return this.View("AllCatalogueSearch", catalogues);
619+
}
554620
}
555621
}

LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,13 @@ public interface ICatalogueService
138138
/// <param name="userUserGroupId">The user - user group id.</param>
139139
/// <returns>The validation result.</returns>
140140
Task<LearningHubValidationResult> RemoveUserFromRestrictedAccessUserGroup(int userUserGroupId);
141+
142+
/// <summary>
143+
/// The GetAllCatalogueAsync.
144+
/// </summary>
145+
/// <param name="filterChar">The letter.</param>
146+
/// <param name="pageSize">The pageSize.</param>
147+
/// <returns>The allcatalogue result based on letters.</returns>
148+
Task<AllCatalogueResponseViewModel> GetAllCatalogueAsync(string filterChar, int pageSize);
141149
}
142150
}

LearningHub.Nhs.WebUI/Interfaces/ISearchService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,12 @@ public interface ISearchService
7777
/// <param name="catalogueSearchRequestModel">catalogue search request model.</param>
7878
/// <returns>The <see cref="Task"/>.</returns>
7979
Task<int> CreateCatalogueSearchTermEventAsync(CatalogueSearchRequestModel catalogueSearchRequestModel);
80+
81+
/// <summary>
82+
/// Get AllCatalogue Search Result Async.
83+
/// </summary>
84+
/// <param name="catalogueSearchRequestModel">The catalogue Search Request Model.</param>
85+
/// <returns>The <see cref="Task{SearchAllCatalogueViewModel}"/>.</returns>
86+
Task<SearchAllCatalogueViewModel> GetAllCatalogueSearchResultAsync(AllCatalogueSearchRequestModel catalogueSearchRequestModel);
8087
}
8188
}

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<PackageReference Include="HtmlAgilityPack" Version="1.11.38" />
109109
<PackageReference Include="IdentityModel" Version="4.3.0" />
110110
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
111-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
111+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.38" />
112112
<PackageReference Include="linqtotwitter" Version="6.9.0" />
113113
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
114114
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />

LearningHub.Nhs.WebUI/Models/NavigationModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ public class NavigationModel
6969
/// Gets or sets a value indicating whether to show my account.
7070
/// </summary>
7171
public bool ShowMyAccount { get; set; }
72+
73+
/// <summary>
74+
/// Gets or sets a value indicating whether to show Browse Catalogues.
75+
/// </summary>
76+
public bool ShowBrowseCatalogues { get; set; }
7277
}
7378
}

LearningHub.Nhs.WebUI/Services/CatalogueService.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,5 +602,33 @@ public async Task<LearningHubValidationResult> RemoveUserFromRestrictedAccessUse
602602

603603
return apiResponse.ValidationResult;
604604
}
605+
606+
/// <summary>
607+
/// GetAllCatalogueAsync.
608+
/// </summary>
609+
/// <param name="filterChar">The filterChar.</param>
610+
/// <param name="pageSize">the pageSize.</param>
611+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
612+
public async Task<AllCatalogueResponseViewModel> GetAllCatalogueAsync(string filterChar, int pageSize)
613+
{
614+
AllCatalogueResponseViewModel viewmodel = new AllCatalogueResponseViewModel { };
615+
var client = await this.LearningHubHttpClient.GetClientAsync();
616+
617+
var request = $"catalogue/allcatalogues/{pageSize}/{filterChar}";
618+
var response = await client.GetAsync(request).ConfigureAwait(false);
619+
620+
if (response.IsSuccessStatusCode)
621+
{
622+
var result = response.Content.ReadAsStringAsync().Result;
623+
viewmodel = JsonConvert.DeserializeObject<AllCatalogueResponseViewModel>(result);
624+
}
625+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
626+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
627+
{
628+
throw new Exception("AccessDenied");
629+
}
630+
631+
return viewmodel;
632+
}
605633
}
606634
}

0 commit comments

Comments
 (0)