-
Notifications
You must be signed in to change notification settings - Fork 1
Develop/feature/td 5829 5862 shared architecture and bff 2 #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Phil-NHS
wants to merge
25
commits into
LHKentia
Choose a base branch
from
Develop/Feature/TD-5829-5862-Shared-Architecture-and-BFF-2
base: LHKentia
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3343656
TD-5700-fix
AnjuJose011 20ca42e
TD-5727
AnjuJose011 19d6cfc
TD-5727
AnjuJose011 247ef8f
TD-5829: Introduced Shared Project refactored code shared with Blazor…
Phil-NHS 2db7358
Merge pull request #1283 from TechnologyEnhancedLearning/TD-5727-Cont…
AnjuJose011 a8c26db
Merge pull request #1286 from TechnologyEnhancedLearning/TD-5700-Reso…
AnjuJose011 aa9a1a5
TD-5862 Squash following merging RC changes
Phil-NHS bcd5659
bit of moodle refactoring and reload the moodle user
60f1317
Rolling back Models to 48 to fix the build
230a260
TD-5862 restoring interface
Phil-NHS 78709c7
TD-5862 reopen pull request
Phil-NHS dcca696
TD-5862 Merge in to new branch
Phil-NHS 99fc2b6
TD-5829 was missing configuration of bff
Phil-NHS 6242cfd
Merge pull request #1289 from TechnologyEnhancedLearning/Develop/Fixe…
binon c800d32
TD-5829 Ivory updated
Phil-NHS 3279ef6
TD-5829 Updating to accomodate changes to Ivory
Phil-NHS bcdff4b
TD-5888 adding blazor serverside and TELBlazor package ref
Phil-NHS ce07ada
TD-5888 Builds, requires httpclient and comments tidying
Phil-NHS 8167a97
TD-5888 Working when not using shared project
Phil-NHS edd96ee
TD-5888 tidy up client registration
Phil-NHS f06621f
TD-5888 NOT FOR PRODUCTION UNTIL SQUASHED AND REVISED PR FOR REVIEW D…
Phil-NHS e8943a6
TD-5888 Adding in WebUI Shared because its quick and its the one chan…
Phil-NHS 5505e8d
TD-5888 Just adding middleware for completeness
Phil-NHS 1217fba
TD-5888 implementing some PR renaming publicconfig
Phil-NHS 15f02cf
Merge pull request #1314 from TechnologyEnhancedLearning/Develop/Feat…
Phil-NHS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
...s.WebUI/Configuration/FindwiseSettings.cs → ...onfiguration/ExposableFindwiseSettings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| namespace LearningHub.Nhs.Shared.Configuration | ||
| { | ||
| using LearningHub.Nhs.Shared.Interfaces.Configuration; | ||
| /// <summary> | ||
| /// Represents configuration values that are safe to expose to clientside frontend applications | ||
| /// (such as Blazor WebAssembly) or public-facing APIs. | ||
| /// | ||
| /// <para> | ||
| /// Implements <see cref="IExposableSettings"/> and contains only non-sensitive, non-secret | ||
| /// values such as public API endpoints and pagination settings. This separation ensures | ||
| /// that secure or private configuration data is not inadvertently exposed to clients. | ||
| /// </para> | ||
| /// </summary> | ||
| public class ExposableSettings : IExposableSettings | ||
| { | ||
| /// <inheritdoc/> | ||
| public string LearningHubApiUrl { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the UserApiUrl. | ||
| /// </summary> | ||
| public string UserApiUrl { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the OpenApiUrl. | ||
| /// </summary> | ||
| public string OpenApiUrl { get; set; } | ||
| /// <summary> | ||
| /// Backend for Frontend (BFF) URL for the Learning Hub API accessed by samesite cookie and uses httpclients with bearers to access external apis. | ||
| /// </summary> | ||
| public string LearningHubApiBFFUrl { get; set; } | ||
| /// <inheritdoc/> | ||
| public IExposableFindwiseSettings FindwiseSettings { get; set; } | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace LearningHub.Nhs.Shared.Helpers | ||
| { | ||
| public static class FormattingHelper | ||
| { | ||
|
|
||
| /// <summary> | ||
| /// Returns a number of milliseconds converted into a duration string, such as "10 min 15 sec". Includes rounding to match the behaviour of the Azure Media Player. | ||
| /// </summary> | ||
| /// <param name="durationInMilliseconds">The number of milliseconds.</param> | ||
| /// <returns>The duration string.</returns> | ||
| public static string GetDurationText(int durationInMilliseconds) | ||
| { | ||
| if (durationInMilliseconds > 0) | ||
| { | ||
| // Azure media player rounds duration to nearest second. e.g. 8:59.88 becomes 9:00. LH needs to match. | ||
| int nearestSecond = (int)Math.Round(((double)durationInMilliseconds) / 1000); | ||
| var duration = new TimeSpan(0, 0, nearestSecond); | ||
| string returnValue = string.Empty; | ||
|
|
||
| // If duration greater than an hour, don't return the seconds part. | ||
| if (duration.Hours > 0) | ||
| { | ||
| returnValue = $"{duration.Hours} hr {duration.Minutes} min "; | ||
|
|
||
| // Exclude "0 min" from the return value. | ||
| if (returnValue.EndsWith(" 0 min ")) | ||
| { | ||
| returnValue = returnValue.Replace("0 min ", string.Empty); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| returnValue = $"{duration.Minutes} min {duration.Seconds} sec "; | ||
|
|
||
| // Exclude "0 min" and "0 sec" from the return value. | ||
| if (returnValue.StartsWith("0 min ")) | ||
| { | ||
| returnValue = returnValue.Replace("0 min ", string.Empty); | ||
| } | ||
|
|
||
| if (returnValue.EndsWith(" 0 sec ")) | ||
| { | ||
| returnValue = returnValue.Replace("0 sec ", string.Empty); | ||
| } | ||
| } | ||
|
|
||
| return returnValue; | ||
| } | ||
| else | ||
| { | ||
| return string.Empty; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| using LearningHub.Nhs.Models.Enums; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace LearningHub.Nhs.Shared.Helpers | ||
| { | ||
| public static class MoodleHelper | ||
| { | ||
| /// TODO: Remove this method after adding to Moodle resource types to models project. | ||
| /// <summary> | ||
| /// Returns a prettified resource type name, suitable for display in the UI. Includes video/audio duration string. | ||
| /// </summary> | ||
| /// <param name="resourceType">The resource type.</param> | ||
| /// <param name="durationInMilliseconds">The media duration in milliseconds.</param> | ||
| /// <returns>The resource type name, and duration if applicable.</returns> | ||
| public static string GetPrettifiedResourceTypeNameMoodle(ResourceTypeEnum resourceType, int? durationInMilliseconds = 0) | ||
| { | ||
| switch (resourceType) | ||
| { | ||
| case ResourceTypeEnum.Assessment: | ||
| return "Assessment"; | ||
| case ResourceTypeEnum.Article: | ||
| return "Article"; | ||
| case ResourceTypeEnum.Audio: | ||
| string durationText = FormattingHelper.GetDurationText(durationInMilliseconds ?? 0); | ||
| durationText = string.IsNullOrEmpty(durationText) ? string.Empty : " - " + durationText; | ||
| return "Audio" + durationText; | ||
| case ResourceTypeEnum.Equipment: | ||
| return "Equipment"; | ||
| case ResourceTypeEnum.Image: | ||
| return "Image"; | ||
| case ResourceTypeEnum.Scorm: | ||
| return "elearning"; | ||
| case ResourceTypeEnum.Video: | ||
| durationText = FormattingHelper.GetDurationText(durationInMilliseconds ?? 0); | ||
| durationText = string.IsNullOrEmpty(durationText) ? string.Empty : " - " + durationText; | ||
| return "Video" + durationText; | ||
| case ResourceTypeEnum.WebLink: | ||
| return "Web link"; | ||
| case ResourceTypeEnum.GenericFile: | ||
| return "File"; | ||
| case ResourceTypeEnum.Embedded: | ||
| return "Embedded"; | ||
| case ResourceTypeEnum.Case: | ||
| return "Case"; | ||
| case ResourceTypeEnum.Html: | ||
| return "HTML"; | ||
| case ResourceTypeEnum.Moodle: | ||
| return "Course"; | ||
| default: | ||
| return "File"; | ||
| } | ||
| } | ||
|
|
||
| /// TODO: Remove this method after adding to Moodle resource types to models project. | ||
| /// <summary> | ||
| /// Findwise Moodle resource type dictionary. | ||
| /// </summary> | ||
| public static readonly Dictionary<string, ResourceTypeEnum> FindwiseResourceMoodleTypeDict = new Dictionary<string, ResourceTypeEnum>() | ||
| { | ||
| { "video", ResourceTypeEnum.Video }, | ||
| { "article", ResourceTypeEnum.Article }, | ||
| { "case", ResourceTypeEnum.Case }, | ||
| { "weblink", ResourceTypeEnum.WebLink }, | ||
| { "audio", ResourceTypeEnum.Audio }, | ||
| { "scorm", ResourceTypeEnum.Scorm }, | ||
| { "assessment", ResourceTypeEnum.Assessment }, | ||
| { "genericfile", ResourceTypeEnum.GenericFile }, | ||
| { "image", ResourceTypeEnum.Image }, | ||
| { "html", ResourceTypeEnum.Html }, | ||
| { "moodle", ResourceTypeEnum.Moodle }, | ||
| }; | ||
|
|
||
| /// <summary> | ||
| /// Returns a prettified resource type name, suitable for display in the UI. Excludes video/audio duration string. | ||
| /// </summary> | ||
| /// <param name="resourceType">The resource type.</param> | ||
| /// <returns>The resource type name, and duration if applicable.</returns> | ||
| public static string GetPrettifiedResourceTypeName(ResourceTypeEnum resourceType) | ||
| { | ||
| switch (resourceType) | ||
| { | ||
| case ResourceTypeEnum.Assessment: | ||
| return "Assessment"; | ||
| case ResourceTypeEnum.Article: | ||
| return "Article"; | ||
| case ResourceTypeEnum.Audio: | ||
| return "Audio"; | ||
| case ResourceTypeEnum.Equipment: | ||
| return "Equipment"; | ||
| case ResourceTypeEnum.Image: | ||
| return "Image"; | ||
| case ResourceTypeEnum.Scorm: | ||
| return "elearning"; | ||
| case ResourceTypeEnum.Video: | ||
| return "Video"; | ||
| case ResourceTypeEnum.WebLink: | ||
| return "Web link"; | ||
| case ResourceTypeEnum.GenericFile: | ||
| return "File"; | ||
| case ResourceTypeEnum.Embedded: | ||
| return "Embedded"; | ||
| case ResourceTypeEnum.Case: | ||
| return "Case"; | ||
| case ResourceTypeEnum.Html: | ||
| return "HTML"; | ||
| default: | ||
| return "File"; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s.WebUI/Helpers/ResourceTypeEnumMoodle.cs → ....Shared/Helpers/ResourceTypeEnumMoodle.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ningHub.Nhs.WebUI/Helpers/SearchHelper.cs → ...ingHub.Nhs.Shared/Helpers/SearchHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
LearningHub.Nhs.Shared/Interfaces/Configuration/IExposableFindwiseSettings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| namespace LearningHub.Nhs.Shared.Interfaces.Configuration | ||
| { | ||
| /// <summary> | ||
| /// Represents configuration values related to Findwise search that are safe to expose | ||
| /// to client-side applications or public-facing APIs. | ||
| /// | ||
| /// <para> | ||
| /// This includes non-sensitive values such as page sizes for different types of search results. | ||
| /// It does not contain any secure credentials or internal service configuration. | ||
| /// </para> | ||
| /// </summary> | ||
| public interface IExposableFindwiseSettings | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the page size for resource search results. | ||
| /// </summary> | ||
| public int ResourceSearchPageSize { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the CatalogueSearchPageSize. | ||
| /// </summary> | ||
| public int CatalogueSearchPageSize { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the AllCatalogueSearchPageSize. | ||
| /// </summary> | ||
| public int AllCatalogueSearchPageSize { get; set; } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
LearningHub.Nhs.Shared/Interfaces/Configuration/IExposableSettings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| namespace LearningHub.Nhs.Shared.Interfaces.Configuration | ||
| { | ||
| /// <summary> | ||
| /// Defines a contract for configuration data that is non-sensitive and safe to expose publicly | ||
| /// | ||
| /// <para> | ||
| /// This interface exposes only data that is safe to be publicly consumed or shared, | ||
| /// such as API endpoint URLs or non-sensitive configuration values. | ||
| /// It explicitly excludes any private or sensitive information (e.g., authentication tokens, | ||
| /// credentials, or secret keys), which should be handled via separate interfaces or services. | ||
| /// </para> | ||
| /// | ||
| /// <para> | ||
| /// The data provided by this interface can be safely used in frontend technologies, | ||
| /// such as Blazor WebAssembly, JavaScript frameworks, or other client-side applications, | ||
| /// without risking exposure of sensitive information. | ||
| /// </para> | ||
| /// </summary> | ||
| public interface IExposableSettings | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the LearningHubApiUrl. | ||
| /// </summary> | ||
| public string LearningHubApiUrl { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the UserApiUrl. | ||
| /// </summary> | ||
| public string UserApiUrl { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the OpenApiUrl. | ||
| /// </summary> | ||
| public string OpenApiUrl { get; set; } | ||
| /// <summary> | ||
| /// Gets or sets the LearningHubApiBFFUrl used to proxy via same domain cookie to the BFF LearningHubAPI calls. | ||
| /// </summary> | ||
| public string LearningHubApiBFFUrl { get; set; } | ||
|
|
||
| public IExposableFindwiseSettings FindwiseSettings { get; set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
| { | ||
| /// <summary> | ||
| /// Represents an HTTP client for a specific API. | ||
| /// </summary> | ||
| public interface IAPIHttpClient | ||
| { | ||
| /// <summary> | ||
| /// Gets the configured <see cref="HttpClient"/> for the API. | ||
| /// </summary> | ||
| Task<HttpClient> GetClientAsync(); | ||
|
|
||
| /// <summary> | ||
| /// Gets the base URL of the API. | ||
| /// </summary> | ||
| string ApiUrl { get; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other versions of this functionality in other project dont have APIUrl this comes from the baseHttpClient |
||
| } | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
LearningHub.Nhs.Shared/Interfaces/Http/ILearningHubHttpClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
| { | ||
| /// <summary> | ||
| /// Marker interface for the LearningHub API HttpClient. | ||
| /// | ||
| /// <para> | ||
| /// Inherits from <see cref="IAPIHttpClient"/> to enable | ||
| /// dependency injection of a specific implementation configured with | ||
| /// different API endpoints or settings specific to LH API. | ||
| /// </para> | ||
| /// | ||
| /// <para> | ||
| /// Currently, this interface is empty and used solely to differentiate implementations | ||
| /// that connect to different endpoints via configuration, but it may be extended in the future | ||
| /// with LearningHub-specific functionality or properties. | ||
| /// </para> | ||
| /// </summary> | ||
| public interface ILearningHubHttpClient : IAPIHttpClient | ||
| { | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are not using this, it is only for comments here, i think we shouldnt include it. Or use System.X libraries so we don't pull through unneeded dependencies which arn't support in blazor for example, but generally more generic, more framework-neutral options are better for compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnjuJose011 I would like a meeting about this i think there isnt enough seperation we have infastructure and presentation concerns in models etc the shared project i think needs to be agnostic, no aspnetcore.asp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Phil-NHS this is what discussed in today's meeting and seems a real blocker .you can please create a subtask and add more details in that ticket