Skip to content

Commit 254ed05

Browse files
Merge branch 'master' into add-project-grouping-for-task-manager
2 parents 152c7e3 + fbde76d commit 254ed05

File tree

23 files changed

+729
-601
lines changed

23 files changed

+729
-601
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
146146
this.__postMessage();
147147
} else {
148148
// create new conversation first
149-
osparc.study.Conversations.addConversation(this.__studyData["uuid"])
149+
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"])
150150
.then(data => {
151151
this.__conversationId = data["conversationId"];
152152
this.__postMessage();
@@ -213,7 +213,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
213213
this.__postNotify(userGid);
214214
} else {
215215
// create new conversation first
216-
osparc.study.Conversations.addConversation(this.__studyData["uuid"])
216+
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"])
217217
.then(data => {
218218
this.__conversationId = data["conversationId"];
219219
this.__postNotify(userGid);
@@ -225,7 +225,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
225225
const commentField = this.getChildControl("comment-field");
226226
const content = commentField.getChildControl("text-area").getValue();
227227
if (content) {
228-
osparc.study.Conversations.addMessage(this.__studyData["uuid"], this.__conversationId, content)
228+
osparc.store.Conversations.getInstance().addMessage(this.__studyData["uuid"], this.__conversationId, content)
229229
.then(data => {
230230
this.fireDataEvent("messageAdded", data);
231231
commentField.getChildControl("text-area").setValue("");
@@ -237,7 +237,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
237237
const commentField = this.getChildControl("comment-field");
238238
const content = commentField.getChildControl("text-area").getValue();
239239
if (content) {
240-
osparc.study.Conversations.editMessage(this.__studyData["uuid"], this.__conversationId, this.__message["messageId"], content)
240+
osparc.store.Conversations.getInstance().editMessage(this.__studyData["uuid"], this.__conversationId, this.__message["messageId"], content)
241241
.then(data => {
242242
this.fireDataEvent("messageUpdated", data);
243243
commentField.getChildControl("text-area").setValue("");
@@ -247,7 +247,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
247247

248248
__postNotify: function(userGid) {
249249
if (userGid) {
250-
osparc.study.Conversations.notifyUser(this.__studyData["uuid"], this.__conversationId, userGid)
250+
osparc.store.Conversations.getInstance().notifyUser(this.__studyData["uuid"], this.__conversationId, userGid)
251251
.then(data => {
252252
this.fireDataEvent("messageAdded", data);
253253
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators();

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

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ qx.Class.define("osparc.conversation.Conversation", {
5959
},
6060
},
6161

62-
events: {
63-
"conversationDeleted": "qx.event.type.Event",
64-
},
65-
6662
members: {
6763
__studyData: null,
6864
__messages: null,
@@ -82,18 +78,19 @@ qx.Class.define("osparc.conversation.Conversation", {
8278
};
8379
const renameButton = new qx.ui.form.Button(null, "@FontAwesome5Solid/pencil-alt/10").set({
8480
...buttonsAesthetics,
81+
visibility: osparc.data.model.Study.canIWrite(this.__studyData["accessRights"]) ? "visible" : "excluded",
8582
});
8683
renameButton.addListener("execute", () => {
8784
const titleEditor = new osparc.widget.Renamer(tabButton.getLabel());
8885
titleEditor.addListener("labelChanged", e => {
8986
titleEditor.close();
9087
const newLabel = e.getData()["newLabel"];
9188
if (this.getConversationId()) {
92-
osparc.study.Conversations.renameConversation(this.__studyData["uuid"], this.getConversationId(), newLabel)
89+
osparc.store.Conversations.getInstance().renameConversation(this.__studyData["uuid"], this.getConversationId(), newLabel)
9390
.then(() => this.renameConversation(newLabel));
9491
} else {
9592
// create new conversation first
96-
osparc.study.Conversations.addConversation(this.__studyData["uuid"], newLabel)
93+
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"], newLabel)
9794
.then(data => {
9895
this.setConversationId(data["conversationId"]);
9996
this.getChildControl("button").setLabel(newLabel);
@@ -112,14 +109,11 @@ qx.Class.define("osparc.conversation.Conversation", {
112109
const closeButton = new qx.ui.form.Button(null, "@FontAwesome5Solid/times/12").set({
113110
...buttonsAesthetics,
114111
paddingLeft: 4, // adds spacing between buttons
112+
visibility: osparc.data.model.Study.canIWrite(this.__studyData["accessRights"]) ? "visible" : "excluded",
115113
});
116114
closeButton.addListener("execute", () => {
117-
const deleteConversation = () => {
118-
osparc.study.Conversations.deleteConversation(this.__studyData["uuid"], this.getConversationId())
119-
.then(() => this.fireEvent("conversationDeleted"));
120-
}
121115
if (this.__messagesList.getChildren().length === 0) {
122-
deleteConversation();
116+
osparc.store.Conversations.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
123117
} else {
124118
const msg = this.tr("Are you sure you want to delete the conversation?");
125119
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
@@ -130,7 +124,7 @@ qx.Class.define("osparc.conversation.Conversation", {
130124
confirmationWin.open();
131125
confirmationWin.addListener("close", () => {
132126
if (confirmationWin.getConfirmed()) {
133-
deleteConversation();
127+
osparc.store.Conversations.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
134128
}
135129
}, this);
136130
}
@@ -166,18 +160,18 @@ qx.Class.define("osparc.conversation.Conversation", {
166160
this.__loadMoreMessages.addListener("execute", () => this.__reloadMessages(false));
167161
this._add(this.__loadMoreMessages);
168162

169-
if (osparc.data.model.Study.canIWrite(this.__studyData["accessRights"])) {
170-
const addMessages = new osparc.conversation.AddMessage(this.__studyData, this.getConversationId());
171-
addMessages.setPaddingLeft(10);
172-
addMessages.addListener("messageAdded", e => {
173-
const data = e.getData();
174-
if (data["conversationId"]) {
175-
this.setConversationId(data["conversationId"]);
176-
this.addMessage(data);
177-
}
178-
});
179-
this._add(addMessages);
180-
}
163+
const addMessages = new osparc.conversation.AddMessage(this.__studyData, this.getConversationId()).set({
164+
enabled: osparc.data.model.Study.canIWrite(this.__studyData["accessRights"]),
165+
paddingLeft: 10,
166+
});
167+
addMessages.addListener("messageAdded", e => {
168+
const data = e.getData();
169+
if (data["conversationId"]) {
170+
this.setConversationId(data["conversationId"]);
171+
this.addMessage(data);
172+
}
173+
});
174+
this._add(addMessages);
181175
},
182176

183177
__getNextRequest: function() {
@@ -197,7 +191,8 @@ qx.Class.define("osparc.conversation.Conversation", {
197191
const options = {
198192
resolveWResponse: true
199193
};
200-
return osparc.data.Resources.fetch("conversations", "getMessagesPage", params, options);
194+
return osparc.data.Resources.fetch("conversations", "getMessagesPage", params, options)
195+
.catch(err => osparc.FlashMessenger.logError(err));
201196
},
202197

203198
__reloadMessages: function(removeMessages = true) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
227227
win.open();
228228
win.addListener("close", () => {
229229
if (win.getConfirmed()) {
230-
osparc.study.Conversations.deleteMessage(message)
230+
osparc.store.Conversations.getInstance().deleteMessage(message)
231231
.then(() => this.fireDataEvent("messageDeleted", message))
232232
.catch(err => osparc.FlashMessenger.logError(err));
233233
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ qx.Class.define("osparc.data.Resources", {
310310
}
311311
},
312312
"conversations": {
313-
useCache: false,
313+
useCache: false, // It has its own cache handler
314314
endpoints: {
315315
addConversation: {
316316
method: "POST",
@@ -320,6 +320,10 @@ qx.Class.define("osparc.data.Resources", {
320320
method: "GET",
321321
url: statics.API + "/projects/{studyId}/conversations?offset={offset}&limit={limit}"
322322
},
323+
getConversation: {
324+
method: "GET",
325+
url: statics.API + "/projects/{studyId}/conversations/{conversationId}"
326+
},
323327
renameConversation: {
324328
method: "PUT",
325329
url: statics.API + "/projects/{studyId}/conversations/{conversationId}"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ qx.Class.define("osparc.data.model.Study", {
7070
this.setWorkbench(workbench);
7171
workbench.setStudy(this);
7272

73-
const workbenchUi = new osparc.data.model.StudyUI(studyData.ui);
74-
this.setUi(workbenchUi);
73+
const studyUI = new osparc.data.model.StudyUI(studyData.ui);
74+
this.setUi(studyUI);
7575

7676
this.getWorkbench().buildWorkbench();
7777
},

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ qx.Class.define("osparc.data.model.StudyUI", {
3838
});
3939

4040
if ("annotations" in studyDataUI) {
41-
this.__annotationsInitData = studyDataUI["annotations"];
41+
Object.entries(studyDataUI["annotations"]).forEach(([annotationId, annotationData]) => {
42+
const annotation = new osparc.workbench.Annotation(annotationData, annotationId);
43+
this.addAnnotation(annotation);
44+
});
4245
}
4346
},
4447

@@ -99,22 +102,12 @@ qx.Class.define("osparc.data.model.StudyUI", {
99102
},
100103

101104
members: {
102-
__annotationsInitData: null,
103-
104105
__applyMode: function(mode) {
105106
if (mode === "guided") {
106107
this.setMode("app");
107108
}
108109
},
109110

110-
getAnnotationsInitData: function() {
111-
return this.__annotationsInitData;
112-
},
113-
114-
nullAnnotationsInitData: function() {
115-
this.__annotationsInitData = null;
116-
},
117-
118111
addAnnotation: function(annotation) {
119112
this.getAnnotations()[annotation.getId()] = annotation;
120113
},

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

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)