Skip to content
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

Wait for custom element definition before using applet #1880

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/main/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def start_algorithm(
# Add in workflow parameters.
existing_params = manifest["spec"].get("arguments", {}).get("parameters", [])
manifest["spec"]["arguments"] = {
"parameters": existing_params + [
"parameters": existing_params
+ [
{
"name": "name",
"value": self.alg.name,
Expand Down
62 changes: 36 additions & 26 deletions ui/src/js/annotation/tools-applet-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,47 @@ export class ToolsAppletPanel extends TatorElement {
initApplet() {
// if (this._appletData == null) { return; }

this._appletElement =
const appletElement =
this._appletView.contentWindow.document.getElementById("toolsApplet");
if (this._appletElement == null) {
if (appletElement == null) {
return;
}

this._appletElement.addEventListener(
"closeApplet",
this.togglePanel.bind(this)
);

// Listen for html registration, and page event with svg as detail
this._appletElement.addEventListener("icon-ready", (evt) => {
if (this._appletTrigger !== null && evt.detail.icon !== null) {
this._appletTrigger.setIcon(evt.detail.icon);
} else {
console.warn(
"Event icon ready heard, but not enough data to set icon."
const appletTagName = appletElement.tagName.toLowerCase();
this._appletView.contentWindow.customElements
.whenDefined(appletTagName)
.then(() => {
this._appletElement =
this._appletView.contentWindow.document.getElementById("toolsApplet");
if (this._appletElement == null) {
return;
}

this._appletElement.addEventListener(
"closeApplet",
this.togglePanel.bind(this)
);
}
});

// RUN THIS LAST! listeners need to be in place above first
this._appletElement.init({
canvas: this._canvas,
canvasElement: this._canvasElement,
data: this._page._data,
});

//
this.dispatchEvent(new Event("appletReady"));
// Listen for html registration, and page event with svg as detail
this._appletElement.addEventListener("icon-ready", (evt) => {
if (this._appletTrigger !== null && evt.detail.icon !== null) {
this._appletTrigger.setIcon(evt.detail.icon);
} else {
console.warn(
"Event icon ready heard, but not enough data to set icon."
);
}
});

// RUN THIS LAST! listeners need to be in place above first
this._appletElement.init({
canvas: this._canvas,
canvasElement: this._canvasElement,
data: this._page._data,
});

//
this.dispatchEvent(new Event("appletReady"));
});
}
}

Expand Down
Loading