Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c79d8d6
Merge pull request #532 from TechnologyEnhancedLearning/Develop/Featu…
AnjuJose011 Aug 15, 2024
b6dacef
modelversionupdate
AnjuJose011 Aug 15, 2024
1ad238d
Merge pull request #534 from TechnologyEnhancedLearning/modelversionu…
AnjuJose011 Aug 15, 2024
e9e6a42
archive replaced file
OluwatobiAwe Aug 18, 2024
32046d2
case publish error catch
OluwatobiAwe Aug 22, 2024
18b9ef3
.
OluwatobiAwe Aug 22, 2024
1d433db
Merge pull request #540 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Aug 22, 2024
21b1bc0
Merge pull request #560 from TechnologyEnhancedLearning/RC
AnjuJose011 Sep 2, 2024
cad0d84
modelversionupdate
AnjuJose011 Sep 2, 2024
1559d2d
Merge pull request #562 from TechnologyEnhancedLearning/ModelVersionU…
AnjuJose011 Sep 2, 2024
fee6969
Update LearningHub.Nhs.Database.sqlproj
AnjuJose011 Sep 2, 2024
342c848
Merge pull request #563 from TechnologyEnhancedLearning/AnjuJose011-p…
AnjuJose011 Sep 2, 2024
1c63739
Merge pull request #561 from TechnologyEnhancedLearning/releases/LHAr…
AnjuJose011 Sep 2, 2024
f51b9eb
removed open api changes
AnjuJose011 Sep 2, 2024
dfb98ff
Merge pull request #564 from TechnologyEnhancedLearning/Removed-OpenA…
AnjuJose011 Sep 2, 2024
600aae9
TD-4037: Fixed Empty search error issue.
ArunimaGeorge Sep 3, 2024
9978f20
TD-4692: Fixed Issue not showing the 'elfh' logo & 'Developed with el…
ArunimaGeorge Sep 5, 2024
d0fbf8d
Merge pull request #570 from TechnologyEnhancedLearning/Develop/Fixes…
ArunimaGeorge Sep 5, 2024
0d59475
TD-4693 cache fix
OluwatobiAwe Sep 5, 2024
2dc1c94
Merge pull request #571 from TechnologyEnhancedLearning/Develop/Fixes…
OluwatobiAwe Sep 5, 2024
caa4157
TD-4038: Fixed AllCatalogue pagination issue
ArunimaGeorge Sep 6, 2024
2dec991
Merge pull request #574 from TechnologyEnhancedLearning/Develop/Fixes…
ArunimaGeorge Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions AdminUI/LearningHub.Nhs.AdminUI/Controllers/UserGroupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public async Task<IActionResult> AddUsersToUserGroup(int userGroupId, string use
var vr = await this.userGroupService.AddUsersToUserGroup(userGroupId, userIdList);
if (vr.IsValid)
{
this.ClearUserCachedPermissions(userIdList);
return this.Json(new
{
success = true,
Expand Down Expand Up @@ -527,5 +528,16 @@ public async Task<IActionResult> UserGroupCatalogues(int id)

return this.PartialView("_UserGroupCatalogues", catalogues);
}

private void ClearUserCachedPermissions(string userIdList)
{
if (!string.IsNullOrWhiteSpace(userIdList))
{
foreach (var userId in userIdList.Split(","))
{
_ = Task.Run(async () => { await this.userService.ClearUserCachedPermissions(int.Parse(userId)); });
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
<PackageReference Include="IdentityModel" Version="4.4.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.38" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
Expand Down
5 changes: 5 additions & 0 deletions LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ public class FindwiseSettings
/// Gets or sets the CatalogueSearchPageSize.
/// </summary>
public int CatalogueSearchPageSize { get; set; }

/// <summary>
/// Gets or sets the AllCatalogueSearchPageSize.
/// </summary>
public int AllCatalogueSearchPageSize { get; set; }
}
}
5 changes: 5 additions & 0 deletions LearningHub.Nhs.WebUI/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,10 @@ public Settings()
/// Gets or sets the MediaKindSettings.
/// </summary>
public MediaKindSettings MediaKindSettings { get; set; } = new MediaKindSettings();

/// <summary>
/// Gets or sets AllCataloguePageSize.
/// </summary>
public int AllCataloguePageSize { get; set; }
}
}
17 changes: 13 additions & 4 deletions LearningHub.Nhs.WebUI/Controllers/Api/ContributeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,18 @@ public async Task<ActionResult> PublishResourceVersionAsync([FromBody] PublishVi
{
if (associatedResource.ResourceType != ResourceTypeEnum.Scorm && associatedResource.ResourceType != ResourceTypeEnum.Html)
{
try
{
var obsoleteFiles = await this.resourceService.GetObsoleteResourceFile(publishViewModel.ResourceVersionId);
if (obsoleteFiles != null && obsoleteFiles.Any())
{
await this.fileService.PurgeResourceFile(null, obsoleteFiles);
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, obsoleteFiles); });
}
}
catch (Exception ex)
{
this.Logger.LogError($"File Archive Error: {ex.Message}", $"ResourceVersionId -{publishViewModel.ResourceVersionId}");
}
}
}

Expand Down Expand Up @@ -707,8 +714,8 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
{
foreach (var oldblock in existingImages)
{
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));
if (entry == null)
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));
if (entry == null)
{
filePaths.Add(oldblock?.MediaBlock?.Image?.File?.FilePath);
}
Expand Down Expand Up @@ -790,8 +797,10 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, deleteList); });
}
}
catch
catch (Exception ex)
{
var param = new object[] { resourceVersionId, existingResource, newResource };
this.Logger.LogError($"BlockCollection Archive Error: {ex.Message}", param);
}
}

Expand Down
5 changes: 3 additions & 2 deletions LearningHub.Nhs.WebUI/Controllers/Api/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace LearningHub.Nhs.WebUI.Controllers.Api
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Resource;
Expand Down Expand Up @@ -565,9 +566,9 @@ public async Task<ActionResult> DeleteResourceProviderAsync(int resourceVersionI
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
[HttpPost]
[Route("ArchiveResourceFile")]
public ActionResult ArchiveResourceFile(List<string> filePaths)
public ActionResult ArchiveResourceFile(IEnumerable<string> filePaths)
{
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, filePaths); });
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, filePaths.ToList()); });
return this.Ok();
}

Expand Down
66 changes: 66 additions & 0 deletions LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public async Task<IActionResult> Index(int pageIndex = 1, string term = null)
BookmarkId = t.BookmarkId,
NodeId = int.Parse(t.Id),
BadgeUrl = t.BadgeUrl,
Providers = t.Providers,
}).ToList();
}
else
Expand Down Expand Up @@ -551,5 +552,70 @@ public async Task<IActionResult> RequestPreviewAccess(CatalogueRequestAccessView
return this.View("RequestPreviewAccess", viewModel);
}
}

/// <summary>
/// Get all catelogues, filter and pagination based on alphabets.
/// </summary>
/// <param name="filterChar">filterChar.</param>
/// <returns>rk.</returns>
[Route("/allcatalogue")]
[Route("/allcatalogue/{filterChar}")]
public async Task<IActionResult> GetAllCatalogue(string filterChar = "a")
{
var pageSize = this.settings.AllCataloguePageSize;
var catalogues = await this.catalogueService.GetAllCatalogueAsync(filterChar, pageSize);
return this.View("allcatalogue", catalogues);
}

/// <summary>
/// AllCatalogues Search.
/// </summary>
/// <param name="pageIndex">pageIndex.</param>
/// <param name="term">Search term.</param>
/// <returns>IActionResult.</returns>
[Route("/allcataloguesearch")]
public async Task<IActionResult> GetAllCatalogueSearch(int pageIndex = 1, string term = null)
{
var catalogues = new AllCatalogueSearchResponseViewModel();
var searchString = term?.Trim() ?? string.Empty;
var allCatalogueSearchPageSize = this.settings.FindwiseSettings.AllCatalogueSearchPageSize;

if (!string.IsNullOrWhiteSpace(term))
{
var termCatalogues = await this.searchService.GetAllCatalogueSearchResultAsync(
new AllCatalogueSearchRequestModel
{
SearchText = searchString,
PageIndex = pageIndex - 1,
PageSize = allCatalogueSearchPageSize,
});

catalogues.TotalCount = termCatalogues.TotalHits;
catalogues.Catalogues = termCatalogues.DocumentModel.Select(t => new AllCatalogueViewModel
{
Url = t.Url,
Name = t.Name,
CardImageUrl = t.CardImageUrl,
BannerUrl = t.BannerUrl,
Description = t.Description,
RestrictedAccess = t.RestrictedAccess,
HasAccess = t.HasAccess,
IsBookmarked = t.IsBookmarked,
BookmarkId = t.BookmarkId,
NodeId = int.Parse(t.Id),
BadgeUrl = t.BadgeUrl,
Providers = t.Providers,
}).ToList();
}
else
{
catalogues.TotalCount = 0;
catalogues.Catalogues = new List<AllCatalogueViewModel>();
}

this.ViewBag.PageIndex = pageIndex;
this.ViewBag.PageSize = allCatalogueSearchPageSize;
return this.View("AllCatalogueSearch", catalogues);
}
}
}
8 changes: 8 additions & 0 deletions LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,13 @@ public interface ICatalogueService
/// <param name="userUserGroupId">The user - user group id.</param>
/// <returns>The validation result.</returns>
Task<LearningHubValidationResult> RemoveUserFromRestrictedAccessUserGroup(int userUserGroupId);

/// <summary>
/// The GetAllCatalogueAsync.
/// </summary>
/// <param name="filterChar">The letter.</param>
/// <param name="pageSize">The pageSize.</param>
/// <returns>The allcatalogue result based on letters.</returns>
Task<AllCatalogueResponseViewModel> GetAllCatalogueAsync(string filterChar, int pageSize);
}
}
7 changes: 7 additions & 0 deletions LearningHub.Nhs.WebUI/Interfaces/ISearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,12 @@ public interface ISearchService
/// <param name="catalogueSearchRequestModel">catalogue search request model.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<int> CreateCatalogueSearchTermEventAsync(CatalogueSearchRequestModel catalogueSearchRequestModel);

/// <summary>
/// Get AllCatalogue Search Result Async.
/// </summary>
/// <param name="catalogueSearchRequestModel">The catalogue Search Request Model.</param>
/// <returns>The <see cref="Task{SearchAllCatalogueViewModel}"/>.</returns>
Task<SearchAllCatalogueViewModel> GetAllCatalogueSearchResultAsync(AllCatalogueSearchRequestModel catalogueSearchRequestModel);
}
}
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.38" />
<PackageReference Include="IdentityModel" Version="4.3.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.38" />
<PackageReference Include="linqtotwitter" Version="6.9.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />
Expand Down
5 changes: 5 additions & 0 deletions LearningHub.Nhs.WebUI/Models/NavigationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ public class NavigationModel
/// Gets or sets a value indicating whether to show my account.
/// </summary>
public bool ShowMyAccount { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to show Browse Catalogues.
/// </summary>
public bool ShowBrowseCatalogues { get; set; }
}
}
5 changes: 3 additions & 2 deletions LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@
this.fileUploadRef.value = null;
(this.$refs.fileUploader as any).uploadResourceFile(this.file);
},
fileUploadComplete(uploadResult: FileUploadResult) {
async fileUploadComplete(uploadResult: FileUploadResult) {
if (!uploadResult.invalid) {
if (uploadResult.resourceType != ResourceType.SCORM) {
this.$store.commit("setResourceType", uploadResult.resourceType);
Expand All @@ -841,7 +841,7 @@
}

if (this.filePathBeforeFileChange.length > 0) {
this.getResourceFilePath('completed');
await this.getResourceFilePath('completed');
if (this.filePathBeforeFileChange.length > 0 && this.filePathAfterFileChange.length > 0) {
let filePaths = this.filePathBeforeFileChange.filter(item => !this.filePathAfterFileChange.includes(item));
if (filePaths.length > 0) {
Expand Down Expand Up @@ -1040,6 +1040,7 @@
await resourceData.getObsoleteResourceFile(resource.resourceVersionId).then(response => {
if (fileChangeStatus == 'initialised') {
this.filePathBeforeFileChange = response;
this.filePathAfterFileChange.length = 0;
}
else if (fileChangeStatus == 'completed') {
this.filePathAfterFileChange = response;
Expand Down
4 changes: 2 additions & 2 deletions LearningHub.Nhs.WebUI/Scripts/vuesrc/data/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ const getObsoleteResourceFile = async function (id: number): Promise<string[]> {
};

const archiveResourceFile = async function (filepaths: string[]): Promise<boolean> {
const params = {filePaths:filepaths};
return await AxiosWrapper.axios.post('/api/Resource/DuplicateBlocks', params).then(() => {

return await AxiosWrapper.axios.post('/api/Resource/ArchiveResourceFile', filepaths).then(() => {
return true
}).catch(e => {
console.log('archiveResourceFile:' + e);
Expand Down
28 changes: 28 additions & 0 deletions LearningHub.Nhs.WebUI/Services/CatalogueService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,33 @@ public async Task<LearningHubValidationResult> RemoveUserFromRestrictedAccessUse

return apiResponse.ValidationResult;
}

/// <summary>
/// GetAllCatalogueAsync.
/// </summary>
/// <param name="filterChar">The filterChar.</param>
/// <param name="pageSize">the pageSize.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public async Task<AllCatalogueResponseViewModel> GetAllCatalogueAsync(string filterChar, int pageSize)
{
AllCatalogueResponseViewModel viewmodel = new AllCatalogueResponseViewModel { };
var client = await this.LearningHubHttpClient.GetClientAsync();

var request = $"catalogue/allcatalogues/{pageSize}/{filterChar}";
var response = await client.GetAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
viewmodel = JsonConvert.DeserializeObject<AllCatalogueResponseViewModel>(result);
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return viewmodel;
}
}
}
7 changes: 7 additions & 0 deletions LearningHub.Nhs.WebUI/Services/NavigationPermissionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public NavigationModel NotAuthenticated()
ShowRegister = false,
ShowSignOut = false,
ShowMyAccount = false,
ShowBrowseCatalogues = false,
};
}

Expand All @@ -104,6 +105,7 @@ private NavigationModel AuthenticatedAdministrator(string controllerName)
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = true,
ShowBrowseCatalogues = true,
};
}

Expand All @@ -128,6 +130,7 @@ private NavigationModel AuthenticatedBlueUser(string controllerName)
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = true,
ShowBrowseCatalogues = true,
};
}

Expand All @@ -151,6 +154,7 @@ private NavigationModel AuthenticatedGuest()
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = false,
ShowBrowseCatalogues = false,
};
}

Expand All @@ -175,6 +179,7 @@ private async Task<NavigationModel> AuthenticatedReadOnly(string controllerName)
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = false,
ShowBrowseCatalogues = true,
};
}

Expand All @@ -198,6 +203,7 @@ private async Task<NavigationModel> AuthenticatedBasicUserOnly()
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = true,
ShowBrowseCatalogues = true,
};
}

Expand All @@ -221,6 +227,7 @@ private NavigationModel InLoginWizard()
ShowRegister = false,
ShowSignOut = true,
ShowMyAccount = false,
ShowBrowseCatalogues = false,
};
}
}
Expand Down
Loading
Loading