Skip to content

Commit 3a32844

Browse files
authored
Merge pull request #3152 from TechnologyEnhancedLearning/Develop/Features/TD-5408-PassUrlParams
TD-5408 Passes email and admin ID as URL params to Tableau
2 parents 78e0adb + 185b1ba commit 3a32844

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public IActionResult DownloadSelfAssessmentReport(int selfAssessmentId)
8787
public IActionResult TableauCompetencyDashboard()
8888
{
8989
var userEmail = User.GetUserPrimaryEmail();
90-
var jwt = tableauConnectionHelper.GetTableauJwt(userEmail);
90+
var adminId = User.GetAdminId();
91+
var jwt = tableauConnectionHelper.GetTableauJwt();
92+
ViewBag.Email = userEmail;
93+
ViewBag.AdminId = adminId;
9194
ViewBag.SiteName = tableauSiteName;
9295
ViewBag.TableauServerUrl = tableauUrl;
9396
ViewBag.WorkbookName = workbookName;

DigitalLearningSolutions.Web/Helpers/ExternalApis/TableauConnectionHelper.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public interface ITableauConnectionHelperService
1111
{
12-
string GetTableauJwt(string email);
12+
string GetTableauJwt();
1313
}
1414
public class TableauConnectionHelper : ITableauConnectionHelperService
1515
{
@@ -24,7 +24,7 @@ public TableauConnectionHelper(IConfiguration config)
2424
connectedAppSecretKey = config.GetTableauClientSecret();
2525
user = config.GetTableauUser();
2626
}
27-
public string GetTableauJwt(string email)
27+
public string GetTableauJwt()
2828
{
2929
var key = Encoding.UTF8.GetBytes(connectedAppSecretKey);
3030
var signingCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256);
@@ -41,8 +41,7 @@ public string GetTableauJwt(string email)
4141
{ "aud", "tableau" },
4242
{ "exp", new DateTimeOffset(DateTime.UtcNow.AddMinutes(5)).ToUnixTimeSeconds() },
4343
{ "sub", user },
44-
{ "scp", new[] { "tableau:views:embed" } },
45-
{ "ExernalUserEmail", new [] { email } }
44+
{ "scp", new[] { "tableau:views:embed" } }
4645
};
4746
var token = new JwtSecurityToken(header, payload);
4847
var tokenHandler = new JwtSecurityTokenHandler();

DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/TableauCompetencyDashboard.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
var viewName = ViewBag.ViewName;
66
var jwtToken = ViewBag.JwtToken;
77
var siteName = ViewBag.SiteName;
8+
var aid = ViewBag.AdminId;
9+
var email = ViewBag.Email;
810
var srcUrl = $"{tableauServerUrl}/t/{siteName}/views/{workbookName}/{viewName}";
911
ViewData["Title"] = "Supervised self assessments dashboard";
1012
}
@@ -21,6 +23,8 @@
2123
<tableau-viz id='tableau-viz'
2224
src='@srcUrl' token='@jwtToken' toolbar='bottom'>
2325
If the dashboard doesn't appear after a few seconds, <a href="#">reload the page</a>
26+
<viz-parameter name="aid" value="@aid"></viz-parameter>
27+
<viz-parameter name="email" value="@email"></viz-parameter>
2428
</tableau-viz>
2529
@section scripts {
2630
@* We are not using Yarn/npm for the Tableau JS becaue of errors during installation relating to a missing dependency *@

0 commit comments

Comments
 (0)