Skip to content

Commit e4d180a

Browse files
authored
Merge pull request #3193 from TechnologyEnhancedLearning/Develop/Fixes/TD-5408-UseTypeScriptToSetUrlParams
TD-5408 use type script to set url params
2 parents 99b6006 + 2d971df commit e4d180a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
async function setTableauParams(): Promise<void> {
2+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3+
const viz = document.getElementById('tableau-viz') as any;
4+
const adminIdElement = document.getElementById('hf-adminid') as HTMLInputElement | null;
5+
const emailElement = document.getElementById('hf-email') as HTMLInputElement | null;
6+
7+
if (!viz) {
8+
// console.error('Tableau Viz element not found.');
9+
return;
10+
}
11+
12+
if (!adminIdElement || !emailElement) {
13+
// console.error('Hidden input fields for adminid or email not found.');
14+
return;
15+
}
16+
17+
const adminId = adminIdElement.value;
18+
const email = emailElement.value;
19+
20+
// Listen for the `firstinteractive` event from the Web Component
21+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22+
viz.addEventListener('firstinteractive', async (event: Event) => {
23+
await viz.workbook.changeParameterValueAsync('adminid', adminId);
24+
await viz.workbook.changeParameterValueAsync('email', email);
25+
});
26+
}
27+
28+
// Run the function after the page loads
29+
document.addEventListener('DOMContentLoaded', () => {
30+
setTableauParams();
31+
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
<tableau-viz id='tableau-viz'
2424
src='@srcUrl' token='@jwtToken' toolbar='bottom'>
2525
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>
2826
</tableau-viz>
27+
<input type="hidden" id="hf-email" value="@email" />
28+
<input type="hidden" id="hf-adminid" value="@aid" />
2929
@section scripts {
3030
@* We are not using Yarn/npm for the Tableau JS becaue of errors during installation relating to a missing dependency *@
3131
<script type="module" src="@tableauServerUrl/javascripts/api/tableau.embedding.3.latest.min.js"></script>
32+
<script src="@Url.Content("~/js/trackingSystem/tableaureports.js")" asp-append-version="true"></script>
3233
}
3334
</feature>
3435
<feature name="@(FeatureFlags.TableauSelfAssessmentDashboards)" negate="true">

0 commit comments

Comments
 (0)