Skip to content

Commit a1b01f7

Browse files
authored
Merge branch 'master' into enhanced-support-center
2 parents 12362f5 + c4cb923 commit a1b01f7

File tree

36 files changed

+542
-178
lines changed

36 files changed

+542
-178
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ qx.Class.define("osparc.auth.Data", {
7575
check: "Number"
7676
},
7777

78-
username: {
78+
userName: {
7979
check: "String",
8080
init: null,
8181
nullable: false,
82-
event: "changeUsername",
82+
event: "changeUserName",
8383
},
8484

8585
email: {
@@ -139,12 +139,12 @@ qx.Class.define("osparc.auth.Data", {
139139
return osparc.utils.Utils.cookie.getCookie("user") === "logout";
140140
},
141141

142-
getFriendlyUsername: function() {
142+
getFriendlyUserName: function() {
143143
const firstName = this.getFirstName();
144144
if (firstName) {
145145
return firstName;
146146
}
147-
return this.getUsername();
147+
return this.getUserName();
148148
},
149149

150150
getFullName: function() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ qx.Class.define("osparc.auth.Manager", {
258258
const authData = osparc.auth.Data.getInstance();
259259
authData.set({
260260
email: profile["login"],
261-
username: profile["userName"],
261+
userName: profile["userName"],
262262
firstName: profile["first_name"],
263263
lastName: profile["last_name"],
264264
expirationDate: profile["expirationDate"] ? new Date(profile["expirationDate"]) : null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ qx.Class.define("osparc.auth.ui.LoginView", {
7373
const email = new qx.ui.form.TextField().set({
7474
required: true
7575
});
76-
email.getContentElement().setAttribute("autocomplete", "username");
76+
email.getContentElement().setAttribute("autocomplete", "userName");
7777
osparc.utils.Utils.setIdToWidget(email, "loginUserEmailFld");
7878
this._form.add(email, " Email", qx.util.Validate.email(), "email");
7979
const focusEmail = () => {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,13 @@ qx.Class.define("osparc.dashboard.CardBase", {
914914
const currentUserGroupIds = osparc.study.Utils.state.getCurrentGroupIds(state);
915915
const usersStore = osparc.store.Users.getInstance();
916916
const userPromises = currentUserGroupIds.map(userGroupId => usersStore.getUser(userGroupId));
917-
const usernames = [];
917+
const userNames = [];
918918
let toolTip = "";
919919
let image = null;
920920
Promise.all(userPromises)
921921
.then(usersResult => {
922922
usersResult.forEach(user => {
923-
usernames.push(user.getUsername());
923+
userNames.push(user.getUserName());
924924
});
925925
})
926926
.catch(error => {
@@ -952,8 +952,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
952952
image = "@FontAwesome5Solid/lock/";
953953
break;
954954
}
955-
usernames.forEach(username => {
956-
toolTip += "<br>" + username;
955+
userNames.forEach(userName => {
956+
toolTip += "<br>" + userName;
957957
});
958958
this.__showBlockedCard(image, toolTip);
959959
});

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

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
16401640
return deleteButton;
16411641
},
16421642

1643-
1644-
16451643
__createSelectButton: function() {
16461644
const selectButton = new qx.ui.form.ToggleButton().set({
16471645
appearance: "form-button-outlined",
@@ -1794,12 +1792,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
17941792
this._reloadCards();
17951793
},
17961794

1797-
__removeFromStudyList: function(studyId) {
1798-
const idx = this._resourcesList.findIndex(study => study["uuid"] === studyId);
1795+
__removeFromList: function(resourceUuid) {
1796+
const idx = this._resourcesList.findIndex(resource => resource["uuid"] === resourceUuid);
17991797
if (idx > -1) {
18001798
this._resourcesList.splice(idx, 1);
18011799
}
1802-
this._resourcesContainer.removeCard(studyId);
1800+
this._resourcesContainer.removeCard(resourceUuid);
18031801
},
18041802

18051803
_populateCardMenu: function(card) {
@@ -1812,7 +1810,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
18121810
this._populateTemplateCardMenu(card);
18131811
break;
18141812
case "function":
1815-
card.getChildControl("menu-selection-stack").exclude();
1813+
this.__populateFunctionCardMenu(card);
18161814
break;
18171815
}
18181816
},
@@ -1919,6 +1917,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19191917
card.evaluateMenuButtons();
19201918
},
19211919

1920+
__populateFunctionCardMenu: function(card) {
1921+
const menu = card.getMenu();
1922+
const functionData = card.getResourceData();
1923+
1924+
const deleteButton = this.__getDeleteFunctionMenuButton(functionData);
1925+
menu.add(deleteButton);
1926+
},
1927+
19221928
__getOpenLocationMenuButton: function(studyData) {
19231929
const openLocationButton = new qx.ui.menu.Button(this.tr("Open location"), "@FontAwesome5Solid/external-link-alt/12");
19241930
openLocationButton.addListener("execute", () => {
@@ -1994,7 +2000,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
19942000
__doMoveStudy: function(studyData, destWorkspaceId, destFolderId) {
19952001
this.__moveStudyToWorkspace(studyData, destWorkspaceId) // first move to workspace
19962002
.then(() => this.__moveStudyToFolder(studyData, destFolderId)) // then move to folder
1997-
.then(() => this.__removeFromStudyList(studyData["uuid"]))
2003+
.then(() => this.__removeFromList(studyData["uuid"]))
19982004
.catch(err => osparc.FlashMessenger.logError(err));
19992005
},
20002006

@@ -2192,6 +2198,54 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
21922198
return deleteButton;
21932199
},
21942200

2201+
__getDeleteFunctionMenuButton: function(functionData) {
2202+
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
2203+
deleteButton.set({
2204+
appearance: "menu-button"
2205+
});
2206+
osparc.utils.Utils.setIdToWidget(deleteButton, "functionItemMenuDelete");
2207+
deleteButton.addListener("execute", () => {
2208+
this.__popUpDeleteFunctionWindow(functionData, false);
2209+
}, this);
2210+
return deleteButton;
2211+
},
2212+
2213+
__popUpDeleteFunctionWindow: function(functionData, force, message) {
2214+
const win = this.__createConfirmDeleteWindow([functionData.title]);
2215+
win.setCaption(this.tr("Delete function"));
2216+
if (force) {
2217+
if (message) {
2218+
win.setMessage(message);
2219+
} else {
2220+
const msg = this.tr("The function has associated jobs. Are you sure you want to delete it?");
2221+
win.setMessage(msg);
2222+
}
2223+
}
2224+
win.center();
2225+
win.open();
2226+
win.addListener("close", () => {
2227+
if (win.getConfirmed()) {
2228+
this.__doDeleteFunction(functionData, force);
2229+
}
2230+
}, this);
2231+
},
2232+
2233+
__doDeleteFunction: function(functionData, force = false) {
2234+
osparc.store.Functions.deleteFunction(functionData.uuid, force)
2235+
.then(() => {
2236+
this.__removeFromList(functionData.uuid);
2237+
const msg = this.tr("Successfully deleted");
2238+
osparc.FlashMessenger.logAs(msg, "INFO");
2239+
})
2240+
.catch(err => {
2241+
if (err && err.status && err.status === 409) {
2242+
this.__popUpDeleteFunctionWindow(functionData, true, err.message);
2243+
} else {
2244+
osparc.FlashMessenger.logError(err);
2245+
}
2246+
});
2247+
},
2248+
21952249
__getStudyData: function(id) {
21962250
return this._resourcesList.find(study => study.uuid === id);
21972251
},
@@ -2303,7 +2357,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23032357
__untrashStudy: function(studyData) {
23042358
osparc.store.Study.getInstance().untrashStudy(studyData.uuid)
23052359
.then(() => {
2306-
this.__removeFromStudyList(studyData.uuid);
2360+
this.__removeFromList(studyData.uuid);
23072361
const msg = this.tr("Successfully restored");
23082362
osparc.FlashMessenger.logAs(msg, "INFO");
23092363
this._resourceFilter.evaluateTrashEmpty();
@@ -2315,7 +2369,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23152369
__trashStudy: function(studyData) {
23162370
osparc.store.Study.getInstance().trashStudy(studyData.uuid)
23172371
.then(() => {
2318-
this.__removeFromStudyList(studyData.uuid);
2372+
this.__removeFromList(studyData.uuid);
23192373
const msg = this.tr("Successfully deleted");
23202374
osparc.FlashMessenger.logAs(msg, "INFO");
23212375
this._resourceFilter.setTrashEmpty(false);
@@ -2353,7 +2407,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
23532407
operationPromise = osparc.store.Study.getInstance().deleteStudy(studyData.uuid);
23542408
}
23552409
operationPromise
2356-
.then(() => this.__removeFromStudyList(studyData.uuid))
2410+
.then(() => this.__removeFromList(studyData.uuid))
23572411
.catch(err => osparc.FlashMessenger.logError(err))
23582412
.finally(() => this.resetSelection());
23592413
},

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ qx.Class.define("osparc.data.Resources", {
644644
method: "POST",
645645
url: statics.API + "/functions"
646646
},
647+
delete: {
648+
method: "DELETE",
649+
url: statics.API + "/functions/{functionId}?force={force}"
650+
},
647651
patch: {
648652
method: "PATCH",
649653
url: statics.API + "/functions/{functionId}?include_extras=true"
@@ -1127,10 +1131,14 @@ qx.Class.define("osparc.data.Resources", {
11271131
},
11281132
"poUsers": {
11291133
endpoints: {
1130-
search: {
1134+
searchByEmail: {
11311135
method: "GET",
11321136
url: statics.API + "/admin/user-accounts:search?email={email}"
11331137
},
1138+
searchByGroupId: {
1139+
method: "GET",
1140+
url: statics.API + "/admin/user-accounts:search?primary_group_id={gId}"
1141+
},
11341142
getPendingUsers: {
11351143
method: "GET",
11361144
url: statics.API + "/admin/user-accounts?review_status=PENDING"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ qx.Class.define("osparc.data.model.Conversation", {
304304
const extraContext = this.getExtraContext() || {};
305305
extraContext["appointment"] = appointment ? appointment.toISOString() : null;
306306
// OM: Supporters are not allowed to patch the conversation metadata yet
307-
const backendAllowsPatch = osparc.store.Products.getInstance().amIASupportUser() ? false : true;
307+
const backendAllowsPatch = osparc.store.Groups.getInstance().amIASupportUser() ? false : true;
308308
if (backendAllowsPatch) {
309309
return osparc.store.ConversationsSupport.getInstance().patchExtraContext(this.getConversationId(), extraContext)
310310
.then(() => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ qx.Class.define("osparc.data.model.Group", {
104104
return Object.values(this.getGroupMembers()).find(user => user.getUserId() === userId);
105105
},
106106

107-
getGroupMemberByUsername: function(username) {
108-
return Object.values(this.getGroupMembers()).find(user => user.getUsername() === username);
107+
getGroupMemberByUserName: function(userName) {
108+
return Object.values(this.getGroupMembers()).find(user => user.getUserName() === userName);
109109
},
110110

111111
getGroupMemberByLogin: function(userEmail) {

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ qx.Class.define("osparc.data.model.User", {
3030

3131
const userId = ("id" in userData) ? parseInt(userData["id"]) : parseInt(userData["userId"]);
3232
const groupId = ("gid" in userData) ? parseInt(userData["gid"]) : parseInt(userData["groupId"]);
33-
const username = userData["userName"] || "-";
33+
const userName = userData["userName"] || "-";
3434
const email = ("login" in userData) ? userData["login"] : userData["email"];
3535
let firstName = "";
3636
if (userData["first_name"]) {
@@ -48,11 +48,11 @@ qx.Class.define("osparc.data.model.User", {
4848
this.set({
4949
userId,
5050
groupId,
51-
username,
51+
userName,
5252
firstName,
5353
lastName,
5454
email,
55-
phoneNumber: userData["phone"] || null,
55+
phone: userData["phone"] || null,
5656
});
5757

5858
const description = osparc.data.model.User.userDataToDescription(firstName, lastName, email);
@@ -62,18 +62,11 @@ qx.Class.define("osparc.data.model.User", {
6262
});
6363

6464
if (userData["contact"]) {
65-
const contact = userData["contact"];
66-
this.set({
67-
institution: contact["institution"] || null,
68-
address: contact["address"] || null,
69-
city: contact["city"] || null,
70-
state: contact["state"] || null,
71-
country: contact["country"] || null,
72-
postalCode: contact["postalCode"] || null,
73-
});
65+
const contactData = userData["contact"];
66+
this.setContactData(contactData);
7467
}
7568

76-
// create the thumbnail after setting email and username
69+
// create the thumbnail after setting email and userName
7770
this.set({
7871
thumbnail: this.createThumbnail(),
7972
});
@@ -108,11 +101,11 @@ qx.Class.define("osparc.data.model.User", {
108101
event: "changeDescription",
109102
},
110103

111-
username: {
104+
userName: {
112105
check: "String",
113106
nullable: false,
114107
init: null,
115-
event: "changeUsername",
108+
event: "changeUserName",
116109
},
117110

118111
firstName: {
@@ -136,11 +129,11 @@ qx.Class.define("osparc.data.model.User", {
136129
event: "changeEmail",
137130
},
138131

139-
phoneNumber: {
132+
phone: {
140133
check: "String",
141134
nullable: true,
142135
init: null,
143-
event: "changePhoneNumber"
136+
event: "changePhone",
144137
},
145138

146139
thumbnail: {
@@ -212,11 +205,22 @@ qx.Class.define("osparc.data.model.User", {
212205

213206
members: {
214207
createThumbnail: function(size) {
215-
return osparc.utils.Avatar.emailToThumbnail(this.getEmail(), this.getUsername(), size);
208+
return osparc.utils.Avatar.emailToThumbnail(this.getEmail(), this.getUserName(), size);
216209
},
217210

218211
getFullName: function() {
219212
return this.self().concatFullName(this.getFirstName(), this.getLastName());
220213
},
214+
215+
setContactData: function(contactData) {
216+
this.set({
217+
institution: contactData["institution"] || null,
218+
address: contactData["address"] || null,
219+
city: contactData["city"] || null,
220+
state: contactData["state"] || null,
221+
country: contactData["country"] || null,
222+
postalCode: contactData["postalCode"] || null,
223+
});
224+
},
221225
},
222226
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
5656
if (!userData) {
5757
userData = osparc.auth.Data.getInstance();
5858
}
59-
const username = userData.getUsername();
59+
const userName = userData.getUserName();
6060
const email = userData.getEmail();
6161
const avatarSize = 80;
6262
const img = new qx.ui.basic.Image().set({
63-
source: osparc.utils.Avatar.emailToThumbnail(email, username, avatarSize),
63+
source: osparc.utils.Avatar.emailToThumbnail(email, userName, avatarSize),
6464
maxWidth: avatarSize,
6565
maxHeight: avatarSize,
6666
scale: true,
@@ -71,12 +71,12 @@ qx.Class.define("osparc.desktop.account.MyAccount", {
7171
});
7272
layout.add(img);
7373

74-
const usernameLabel = new qx.ui.basic.Label().set({
74+
const userNameLabel = new qx.ui.basic.Label().set({
7575
font: "text-14",
7676
alignX: "center"
7777
});
78-
userData.bind("username", usernameLabel, "value");
79-
layout.add(usernameLabel);
78+
userData.bind("userName", userNameLabel, "value");
79+
layout.add(userNameLabel);
8080

8181
const fullNameLabel = new qx.ui.basic.Label().set({
8282
font: "text-13",

0 commit comments

Comments
 (0)