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 0f8667f59710..46a05799fddc 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/CardBase.js @@ -148,10 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", { return false; } case "shared-with-everyone": { - const everyoneGroupIds = [ - groupsStore.getEveryoneProductGroup().getGroupId(), - groupsStore.getEveryoneGroup().getGroupId(), - ]; + const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); const found = Object.keys(checks).some(gId => everyoneGroupIds.includes(parseInt(gId))); // show those that are shared with "1" or product everyone's groupId return !found; @@ -190,13 +187,12 @@ qx.Class.define("osparc.dashboard.CardBase", { // Icon const groupsStore = osparc.store.Groups.getInstance(); - const groupEveryone = groupsStore.getEveryoneGroup(); - const groupProductEveryone = groupsStore.getEveryoneProductGroup(); + const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); const organizations = groupsStore.getOrganizations(); const myGroupId = groupsStore.getMyGroupId(); const organizationIds = Object.keys(organizations).map(key => parseInt(key)); - if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) { + if (gids.some(gid => everyoneGroupIds.includes(gid))) { shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL); } else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS); @@ -230,14 +226,11 @@ qx.Class.define("osparc.dashboard.CardBase", { addHintFromGids: function(icon, gids) { const groupsStore = osparc.store.Groups.getInstance(); - const groupEveryone = groupsStore.getEveryoneGroup(); - const groupProductEveryone = groupsStore.getEveryoneProductGroup(); + const everyoneGroups = groupsStore.getEveryoneGroups(); const organizations = groupsStore.getOrganizations(); const myGroupId = groupsStore.getMyGroupId(); - const groups = []; - groups.push(groupEveryone); - groups.push(groupProductEveryone); + const groups = everyoneGroups.slice(); groups.push(...Object.values(organizations)); const sharedGrps = []; groups.forEach(group => { @@ -275,7 +268,7 @@ qx.Class.define("osparc.dashboard.CardBase", { break; } let sharedGrpLabel = sharedGrps[i].getLabel(); - if ([groupEveryone, groupProductEveryone].includes(sharedGrps[i])) { + if (everyoneGroups.includes(sharedGrps[i])) { sharedGrpLabel = "Public"; } if (!sharedGrpLabels.includes(sharedGrpLabel)) { diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 766e0d11bf50..189655e9065f 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -323,10 +323,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { templates.forEach(template => template["resourceType"] = "template"); // For now, filtered in the frontend const groupsStore = osparc.store.Groups.getInstance(); - const everyoneGid = groupsStore.getEveryoneGroup().getGroupId(); - const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId(); + const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); const filteredTemplates = templates.filter(template => { - const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"]; + const templateGroupIds = Object.keys(template["accessRights"]); + const publicAccess = templateGroupIds.some(gid => everyoneGroupIds.includes(parseInt(gid))); if ([ osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES, osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES, 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 47d665f847d1..14ecd3a05d80 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 @@ -59,6 +59,7 @@ qx.Class.define("osparc.data.model.User", { firstName, lastName, email, + phoneNumber: userData["phone"] || null, thumbnail, label: userData["userName"] || description, description, @@ -122,6 +123,13 @@ qx.Class.define("osparc.data.model.User", { event: "changeEmail", }, + phoneNumber: { + check: "String", + nullable: true, + init: null, + event: "changePhoneNumber" + }, + thumbnail: { check: "String", nullable: true, diff --git a/services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js b/services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js index e522d53975f8..4dc1c47caf57 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js @@ -54,6 +54,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { __userPrivacyModel: null, __updatePrivacyBtn: null, __userProfileForm: null, + __sms2FAItem: null, __fetchProfile: function() { osparc.data.Resources.getOne("profile", {}, null, false) @@ -72,10 +73,15 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { "firstName": data["first_name"] || "", "lastName": data["last_name"] || "", "email": data["login"], + "phone": data["phone"] || "-", "expirationDate": data["expirationDate"] || null, }); } this.__updateProfileBtn.setEnabled(false); + + if (this.__sms2FAItem) { + this.__sms2FAItem.setEnabled(Boolean(data["phone"])); + } }, __setDataToPrivacy: function(privacyData) { @@ -124,11 +130,19 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { readOnly: true }); + const phoneNumber = new qx.ui.form.TextField().set({ + placeholder: this.tr("Phone Number"), + readOnly: true + }); + const profileForm = this.__userProfileForm = new qx.ui.form.Form(); profileForm.add(username, "Username", null, "username"); profileForm.add(firstName, "First Name", null, "firstName"); profileForm.add(lastName, "Last Name", null, "lastName"); profileForm.add(email, "Email", null, "email"); + if (osparc.store.StaticInfo.getInstance().is2FARequired()) { + profileForm.add(phoneNumber, "Phone Number", null, "phoneNumber"); + } const singleWithIcon = this.__userProfileRenderer = new osparc.ui.form.renderer.SingleWithIcon(profileForm); box.add(singleWithIcon); @@ -155,6 +169,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { "firstName": "", "lastName": "", "email": "", + "phone": "", "expirationDate": null, }; @@ -169,6 +184,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { } }); controller.addTarget(lastName, "value", "lastName", true); + controller.addTarget(phoneNumber, "value", "phone", true); controller.addTarget(expirationDate, "value", "expirationDate", false, { converter: expirationDay => { if (expirationDay) { @@ -404,6 +420,9 @@ qx.Class.define("osparc.desktop.account.ProfilePage", { label: "Disabled" }].forEach(options => { const lItem = new qx.ui.form.ListItem(options.label, null, options.id); + if (options.id === "SMS") { + this.__sms2FAItem = lItem; + } twoFAPreferenceSB.add(lItem); }); const value = preferencesSettings.getTwoFAPreference(); 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 4cd75bc5b54d..d20a1d2b8f34 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -434,16 +434,13 @@ qx.Class.define("osparc.share.Collaborators", { // reload list this.__collaboratorsModel.removeAll(); + const usersStore = osparc.store.Users.getInstance(); const groupsStore = osparc.store.Groups.getInstance(); - const everyoneGIds = [ - groupsStore.getEveryoneProductGroup().getGroupId(), - groupsStore.getEveryoneGroup().getGroupId() - ]; + const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); + const allGroups = groupsStore.getAllGroups(); + const showOptions = this.__canIChangePermissions(); const accessRights = this._serializedDataCopy["accessRights"]; const collaboratorsList = []; - const showOptions = this.__canIChangePermissions(); - const allGroups = groupsStore.getAllGroups(); - const usersStore = osparc.store.Users.getInstance(); for (let i=0; i g.getGroupId()); + return everyoneGroupIds; + }, + + getEveryoneGroups: function() { + const everyoneGroups = []; + if (this.getEveryoneProductGroup()) { + everyoneGroups.push(this.getEveryoneProductGroup()); + } + if (this.getEveryoneGroup()) { + everyoneGroups.push(this.getEveryoneGroup()); + } + return everyoneGroups; + }, + getGroup: function(groupId) { const groups = []; @@ -177,12 +197,16 @@ qx.Class.define("osparc.store.Groups", { }); const groupProductEveryone = this.getEveryoneProductGroup(); - groupProductEveryone["collabType"] = 0; - groups.push(groupProductEveryone); + if (groupProductEveryone) { + groupProductEveryone["collabType"] = 0; + groups.push(groupProductEveryone); + } const groupEveryone = this.getEveryoneGroup(); - groupEveryone["collabType"] = 0; - groups.push(groupEveryone); + if (groupEveryone) { + groupEveryone["collabType"] = 0; + groups.push(groupEveryone); + } const idx = groups.findIndex(group => group.getGroupId() === parseInt(groupId)); if (idx > -1) { return groups[idx]; diff --git a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js index 8d87bcc668b5..5a2eb6c160bf 100644 --- a/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js +++ b/services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js @@ -129,10 +129,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", { return; } const groupsStore = osparc.store.Groups.getInstance(); - const everyoneGroupIds = [ - groupsStore.getEveryoneProductGroup().getGroupId(), - groupsStore.getEveryoneGroup().getGroupId(), - ]; + const everyoneGroupIds = groupsStore.getEveryoneGroupIds(); const label = this.getChildControl("title"); if (everyoneGroupIds.includes(this.getModel())) { label.setValue(this.tr("Public"));