Skip to content

Commit 93d7e65

Browse files
committed
avatar group on NavBar
1 parent bacdc89 commit 93d7e65

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

services/static-webserver/client/source/class/osparc/navigation/NavigationBar.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ qx.Class.define("osparc.navigation.NavigationBar", {
5454
});
5555

5656
osparc.utils.Utils.setIdToWidget(this, "navigationBar");
57+
58+
this.__listenToProjectStateUpdated();
5759
},
5860

5961
events: {
@@ -234,6 +236,12 @@ qx.Class.define("osparc.navigation.NavigationBar", {
234236
this.getChildControl("center-items").add(control);
235237
break;
236238
}
239+
case "avatar-group": {
240+
const maxWidth = osparc.WindowSizeTracker.getInstance().isCompactVersion() ? 150 : 300;
241+
control = new osparc.ui.basic.AvatarGroup(32, "right", maxWidth);
242+
this.getChildControl("right-items").addAt(control);
243+
break;
244+
}
237245
case "tasks-button":
238246
control = new osparc.task.TasksButton();
239247
this.getChildControl("right-items").add(control);
@@ -310,6 +318,21 @@ qx.Class.define("osparc.navigation.NavigationBar", {
310318
return control || this.base(arguments, id);
311319
},
312320

321+
__listenToProjectStateUpdated: function() {
322+
const socket = osparc.wrapper.WebSocket.getInstance();
323+
socket.on("projectStateUpdated", data => {
324+
if (this.getStudy() && data["project_uuid"] === this.getStudy().getUuid()) {
325+
const projectState = data["data"];
326+
const currentUserGroupIds = osparc.study.Utils.state.getCurrentGroupIds(projectState);
327+
// remove myself from the list of users
328+
currentUserGroupIds = currentUserGroupIds.filter(gid => gid !== osparc.store.Groups.getInstance().getMyGroupId());
329+
// show the rest of the users in the avatar group
330+
const avatarGroup = this.getChildControl("avatar-group");
331+
avatarGroup.setUserGroupIds(currentUserGroupIds);
332+
}
333+
}, this);
334+
},
335+
313336
__createHelpMenuBtn: function() {
314337
const menu = new qx.ui.menu.Menu().set({
315338
position: "top-right",
@@ -351,7 +374,8 @@ qx.Class.define("osparc.navigation.NavigationBar", {
351374

352375
__applyStudy: function(study) {
353376
const savingStudyIcon = this.getChildControl("saving-study-icon");
354-
const readOnlyInfo = this.getChildControl("read-only-info")
377+
const readOnlyInfo = this.getChildControl("read-only-info");
378+
const avatarGroup = this.getChildControl("avatar-group");
355379
if (study) {
356380
this.getChildControl("study-title-options").setStudy(study);
357381
study.bind("savePending", savingStudyIcon, "visibility", {
@@ -360,9 +384,11 @@ qx.Class.define("osparc.navigation.NavigationBar", {
360384
study.bind("readOnly", readOnlyInfo, "visibility", {
361385
converter: value => value ? "visible" : "excluded"
362386
});
387+
avatarGroup.show();
363388
} else {
364389
savingStudyIcon.exclude();
365390
readOnlyInfo.exclude();
391+
avatarGroup.exclude();
366392
}
367393
},
368394

0 commit comments

Comments
 (0)