diff --git a/DigitalLearningSolutions.Web/Scripts/trackingSystem/tableaureports.ts b/DigitalLearningSolutions.Web/Scripts/trackingSystem/tableaureports.ts new file mode 100644 index 0000000000..873f322189 --- /dev/null +++ b/DigitalLearningSolutions.Web/Scripts/trackingSystem/tableaureports.ts @@ -0,0 +1,31 @@ +async function setTableauParams(): Promise { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const viz = document.getElementById('tableau-viz') as any; + const adminIdElement = document.getElementById('hf-adminid') as HTMLInputElement | null; + const emailElement = document.getElementById('hf-email') as HTMLInputElement | null; + + if (!viz) { + // console.error('Tableau Viz element not found.'); + return; + } + + if (!adminIdElement || !emailElement) { + // console.error('Hidden input fields for adminid or email not found.'); + return; + } + + const adminId = adminIdElement.value; + const email = emailElement.value; + + // Listen for the `firstinteractive` event from the Web Component + // eslint-disable-next-line @typescript-eslint/no-unused-vars + viz.addEventListener('firstinteractive', async (event: Event) => { + await viz.workbook.changeParameterValueAsync('adminid', adminId); + await viz.workbook.changeParameterValueAsync('email', email); + }); +} + +// Run the function after the page loads +document.addEventListener('DOMContentLoaded', () => { + setTableauParams(); +}); diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/TableauCompetencyDashboard.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/TableauCompetencyDashboard.cshtml index c9b29164f1..3c292de124 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/TableauCompetencyDashboard.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/TableauCompetencyDashboard.cshtml @@ -23,12 +23,13 @@ If the dashboard doesn't appear after a few seconds, reload the page - - + + @section scripts { @* We are not using Yarn/npm for the Tableau JS becaue of errors during installation relating to a missing dependency *@ + }