Skip to content

Commit 63ebf67

Browse files
committed
rename and new store
1 parent 9d42027 commit 63ebf67

File tree

9 files changed

+168
-68
lines changed

9 files changed

+168
-68
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
@@ -153,7 +153,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
153153
this.__postMessage();
154154
} else {
155155
// create new conversation first
156-
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"])
156+
osparc.store.ConversationsProject.getInstance().addConversation(this.__studyData["uuid"])
157157
.then(data => {
158158
this.__conversationId = data["conversationId"];
159159
this.__postMessage();
@@ -220,7 +220,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
220220
this.__postNotify(userGid);
221221
} else {
222222
// create new conversation first
223-
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"])
223+
osparc.store.ConversationsProject.getInstance().addConversation(this.__studyData["uuid"])
224224
.then(data => {
225225
this.__conversationId = data["conversationId"];
226226
this.__postNotify(userGid);
@@ -232,7 +232,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
232232
const commentField = this.getChildControl("comment-field");
233233
const content = commentField.getChildControl("text-area").getValue();
234234
if (content) {
235-
osparc.store.Conversations.getInstance().addMessage(this.__studyData["uuid"], this.__conversationId, content)
235+
osparc.store.ConversationsProject.getInstance().addMessage(this.__studyData["uuid"], this.__conversationId, content)
236236
.then(data => {
237237
this.fireDataEvent("messageAdded", data);
238238
commentField.getChildControl("text-area").setValue("");
@@ -244,7 +244,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
244244
const commentField = this.getChildControl("comment-field");
245245
const content = commentField.getChildControl("text-area").getValue();
246246
if (content) {
247-
osparc.store.Conversations.getInstance().editMessage(this.__studyData["uuid"], this.__conversationId, this.__message["messageId"], content)
247+
osparc.store.ConversationsProject.getInstance().editMessage(this.__studyData["uuid"], this.__conversationId, this.__message["messageId"], content)
248248
.then(data => {
249249
this.fireDataEvent("messageUpdated", data);
250250
commentField.getChildControl("text-area").setValue("");
@@ -254,7 +254,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
254254

255255
__postNotify: function(userGid) {
256256
if (userGid) {
257-
osparc.store.Conversations.getInstance().notifyUser(this.__studyData["uuid"], this.__conversationId, userGid)
257+
osparc.store.ConversationsProject.getInstance().notifyUser(this.__studyData["uuid"], this.__conversationId, userGid)
258258
.then(data => {
259259
this.fireDataEvent("messageAdded", data);
260260
const potentialCollaborators = osparc.store.Groups.getInstance().getPotentialCollaborators();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ qx.Class.define("osparc.conversation.Conversation", {
8787
titleEditor.close();
8888
const newLabel = e.getData()["newLabel"];
8989
if (this.getConversationId()) {
90-
osparc.store.Conversations.getInstance().renameConversation(this.__studyData["uuid"], this.getConversationId(), newLabel)
90+
osparc.store.ConversationsProject.getInstance().renameConversation(this.__studyData["uuid"], this.getConversationId(), newLabel)
9191
.then(() => this.renameConversation(newLabel));
9292
} else {
9393
// create new conversation first
94-
osparc.store.Conversations.getInstance().addConversation(this.__studyData["uuid"], newLabel)
94+
osparc.store.ConversationsProject.getInstance().addConversation(this.__studyData["uuid"], newLabel)
9595
.then(data => {
9696
this.setConversationId(data["conversationId"]);
9797
this.getChildControl("button").setLabel(newLabel);
@@ -114,7 +114,7 @@ qx.Class.define("osparc.conversation.Conversation", {
114114
});
115115
closeButton.addListener("execute", () => {
116116
if (this.__messagesList.getChildren().length === 0) {
117-
osparc.store.Conversations.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
117+
osparc.store.ConversationsProject.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
118118
} else {
119119
const msg = this.tr("Are you sure you want to delete the conversation?");
120120
const confirmationWin = new osparc.ui.window.Confirmation(msg).set({
@@ -125,7 +125,7 @@ qx.Class.define("osparc.conversation.Conversation", {
125125
confirmationWin.open();
126126
confirmationWin.addListener("close", () => {
127127
if (confirmationWin.getConfirmed()) {
128-
osparc.store.Conversations.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
128+
osparc.store.ConversationsProject.getInstance().deleteConversation(this.__studyData["uuid"], this.getConversationId());
129129
}
130130
}, this);
131131
}
@@ -197,7 +197,7 @@ qx.Class.define("osparc.conversation.Conversation", {
197197
const options = {
198198
resolveWResponse: true
199199
};
200-
return osparc.data.Resources.fetch("conversations", "getMessagesPage", params, options)
200+
return osparc.data.Resources.fetch("conversationsProject", "getMessagesPage", params, options)
201201
.catch(err => osparc.FlashMessenger.logError(err));
202202
},
203203

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.store.Conversations.getInstance().deleteMessage(message)
230+
osparc.store.ConversationsProject.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ qx.Class.define("osparc.data.Resources", {
305305
},
306306
}
307307
},
308-
"conversations": {
308+
"conversationsProject": {
309309
useCache: false, // It has its own cache handler
310310
endpoints: {
311311
addConversation: {

services/static-webserver/client/source/class/osparc/store/Conversations.js renamed to services/static-webserver/client/source/class/osparc/store/ConversationsProject.js

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
************************************************************************ */
1717

18-
qx.Class.define("osparc.store.Conversations", {
18+
qx.Class.define("osparc.store.ConversationsProject", {
1919
extend: qx.core.Object,
2020
type: "singleton",
2121

@@ -33,7 +33,7 @@ qx.Class.define("osparc.store.Conversations", {
3333
limit: 42,
3434
}
3535
};
36-
return osparc.data.Resources.fetch("conversations", "getConversationsPage", params)
36+
return osparc.data.Resources.fetch("conversationsProject", "getConversationsPage", params)
3737
.then(conversations => {
3838
if (conversations.length) {
3939
// Sort conversations by created date, oldest first (the new ones will be next to the plus button)
@@ -51,7 +51,7 @@ qx.Class.define("osparc.store.Conversations", {
5151
conversationId,
5252
}
5353
};
54-
return osparc.data.Resources.fetch("conversations", "getConversation", params);
54+
return osparc.data.Resources.fetch("conversationsProject", "getConversation", params);
5555
},
5656

5757
addConversation: function(studyId, name = "new 1", type = osparc.study.Conversations.TYPES.PROJECT_STATIC) {
@@ -64,7 +64,7 @@ qx.Class.define("osparc.store.Conversations", {
6464
type,
6565
}
6666
};
67-
return osparc.data.Resources.fetch("conversations", "addConversation", params)
67+
return osparc.data.Resources.fetch("conversationsProject", "addConversation", params)
6868
.catch(err => osparc.FlashMessenger.logError(err));
6969
},
7070

@@ -75,7 +75,7 @@ qx.Class.define("osparc.store.Conversations", {
7575
conversationId,
7676
},
7777
};
78-
return osparc.data.Resources.fetch("conversations", "deleteConversation", params)
78+
return osparc.data.Resources.fetch("conversationsProject", "deleteConversation", params)
7979
.then(() => {
8080
this.fireDataEvent("conversationDeleted", {
8181
studyId,
@@ -95,7 +95,7 @@ qx.Class.define("osparc.store.Conversations", {
9595
name,
9696
}
9797
};
98-
return osparc.data.Resources.fetch("conversations", "renameConversation", params)
98+
return osparc.data.Resources.fetch("conversationsProject", "renameConversation", params)
9999
.then(() => {
100100
this.fireDataEvent("conversationRenamed", {
101101
studyId,
@@ -117,7 +117,7 @@ qx.Class.define("osparc.store.Conversations", {
117117
"type": "MESSAGE",
118118
}
119119
};
120-
return osparc.data.Resources.fetch("conversations", "addMessage", params)
120+
return osparc.data.Resources.fetch("conversationsProject", "addMessage", params)
121121
.catch(err => osparc.FlashMessenger.logError(err));
122122
},
123123

@@ -132,7 +132,7 @@ qx.Class.define("osparc.store.Conversations", {
132132
"content": message,
133133
},
134134
};
135-
return osparc.data.Resources.fetch("conversations", "editMessage", params)
135+
return osparc.data.Resources.fetch("conversationsProject", "editMessage", params)
136136
.catch(err => osparc.FlashMessenger.logError(err));
137137
},
138138

@@ -144,7 +144,7 @@ qx.Class.define("osparc.store.Conversations", {
144144
messageId: message["messageId"],
145145
},
146146
};
147-
return osparc.data.Resources.fetch("conversations", "deleteMessage", params)
147+
return osparc.data.Resources.fetch("conversationsProject", "deleteMessage", params)
148148
.catch(err => osparc.FlashMessenger.logError(err));
149149
},
150150

@@ -159,47 +159,8 @@ qx.Class.define("osparc.store.Conversations", {
159159
"type": "NOTIFICATION",
160160
}
161161
};
162-
return osparc.data.Resources.fetch("conversations", "addMessage", params)
162+
return osparc.data.Resources.fetch("conversationsProject", "addMessage", params)
163163
.catch(err => osparc.FlashMessenger.logError(err));
164164
},
165-
166-
__addToCache: function(pricingPlanData) {
167-
let pricingPlan = this.__pricingPlansCached.find(f => f.getPricingPlanId() === pricingPlanData["pricingPlanId"]);
168-
if (pricingPlan) {
169-
// put
170-
pricingPlan.set({
171-
pricingPlanKey: pricingPlanData["pricingPlanKey"],
172-
name: pricingPlanData["displayName"],
173-
description: pricingPlanData["description"],
174-
classification: pricingPlanData["classification"],
175-
isActive: pricingPlanData["isActive"],
176-
});
177-
} else {
178-
// get and post
179-
pricingPlan = new osparc.data.model.PricingPlan(pricingPlanData);
180-
this.__pricingPlansCached.unshift(pricingPlan);
181-
}
182-
return pricingPlan;
183-
},
184-
185-
__addPricingUnitToCache: function(pricingPlan, pricingUnitData) {
186-
const pricingUnits = pricingPlan.getPricingUnits();
187-
let pricingUnit = pricingUnits ? pricingUnits.find(unit => ("getPricingUnitId" in unit) && unit.getPricingUnitId() === pricingUnitData["pricingUnitId"]) : null;
188-
if (pricingUnit) {
189-
const props = Object.keys(qx.util.PropertyUtil.getProperties(osparc.data.model.PricingPlan));
190-
// put
191-
Object.keys(pricingUnitData).forEach(key => {
192-
if (props.includes(key)) {
193-
pricingPlan.set(key, pricingUnitData[key]);
194-
}
195-
});
196-
} else {
197-
// get and post
198-
pricingUnit = new osparc.data.model.PricingUnit(pricingUnitData);
199-
pricingPlan.bind("classification", pricingUnit, "classification");
200-
pricingUnits.push(pricingUnit);
201-
}
202-
return pricingUnit;
203-
},
204165
}
205166
});
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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.store.ConversationsSupport", {
19+
extend: qx.core.Object,
20+
type: "singleton",
21+
22+
events: {
23+
"conversationRenamed": "qx.event.type.Data",
24+
"conversationDeleted": "qx.event.type.Data",
25+
},
26+
27+
members: {
28+
getConversations: function() {
29+
const params = {
30+
url: {
31+
offset: 0,
32+
limit: 42,
33+
}
34+
};
35+
return osparc.data.Resources.fetch("conversationsSupport", "getConversationsPage", params)
36+
.then(conversations => {
37+
if (conversations.length) {
38+
// Sort conversations by created date, oldest first (the new ones will be next to the plus button)
39+
conversations.sort((a, b) => new Date(a["created"]) - new Date(b["created"]));
40+
}
41+
return conversations;
42+
})
43+
.catch(err => osparc.FlashMessenger.logError(err));
44+
},
45+
46+
getConversation: function(conversationId) {
47+
const params = {
48+
url: {
49+
conversationId,
50+
}
51+
};
52+
return osparc.data.Resources.fetch("conversationsSupport", "getConversation", params);
53+
},
54+
55+
addConversation: function(name = "new 1", type = osparc.study.Conversations.TYPES.PROJECT_STATIC) {
56+
const params = {
57+
data: {
58+
name,
59+
type,
60+
}
61+
};
62+
return osparc.data.Resources.fetch("conversationsSupport", "addConversation", params)
63+
.catch(err => osparc.FlashMessenger.logError(err));
64+
},
65+
66+
deleteConversation: function(conversationId) {
67+
const params = {
68+
url: {
69+
conversationId,
70+
},
71+
};
72+
return osparc.data.Resources.fetch("conversationsSupport", "deleteConversation", params)
73+
.then(() => {
74+
this.fireDataEvent("conversationDeleted", {
75+
conversationId,
76+
})
77+
})
78+
.catch(err => osparc.FlashMessenger.logError(err));
79+
},
80+
81+
renameConversation: function(conversationId, name) {
82+
const params = {
83+
url: {
84+
conversationId,
85+
},
86+
data: {
87+
name,
88+
}
89+
};
90+
return osparc.data.Resources.fetch("conversationsSupport", "renameConversation", params)
91+
.then(() => {
92+
this.fireDataEvent("conversationRenamed", {
93+
conversationId,
94+
name,
95+
});
96+
})
97+
.catch(err => osparc.FlashMessenger.logError(err));
98+
},
99+
100+
addMessage: function(conversationId, message) {
101+
const params = {
102+
url: {
103+
conversationId,
104+
},
105+
data: {
106+
"content": message,
107+
"type": "MESSAGE",
108+
}
109+
};
110+
return osparc.data.Resources.fetch("conversationsSupport", "addMessage", params)
111+
.catch(err => osparc.FlashMessenger.logError(err));
112+
},
113+
114+
editMessage: function(conversationId, messageId, message) {
115+
const params = {
116+
url: {
117+
conversationId,
118+
messageId,
119+
},
120+
data: {
121+
"content": message,
122+
},
123+
};
124+
return osparc.data.Resources.fetch("conversationsSupport", "editMessage", params)
125+
.catch(err => osparc.FlashMessenger.logError(err));
126+
},
127+
128+
deleteMessage: function(message) {
129+
const params = {
130+
url: {
131+
conversationId: message["conversationId"],
132+
messageId: message["messageId"],
133+
},
134+
};
135+
return osparc.data.Resources.fetch("conversationsSupport", "deleteMessage", params)
136+
.catch(err => osparc.FlashMessenger.logError(err));
137+
},
138+
}
139+
});

0 commit comments

Comments
 (0)