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

TASK-6052 - Returned events by variant query endpoint are not displayed in Variant Browser and Sample Variant Browser #905

Merged
merged 6 commits into from
Apr 19, 2024
26 changes: 26 additions & 0 deletions src/webcomponents/commons/grid-commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,30 @@ export default class GridCommons {
return columns;
}

displayResponseWarningEvents(response) {
const eventsContainer = this.context.querySelector(`div#${this.gridId}WarningEvents`);
if (eventsContainer && (response?.events?.length > 0 || response?.responses?.[0]?.events?.length > 0)) {
const events = [...(response?.events || []), ...(response?.responses?.[0]?.events || [])]
.filter(event => event && event.type === "WARNING" && !!event.message);
if (events.length > 0) {
const eventsMessages = events.map(event => {
return `
<div class="alert alert-warning" style="margin-bottom:8px;">
<i class="fas fa-exclamation-triangle icon-padding"></i>
<span>${event.message}</span>
</div>
`;
});
eventsContainer.replaceChildren(UtilsNew.renderHTML(eventsMessages.join("")));
}
}
}

clearResponseWarningEvents() {
const eventsContainer = this.context.querySelector(`div#${this.gridId}WarningEvents`);
if (eventsContainer) {
eventsContainer.replaceChildren();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export default class VariantInterpreterGrid extends LitElement {
variantGrid: this,

ajax: params => {
this.gridCommons.clearResponseWarningEvents();
// Make a deep clone object to manipulate the query sent to OpenCGA
const internalQuery = JSON.parse(JSON.stringify(this.query));

Expand Down Expand Up @@ -307,6 +308,7 @@ export default class VariantInterpreterGrid extends LitElement {
});
},
responseHandler: response => {
this.gridCommons.displayResponseWarningEvents(response);
const result = this.gridCommons.responseHandler(response, $(this.table).bootstrapTable("getOptions"));
return result.response;
},
Expand Down Expand Up @@ -1456,6 +1458,8 @@ export default class VariantInterpreterGrid extends LitElement {
}
</style>

<div id="${this.gridId}WarningEvents"></div>

<opencb-grid-toolbar
.config="${this.toolbarConfig}"
.settings="${this.toolbarSetting}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export default class VariantInterpreterRearrangementGrid extends LitElement {
variantGrid: this,

ajax: params => {
this.gridCommons.clearResponseWarningEvents();
let rearrangementResponse = null;

// Make a deep clone object to manipulate the query sent to OpenCGA
Expand Down Expand Up @@ -343,6 +344,7 @@ export default class VariantInterpreterRearrangementGrid extends LitElement {
});
},
responseHandler: response => {
this.gridCommons.displayResponseWarningEvents(response);
const result = this.gridCommons.responseHandler(response, $(this.table).bootstrapTable("getOptions"));
return result.response;
},
Expand Down Expand Up @@ -1025,6 +1027,8 @@ export default class VariantInterpreterRearrangementGrid extends LitElement {
}
</style>

<div id="${this.gridId}WarningEvents"></div>

<opencb-grid-toolbar
.config="${this.toolbarConfig}"
.settings="${this.toolbarSetting}"
Expand Down
9 changes: 8 additions & 1 deletion src/webcomponents/variant/variant-browser-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export default class VariantBrowserGrid extends LitElement {
// this makes the variant-browser-grid properties available in the bootstrap-table detail formatter
variantGrid: this,
ajax: params => {
this.gridCommons.clearResponseWarningEvents();
const tableOptions = $(this.table).bootstrapTable("getOptions");
this.filters = {
study: this.opencgaSession.study.fqn,
Expand Down Expand Up @@ -291,12 +292,17 @@ export default class VariantBrowserGrid extends LitElement {
}
params.success(res);
})
.catch(e => params.error(e))
.catch(error => {
console.error(error);
params.error(error);
})
.finally(() => {
LitUtils.dispatchCustomEvent(this, "queryComplete", null);
});
},
responseHandler: response => {
this.gridCommons.displayResponseWarningEvents(response);

const result = this.gridCommons.responseHandler(response, $(this.table).bootstrapTable("getOptions"));

// Only the first 1M pages must be shown
Expand Down Expand Up @@ -1056,6 +1062,7 @@ export default class VariantBrowserGrid extends LitElement {

render() {
return html`
<div id="${this.gridId}WarningEvents"></div>
${this._config?.showToolbar ? html`
<opencb-grid-toolbar
.query="${this.query}"
Expand Down
Loading