Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Embed dashboard iframe in 'end message' - needs node.js / jsonwebtoken

More
8 years 1 month ago - 8 years 1 month ago #171761 by redbeard
Hi,

I would like to display a chart being powered by my BI tool at the end of a survey on the 'end message'.


For this, my BI tool says I have two things to do:

1) Insert this code snippet in your server code to generate the signed embedding URL - I have a choice of languages I can use:
Javascript:
Code:
// you will need to install via 'npm install jsonwebtoken' or in your package.json var jwt = require("jsonwebtoken"); var METABASE_SITE_URL = "<URL>"; var METABASE_SECRET_KEY = "<secret key>"; var payload = { resource: { dashboard: 6 }, params: { "category": "<survey ID>" } }; var token = jwt.sign(payload, METABASE_SECRET_KEY); var iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token + "#bordered=true&titled=true";

It is worth noting that: I am on a shared hosting account with SiteGround (node.js is not allowed to run) - if I need node.js I can probably install LimeSurvey on a dedicated account.

Python
Code:
# You'll need to install PyJWT via pip 'pip install PyJWT' or your project packages file import jwt METABASE_SITE_URL = "<URL>" METABASE_SECRET_KEY = "<Secret key>" payload = { "resource": {"dashboard": 6}, "params": { "category": "<survey id>" } } token = jwt.encode(payload, METABASE_SECRET_KEY, algorithm="HS256") iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token.decode("utf8") + "#bordered=true&titled=true"

2) Then insert this code snippet in your HTML template or single page app.
iframe(
src=iframeUrl
frameborder="0"
width="800"
height="600"
allowtransparency
)


I have tried uploading the code from 1 as a javascript file in a theme I extended (see capture.png, attached)



And the end message looks like:
Code:
<iframe allowtransparency="" frameborder="0" height="600" src="iframeUrl" width="800"></iframe>

Attached in capture2.png is the error message when I run the survey and reach the 'end page'
Last edit: 8 years 1 month ago by redbeard. Reason: Add screenshot of error message + detail
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose