Skip to content

Commit 5f9a860

Browse files
committed
groupMembers
1 parent ffb56ae commit 5f9a860

File tree

13 files changed

+65
-91
lines changed

13 files changed

+65
-91
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ qx.Class.define("osparc.dashboard.Dashboard", {
179179

180180
const preResourcePromises = [];
181181
const groupsStore = osparc.store.Groups.getInstance();
182-
preResourcePromises.push(groupsStore.fetchAll());
182+
preResourcePromises.push(groupsStore.fetchGroupsAndMembers());
183183
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
184184
Promise.all(preResourcePromises)
185185
.then(() => {

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,42 @@ qx.Class.define("osparc.data.model.Group", {
4242
check: "Number",
4343
nullable: false,
4444
init: null,
45-
event: "changeGroupId"
45+
event: "changeGroupId",
4646
},
4747

4848
label: {
4949
check: "String",
5050
nullable: false,
5151
init: null,
52-
event: "changeLabel"
52+
event: "changeLabel",
5353
},
5454

5555
description: {
5656
check: "String",
5757
nullable: true,
5858
init: null,
59-
event: "changeDescription"
59+
event: "changeDescription",
6060
},
6161

6262
accessRights: {
6363
check: "Object",
6464
nullable: false,
6565
init: null,
66-
event: "changeAccessRights"
66+
event: "changeAccessRights",
6767
},
6868

6969
thumbnail: {
7070
check: "String",
7171
nullable: true,
72-
init: ""
72+
init: "",
73+
event: "changeThumbnail",
74+
},
75+
76+
groupMembers: {
77+
check: "Object",
78+
nullable: true,
79+
init: null,
80+
event: "changeGroupMembers",
7381
},
7482

7583
groupType: {

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationDetails.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ qx.Class.define("osparc.desktop.organizations.OrganizationDetails", {
4848
this.__orgModel = orgModel;
4949

5050
const organizationListItem = this.__addOrganizationListItem();
51-
orgModel.bind("gid", organizationListItem, "key");
52-
orgModel.bind("gid", organizationListItem, "model");
51+
orgModel.bind("groupId", organizationListItem, "key");
52+
orgModel.bind("groupId", organizationListItem, "model");
5353
orgModel.bind("thumbnail", organizationListItem, "thumbnail");
5454
orgModel.bind("label", organizationListItem, "title");
5555
orgModel.bind("description", organizationListItem, "subtitle");
56-
orgModel.bind("nMembers", organizationListItem, "role");
56+
orgModel.bindProperty("groupMembers", "role", {
57+
converter: groupMembers => groupMembers ? Object.keys(groupMembers).length + this.tr(" members") : "-"
58+
});
5759
orgModel.bind("accessRights", organizationListItem, "accessRights");
5860

5961
// set orgModel to the tab views

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
135135
ctrl.bindProperty("thumbnail", "thumbnail", null, item, id);
136136
ctrl.bindProperty("label", "title", null, item, id);
137137
ctrl.bindProperty("description", "subtitle", null, item, id);
138-
ctrl.bindProperty("nMembers", "role", null, item, id);
138+
ctrl.bindProperty("groupMembers", "role", {
139+
converter: groupMembers => groupMembers ? Object.keys(groupMembers).length + this.tr(" members") : "-"
140+
}, item, id);
139141
ctrl.bindProperty("accessRights", "accessRights", null, item, id);
140142
},
141143
configureItem: item => {
@@ -179,13 +181,8 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
179181

180182
const groupsStore = osparc.store.Groups.getInstance();
181183
const orgs = Object.values(groupsStore.getOrganizations());
182-
const orgsList = orgs.map(org => {
183-
const respOrgMembers = groupsStore.getOrganizationMembers(org["gid"]);
184-
org["nMembers"] = Object.keys(respOrgMembers).length + this.tr(" members");
185-
return org;
186-
});
187-
orgsList.sort(this.self().sortOrganizations);
188-
orgsList.forEach(org => orgsModel.append(org));
184+
orgs.sort(this.self().sortOrganizations);
185+
orgs.forEach(org => orgsModel.append(org));
189186
this.setOrganizationsLoaded(true);
190187
if (orgId) {
191188
this.fireDataEvent("organizationSelected", orgId);

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsWindow.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsWindow", {
4949

5050
members: {
5151
__stack: null,
52-
__orgsList: null,
52+
__orgsPage: null,
5353
__orgDetails: null,
5454

5555
__buildLayout: function() {
@@ -58,7 +58,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsWindow", {
5858
flex: 1
5959
});
6060

61-
const orgsPage = this.__orgsList = new osparc.desktop.organizations.OrganizationsList();
61+
const orgsPage = this.__orgsPage = new osparc.desktop.organizations.OrganizationsList();
6262
const orgDetails = this.__orgDetails = new osparc.desktop.organizations.OrganizationDetails();
6363
stack.add(orgsPage);
6464
stack.add(orgDetails);
@@ -77,15 +77,15 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsWindow", {
7777

7878
openOrganizationDetails: function(organizationId) {
7979
const openOrgDetails = orgId => {
80-
const orgModel = this.__orgsList.getOrgModel(orgId);
80+
const orgModel = this.__orgsPage.getOrgModel(orgId);
8181
this.__orgDetails.setCurrentOrg(orgModel);
8282
this.getChildControl("title").setValue(this.tr("Organization details"));
8383
this.__stack.setSelection([this.__orgDetails]);
8484
};
85-
if (this.__orgsList.isOrganizationsLoaded()) {
85+
if (this.__orgsPage.isOrganizationsLoaded()) {
8686
openOrgDetails(organizationId);
8787
} else {
88-
this.__orgsList.addListenerOnce("changeOrganizationsLoaded", () => openOrgDetails(organizationId));
88+
this.__orgsPage.addListenerOnce("changeOrganizationsLoaded", () => openOrgDetails(organizationId));
8989
}
9090
}
9191
}

services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", {
142142

143143
__setRecipientGid: function(gid) {
144144
this.setRecipientGid(gid);
145-
osparc.store.Groups.getInstance().getGroup(gid)
145+
osparc.store.Groups.getInstance().fetchGroup(gid)
146146
.then(user => {
147147
this.getChildControl("selected-recipient").setValue(user.label);
148148
});

services/static-webserver/client/source/class/osparc/notification/NotificationUI.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ qx.Class.define("osparc.notification.NotificationUI", {
134134
case "NEW_ORGANIZATION":
135135
icon.setSource("@FontAwesome5Solid/users/14");
136136
if (resourceId) {
137-
osparc.store.Groups.getInstance().getGroup(resourceId)
137+
osparc.store.Groups.getInstance().fetchGroup(resourceId)
138138
.then(group => descriptionLabel.setValue("You're now member of '" + group["label"] + "'"))
139139
.catch(() => this.setEnabled(false));
140140
}
@@ -264,7 +264,7 @@ qx.Class.define("osparc.notification.NotificationUI", {
264264

265265
__openOrganizationDetails: function(orgId) {
266266
// make sure org is available
267-
osparc.store.Groups.getInstance().getGroup(orgId)
267+
osparc.store.Groups.getInstance().fetchGroup(orgId)
268268
.then(org => {
269269
if (org) {
270270
const orgsWindow = osparc.desktop.organizations.OrganizationsWindow.openWindow();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ qx.Class.define("osparc.share.CollaboratorsStudy", {
226226
);
227227
};
228228

229-
const groupData = await osparc.store.Store.getInstance().getGroup(groupId);
229+
const groupData = await osparc.store.Store.getInstance().fetchGroup(groupId);
230230
const isOrganization = (groupData && !("id" in groupData));
231231
if (isOrganization) {
232232
const msg = this.tr(`Demoting to ${osparc.data.Roles.STUDY[1].label} will remove write access to all the members of the Organization. Are you sure?`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ qx.Class.define("osparc.share.CollaboratorsWorkspace", {
157157
);
158158
};
159159

160-
const groupData = await osparc.store.Groups.getInstance().getGroup(groupId);
160+
const groupData = await osparc.store.Groups.getInstance().fetchGroup(groupId);
161161
const isOrganization = (groupData && !("id" in groupData));
162162
if (isOrganization) {
163163
const msg = this.tr(`Demoting to ${osparc.data.Roles.WORKSPACE[1].label} will remove write access to all the members of the Organization. Are you sure?`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ qx.Class.define("osparc.share.ShareePermissions", {
3333
this._add(layout);
3434
for (let i=0; i<shareesData.length; i++) {
3535
const shareeData = shareesData[i];
36-
osparc.store.Groups.getInstance().getGroup(shareeData.gid)
36+
osparc.store.Groups.getInstance().fetchGroup(shareeData.gid)
3737
.then(group => {
3838
if (group) {
3939
layout.add(new qx.ui.basic.Label(group.label), {

0 commit comments

Comments
 (0)