File tree Expand file tree Collapse file tree 4 files changed +52
-12
lines changed
services/static-webserver/client/source/class/osparc Expand file tree Collapse file tree 4 files changed +52
-12
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ qx.Class.define("osparc.conversation.MessageUI", {
4040
4141 statics : {
4242 isMyMessage : function ( message ) {
43+ if ( message [ "userGroupId" ] === "system" ) {
44+ return false ;
45+ }
4346 return message && osparc . auth . Data . getInstance ( ) . getGroupId ( ) === message [ "userGroupId" ] ;
4447 }
4548 } ,
@@ -163,15 +166,19 @@ qx.Class.define("osparc.conversation.MessageUI", {
163166 const messageContent = this . getChildControl ( "message-content" ) ;
164167 messageContent . setValue ( message [ "content" ] ) ;
165168
166- osparc . store . Users . getInstance ( ) . getUser ( message [ "userGroupId" ] )
167- . then ( user => {
168- thumbnail . setUser ( user ) ;
169- userName . setValue ( user ? user . getLabel ( ) : "Unknown user" ) ;
170- } )
171- . catch ( ( ) => {
169+ if ( message [ "userGroupId" ] === "system" ) {
170+ userName . setValue ( "Support" ) ;
171+ } else {
172+ osparc . store . Users . getInstance ( ) . getUser ( message [ "userGroupId" ] )
173+ . then ( user => {
174+ thumbnail . setUser ( user ) ;
175+ userName . setValue ( user ? user . getLabel ( ) : "Unknown user" ) ;
176+ } )
177+ . catch ( ( ) => {
172178 thumbnail . setSource ( osparc . utils . Avatar . emailToThumbnail ( ) ) ;
173179 userName . setValue ( "Unknown user" ) ;
174- } ) ;
180+ } ) ;
181+ }
175182
176183 this . getChildControl ( "spacer" ) ;
177184
Original file line number Diff line number Diff line change @@ -251,6 +251,20 @@ qx.Class.define("osparc.support.Conversation", {
251251 . finally ( ( ) => loadMoreMessages . setFetching ( false ) ) ;
252252 } ,
253253
254+ addSystemMessage : function ( message ) {
255+ const now = new Date ( ) ;
256+ const systemMessage = {
257+ "content" : message ,
258+ "conversationId" : null ,
259+ "created" : now . toISOString ( ) ,
260+ "messageId" : `system-${ now . getTime ( ) } ` ,
261+ "modified" : now . toISOString ( ) ,
262+ "type" : "MESSAGE" ,
263+ "userGroupId" : "system" ,
264+ } ;
265+ this . addMessage ( systemMessage ) ;
266+ } ,
267+
254268 addMessage : function ( message ) {
255269 // ignore it if it was already there
256270 const messageIndex = this . __messages . findIndex ( msg => msg [ "messageId" ] === message [ "messageId" ] ) ;
Original file line number Diff line number Diff line change @@ -145,12 +145,32 @@ qx.Class.define("osparc.support.ConversationPage", {
145145 return control || this . base ( arguments , id ) ;
146146 } ,
147147
148+ // type can be "askAQuestion", "bookACall" or "reportOEC"
149+ proposeConversation : function ( type ) {
150+ type = type || "askAQuestion" ;
151+ this . setConversation ( null ) ;
152+
153+ const title = this . getChildControl ( "conversation-title" ) ;
154+ switch ( type ) {
155+ case "askAQuestion" :
156+ title . setValue ( this . tr ( "Ask a Question" ) ) ;
157+ break ;
158+ case "bookACall" :
159+ title . setValue ( this . tr ( "Book a Call" ) ) ;
160+ break ;
161+ case "reportOEC" :
162+ title . setValue ( this . tr ( "Report an Error" ) ) ;
163+ break ;
164+ }
165+
166+ const conversationContent = this . getChildControl ( "conversation-content" ) ;
167+ conversationContent . addSystemMessage ( "Hello world" ) ;
168+ } ,
169+
148170 __applyConversation : function ( conversation ) {
149171 const title = this . getChildControl ( "conversation-title" ) ;
150172 if ( conversation ) {
151173 conversation . bind ( "nameAlias" , title , "value" ) ;
152- } else {
153- title . setValue ( this . tr ( "Ask a Question" ) ) ;
154174 }
155175
156176 const extraContextLayout = this . getChildControl ( "conversation-extra-layout" ) ;
Original file line number Diff line number Diff line change @@ -196,14 +196,13 @@ qx.Class.define("osparc.support.SupportCenter", {
196196 }
197197 } ,
198198
199- // type can be "askAQuestion", "bookACall" or "reportOEC"
200199 createConversation : function ( type ) {
201- type = type || "askAQuestion" ;
202200 const conversationPage = this . getChildControl ( "conversation-page" ) ;
203- conversationPage . setConversation ( null ) ;
201+ conversationPage . proposeConversation ( type ) ;
204202 this . __showConversation ( ) ;
205203 } ,
206204
205+ // OM remove this
207206 createConversationBookCall : function ( ) {
208207 const conversationPage = this . getChildControl ( "conversation-page" ) ;
209208 conversationPage . setConversation ( null ) ;
You can’t perform that action at this time.
0 commit comments