Skip to content

Commit a6cdffe

Browse files
committed
Merge release-v1.0.0
2 parents 35c510c + 7c3b543 commit a6cdffe

File tree

114 files changed

+1963
-618
lines changed

Some content is hidden

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

114 files changed

+1963
-618
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ obj
5050
/LearningHub.Nhs.WebUI.AutomatedUiTests/appsettings.Development.json
5151
/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.Development.json
5252
/OpenAPI/LearningHub.Nhs.OpenApi/web.config
53+
/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj.user
54+
/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj.user

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.40" />
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" />

AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/Edit.cshtml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
<span class="input-validation-error keyword-maxlength" style="display: none;">The maximum length is 50 characters.</span>
163163
</div>
164164
</div>
165+
<div class="row">
166+
<div class="col-12">
167+
<span id="keyword-error-span" class="field-validation-error" style="display: none;"></span>
168+
</div>
169+
</div>
165170

166171
</div>
167172
<div class="col-12">
@@ -341,6 +346,9 @@
341346
} else {
342347
$('#add-keyword').removeAttr('disabled');
343348
}
349+
350+
$('#keyword-error-span').hide();
351+
$('#keyword-error-span').html('');
344352
});
345353
346354
$('#add-keyword').on('click', function () {
@@ -352,9 +360,11 @@
352360
353361
// Split the input value by commas and trim each keyword
354362
var values = value.split(',').map(function (item) {
355-
return item.trim();
363+
return item.trim().toLowerCase();
356364
});
357365
366+
var duplicateKeywords = [];
367+
$('#keyword-error-span').hide();
358368
values.forEach(function (value) {
359369
if (value && keywords.indexOf(value) === -1) {
360370
keywords.push(value);
@@ -368,9 +378,15 @@
368378
$(x).attr('name', "Keywords[" + i + "]");
369379
});
370380
}
381+
else
382+
{
383+
duplicateKeywords.push(value);
384+
$('#keyword-error-span').show();
385+
$('#keyword-error-span').html('The keyword(s) have already been added : ' + duplicateKeywords.join(', '))
386+
}
371387
});
372388
373-
$keywordInput.val("");
389+
$keywordInput.val("");
374390
if (keywords.length > 4) {
375391
$('#add-keyword').attr('disabled', 'disabled');
376392
$('#add-keyword-input').attr('disabled', 'disabled');
@@ -441,4 +457,4 @@
441457
442458
</script>
443459
<script src="~/js/imageInput.js"></script>
444-
}
460+
}

AdminUI/LearningHub.Nhs.AdminUI/Views/User/_UserLearningRecord.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<tr>
3737
<td>
3838
<span class="nhsuk-u-text-align-left table-content-spacing">
39-
@if (userLearningRecord.ResourceReferenceId > 0 && userLearningRecord.VersionStatusId != (int?)VersionStatusEnum.Unpublished)
39+
@if (userLearningRecord.IsCurrentResourceVersion && userLearningRecord.ResourceReferenceId > 0 && userLearningRecord.VersionStatusId != (int?)VersionStatusEnum.Unpublished)
4040
{
4141
<span>
4242
<a class="learning-td" href="@resourceUrl/@userLearningRecord.ResourceReferenceId" target="_blank">@userLearningRecord.Title</a><br />
@@ -46,7 +46,8 @@
4646
else
4747
{
4848
<span class="learning-td">
49-
@userLearningRecord.Title
49+
@userLearningRecord.Title<br />
50+
<b>Last @LearningActivityHelper.GetResourceTypeVerb(userLearningRecord).ToLower() on : </b> @userLearningRecord.ActivityDate.DateTime.ToString("dd MMM yyyy") at @userLearningRecord.ActivityDate.DateTime.ToShortTimeString()<br />
5051
</span>
5152

5253
}

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/Api/ContributeController.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,18 @@ public async Task<ActionResult> PublishResourceVersionAsync([FromBody] PublishVi
349349
{
350350
if (associatedResource.ResourceType != ResourceTypeEnum.Scorm && associatedResource.ResourceType != ResourceTypeEnum.Html)
351351
{
352+
try
353+
{
352354
var obsoleteFiles = await this.resourceService.GetObsoleteResourceFile(publishViewModel.ResourceVersionId);
353355
if (obsoleteFiles != null && obsoleteFiles.Any())
354356
{
355-
await this.fileService.PurgeResourceFile(null, obsoleteFiles);
357+
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, obsoleteFiles); });
356358
}
359+
}
360+
catch (Exception ex)
361+
{
362+
this.Logger.LogError($"File Archive Error: {ex.Message}", $"ResourceVersionId -{publishViewModel.ResourceVersionId}");
363+
}
357364
}
358365
}
359366

@@ -707,8 +714,8 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
707714
{
708715
foreach (var oldblock in existingImages)
709716
{
710-
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null && (x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId || x.MediaBlock?.Image?.File?.FilePath == oldblock.MediaBlock?.Image?.File?.FilePath));
711-
if (entry == null)
717+
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null && (x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId || x.MediaBlock?.Image?.File?.FilePath == oldblock.MediaBlock?.Image?.File?.FilePath));
718+
if (entry == null)
712719
{
713720
filePaths.Add(oldblock?.MediaBlock?.Image?.File?.FilePath);
714721
}
@@ -790,8 +797,10 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
790797
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, deleteList); });
791798
}
792799
}
793-
catch
800+
catch (Exception ex)
794801
{
802+
var param = new object[] { resourceVersionId, existingResource, newResource };
803+
this.Logger.LogError($"BlockCollection Archive Error: {ex.Message}", param);
795804
}
796805
}
797806

LearningHub.Nhs.WebUI/Controllers/Api/ResourceController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace LearningHub.Nhs.WebUI.Controllers.Api
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Threading.Tasks;
67
using LearningHub.Nhs.Models.Enums;
78
using LearningHub.Nhs.Models.Resource;
@@ -565,9 +566,9 @@ public async Task<ActionResult> DeleteResourceProviderAsync(int resourceVersionI
565566
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
566567
[HttpPost]
567568
[Route("ArchiveResourceFile")]
568-
public ActionResult ArchiveResourceFile(List<string> filePaths)
569+
public ActionResult ArchiveResourceFile(IEnumerable<string> filePaths)
569570
{
570-
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, filePaths); });
571+
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, filePaths.ToList()); });
571572
return this.Ok();
572573
}
573574

LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public async Task<IActionResult> Index(int pageIndex = 1, string term = null)
110110
});
111111

112112
catalogues.TotalCount = termCatalogues.TotalHits;
113+
catalogues.GroupId = Guid.NewGuid();
113114
catalogues.Catalogues = termCatalogues.DocumentModel.Select(t => new DashboardCatalogueViewModel
114115
{
115116
Url = t.Url,
@@ -123,6 +124,8 @@ public async Task<IActionResult> Index(int pageIndex = 1, string term = null)
123124
BookmarkId = t.BookmarkId,
124125
NodeId = int.Parse(t.Id),
125126
BadgeUrl = t.BadgeUrl,
127+
Providers = t.Providers,
128+
ClickPayload = t.Click.Payload,
126129
}).ToList();
127130
}
128131
else
@@ -551,5 +554,70 @@ public async Task<IActionResult> RequestPreviewAccess(CatalogueRequestAccessView
551554
return this.View("RequestPreviewAccess", viewModel);
552555
}
553556
}
557+
558+
/// <summary>
559+
/// Get all catelogues, filter and pagination based on alphabets.
560+
/// </summary>
561+
/// <param name="filterChar">filterChar.</param>
562+
/// <returns>rk.</returns>
563+
[Route("/allcatalogue")]
564+
[Route("/allcatalogue/{filterChar}")]
565+
public async Task<IActionResult> GetAllCatalogue(string filterChar = "a")
566+
{
567+
var pageSize = this.settings.AllCataloguePageSize;
568+
var catalogues = await this.catalogueService.GetAllCatalogueAsync(filterChar, pageSize);
569+
return this.View("allcatalogue", catalogues);
570+
}
571+
572+
/// <summary>
573+
/// AllCatalogues Search.
574+
/// </summary>
575+
/// <param name="pageIndex">pageIndex.</param>
576+
/// <param name="term">Search term.</param>
577+
/// <returns>IActionResult.</returns>
578+
[Route("/allcataloguesearch")]
579+
public async Task<IActionResult> GetAllCatalogueSearch(int pageIndex = 1, string term = null)
580+
{
581+
var catalogues = new AllCatalogueSearchResponseViewModel();
582+
var searchString = term?.Trim() ?? string.Empty;
583+
var allCatalogueSearchPageSize = this.settings.FindwiseSettings.AllCatalogueSearchPageSize;
584+
585+
if (!string.IsNullOrWhiteSpace(term))
586+
{
587+
var termCatalogues = await this.searchService.GetAllCatalogueSearchResultAsync(
588+
new AllCatalogueSearchRequestModel
589+
{
590+
SearchText = searchString,
591+
PageIndex = pageIndex - 1,
592+
PageSize = allCatalogueSearchPageSize,
593+
});
594+
595+
catalogues.TotalCount = termCatalogues.TotalHits;
596+
catalogues.Catalogues = termCatalogues.DocumentModel.Select(t => new AllCatalogueViewModel
597+
{
598+
Url = t.Url,
599+
Name = t.Name,
600+
CardImageUrl = t.CardImageUrl,
601+
BannerUrl = t.BannerUrl,
602+
Description = t.Description,
603+
RestrictedAccess = t.RestrictedAccess,
604+
HasAccess = t.HasAccess,
605+
IsBookmarked = t.IsBookmarked,
606+
BookmarkId = t.BookmarkId,
607+
NodeId = int.Parse(t.Id),
608+
BadgeUrl = t.BadgeUrl,
609+
Providers = t.Providers,
610+
}).ToList();
611+
}
612+
else
613+
{
614+
catalogues.TotalCount = 0;
615+
catalogues.Catalogues = new List<AllCatalogueViewModel>();
616+
}
617+
618+
this.ViewBag.PageIndex = pageIndex;
619+
this.ViewBag.PageSize = allCatalogueSearchPageSize;
620+
return this.View("AllCatalogueSearch", catalogues);
621+
}
554622
}
555623
}

0 commit comments

Comments
 (0)