Skip to content

Commit 656c83d

Browse files
authored
✨ [Frontend] Expose Phone number (#8260)
1 parent 7881d83 commit 656c83d

File tree

7 files changed

+74
-36
lines changed

7 files changed

+74
-36
lines changed

services/static-webserver/client/source/class/osparc/dashboard/CardBase.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
148148
return false;
149149
}
150150
case "shared-with-everyone": {
151-
const everyoneGroupIds = [
152-
groupsStore.getEveryoneProductGroup().getGroupId(),
153-
groupsStore.getEveryoneGroup().getGroupId(),
154-
];
151+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
155152
const found = Object.keys(checks).some(gId => everyoneGroupIds.includes(parseInt(gId)));
156153
// show those that are shared with "1" or product everyone's groupId
157154
return !found;
@@ -190,13 +187,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
190187

191188
// Icon
192189
const groupsStore = osparc.store.Groups.getInstance();
193-
const groupEveryone = groupsStore.getEveryoneGroup();
194-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
195191
const organizations = groupsStore.getOrganizations();
196192
const myGroupId = groupsStore.getMyGroupId();
197193

198194
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
199-
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
195+
if (gids.some(gid => everyoneGroupIds.includes(gid))) {
200196
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
201197
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
202198
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
@@ -230,14 +226,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
230226

231227
addHintFromGids: function(icon, gids) {
232228
const groupsStore = osparc.store.Groups.getInstance();
233-
const groupEveryone = groupsStore.getEveryoneGroup();
234-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
229+
const everyoneGroups = groupsStore.getEveryoneGroups();
235230
const organizations = groupsStore.getOrganizations();
236231
const myGroupId = groupsStore.getMyGroupId();
237232

238-
const groups = [];
239-
groups.push(groupEveryone);
240-
groups.push(groupProductEveryone);
233+
const groups = everyoneGroups.slice();
241234
groups.push(...Object.values(organizations));
242235
const sharedGrps = [];
243236
groups.forEach(group => {
@@ -275,7 +268,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
275268
break;
276269
}
277270
let sharedGrpLabel = sharedGrps[i].getLabel();
278-
if ([groupEveryone, groupProductEveryone].includes(sharedGrps[i])) {
271+
if (everyoneGroups.includes(sharedGrps[i])) {
279272
sharedGrpLabel = "Public";
280273
}
281274
if (!sharedGrpLabels.includes(sharedGrpLabel)) {

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
323323
templates.forEach(template => template["resourceType"] = "template");
324324
// For now, filtered in the frontend
325325
const groupsStore = osparc.store.Groups.getInstance();
326-
const everyoneGid = groupsStore.getEveryoneGroup().getGroupId();
327-
const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId();
326+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
328327
const filteredTemplates = templates.filter(template => {
329-
const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"];
328+
const templateGroupIds = Object.keys(template["accessRights"]);
329+
const publicAccess = templateGroupIds.some(gid => everyoneGroupIds.includes(parseInt(gid)));
330330
if ([
331331
osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES,
332332
osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES,

services/static-webserver/client/source/class/osparc/data/model/User.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ qx.Class.define("osparc.data.model.User", {
5959
firstName,
6060
lastName,
6161
email,
62+
phoneNumber: userData["phone"] || null,
6263
thumbnail,
6364
label: userData["userName"] || description,
6465
description,
@@ -122,6 +123,13 @@ qx.Class.define("osparc.data.model.User", {
122123
event: "changeEmail",
123124
},
124125

126+
phoneNumber: {
127+
check: "String",
128+
nullable: true,
129+
init: null,
130+
event: "changePhoneNumber"
131+
},
132+
125133
thumbnail: {
126134
check: "String",
127135
nullable: true,

services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
5454
__userPrivacyModel: null,
5555
__updatePrivacyBtn: null,
5656
__userProfileForm: null,
57+
__sms2FAItem: null,
5758

5859
__fetchProfile: function() {
5960
osparc.data.Resources.getOne("profile", {}, null, false)
@@ -72,10 +73,15 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
7273
"firstName": data["first_name"] || "",
7374
"lastName": data["last_name"] || "",
7475
"email": data["login"],
76+
"phone": data["phone"] || "-",
7577
"expirationDate": data["expirationDate"] || null,
7678
});
7779
}
7880
this.__updateProfileBtn.setEnabled(false);
81+
82+
if (this.__sms2FAItem) {
83+
this.__sms2FAItem.setEnabled(Boolean(data["phone"]));
84+
}
7985
},
8086

8187
__setDataToPrivacy: function(privacyData) {
@@ -124,11 +130,19 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
124130
readOnly: true
125131
});
126132

133+
const phoneNumber = new qx.ui.form.TextField().set({
134+
placeholder: this.tr("Phone Number"),
135+
readOnly: true
136+
});
137+
127138
const profileForm = this.__userProfileForm = new qx.ui.form.Form();
128139
profileForm.add(username, "Username", null, "username");
129140
profileForm.add(firstName, "First Name", null, "firstName");
130141
profileForm.add(lastName, "Last Name", null, "lastName");
131142
profileForm.add(email, "Email", null, "email");
143+
if (osparc.store.StaticInfo.getInstance().is2FARequired()) {
144+
profileForm.add(phoneNumber, "Phone Number", null, "phoneNumber");
145+
}
132146
const singleWithIcon = this.__userProfileRenderer = new osparc.ui.form.renderer.SingleWithIcon(profileForm);
133147
box.add(singleWithIcon);
134148

@@ -155,6 +169,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
155169
"firstName": "",
156170
"lastName": "",
157171
"email": "",
172+
"phone": "",
158173
"expirationDate": null,
159174
};
160175

@@ -169,6 +184,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
169184
}
170185
});
171186
controller.addTarget(lastName, "value", "lastName", true);
187+
controller.addTarget(phoneNumber, "value", "phone", true);
172188
controller.addTarget(expirationDate, "value", "expirationDate", false, {
173189
converter: expirationDay => {
174190
if (expirationDay) {
@@ -404,6 +420,9 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
404420
label: "Disabled"
405421
}].forEach(options => {
406422
const lItem = new qx.ui.form.ListItem(options.label, null, options.id);
423+
if (options.id === "SMS") {
424+
this.__sms2FAItem = lItem;
425+
}
407426
twoFAPreferenceSB.add(lItem);
408427
});
409428
const value = preferencesSettings.getTwoFAPreference();

services/static-webserver/client/source/class/osparc/share/Collaborators.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,13 @@ qx.Class.define("osparc.share.Collaborators", {
434434
// reload list
435435
this.__collaboratorsModel.removeAll();
436436

437+
const usersStore = osparc.store.Users.getInstance();
437438
const groupsStore = osparc.store.Groups.getInstance();
438-
const everyoneGIds = [
439-
groupsStore.getEveryoneProductGroup().getGroupId(),
440-
groupsStore.getEveryoneGroup().getGroupId()
441-
];
439+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
440+
const allGroups = groupsStore.getAllGroups();
441+
const showOptions = this.__canIChangePermissions();
442442
const accessRights = this._serializedDataCopy["accessRights"];
443443
const collaboratorsList = [];
444-
const showOptions = this.__canIChangePermissions();
445-
const allGroups = groupsStore.getAllGroups();
446-
const usersStore = osparc.store.Users.getInstance();
447444
for (let i=0; i<Object.keys(accessRights).length; i++) {
448445
const gid = parseInt(Object.keys(accessRights)[i]);
449446
let collab = null;
@@ -462,7 +459,7 @@ qx.Class.define("osparc.share.Collaborators", {
462459
};
463460
if (!("getUserId" in collab)) {
464461
// organization
465-
if (everyoneGIds.includes(parseInt(gid))) {
462+
if (everyoneGroupIds.includes(parseInt(gid))) {
466463
collaborator["thumbnail"] = "@FontAwesome5Solid/globe/32";
467464
} else if (!collaborator["thumbnail"]) {
468465
collaborator["thumbnail"] = "@FontAwesome5Solid/users/26";

services/static-webserver/client/source/class/osparc/store/Groups.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ qx.Class.define("osparc.store.Groups", {
2828
properties: {
2929
everyoneGroup: {
3030
check: "osparc.data.model.Group",
31-
init: {}
31+
init: null // this will stay null for guest users
3232
},
3333

3434
everyoneProductGroup: {
3535
check: "osparc.data.model.Group",
36-
init: {}
36+
init: null // this will stay null for guest users
3737
},
3838

3939
organizations: {
@@ -120,10 +120,14 @@ qx.Class.define("osparc.store.Groups", {
120120
const allGroupsAndUsers = {};
121121

122122
const groupEveryone = this.getEveryoneGroup();
123-
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
123+
if (groupEveryone) {
124+
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
125+
}
124126

125127
const groupProductEveryone = this.getEveryoneProductGroup();
126-
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
128+
if (groupProductEveryone) {
129+
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
130+
}
127131

128132
const groupMe = this.getGroupMe();
129133
allGroupsAndUsers[groupMe.getGroupId()] = groupMe;
@@ -157,6 +161,22 @@ qx.Class.define("osparc.store.Groups", {
157161
return allMyGroupIds;
158162
},
159163

164+
getEveryoneGroupIds: function() {
165+
const everyoneGroupIds = this.getEveryoneGroups().map(g => g.getGroupId());
166+
return everyoneGroupIds;
167+
},
168+
169+
getEveryoneGroups: function() {
170+
const everyoneGroups = [];
171+
if (this.getEveryoneProductGroup()) {
172+
everyoneGroups.push(this.getEveryoneProductGroup());
173+
}
174+
if (this.getEveryoneGroup()) {
175+
everyoneGroups.push(this.getEveryoneGroup());
176+
}
177+
return everyoneGroups;
178+
},
179+
160180
getGroup: function(groupId) {
161181
const groups = [];
162182

@@ -177,12 +197,16 @@ qx.Class.define("osparc.store.Groups", {
177197
});
178198

179199
const groupProductEveryone = this.getEveryoneProductGroup();
180-
groupProductEveryone["collabType"] = 0;
181-
groups.push(groupProductEveryone);
200+
if (groupProductEveryone) {
201+
groupProductEveryone["collabType"] = 0;
202+
groups.push(groupProductEveryone);
203+
}
182204

183205
const groupEveryone = this.getEveryoneGroup();
184-
groupEveryone["collabType"] = 0;
185-
groups.push(groupEveryone);
206+
if (groupEveryone) {
207+
groupEveryone["collabType"] = 0;
208+
groups.push(groupEveryone);
209+
}
186210
const idx = groups.findIndex(group => group.getGroupId() === parseInt(groupId));
187211
if (idx > -1) {
188212
return groups[idx];

services/static-webserver/client/source/class/osparc/ui/list/CollaboratorListItem.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ qx.Class.define("osparc.ui.list.CollaboratorListItem", {
129129
return;
130130
}
131131
const groupsStore = osparc.store.Groups.getInstance();
132-
const everyoneGroupIds = [
133-
groupsStore.getEveryoneProductGroup().getGroupId(),
134-
groupsStore.getEveryoneGroup().getGroupId(),
135-
];
132+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
136133
const label = this.getChildControl("title");
137134
if (everyoneGroupIds.includes(this.getModel())) {
138135
label.setValue(this.tr("Public"));

0 commit comments

Comments
 (0)