Skip to content

Commit bc4d0df

Browse files
committed
UserThumbnail and UserDetails
1 parent 1df610c commit bc4d0df

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2025 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.ui.basic.UserThumbnail", {
19+
extend: qx.ui.basic.Image,
20+
21+
construct: function(size) {
22+
this.base(arguments);
23+
24+
this.set(osparc.utils.Utils.getThumbnailProps(size));
25+
26+
if (osparc.data.Permissions.getInstance().isProductOwner()) {
27+
this.setCursor("pointer");
28+
this.addListener("tap", this.__openUserDetails, this);
29+
}
30+
},
31+
32+
properties: {
33+
user: {
34+
check: "osparc.data.model.User",
35+
init: true,
36+
nullable: true,
37+
apply: "__applyUser",
38+
}
39+
},
40+
41+
members: {
42+
__openUserDetails: function() {
43+
if (this.getUser()) {
44+
osparc.user.UserDetails.popUpInWindow(this.getUser());
45+
}
46+
},
47+
}
48+
});
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2022 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.user.UserDetails", {
19+
extend: osparc.ui.window.Window,
20+
21+
construct: function(user) {
22+
this.base(arguments);
23+
24+
this.setLayout(new qx.ui.layout.VBox(10));
25+
26+
this.setUser(user);
27+
},
28+
29+
statics: {
30+
WIDTH: 300,
31+
HEIGHT: 200,
32+
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+
42+
GRID_POS: {
43+
USERNAME: 0,
44+
FULLNAME: 1,
45+
EMAIL: 2,
46+
}
47+
},
48+
49+
properties: {
50+
user: {
51+
check: "osparc.data.model.User",
52+
init: true,
53+
nullable: false,
54+
event: "changeUser",
55+
apply: "__applyUser",
56+
}
57+
},
58+
59+
members: {
60+
_createChildControlImpl: function(id) {
61+
let control;
62+
switch (id) {
63+
case "top-layout":
64+
control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
65+
this._add(control);
66+
break;
67+
case "thumbnail":
68+
control = new osparc.ui.basic.Thumbnail(null, 100, 100);
69+
this.getChildControl("top-layout").add(control);
70+
break;
71+
case "main-info": {
72+
const grid = new qx.ui.layout.Grid(5, 10);
73+
grid.setColumnFlex(1, 1);
74+
control = new qx.ui.container.Composite(grid);
75+
this.getChildControl("top-layout").add(control, {
76+
flex: 1
77+
});
78+
break;
79+
}
80+
case "username": {
81+
const title = new qx.ui.basic.Label("Username");
82+
this.getChildControl("main-info").add(title, {
83+
row: this.self().GRID_POS.USERNAME,
84+
column: 0
85+
});
86+
control = new qx.ui.basic.Label();
87+
this.getChildControl("main-info").add(control, {
88+
row: this.self().GRID_POS.USERNAME,
89+
column: 1
90+
});
91+
break;
92+
}
93+
case "fullname": {
94+
const title = new qx.ui.basic.Label("Full Name");
95+
this.getChildControl("main-info").add(title, {
96+
row: this.self().GRID_POS.FULLNAME,
97+
column: 0
98+
});
99+
control = new qx.ui.basic.Label();
100+
this.getChildControl("main-info").add(control, {
101+
row: this.self().GRID_POS.FULLNAME,
102+
column: 1
103+
});
104+
break;
105+
}
106+
case "email": {
107+
const title = new qx.ui.basic.Label("Email");
108+
this.getChildControl("main-info").add(title, {
109+
row: this.self().GRID_POS.EMAIL,
110+
column: 0
111+
});
112+
control = new qx.ui.basic.Label();
113+
this.getChildControl("main-info").add(control, {
114+
row: this.self().GRID_POS.EMAIL,
115+
column: 1
116+
});
117+
break;
118+
}
119+
}
120+
return control || this.base(arguments, id);
121+
},
122+
123+
__applyUser: function(user) {
124+
console.log("user", user);
125+
126+
this.getChildControl("thumbnail").setSource(user.getThumbnail());
127+
this.getChildControl("username").setValue(user.getUsername());
128+
this.getChildControl("fullname").setValue(user.getFirstName() + " " + this.getLastName());
129+
this.getChildControl("email").setValue(user.getEmail());
130+
},
131+
}
132+
});

0 commit comments

Comments
 (0)