Skip to content

Commit 25544ad

Browse files
committed
UserDetails working
1 parent b75cb30 commit 25544ad

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

services/static-webserver/client/source/class/osparc/conversation/MessageUI.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,8 @@ qx.Class.define("osparc.conversation.MessageUI", {
165165

166166
osparc.store.Users.getInstance().getUser(message["userGroupId"])
167167
.then(user => {
168-
if (user) {
169-
thumbnail.setSource(user.getThumbnail());
170-
thumbnail.setUser(user);
171-
userName.setValue(user.getLabel());
172-
} else {
173-
thumbnail.setSource(osparc.utils.Avatar.emailToThumbnail());
174-
userName.setValue("Unknown user");
175-
}
168+
thumbnail.setUser(user);
169+
userName.setValue(user ? user.getLabel() : "Unknown user");
176170
})
177171
.catch(() => {
178172
thumbnail.setSource(osparc.utils.Avatar.emailToThumbnail());

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ qx.Class.define("osparc.data.model.User", {
5151
}
5252
description += email;
5353
}
54-
const thumbnail = osparc.utils.Avatar.emailToThumbnail(email, username);
54+
5555
this.set({
5656
userId,
5757
groupId,
@@ -60,10 +60,14 @@ qx.Class.define("osparc.data.model.User", {
6060
lastName,
6161
email,
6262
phoneNumber: userData["phone"] || null,
63-
thumbnail,
6463
label: userData["userName"] || description,
6564
description,
6665
});
66+
67+
// create the thumbnail after setting email and username
68+
this.set({
69+
thumbnail: this.createThumbnail(),
70+
});
6771
},
6872

6973
properties: {
@@ -137,4 +141,10 @@ qx.Class.define("osparc.data.model.User", {
137141
event: "changeThumbnail",
138142
},
139143
},
144+
145+
members: {
146+
createThumbnail: function(size) {
147+
return osparc.utils.Avatar.emailToThumbnail(this.getEmail(), this.getUsername(), size);
148+
},
149+
},
140150
});

services/static-webserver/client/source/class/osparc/ui/basic/UserThumbnail.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ qx.Class.define("osparc.ui.basic.UserThumbnail", {
3939
},
4040

4141
members: {
42+
__applyUser: function(user) {
43+
if (user) {
44+
this.setSource(user.getThumbnail());
45+
} else {
46+
this.setSource(osparc.utils.Avatar.emailToThumbnail());
47+
}
48+
},
49+
4250
__openUserDetails: function() {
4351
if (this.getUser()) {
44-
osparc.user.UserDetails.popUpInWindow(this.getUser());
52+
const userDetails = new osparc.user.UserDetails(this.getUser());
53+
userDetails.center();
54+
userDetails.open();
4555
}
4656
},
4757
}

services/static-webserver/client/source/class/osparc/user/UserDetails.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ qx.Class.define("osparc.user.UserDetails", {
2121
construct: function(user) {
2222
this.base(arguments);
2323

24-
this.setLayout(new qx.ui.layout.VBox(10));
24+
this.set({
25+
layout: new qx.ui.layout.VBox(10),
26+
autoDestroy: true,
27+
showMaximize: false,
28+
showMinimize: false,
29+
clickAwayClose: true,
30+
});
2531

2632
this.setUser(user);
2733
},
@@ -30,15 +36,6 @@ qx.Class.define("osparc.user.UserDetails", {
3036
WIDTH: 300,
3137
HEIGHT: 200,
3238

33-
popUpInWindow: function(userModel) {
34-
const userDetails = new osparc.user.UserDetails(userModel);
35-
const title = userModel.getUsername();
36-
osparc.ui.window.Window.popUpInWindow(userDetails, title, this.WIDTH, this.HEIGHT).set({
37-
// layout: new qx.ui.layout.Grow(),
38-
// ...osparc.ui.window.TabbedWindow.DEFAULT_PROPS,
39-
});
40-
},
41-
4239
GRID_POS: {
4340
USERNAME: 0,
4441
FULLNAME: 1,
@@ -62,15 +59,20 @@ qx.Class.define("osparc.user.UserDetails", {
6259
switch (id) {
6360
case "top-layout":
6461
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
65-
this._add(control);
62+
this.add(control);
6663
break;
6764
case "thumbnail":
6865
control = new osparc.ui.basic.Thumbnail(null, 100, 100);
66+
control.getChildControl("image").set({
67+
anonymous: true,
68+
decorator: "rounded",
69+
});
6970
this.getChildControl("top-layout").add(control);
7071
break;
7172
case "main-info": {
7273
const grid = new qx.ui.layout.Grid(5, 10);
7374
grid.setColumnFlex(1, 1);
75+
grid.setColumnAlign(0, "right", "middle");
7476
control = new qx.ui.container.Composite(grid);
7577
this.getChildControl("top-layout").add(control, {
7678
flex: 1
@@ -121,11 +123,11 @@ qx.Class.define("osparc.user.UserDetails", {
121123
},
122124

123125
__applyUser: function(user) {
124-
console.log("user", user);
126+
this.setCaption(user.getUsername());
125127

126-
this.getChildControl("thumbnail").setSource(user.getThumbnail());
128+
this.getChildControl("thumbnail").setSource(user.createThumbnail(96));
127129
this.getChildControl("username").setValue(user.getUsername());
128-
this.getChildControl("fullname").setValue(user.getFirstName() + " " + this.getLastName());
130+
this.getChildControl("fullname").setValue(user.getFirstName() + " " + user.getLastName());
129131
this.getChildControl("email").setValue(user.getEmail());
130132
},
131133
}

0 commit comments

Comments
 (0)