Skip to content

Commit bbc1f5f

Browse files
authored
Merge pull request #1579 from TechnologyEnhancedLearning/Develop/Fixes/TD-6100-refactor-latest
Code clean up
2 parents 7937258 + 042fb60 commit bbc1f5f

File tree

7 files changed

+92
-28
lines changed

7 files changed

+92
-28
lines changed

LearningHub.Nhs.WebUI/Configuration/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,6 @@ public Settings()
269269
/// <summary>
270270
/// Gets or sets the StatMandId.
271271
/// </summary>
272-
public int StatMandId { get; set; } = 12;
272+
public int StatMandId { get; set; }
273273
}
274274
}

LearningHub.Nhs.WebUI/Views/Reports/Index.cshtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@
179179

180180
</div>
181181
</div>
182+
<div class="nhsuk-grid-column-full nhsuk-u-padding-5">
183+
@await Html.PartialAsync("_ReportHistoryPaging", Model)
184+
</div>
182185
</div>
183186
</div>
184187
</div>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@using System.Web;
2+
@using LearningHub.Nhs.WebUI.Models.Learning
3+
@using LearningHub.Nhs.WebUI.Models.Search;
4+
@model LearningHub.Nhs.WebUI.Models.Report.ReportHistoryViewModel
5+
6+
7+
@{
8+
var pagingModel = Model.ReportPaging;
9+
var showPaging = pagingModel.CurrentPage >= 0 && pagingModel.CurrentPage <= pagingModel.TotalPages - 1;
10+
var previousMessage = $"{pagingModel.CurrentPage} of {pagingModel.TotalPages}";
11+
int CurrentPageNumber = pagingModel.CurrentPage + 1;
12+
var nextMessage = string.Empty;
13+
if (CurrentPageNumber <= pagingModel.TotalPages)
14+
{
15+
nextMessage = $"{CurrentPageNumber + 1} of {pagingModel.TotalPages}";
16+
}
17+
else
18+
{
19+
previousMessage = $"{CurrentPageNumber - 1} of {pagingModel.TotalPages}";
20+
nextMessage = $"{CurrentPageNumber} of {pagingModel.TotalPages}";
21+
}
22+
23+
var routeData = new Dictionary<string, string>();
24+
routeData["CurrentPageIndex"] = pagingModel.CurrentPage.ToString();
25+
var nextRouteData = new Dictionary<string, string>(routeData);
26+
var previousRouteData = new Dictionary<string, string>(routeData);
27+
nextRouteData["ReportFormActionType"] = ReportFormActionTypeEnum.NextPageChange.ToString();
28+
previousRouteData["ReportFormActionType"] = ReportFormActionTypeEnum.PreviousPageChange.ToString();
29+
}
30+
31+
@if (pagingModel.TotalPages > 1)
32+
{
33+
<nav class="nhsuk-pagination" role="navigation" aria-label="Pagination">
34+
<ul class="nhsuk-list nhsuk-pagination__list">
35+
36+
@if (pagingModel.CurrentPage <= 0)
37+
{
38+
<li class="nhsuk-pagination-item--previous">
39+
40+
</li>
41+
}
42+
else
43+
{
44+
<li class="nhsuk-pagination-item--previous">
45+
<a class="nhsuk-pagination__link nhsuk-pagination__link--prev" asp-action="Index" asp-all-route-data="@previousRouteData">
46+
<span class="nhsuk-pagination__title">Previous</span>
47+
<span class="nhsuk-u-visually-hidden">:</span>
48+
<span class="nhsuk-pagination__page">@previousMessage</span>
49+
<svg class="nhsuk-icon nhsuk-icon__arrow-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
50+
<path d="M4.1 12.3l2.7 3c.2.2.5.2.7 0 .1-.1.1-.2.1-.3v-2h11c.6 0 1-.4 1-1s-.4-1-1-1h-11V9c0-.2-.1-.4-.3-.5h-.2c-.1 0-.3.1-.4.2l-2.7 3c0 .2 0 .4.1.6z"></path>
51+
</svg>
52+
</a>
53+
</li>
54+
}
55+
@if (pagingModel.CurrentPage >= pagingModel.TotalPages - 1)
56+
{
57+
<li class="nhsuk-pagination-item--next">
58+
59+
</li>
60+
}
61+
else
62+
{
63+
<li class="nhsuk-pagination-item--next">
64+
<a class="nhsuk-pagination__link nhsuk-pagination__link--next" asp-action="Index" asp-all-route-data="@nextRouteData">
65+
<span class="nhsuk-pagination__title">Next</span>
66+
<span class="nhsuk-u-visually-hidden">:</span>
67+
<span class="nhsuk-pagination__page">@nextMessage</span>
68+
<svg class="nhsuk-icon nhsuk-icon__arrow-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
69+
<path d="M19.6 11.66l-2.73-3A.51.51 0 0 0 16 9v2H5a1 1 0 0 0 0 2h11v2a.5.5 0 0 0 .32.46.39.39 0 0 0 .18 0 .52.52 0 0 0 .37-.16l2.73-3a.5.5 0 0 0 0-.64z"></path>
70+
</svg>
71+
</a>
72+
</li>
73+
}
74+
</ul>
75+
</nav>
76+
}

LearningHub.Nhs.WebUI/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@
115115
"MKPlayerLicence": "",
116116
"MediaKindStorageConnectionString": ""
117117
},
118+
"StatMandId": 0,
118119
"EnableTempDebugging": "false",
119120
"LimitScormToAdmin": "false"
120121

121-
},
122+
},
122123
"LearningHubAuthServiceConfig": {
123124
"Authority": "",
124125
"ClientId": "",

OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/DatabricksConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class DatabricksConfig
3838
/// <summary>
3939
/// Gets or sets the client scret of the service pricncipl.
4040
/// </summary>
41-
public string clientSecret { get; set; } = null!;
41+
public string ClientSecret { get; set; } = null!;
4242

4343
/// <summary>
4444
/// Gets or sets the endpoint to check user permission.

OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/DatabricksService.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,24 @@
1-
using LearningHub.Nhs.Models.Bookmark;
2-
using LearningHub.Nhs.Models.Entities.Reporting;
3-
using LearningHub.Nhs.OpenApi.Models.Configuration;
1+
using LearningHub.Nhs.OpenApi.Models.Configuration;
42
using LearningHub.Nhs.OpenApi.Services.HttpClients;
5-
using LearningHub.Nhs.OpenApi.Services.Interface.HttpClients;
63
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
7-
using Microsoft.Extensions.Logging;
84
using Microsoft.Extensions.Options;
95
using Newtonsoft.Json;
106
using System;
117
using System.Collections.Generic;
128
using System.Net;
139
using System.Net.Http;
14-
using System.Text.Json.Nodes;
1510
using System.Text;
1611
using System.Threading.Tasks;
1712
using LearningHub.Nhs.Models.Databricks;
1813
using System.Linq;
19-
using System.Net.Http.Headers;
2014
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
2115
using LearningHub.Nhs.Models.Entities.DatabricksReport;
2216
using AutoMapper;
23-
using LearningHub.Nhs.Models.Entities.Activity;
24-
using LearningHub.Nhs.Models.Resource.Activity;
2517
using LearningHub.Nhs.Models.Common;
26-
using LearningHub.Nhs.Models.Notification;
2718
using Microsoft.EntityFrameworkCore;
28-
using LearningHub.Nhs.Models.Enums.Report;
29-
using Newtonsoft.Json.Linq;
3019
using LearningHub.Nhs.OpenApi.Models.ViewModels;
31-
using LearningHub.Nhs.Models.Resource;
32-
using LearningHub.Nhs.OpenApi.Repositories.Repositories;
33-
using LearningHub.Nhs.Models.Constants;
34-
using LearningHub.Nhs.Models.Hierarchy;
3520
using LearningHub.Nhs.Models.Enums;
3621
using System.Text.Json;
37-
using LearningHub.Nhs.Models.Entities.Resource;
3822
using LearningHub.Nhs.Models.Entities;
3923

4024
namespace LearningHub.Nhs.OpenApi.Services.Services
@@ -83,7 +67,7 @@ public DatabricksService(IOptions<DatabricksConfig> databricksConfig,IOptions<Le
8367
/// <inheritdoc/>
8468
public async Task<bool> IsUserReporter(int userId)
8569
{
86-
string cacheKey = $"{CacheKey}_{userId}";
70+
string cacheKey = $"{userId}:{CacheKey}";
8771
var userReportPermission = await this.cachingService.GetAsync<bool>(cacheKey);
8872
if (userReportPermission.ResponseEnum == CacheReadResponseEnum.Found)
8973
{
@@ -129,7 +113,6 @@ public async Task<bool> IsUserReporter(int userId)
129113
/// <inheritdoc/>
130114
public async Task<DatabricksDetailedViewModel> CourseCompletionReport(int userId, DatabricksRequestModel model)
131115
{
132-
userId = 22527;
133116
newEntry:
134117
if (model.ReportHistoryId == 0 && model.Take > 1)
135118
{
@@ -214,7 +197,6 @@ public async Task<DatabricksDetailedViewModel> CourseCompletionReport(int userId
214197
/// <inheritdoc/>
215198
public async Task<PagedResultSet<ReportHistoryModel>> GetPagedReportHistory(int userId,int page, int pageSize)
216199
{
217-
userId = 22527;
218200
var result = new PagedResultSet<ReportHistoryModel>();
219201
var query = this.reportHistoryRepository.GetByUserIdAsync(userId);
220202

@@ -242,7 +224,6 @@ public async Task<PagedResultSet<ReportHistoryModel>> GetPagedReportHistory(int
242224
/// <inheritdoc/>
243225
public async Task<ReportHistoryModel> GetPagedReportHistoryById(int userId, int reportHistoryId)
244226
{
245-
userId = 22527;
246227
var result = new ReportHistoryModel();
247228

248229
var reportHistory = await this.reportHistoryRepository.GetByIdAsync(reportHistoryId);
@@ -266,7 +247,6 @@ public async Task<ReportHistoryModel> GetPagedReportHistoryById(int userId, int
266247
/// <inheritdoc/>
267248
public async Task<bool> QueueReportDownload(int userId, int reportHistoryId)
268249
{
269-
userId = 22527;
270250
var result = new ReportHistoryModel();
271251

272252
var reportHistory = await this.reportHistoryRepository.GetByIdAsync(reportHistoryId);
@@ -302,7 +282,8 @@ public async Task<bool> QueueReportDownload(int userId, int reportHistoryId)
302282
par_PageSize = 0,
303283
par_PageNumber = 0,
304284
par_Date_from = reportHistory.StartDate.GetValueOrDefault().ToString("yyyy-MM-dd"),
305-
par_Date_to = reportHistory.EndDate.GetValueOrDefault().ToString("yyyy-MM-dd")
285+
par_Date_to = reportHistory.EndDate.GetValueOrDefault().ToString("yyyy-MM-dd"),
286+
par_reportId = reportHistoryId
306287
}
307288
};
308289

@@ -332,7 +313,6 @@ public async Task<bool> QueueReportDownload(int userId, int reportHistoryId)
332313
/// <inheritdoc/>
333314
public async Task<ReportHistoryModel> DownloadReport(int userId, int reportHistoryId)
334315
{
335-
userId = 22527;
336316
var response = new ReportHistoryModel();
337317

338318
var reportHistory = await this.reportHistoryRepository.GetByIdAsync(reportHistoryId);

OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
"WarehouseId": "",
138138
"JobId": "",
139139
"UserPermissionEndpoint": "",
140-
"CourseCompletionEndpoint": ""
140+
"CourseCompletionEndpoint": "",
141+
"ResourceId": "",
142+
"TenantId": "",
143+
"ClientId": "",
144+
"ClientSecret": ""
141145
}
142146
}

0 commit comments

Comments
 (0)