-
Notifications
You must be signed in to change notification settings - Fork 1
feat: callback added to demo, add a server, and remove vite dependency #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9434280
remove vite
girarda 35b2465
Add the new files
girarda 33c71c2
pull directly from npm
girarda 4cb22d6
remove some prints
girarda 880f2d6
Merge branch 'main' into alex/viteless_demo
teallarson 0554f82
fix
girarda bb65f32
merge
girarda 11d555a
update
girarda f267a78
do the thing
teallarson 234745a
cleanup
teallarson 59e7cfa
moving things, documenting things
teallarson 275a7d3
add dependencies back to package.json
teallarson 6ab8819
remove `dev` script from main demo, fix tests, respond to review asks
teallarson ab41e77
Merge branch 'main' into teal/callback-in-demo
teallarson 1a8eb04
bump version
teallarson 1bde788
change license type back
teallarson 4157c12
review response
teallarson b0ea435
fix return type in playwright tests
teallarson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -2,57 +2,44 @@ | |
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Airbyte Widget Demo</title> | ||
<style> | ||
.loading { | ||
display: none; | ||
color: #fff; | ||
margin-top: 1rem; | ||
} | ||
.error { | ||
color: red; | ||
margin-top: 1rem; | ||
} | ||
#app { | ||
min-height: 200px; | ||
} | ||
</style> | ||
<title>Airbyte Embedded Widget</title> | ||
</head> | ||
<body> | ||
<h1>Airbyte Widget Demo</h1> | ||
<div id="app"> | ||
<div id="loading" class="loading">Loading widget...</div> | ||
<div id="error" class="error"></div> | ||
</div> | ||
<script type="module"> | ||
import { EmbeddedWidget } from "@airbyte-embedded/airbyte-embedded-widget"; | ||
<div id="widget-container"></div> | ||
|
||
const loadingEl = document.getElementById("loading"); | ||
const errorEl = document.getElementById("error"); | ||
<script type="module"> | ||
import { EmbeddedWidget } from "https://cdn.jsdelivr.net/npm/@airbyte-embedded/[email protected]/+esm"; | ||
|
||
async function initializeWidget() { | ||
window.addEventListener("load", async () => { | ||
try { | ||
new EmbeddedWidget({ | ||
token: import.meta.env.VITE_AB_EMBEDDED_TOKEN, | ||
}); | ||
const response = await fetch("http://localhost:3001/api/widget"); | ||
const data = await response.json(); | ||
|
||
// Hide loading state on success | ||
loadingEl.style.display = "none"; | ||
} catch (error) { | ||
console.error("Error initializing widget:", error); | ||
// Hide loading state and show error | ||
loadingEl.style.display = "none"; | ||
errorEl.innerHTML = ` | ||
<p>Failed to initialize widget:</p> | ||
<pre style="white-space: pre-wrap;">${error.message}</pre> | ||
<p>Check console for more details.</p> | ||
`; | ||
} | ||
} | ||
if (!data.token) { | ||
throw new Error("Missing 'token' in response"); | ||
} | ||
|
||
// Start initialization | ||
initializeWidget(); | ||
const widgetResultCallback = (result) => { | ||
// Send the result data to the embedded_response endpoint | ||
fetch("http://localhost:3001/api/embedded_response", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(result), | ||
}) | ||
.then((response) => console.log("Callback response:", response.status)) | ||
.catch((err) => console.error("Callback error:", err)); | ||
}; | ||
|
||
const widget = new EmbeddedWidget({ | ||
token: data.token, | ||
onEvent: widgetResultCallback, | ||
}); | ||
} catch (err) { | ||
console.error("Failed to load widget:", err); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to ourselves: we'll want a way to update this automatically