forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#29 from tgunther-zerofox/ZFE-75240-proxy-re…
…quests-to-superset Add host to assets and add spa_bff/superset prefix
- Loading branch information
Showing
12 changed files
with
190 additions
and
202 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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Run sample local embedded Dashboard | ||
|
||
## ZF-Dashboard | ||
|
||
1. Configure on `.env`: `SUPERSET_URL=http://host.docker.internal:8088` | ||
2. Run zf-dashboard locally on Docker | ||
|
||
## Superset | ||
|
||
1. Run `make build` | ||
2. Run `make run` | ||
3. Log in and make sure you have a Dashboard configured to be embedded. Copy the ID of the Dashboard | ||
|
||
## Sample | ||
|
||
1. Edit the ID of the `embedded/sample.html` to the one you copied | ||
2. You might have some CORS issues locally. Open Chrome running `open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security` to avoid CORS problems at all | ||
3. Open `embedded/sample.html` in your browser | ||
|
||
# Tips | ||
|
||
- Run `cd superset-frontend` and `npm run build-dev` to run assets locally faster | ||
- Run `make build` and `make run` to update Superset if you change Phyton code |
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,89 @@ | ||
<script src="https://unpkg.com/@superset-ui/embedded-sdk"></script> | ||
|
||
<div id="my-superset-container"></div> | ||
|
||
<style> | ||
iframe { width: 100%; height: 700px; border: 0; overflow: hidden; } | ||
</style> | ||
|
||
<script> | ||
supersetEmbeddedSdk.embedDashboard({ | ||
// replace with your local id | ||
id: "9842845b-15da-4b0f-a1a5-0006e2c91e47", | ||
// supersetDomain: "http://localhost:8088", | ||
supersetDomain: "http://localhost:8000/spa_bff/superset", | ||
mountPoint: document.getElementById("my-superset-container"), | ||
fetchGuestToken: fetchGuestToken, | ||
dashboardUiConfig: { | ||
hideTitle: true, | ||
filters: { | ||
expanded: true, | ||
} | ||
}, | ||
}); | ||
|
||
async function fetchAccessToken() { | ||
try { | ||
const body = { | ||
username: "admin", | ||
password: "admin", | ||
provider: "db", | ||
refresh: true, | ||
} | ||
|
||
const response = await fetch( | ||
"http://localhost:8088/api/v1/security/login", | ||
{ | ||
method: "POST", | ||
body: JSON.stringify(body), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
} | ||
) | ||
|
||
const jsonResponse = await response.json() | ||
return jsonResponse?.access_token | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
} | ||
|
||
async function fetchGuestToken() { | ||
const accessToken = await fetchAccessToken() | ||
try { | ||
const body = { | ||
resources: [ | ||
{ | ||
type: "dashboard", | ||
// replace with your local id | ||
id: "9842845b-15da-4b0f-a1a5-0006e2c91e47", | ||
}, | ||
], | ||
rls: [], | ||
user: { | ||
username: "admin", | ||
first_name: "admin", | ||
last_name: "admin", | ||
}, | ||
} | ||
const response = await fetch( | ||
"http://localhost:8088/api/v1/security/guest_token/", | ||
{ | ||
method: "POST", | ||
body: JSON.stringify(body), | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
} | ||
) | ||
const jsonResponse = await response.json() | ||
return jsonResponse?.token | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
</script> | ||
|
||
|
Oops, something went wrong.