Skip to content

Commit

Permalink
Merge branch 'release-3.2.x' into TASK-6783
Browse files Browse the repository at this point in the history
  • Loading branch information
gpveronica authored Aug 30, 2024
2 parents 35345b9 + 03ad9d9 commit 44ef7ce
Show file tree
Hide file tree
Showing 51 changed files with 7,546 additions and 782 deletions.
8 changes: 4 additions & 4 deletions src/core/clients/opencga/api/Job.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* WARNING: AUTOGENERATED CODE
*
*
* This code was generated by a tool.
*
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
* Manual changes to this file will be overwritten if the code is regenerated.
*
**/

Expand Down Expand Up @@ -241,4 +241,4 @@ export default class Job extends OpenCGAParentClass {
return this._get("jobs", job, "log", null, "tail", params);
}

}
}
8 changes: 4 additions & 4 deletions src/core/clients/opencga/api/Organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* WARNING: AUTOGENERATED CODE
*
*
* This code was generated by a tool.
*
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
* Manual changes to this file will be overwritten if the code is regenerated.
*
**/

Expand Down Expand Up @@ -180,4 +180,4 @@ export default class Organization extends OpenCGAParentClass {
return this._post("organizations", organization, null, null, "update", data, params);
}

}
}
8 changes: 4 additions & 4 deletions src/core/clients/opencga/api/Study.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* WARNING: AUTOGENERATED CODE
*
*
* This code was generated by a tool.
*
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
* Manual changes to this file will be overwritten if the code is regenerated.
*
**/

Expand Down Expand Up @@ -342,4 +342,4 @@ export default class Study extends OpenCGAParentClass {
return this._post("studies", study, "variableSets", variableSet, "variables/update", data, params);
}

}
}
28 changes: 18 additions & 10 deletions src/core/clients/opencga/opencga-catalog-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,34 @@ export default class OpencgaCatalogUtils {
return false;
}

// Check if the user has the right the permissions in the study.
static isAdmin(study, userLogged) {
if (!study || !userLogged) {
console.error(`No valid parameters, study: ${study}, user: ${userLogged}`);
// Check if the provided user is admin in the organization
static isOrganizationAdmin(organization, userId) {
if (!organization || !userId) {
return false;
}
// Check if user is the Study owner
const studyOwner = study.fqn.split("@")[0];
if (userLogged === studyOwner) {
// 1. Check if user is the organization admin
if (organization?.owner === userId) {
return true;
} else {
// Check if user is a Study admin, belongs to @admins group
const admins = study.groups.find(group => group.id === "@admins");
if (admins.userIds.includes(userLogged)) {
// Check if user is an admin of the organization
if (organization?.admins?.includes?.(userId)) {
return true;
}
}
// Other case, user is not admin of the organization
return false;
}

// Check if the user has the right the permissions in the study.
static isAdmin(study, userLogged) {
if (!study || !userLogged) {
console.error(`No valid parameters, study: ${study}, user: ${userLogged}`);
return false;
}
const admins = study.groups.find(group => group.id === "@admins");
return !!admins.userIds.includes(userLogged);
}

// Check if the provided user is admin in the organization
static isOrganizationAdmin(organization, userId) {
if (!organization || !userId) {
Expand Down
11 changes: 7 additions & 4 deletions src/core/clients/opencga/opencga-parent-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export default class OpenCGAParentClass {
_options.token = sid;
}
}

// CAUTION Vero 2024-05-10: We believe this bit of code is useless. Temporarily commented out.
// In users endpoint, we cannot find GET method where the path param {user/users} should be autocompleted.
// When needed, they should be explicitly set.
// If category == users and userId is not given, we try to set it
if (category1 === "users" && (ids1 === undefined || ids1 === null || ids1 === "")) {
ids1 = this._getUserId();
}
// if (category1 === "users" && (ids1 === undefined || ids1 === null || ids1 === "")) {
// ids1 = this._getUserId();
// }

let url = this._createRestUrl(host, version, category1, ids1, category2, ids2, action);
// if (method === "GET") {
url = this._addQueryParams(url, _params);
Expand Down
48 changes: 33 additions & 15 deletions src/sites/iva/conf/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const hosts = [
url: "https://demo.app.zettagenomics.com/opencga"
},
{
id: "xeta-110e",
url: "https://test.app.zettagenomics.com/xeta-110e/opencga"
id: "reference",
url: "https://test.app.zettagenomics.com/reference/opencga"
},
];

Expand Down Expand Up @@ -762,9 +762,18 @@ const SUITE = {
<br>`
},
menu: [
{
id: "organization-admin",
name: "Organizations Admin",
fa_icon: "fas fa-file-invoice",
icon: "img/tools/icons/variant_browser.svg",
description: "",
visibility: "public",
featured: true,
},
{
id: "study-admin",
name: "Study admin",
name: "Study Admin",
fa_icon: "fas fa-file-invoice",
icon: "img/tools/icons/variant_browser.svg",
description: "",
Expand All @@ -782,7 +791,7 @@ const SUITE = {
// },
{
id: "study-admin-iva",
name: "IVA configuration",
name: "IVA Configuration",
fa_icon: "fas fa-file-invoice",
icon: "img/tools/icons/variant_browser.svg",
description: "",
Expand All @@ -798,24 +807,33 @@ const SUITE = {
// visibility: "public",
// featured: false,
// },
// {
// id: "study-variant-admin",
// name: "Study Variant Admin",
// fa_icon: "fas fa-file-invoice",
// icon: "img/tools/icons/variant_browser.svg",
// description: "",
// visibility: "public",
// featured: true,
// },
{
id: "study-variant-admin",
name: "Study Variant Admin",
fa_icon: "fas fa-file-invoice",
icon: "img/tools/icons/variant_browser.svg",
description: "",
visibility: "public",
featured: true,
},
{
id: "projects-admin",
name: "Project Manager",
id: "operations-admin",
name: "Operations Admin",
fa_icon: "fas fa-file-invoice",
icon: "img/tools/icons/variant_browser.svg",
description: "",
visibility: "public",
featured: true,
},
// {
// id: "projects-admin",
// name: "Project Manager",
// fa_icon: "fas fa-file-invoice",
// icon: "img/tools/icons/variant_browser.svg",
// description: "",
// visibility: "public",
// featured: true,
// },
],
fileExplorer: {
visibility: "private"
Expand Down
33 changes: 22 additions & 11 deletions src/sites/iva/iva-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ import "../../webcomponents/clinical/clinical-analysis-create.js";
import "../../webcomponents/file/file-manager.js";
import "../../webcomponents/job/job-monitor.js";
import "../../webcomponents/loading-spinner.js";
import "../../webcomponents/organization/admin/organization-admin.js";
import "../../webcomponents/project/projects-admin.js";
import "../../webcomponents/study/admin/study-admin.js";
import "../../webcomponents/study/admin/study-admin-iva.js";
import "../../webcomponents/study/admin/catalog-admin.js";
import "../../webcomponents/study/admin/variant/study-variant-admin.js";
import "../../webcomponents/study/admin/variant/operations-admin.js";
import "../../webcomponents/user/user-profile.js";
import "../../webcomponents/api/rest-api.js";
import "../../webcomponents/note/note-browser.js";
Expand Down Expand Up @@ -224,13 +226,15 @@ class IvaApp extends LitElement {
"diseasePanelUpdate",
"clinicalAnalysis",
// Admin
"organization-admin",
"study-admin",
"study-admin-iva",
// "catalog-admin",
"operations-admin",
"study-variant-admin",
"opencga-admin",
"variants-admin",
"projects-admin",
// "projects-admin",
// REST-API
"rest-api",
// note
Expand Down Expand Up @@ -1135,6 +1139,10 @@ class IvaApp extends LitElement {
// }

onSessionUpdateRequest() {
NotificationUtils.dispatch(this, NotificationUtils.NOTIFY_SUCCESS, {
title: "Refresh Session: Session Update Request",
message: "Session updated correctly",
});
this._createOpenCGASession();
}

Expand Down Expand Up @@ -1979,13 +1987,15 @@ class IvaApp extends LitElement {
` : nothing}
<!-- Admin -->
${this.config.enabledComponents["projects-admin"] ? html`
<tool-header title="Projects Admin" icon="${"fas fa-rocket"}"></tool-header>
<div id="projects-admin">
<projects-admin
${this.config.enabledComponents["organization-admin"] ? html`
<tool-header title="Organization Admin: ${this.opencgaSession?.user?.organization}" icon="${"fas fa-sitemap"}"></tool-header>
<div id="organization-admin">
<organization-admin
.organization="${this.opencgaSession?.organization}"
.opencgaSession="${this.opencgaSession}"
@studyUpdateRequest="${this.onStudyUpdateRequest}"
@sessionUpdateRequest="${this.onSessionUpdateRequest}">
</projects-admin>
</organization-admin>
</div>
` : nothing}
Expand All @@ -1998,7 +2008,7 @@ class IvaApp extends LitElement {
</div>
` : nothing}
${this.config.enabledComponents["opencga-admin"] ? html`
${this.config.enabledComponents["projects-admin"] ? html`
<tool-header title="Study Dashboard" icon="${"fas fa-rocket"}"></tool-header>
<div id="projects-admin">
<projects-admin
Expand All @@ -2011,7 +2021,6 @@ class IvaApp extends LitElement {
${this.config.enabledComponents["study-admin"] ? html`
<div class="content" id="study-admin">
<study-admin
.study="${this.opencgaSession.study}"
.opencgaSession="${this.opencgaSession}"
@studyUpdateRequest="${this.onStudyUpdateRequest}">
</study-admin>
Expand All @@ -2023,20 +2032,22 @@ class IvaApp extends LitElement {
${this.config.enabledComponents["study-admin-iva"] ? html`
<div class="content row">
<study-admin-iva
.organizationId="${this.opencgaSession?.user?.organization}"
.opencgaSession="${this.opencgaSession}"
.settings="${this.settings}"
@studyUpdateRequest="${this.onStudyUpdateRequest}">
</study-admin-iva>
</div>
` : nothing}
${this.config.enabledComponents["study-variant-admin"] ? html`
${this.config.enabledComponents["operations-admin"] ? html`
<div class="content row">
<study-variant-admin
<operations-admin
.organizationId="${this.opencgaSession?.user?.organization}"
.study="${this.opencgaSession.study}"
.opencgaSession="${this.opencgaSession}"
@studyUpdateRequest="${this.onStudyUpdateRequest}">
</study-variant-admin>
</operations-admin>
</div>
` : nothing}
Expand Down
3 changes: 2 additions & 1 deletion src/webcomponents/api/opencga-rest-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ export default class OpencgaRestInput extends LitElement {

#postEndpoint(url, isForm) {
// Add Study
url += "study=" + encodeURIComponent(this.opencgaSession.study.fqn);
// Fixme: not all endpoints require study. E.g. POST /users/password/
url += "study=" + encodeURIComponent(this.opencgaSession?.study?.fqn);

// Replace PATH params
this.endpoint.parameters
Expand Down
2 changes: 1 addition & 1 deletion src/webcomponents/cohort/cohort-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export default class CohortGrid extends LitElement {
id: "actions",
title: "Actions",
field: "actions",
align: "center",
formatter: () => `
<div class="d-inline-block dropdown">
<button class="btn btn-light btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown">
Expand All @@ -367,7 +368,6 @@ export default class CohortGrid extends LitElement {
</ul>
</div>
`,
align: "center",
events: {
"click a": this.onActionClick.bind(this),
},
Expand Down
10 changes: 10 additions & 0 deletions src/webcomponents/commons/catalog-grid-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import BioinfoUtils from "../../core/bioinfo/bioinfo-utils.js";

export default class CatalogGridFormatter {

static userStatusFormatter(status, config) {
const _config = config || [];
const currentStatus = status.id || status.name || "UNDEFINED"; // Get current status
const displayCurrentStatus = _config.find(status => status.id === currentStatus);
return `
<span class="badge" style="background-color: ${displayCurrentStatus.displayColor}">
<strong>${displayCurrentStatus.displayLabel}</strong>
</span>
`;
}
static sexFormatter(value, row) {
let sexHtml = `${UtilsNew.isEmpty(row?.sex) ? "Not specified" : row.sex.id || row.sex}`;
if (row?.karyotypicSex && row.karyotypicSex !== "UNKNOWN") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class CatalogSearchAutocomplete extends LitElement {
searchField: "id",
placeholder: "project...",
// client: this.opencgaSession.opencgaClient.projects(),
fetch: filters => this.opencgaSession.opencgaClient.projects().search(filters),
fetch: ({study, ...params}) => this.opencgaSession.opencgaClient.projects().search(params),
fields: item => ({
"name": item.id,
}),
Expand All @@ -94,7 +94,7 @@ export default class CatalogSearchAutocomplete extends LitElement {
searchField: "id",
placeholder: "study...",
// client: this.opencgaSession.opencgaClient.studies(),
fetch: filters => this.opencgaSession.opencgaClient.studies().search(filters),
fetch: ({study, ...params}) => this.opencgaSession.opencgaClient.studies().search(params),
fields: item => ({
"name": item.id,
}),
Expand Down Expand Up @@ -286,6 +286,7 @@ export default class CatalogSearchAutocomplete extends LitElement {
...this.query || this.RESOURCES[this.resource].query,
...attr,
};

this.RESOURCES[this.resource].fetch(filters)
.then(response => success(response))
.catch(error => failure(error));
Expand Down
Loading

0 comments on commit 44ef7ce

Please sign in to comment.