Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ qx.Class.define("osparc.data.model.User", {
firstName,
lastName,
email,
phoneNumber: userData["phone"] || null,
thumbnail,
label: userData["userName"] || description,
description,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -155,6 +169,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
"firstName": "",
"lastName": "",
"email": "",
"phone": "",
"expirationDate": null,
};

Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object.keys(accessRights).length; i++) {
const gid = parseInt(Object.keys(accessRights)[i]);
let collab = null;
Expand All @@ -462,7 +459,7 @@ qx.Class.define("osparc.share.Collaborators", {
};
if (!("getUserId" in collab)) {
// organization
if (everyoneGIds.includes(parseInt(gid))) {
if (everyoneGroupIds.includes(parseInt(gid))) {
collaborator["thumbnail"] = "@FontAwesome5Solid/globe/32";
} else if (!collaborator["thumbnail"]) {
collaborator["thumbnail"] = "@FontAwesome5Solid/users/26";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ qx.Class.define("osparc.store.Groups", {
properties: {
everyoneGroup: {
check: "osparc.data.model.Group",
init: {}
init: null // this will stay null for guest users
},

everyoneProductGroup: {
check: "osparc.data.model.Group",
init: {}
init: null // this will stay null for guest users
},

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

const groupEveryone = this.getEveryoneGroup();
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
if (groupEveryone) {
allGroupsAndUsers[groupEveryone.getGroupId()] = groupEveryone;
}

const groupProductEveryone = this.getEveryoneProductGroup();
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
if (groupProductEveryone) {
allGroupsAndUsers[groupProductEveryone.getGroupId()] = groupProductEveryone;
}

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

getEveryoneGroupIds: function() {
const everyoneGroupIds = this.getEveryoneGroups().map(g => 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 = [];

Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Loading