-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example application for embedding
- Loading branch information
Showing
8 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
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,8 @@ | ||
# Example application with IVIS panel embedding | ||
|
||
The [`panel.html`](panel.html) file shows an example of embedding a panel (from `panelId`). | ||
The [`template.html`](template.html) file shows an example of embedding a dynamic panel from a template (`templateId`) without instantiating an explicit panel in IVIS. | ||
|
||
1. Build the `ivis-embedding-client` package: `cd .. ; npm run build` | ||
2. Set the `apiAccessToken` (obtain it from the IVIS user interface – Account / API) and `panelId`/`templateId` in [`panel.html`](panel.html) and [`template.html`](template.html). For [`template.html`](template.html), you also need to set the `parameters` accordingly (based on the template's parameters). | ||
3. Open [`panel.html`](panel.html) or [`template.html`](template.html) in your browser. |
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,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>IVIS embed example</title> | ||
</head> | ||
<body> | ||
|
||
<div id="embedded-panel"></div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
<script type="text/javascript" src="../dist/ivis.js"></script> | ||
|
||
<script type="text/javascript" async> | ||
const ivisApiUrlBase = "http://localhost:8082/"; | ||
const ivisSandboxUrlBase = "http://localhost:8081/"; | ||
const apiAccessToken = "SET_YOUR_ACCESS_TOKEN_HERE"; | ||
const panelId = 1; | ||
|
||
axios.post(`${ivisApiUrlBase}api/embedded-panel-token`, { | ||
panelId: panelId, | ||
renewableBySandbox: true, | ||
}, { | ||
headers: {'access-token': apiAccessToken}, | ||
}).then((response) => { | ||
const restrictedAccessToken = response.data; | ||
IVIS.embedPanel('embedded-panel', ivisSandboxUrlBase, panelId, restrictedAccessToken); | ||
}) | ||
</script> | ||
|
||
|
||
</body> | ||
</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,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>IVIS embed example</title> | ||
</head> | ||
<body> | ||
|
||
<div id="embedded-panel"></div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | ||
<script type="text/javascript" src="../dist/ivis.js"></script> | ||
|
||
<script type="text/javascript" async> | ||
const ivisApiUrlBase = "http://localhost:8082/"; | ||
const ivisSandboxUrlBase = "http://localhost:8081/"; | ||
const apiAccessToken = "SET_YOUR_ACCESS_TOKEN_HERE"; | ||
const templateId = 1; | ||
/* assuming the following definition of template parameters: | ||
[{ | ||
"id": "label", | ||
"label": "Label", | ||
"type": "string" | ||
}] | ||
*/ | ||
const parameters = { | ||
"label": "Test" | ||
} | ||
|
||
axios.post(`${ivisApiUrlBase}api/embedded-template-token`, { | ||
templateId: templateId, | ||
renewableBySandbox: true, | ||
params: parameters, | ||
}, { | ||
headers: {'access-token': apiAccessToken}, | ||
}).then((response) => { | ||
const restrictedAccessToken = response.data; | ||
IVIS.embedTemplate('embedded-panel', ivisSandboxUrlBase, templateId, { params: parameters }, restrictedAccessToken); | ||
}) | ||
</script> | ||
|
||
|
||
</body> | ||
</html> | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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