-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:metabase/embedding-reference-apps
- Loading branch information
Showing
8 changed files
with
156 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
django/embedded_analytics/user_stats/templates/user_stats/signed_public_dashboard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{% extends "user_stats/base.html" %} | ||
|
||
|
||
{% block content %} | ||
<hr> | ||
<h1>Signed dashboards without parameters</h1> | ||
<p> | ||
This is an example of a signed embedded dashboard. We haven't signed any parameters, but we have signed the resource id (in this case dashboard 1). This is means that only application with the signing key are allowed to embed a Metabase resource (vs the public link which can be copy/pasted and shared). Signed embeds can also be set to have an expiration time, which further improves security. | ||
</p> | ||
<p> | ||
To embed this dasbhoard in a webpage (as below), you'll need to generate a url on the server by signing a dictionary specifying the resource and it's signed parameters as below | ||
</p> | ||
<pre> | ||
payload = { | ||
"resource": {"dashboard": 1}, | ||
"params": { | ||
} | ||
} | ||
|
||
token = jwt.encode(payload, METABASE_SECRET_KEY, algorithm="HS256") | ||
|
||
iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token + "#bordered=true" | ||
</pre> | ||
<p> | ||
In the place you wish to embed the chart in your HTML, insert the below: | ||
</p> | ||
|
||
<pre> | ||
<code> | ||
|
||
|
||
<iframe | ||
src="http://{% templatetag openvariable %}iframeUrl{% templatetag closevariable %}" | ||
frameborder="0" | ||
width="800" | ||
height="600" | ||
allowtransparency | ||
/></iframe> | ||
</code> | ||
</pre> | ||
|
||
<a href="/">Go back to a global view</a> | ||
<hr> | ||
<p> | ||
This results in the below when put together | ||
</p> | ||
<h1>Global Order Stats</h1> | ||
<iframe src="http://{{iframeUrl}}" | ||
width="1200" | ||
height="800" | ||
frameborder="0"> | ||
</iframe> | ||
{% endblock %} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.