diff --git a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js index bad4b42af49..db29b945549 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -168,7 +168,7 @@ qx.Class.define("osparc.dashboard.CardBase", { if (gid === myGroupId) { continue; } - const grp = groups[i].find(group => "gid" in group ? group["gid"] === gid : group.getGroupId() === gid); + const grp = groups[i].find(group => group.getGroupId() === gid); if (grp) { sharedGrp.push(grp); } @@ -203,7 +203,7 @@ qx.Class.define("osparc.dashboard.CardBase", { sharedGrpLabels.push("..."); break; } - const sharedGrpLabel = sharedGrps[i]["label"]; + const sharedGrpLabel = sharedGrps[i].getLabel(); if (!sharedGrpLabels.includes(sharedGrpLabel)) { sharedGrpLabels.push(sharedGrpLabel); } diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js index 69b86e4cd66..2c1c119ca36 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceContainerManager.js @@ -478,8 +478,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { const org = groupsStore.getOrganizationOrUser(orgId); if (org) { let icon = ""; - if ("thumbnail" in org || ("getThumbnail" in org && org.getThumbnail())) { - icon = "thumbnail" in org ? org["thumbnail"] : org.getThumbnail(); + if (org.getThumbnail()) { + icon = org.getThumbnail(); } else if (org["collabType"] === 0) { icon = "@FontAwesome5Solid/globe/24"; } else if (org["collabType"] === 1) { @@ -489,7 +489,7 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", { } groupContainer.set({ headerIcon: icon, - headerLabel: "label" in org ? org["label"] : org.getLabel(), + headerLabel: org.getLabel(), }); } else { groupContainer.exclude(); diff --git a/services/static-webserver/client/source/class/osparc/data/model/User.js b/services/static-webserver/client/source/class/osparc/data/model/User.js index 5ceb91bed4b..4fa90dfaab8 100644 --- a/services/static-webserver/client/source/class/osparc/data/model/User.js +++ b/services/static-webserver/client/source/class/osparc/data/model/User.js @@ -40,6 +40,7 @@ qx.Class.define("osparc.data.model.User", { groupId: userData.gid, label: label, login: userData.login, + thumbnail: osparc.utils.Avatar.getUrl(userData.login, 32), accessRights: userData.accessRights, }); }, @@ -79,5 +80,12 @@ qx.Class.define("osparc.data.model.User", { init: null, event: "changeAccessRights", }, + + thumbnail: { + check: "String", + nullable: true, + init: "", + event: "changeThumbnail", + }, } }); diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js index 074c01207a9..d5d7e6ba6dc 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js @@ -279,27 +279,23 @@ qx.Class.define("osparc.desktop.preferences.pages.ClustersPage", { const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators(); clusterMembers.forEach(clusterMember => { - const gid = "gid" in clusterMember ? clusterMember["gid"] : clusterMember.getGroupId(); + const gid = clusterMember.getGroupId(); if (gid in potentialCollaborators) { const collaborator = potentialCollaborators[gid]; const collabObj = {}; if (collaborator["collabType"] === 1) { - collabObj["thumbnail"] = collaborator["thumbnail"] || "@FontAwesome5Solid/users/24"; - collabObj["name"] = osparc.utils.Utils.firstsUp(collaborator["label"]); - collabObj["login"] = collaborator["description"]; + // group + collabObj["thumbnail"] = collaborator.getThumbnail() || "@FontAwesome5Solid/users/24"; + collabObj["login"] = collaborator.getDescription(); } else if (collaborator["collabType"] === 2) { - collabObj["thumbnail"] = osparc.utils.Avatar.getUrl(collaborator["login"], 32); - collaborator["name"] = osparc.utils.Utils.firstsUp( - `${"first_name" in collaborator && collaborator["first_name"] != null ? - collaborator["first_name"] : collaborator["login"]}`, - `${"last_name" in collaborator && collaborator["last_name"] ? - collaborator["last_name"] : ""}` - ); - collabObj["login"] = collaborator["login"]; + // user + collabObj["thumbnail"] = collaborator.getThumbnail() || "@FontAwesome5Solid/user/24"; + collabObj["login"] = collaborator.getLogin(); } if (Object.keys(collabObj).length) { - collabObj["id"] = collaborator["gid"]; - collabObj["accessRights"] = JSON.parse(qx.util.Serializer.toJson(clusterMember)); + collabObj["id"] = collaborator.getGroupId(); + collabObj["name"] = collaborator.getLabel(); + collabObj["accessRights"] = clusterMember.getAccessRights(); collabObj["showOptions"] = canWrite; membersArrayModel.append(qx.data.marshal.Json.createModel(collabObj)); } diff --git a/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js b/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js index 2d45199661f..03f07f01c97 100644 --- a/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js +++ b/services/static-webserver/client/source/class/osparc/filter/OrganizationsAndMembers.js @@ -37,14 +37,9 @@ qx.Class.define("osparc.filter.OrganizationsAndMembers", { __collaboratorsToBeRemoved: null, addOption: function(group) { - let name = ""; - if ("first_name" in group) { - name = `${group["first_name"]} ${"last_name" in group && group["last_name"] != null ? group["last_name"] : ""}`; - } else { - name = group["label"]; - } + const name = group.getLabel(); const btn = this._addOption(name); - btn.gid = group["gid"]; + btn.gid = group.getGroupId(); return btn; }, @@ -89,7 +84,7 @@ qx.Class.define("osparc.filter.OrganizationsAndMembers", { if (a["collabType"] < b["collabType"]) { return -1; } - if (a["label"] > b["label"]) { + if (a.getLabel() > b.getLabel()) { return 1; } return -1; diff --git a/services/static-webserver/client/source/class/osparc/info/CommentAdd.js b/services/static-webserver/client/source/class/osparc/info/CommentAdd.js index 060ce42ca69..b8f36a839e6 100644 --- a/services/static-webserver/client/source/class/osparc/info/CommentAdd.js +++ b/services/static-webserver/client/source/class/osparc/info/CommentAdd.js @@ -68,9 +68,9 @@ qx.Class.define("osparc.info.CommentAdd", { maxHeight: 32, decorator: "rounded", }); - const userEmail = osparc.auth.Data.getInstance().getEmail(); + const myEmail = osparc.auth.Data.getInstance().getEmail(); control.set({ - source: osparc.utils.Avatar.getUrl(userEmail, 32) + source: osparc.utils.Avatar.getUrl(myEmail, 32) }); const layout = this.getChildControl("add-comment-layout"); layout.add(control, { diff --git a/services/static-webserver/client/source/class/osparc/info/CommentUI.js b/services/static-webserver/client/source/class/osparc/info/CommentUI.js index 06b121d1287..30c5891907f 100644 --- a/services/static-webserver/client/source/class/osparc/info/CommentUI.js +++ b/services/static-webserver/client/source/class/osparc/info/CommentUI.js @@ -119,9 +119,8 @@ qx.Class.define("osparc.info.CommentUI", { const user = osparc.store.Groups.getInstance().getUser(this.__comment["user_id"]) if (user) { - const userSource = osparc.utils.Avatar.getUrl(user["login"], 32); - thumbnail.setSource(userSource); - userName.setValue(user["label"]); + thumbnail.setSource(user.getThumbnail()); + userName.setValue(user.getLabel()); } } } diff --git a/services/static-webserver/client/source/class/osparc/navigation/UserMenuButton.js b/services/static-webserver/client/source/class/osparc/navigation/UserMenuButton.js index ac256291335..e53fc4e7e1c 100644 --- a/services/static-webserver/client/source/class/osparc/navigation/UserMenuButton.js +++ b/services/static-webserver/client/source/class/osparc/navigation/UserMenuButton.js @@ -51,7 +51,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", { const preferencesSettings = osparc.Preferences.getInstance(); preferencesSettings.addListener("changeCreditsWarningThreshold", () => this.__updateHaloColor()); - const userEmail = authData.getEmail() || "bizzy@itis.ethz.ch"; + const myEmail = authData.getEmail() || "bizzy@itis.ethz.ch"; const icon = this.getChildControl("icon"); authData.bind("role", this, "icon", { converter: role => { @@ -64,7 +64,7 @@ qx.Class.define("osparc.navigation.UserMenuButton", { icon.getContentElement().setStyles({ "margin-left": "-4px" }); - return osparc.utils.Avatar.getUrl(userEmail, 32); + return osparc.utils.Avatar.getUrl(myEmail, 32); } }); }, diff --git a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js index ce3b0a2ad30..64ca828951c 100644 --- a/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js +++ b/services/static-webserver/client/source/class/osparc/notification/NotificationUI.js @@ -135,7 +135,7 @@ qx.Class.define("osparc.notification.NotificationUI", { icon.setSource("@FontAwesome5Solid/users/14"); if (resourceId) { osparc.store.Groups.getInstance().fetchGroup(resourceId) - .then(group => descriptionLabel.setValue("You're now member of '" + group["label"] + "'")) + .then(group => descriptionLabel.setValue("You're now member of '" + group.getLabel() + "'")) .catch(() => this.setEnabled(false)); } break; @@ -159,7 +159,7 @@ qx.Class.define("osparc.notification.NotificationUI", { if (userFromId) { const user = osparc.store.Groups.getInstance().getUser(userFromId); if (user) { - descriptionLabel.setValue("was shared by " + user["label"]); + descriptionLabel.setValue("was shared by " + user.getLabel()); } } break; @@ -179,7 +179,7 @@ qx.Class.define("osparc.notification.NotificationUI", { if (userFromId) { const user = osparc.store.Groups.getInstance().getUser(userFromId); if (user) { - descriptionLabel.setValue("was shared by " + user["label"]); + descriptionLabel.setValue("was shared by " + user.getLabel()); } } break; @@ -198,7 +198,7 @@ qx.Class.define("osparc.notification.NotificationUI", { if (userFromId) { const user = osparc.store.Groups.getInstance().getUser(userFromId); if (user) { - descriptionLabel.setValue("was added by " + user["label"]); + descriptionLabel.setValue("was added by " + user.getLabel()); } } break; diff --git a/services/static-webserver/client/source/class/osparc/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/share/Collaborators.js index 76844f4f0e2..989e8e0fd23 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -417,13 +417,8 @@ qx.Class.define("osparc.share.Collaborators", { const collaborator = osparc.utils.Utils.deepCloneObject(collab); if ("first_name" in collaborator) { // user - collaborator["thumbnail"] = osparc.utils.Avatar.getUrl(collaborator["login"], 32); - collaborator["name"] = osparc.utils.Utils.firstsUp( - `${"first_name" in collaborator && collaborator["first_name"] != null ? - collaborator["first_name"] : collaborator["login"]}`, - `${"last_name" in collaborator && collaborator["last_name"] ? - collaborator["last_name"] : ""}` - ); + collaborator["thumbnail"] = collaborator.getThumbnail(); + collaborator["name"] = collaborator.getLabel(); } else if (everyoneGIds.includes(parseInt(gid))) { // everyone product or everyone if (collaborator["thumbnail"] === null) { diff --git a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js index db2ca38c3fd..b3f8509dc43 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -154,7 +154,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { if (a["collabType"] < b["collabType"]) { return -1; } - if (a["label"] > b["label"]) { + if (a.getLabel() > b.getLabel()) { return 1; } return -1; diff --git a/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js b/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js index efd453b238d..015f6ca3fba 100644 --- a/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js +++ b/services/static-webserver/client/source/class/osparc/share/PublishTemplate.js @@ -66,7 +66,7 @@ qx.Class.define("osparc.share.PublishTemplate", { const currentGids = this.getSelectedGroups(); gids.forEach(gid => { if (gid in potentialCollaborators && !currentGids.includes(gid)) { - const collabButton = new qx.ui.toolbar.Button(potentialCollaborators[gid]["label"], "@MaterialIcons/close/12"); + const collabButton = new qx.ui.toolbar.Button(potentialCollaborators[gid].getLabel(), "@MaterialIcons/close/12"); collabButton.gid = gid; this.__selectedCollabs.add(collabButton); collabButton.addListener("execute", () => { diff --git a/services/static-webserver/client/source/class/osparc/store/Groups.js b/services/static-webserver/client/source/class/osparc/store/Groups.js index afd10c41487..56ea082e8a7 100644 --- a/services/static-webserver/client/source/class/osparc/store/Groups.js +++ b/services/static-webserver/client/source/class/osparc/store/Groups.js @@ -110,7 +110,7 @@ qx.Class.define("osparc.store.Groups", { if (group) { group.setGroupMembers({}); orgMembers.forEach(orgMember => { - const user = new osparc.data.model.User(orgMember) + const user = new osparc.data.model.User(orgMember); group.getGroupMembers()[orgMember["gid"]] = user; this.getReachableMembers()[orgMember["gid"]] = user; }); @@ -167,9 +167,9 @@ qx.Class.define("osparc.store.Groups", { return groups; }, - getOrganizationOrUser: function(orgId) { + getOrganizationOrUser: function(groupId) { const orgs = this.__getAllGroups(); - const idx = orgs.findIndex(org => "gid" in org ? org["gid"] === parseInt(orgId) : org.getGroupId() === parseInt(orgId)); + const idx = orgs.findIndex(org => org.getGroupId() === parseInt(groupId)); if (idx > -1) { return orgs[idx]; }