Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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; }
}
}
58 changes: 58 additions & 0 deletions LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,63 @@ 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,
}).ToList();
}

this.ViewBag.PageIndex = pageIndex;
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; }
}
}
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
47 changes: 47 additions & 0 deletions LearningHub.Nhs.WebUI/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,53 @@ public async Task<int> CreateCatalogueSearchTermEventAsync(CatalogueSearchReques
}
}

/// <summary>
/// GetAllCatalogueSearchResultAsync.
/// </summary>
/// <param name="catalogueSearchRequestModel">catalogueSearchRequestModel.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task<SearchAllCatalogueViewModel> GetAllCatalogueSearchResultAsync(AllCatalogueSearchRequestModel catalogueSearchRequestModel)
{
SearchAllCatalogueViewModel searchViewModel = new SearchAllCatalogueViewModel();

try
{
var client = await this.LearningHubHttpClient.GetClientAsync();

catalogueSearchRequestModel.SearchText = this.DecodeProblemCharacters(catalogueSearchRequestModel.SearchText);

var json = JsonConvert.SerializeObject(catalogueSearchRequestModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

var request = $"Search/GetAllCatalogueSearchResult";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
searchViewModel = JsonConvert.DeserializeObject<SearchAllCatalogueViewModel>(result);

if (searchViewModel.DocumentModel != null
&& searchViewModel.DocumentModel.Count != 0)
{
searchViewModel.DocumentModel.ForEach(x => x.Description = this.RemoveHtmlTags(x.Description));
}
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return searchViewModel;
}
catch (Exception ex)
{
searchViewModel.ErrorOnAPI = true;
this.Logger.LogError(string.Format("Error occurred in GetAllCatalogueSearchResultAsync: {0}", ex.Message));
return searchViewModel;
}
}

/// <summary>
/// The RemoveHtmlTags.
/// </summary>
Expand Down
13 changes: 12 additions & 1 deletion LearningHub.Nhs.WebUI/Styles/nhsuk/pages/catalogue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,15 @@ textarea {
font-weight: 700;
line-height: 24px;
word-wrap: break-word
}
}
.allCatalogue-lettercard {
background: $nhsuk-blue !important;
padding: 12px 8px;
margin-left: 16px;
width: 52px;
height: 56px;
display: flex;
align-items: center;
justify-content: center;
color: $nhsuk-white !important;
}
Loading