Skip to content

Commit e45e83f

Browse files
committed
username
1 parent 72a5d99 commit e45e83f

File tree

8 files changed

+33
-26
lines changed

8 files changed

+33
-26
lines changed

services/static-webserver/client/source/class/osparc/auth/Data.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ qx.Class.define("osparc.auth.Data", {
5353
apply: "__applyAuth"
5454
},
5555

56+
username: {
57+
check: "String",
58+
init: null,
59+
nullable: false,
60+
event: "changeUsername",
61+
},
62+
5663
/**
5764
* Email of logged in user, otherwise null
5865
*/
@@ -135,18 +142,6 @@ qx.Class.define("osparc.auth.Data", {
135142
return osparc.utils.Utils.cookie.getCookie("user") === "logout";
136143
},
137144

138-
getUserName: function() {
139-
const firstName = this.getFirstName();
140-
if (firstName) {
141-
return firstName;
142-
}
143-
const email = this.getEmail();
144-
if (email) {
145-
return osparc.utils.Utils.getNameFromEmail(email);
146-
}
147-
return "user";
148-
},
149-
150145
getFriendlyRole: function() {
151146
const role = this.getRole();
152147
let friendlyRole = role.replace(/_/g, " ");

services/static-webserver/client/source/class/osparc/auth/Manager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ qx.Class.define("osparc.auth.Manager", {
240240
const authData = osparc.auth.Data.getInstance();
241241
authData.set({
242242
email: profile["login"],
243+
username: profile["userName"],
243244
firstName: profile["first_name"] || profile["login"],
244245
lastName: profile["last_name"] || "",
245246
expirationDate: "expirationDate" in profile ? new Date(profile["expirationDate"]) : null

services/static-webserver/client/source/class/osparc/desktop/account/MyAccount.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
6868
converter: lastName => authData.getFirstName() + " " + lastName
6969
});
7070

71+
const usernameLabel = new qx.ui.basic.Label().set({
72+
font: "text-14",
73+
alignX: "center"
74+
});
75+
authData.bind("username", usernameLabel, "value");
76+
layout.add(usernameLabel);
77+
7178
if (authData.getRole() !== "user") {
7279
const role = authData.getFriendlyRole();
7380
const roleLabel = new qx.ui.basic.Label(role).set({
@@ -77,12 +84,6 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
7784
layout.add(roleLabel);
7885
}
7986

80-
const emailLabel = new qx.ui.basic.Label(email).set({
81-
font: "text-13",
82-
alignX: "center"
83-
});
84-
layout.add(emailLabel);
85-
8687
if (withSpacer) {
8788
layout.add(new qx.ui.core.Spacer(15, 15));
8889
}

services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
3131

3232
this._setLayout(new qx.ui.layout.VBox(15));
3333

34-
this.__userProfileData = null;
35-
this.__userProfileModel = null;
36-
3734
this.__fetchProfile();
3835

3936
this._add(this.__createProfileUser());
@@ -64,6 +61,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
6461
this.__userProfileModel.set({
6562
"firstName": data["first_name"] || "",
6663
"lastName": data["last_name"] || "",
64+
"username": data["userName"] || "",
6765
"email": data["login"],
6866
"expirationDate": data["expirationDate"] || null
6967
});
@@ -86,6 +84,10 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
8684
placeholder: this.tr("Last Name")
8785
});
8886

87+
const username = new qx.ui.form.TextField().set({
88+
placeholder: this.tr("username")
89+
});
90+
8991
const email = new qx.ui.form.TextField().set({
9092
placeholder: this.tr("Email"),
9193
readOnly: true
@@ -94,6 +96,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
9496
const form = new qx.ui.form.Form();
9597
form.add(firstName, "First Name", null, "firstName");
9698
form.add(lastName, "Last Name", null, "lastName");
99+
form.add(username, "Username", null, "username");
97100
form.add(email, "Email", null, "email");
98101
box.add(new qx.ui.form.renderer.Single(form));
99102

@@ -118,6 +121,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
118121
const raw = {
119122
"firstName": "",
120123
"lastName": "",
124+
"username": "",
121125
"email": "",
122126
"expirationDate": null
123127
};
@@ -132,6 +136,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
132136
}
133137
});
134138
controller.addTarget(lastName, "value", "lastName", true);
139+
controller.addTarget(username, "value", "username", true);
135140
controller.addTarget(expirationDate, "value", "expirationDate", false, {
136141
converter: expirationDay => {
137142
if (expirationDay) {
@@ -163,12 +168,17 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
163168
return;
164169
}
165170

166-
if (this.__userProfileData["first_name"] !== model.getFirstName() || this.__userProfileData["last_name"] !== model.getLastName()) {
171+
if (
172+
this.__userProfileData["first_name"] !== model.getFirstName() ||
173+
this.__userProfileData["last_name"] !== model.getLastName() ||
174+
this.__userProfileData["username"] !== model.getUsername()
175+
) {
167176
if (namesValidator.validate()) {
168177
const params = {
169178
data: {
170179
"first_name": model.getFirstName(),
171180
"last_name": model.getLastName(),
181+
"userName": model.getUsername(),
172182
}
173183
};
174184
osparc.data.Resources.fetch("profile", "patch", params)

services/static-webserver/client/source/class/osparc/product/quickStart/s4l/Welcome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ qx.Class.define("osparc.product.quickStart.s4l.Welcome", {
5555
});
5656
content.add(intro1);
5757

58-
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUserName()) + ",";
58+
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUsername()) + ",";
5959
const welcome = osparc.product.quickStart.Utils.createLabel(welcomeText);
6060
content.add(welcome);
6161

services/static-webserver/client/source/class/osparc/product/quickStart/s4lacad/Welcome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ qx.Class.define("osparc.product.quickStart.s4lacad.Welcome", {
5555
});
5656
content.add(intro1);
5757

58-
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUserName()) + ",";
58+
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUsername()) + ",";
5959
const welcome = osparc.product.quickStart.Utils.createLabel(welcomeText);
6060
content.add(welcome);
6161

services/static-webserver/client/source/class/osparc/product/quickStart/s4llite/Welcome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ qx.Class.define("osparc.product.quickStart.s4llite.Welcome", {
2525

2626
members: {
2727
_populateCard: function() {
28-
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUserName()) + ",";
28+
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUsername()) + ",";
2929
const welcome = osparc.product.quickStart.Utils.createLabel(welcomeText);
3030
this._add(welcome);
3131

services/static-webserver/client/source/class/osparc/product/quickStart/tis/Welcome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ qx.Class.define("osparc.product.quickStart.tis.Welcome", {
2525

2626
members: {
2727
_populateCard: function() {
28-
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUserName()) + ",";
28+
const welcomeText = this.tr("Welcome onboard ") + osparc.utils.Utils.capitalize(osparc.auth.Data.getInstance().getUsername()) + ",";
2929
const welcome = osparc.product.quickStart.Utils.createLabel(welcomeText);
3030
this._add(welcome);
3131

0 commit comments

Comments
 (0)