@@ -124,5 +125,4 @@ export default class ModalUtils {
modalHeader.style.cursor = "move";
}
-
}
diff --git a/src/webcomponents/commons/opencb-grid-toolbar.js b/src/webcomponents/commons/opencb-grid-toolbar.js
index 663ac44c00..eaef8b6ccc 100644
--- a/src/webcomponents/commons/opencb-grid-toolbar.js
+++ b/src/webcomponents/commons/opencb-grid-toolbar.js
@@ -149,13 +149,6 @@ export default class OpencbGridToolbar extends LitElement {
`) : nothing}
- ${this._settings.showRefresh ? html`
-
- ` :nothing}
-
-
${this._config?.create && (this._settings.showCreate || this._settings.showNew) ? html`
diff --git a/src/webcomponents/individual/individual-grid.js b/src/webcomponents/individual/individual-grid.js
index 49d0f1b62c..385b2e258e 100644
--- a/src/webcomponents/individual/individual-grid.js
+++ b/src/webcomponents/individual/individual-grid.js
@@ -638,11 +638,81 @@ export default class IndividualGrid extends LitElement {
});
}
+ onCreateCohortShow() {
+ const filters = {
+ ...this.filters,
+ include: "id,samples.id,samples.internal",
+ limit: 5000,
+ };
+ this.opencgaSession.opencgaClient.individuals()
+ .search(filters)
+ .then(response => {
+ const results = response.getResults();
+ if (results) {
+ this.createCohortSampleIds = [];
+ for (const result of results) {
+ for (const sample of result.samples) {
+ this.createCohortSampleIds.push({"id": sample.id});
+ }
+ }
+ this.requestUpdate();
+ ModalUtils.show(`${this._prefix}CreateCohortModal`);
+ } else {
+ console.error("Error in result format");
+ }
+ })
+ .catch(response => {
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_RESPONSE, response);
+ });
+ }
+
+ onCreateCohortSave() {
+ const cohortId = document.querySelector(`#${this._prefix}CohortId`).value;
+ const cohortName = document.querySelector(`#${this._prefix}CohortName`).value;
+
+ const params = {
+ study: this.opencgaSession.study.fqn,
+ includeResult: false
+ };
+ let error;
+ this.opencgaSession.opencgaClient.cohorts()
+ .create(
+ {
+ id: cohortId,
+ name: cohortName ?? "",
+ samples: this.createCohortSampleIds,
+ }, params)
+ .then(() => {
+ this.createCohortSampleIds = [];
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_SUCCESS, {
+ title: "Cohort Create",
+ message: "Cohort created correctly"
+ });
+ })
+ .catch(reason => {
+ error = reason;
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_RESPONSE, reason);
+ });
+ }
+
+ getRightToolbar() {
+ return [
+ {
+ render: () => html`
+
+ `,
+ }
+ ];
+ }
+
render() {
return html`
${this._config.showToolbar ? html`
{
+ return html`
+ Create a new cohort with ${this.createCohortSampleIds?.length} samples.
+ This can take few seconds depending on the number of samples.
+ ${this.createCohortSampleIds?.length === 5000 ? html`
+ No more than 5,000 samples allowed
+ ` : nothing}
+ Select the new Cohort ID and Name:
+
+ `;
+ },
+ onOk: e => this.onCreateCohortSave(e)
+ })}
`;
}
diff --git a/src/webcomponents/job/job-grid.js b/src/webcomponents/job/job-grid.js
index 8eaec6ee64..9c22ac6080 100644
--- a/src/webcomponents/job/job-grid.js
+++ b/src/webcomponents/job/job-grid.js
@@ -306,10 +306,6 @@ export default class JobGrid extends LitElement {
this.gridCommons.onColumnChange(e);
}
- onRefresh() {
- this.table.bootstrapTable("refresh");
- }
-
detailFormatter(value, row) {
let result = "";
let detailHtml = "";
@@ -369,6 +365,12 @@ export default class JobGrid extends LitElement {
async onActionClick(e, _, row) {
const action = e.target.dataset.action?.toLowerCase();
switch (action) {
+ case "retry":
+ this.jobRetryObj = row;
+ this.requestUpdate();
+ // await this.updateComplete;
+ ModalUtils.show(`${this._prefix}RetryModal`);
+ break;
case "edit":
this.jobUpdateId = row.id;
this.requestUpdate();
@@ -436,7 +438,7 @@ export default class JobGrid extends LitElement {
${nestedObject}
` :
- `
${key}: ${params[key]}`}
+ `
${key}: ${params[key]}`}
`;
}
@@ -533,6 +535,12 @@ export default class JobGrid extends LitElement {
+ ${ModalUtils.create(this, `${this._prefix}RetryModal`, {
+ display: {
+ modalTitle: "Job Retry",
+ modalDraggable: true,
+ modalbtnsVisible: true
+ },
+ render: () => {
+ return html`
+
This will execute a new Job with the same parameters as the original job.
+ Are you sure do you want to execute again ${this.jobRetryObj?.id}?
+
+ `;
+ },
+ onOk: e => this.onJobRetry(e)
+ })}
+
${ModalUtils.create(this, `${this._prefix}UpdateModal`, {
display: {
modalTitle: "Job Update",
diff --git a/src/webcomponents/sample/sample-grid.js b/src/webcomponents/sample/sample-grid.js
index 99aadef9c0..7b45aaeded 100644
--- a/src/webcomponents/sample/sample-grid.js
+++ b/src/webcomponents/sample/sample-grid.js
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import {LitElement, html, nothing} from "lit";
+import {html, LitElement, nothing} from "lit";
import UtilsNew from "../../core/utils-new.js";
import GridCommons from "../commons/grid-commons.js";
import CatalogGridFormatter from "../commons/catalog-grid-formatter.js";
@@ -510,11 +510,78 @@ export default class SampleGrid extends LitElement {
});
}
+ onCreateCohortShow() {
+ const filters = {
+ ...this.filters,
+ include: "id",
+ limit: 5000,
+ };
+ this.opencgaSession.opencgaClient.samples()
+ .search(filters)
+ .then(response => {
+ const results = response.getResults();
+ if (results) {
+ this.createCohortSampleIds = results.map(s => {
+ return {"id": s.id};
+ });
+ this.requestUpdate();
+ ModalUtils.show(`${this._prefix}CreateCohortModal`);
+ } else {
+ console.error("Error in result format");
+ }
+ })
+ .catch(response => {
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_RESPONSE, response);
+ });
+ }
+
+ onCreateCohortSave() {
+ const cohortId = document.querySelector(`#${this._prefix}CohortId`).value;
+ const cohortName = document.querySelector(`#${this._prefix}CohortName`).value;
+
+ const params = {
+ study: this.opencgaSession.study.fqn,
+ includeResult: false
+ };
+ let error;
+ this.opencgaSession.opencgaClient.cohorts()
+ .create(
+ {
+ id: cohortId,
+ name: cohortName ?? "",
+ samples: this.createCohortSampleIds,
+ }, params)
+ .then(() => {
+ this.createCohortSampleIds = [];
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_SUCCESS, {
+ title: "Cohort Create",
+ message: "Cohort created correctly"
+ });
+ })
+ .catch(reason => {
+ error = reason;
+ NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_RESPONSE, reason);
+ });
+ }
+
+ getRightToolbar() {
+ return [
+ {
+ render: () => html`
+
+ `,
+ }
+ ];
+ }
+
render() {
return html`
${this._config.showToolbar ? html`
{
+ return html`
+ Create a new cohort with ${this.createCohortSampleIds?.length} samples.
+ This can take few seconds depending on the number of samples.
+ ${this.createCohortSampleIds?.length === 5000 ? html`
+ No more than 5,000 samples allowed
+ ` : nothing}
+ Select the new Cohort ID and Name:
+
+ `;
+ },
+ onOk: e => this.onCreateCohortSave(e)
+ })}
`;
}